xmllint and xsd & how to check dtd/schema/etc

Discussion in 'XML' started by Stan R., Jun 8, 2006.

  1. Stan R.

    Stan R. Guest

    Hello, I have xmllint and xsltproc installed and running on both my
    linux and win32 platforms, all seems good.

    I have a couple questions though.

    1) If I have an external dtd file, which is included in my xml file,
    like

    <!DOCTYPE userlist SYSTEM "test.dtd">

    xmllint automatically uses that dtd when I do

    $ xmllint --valid --noout test.xml

    But, if I want to use a scheme (xsd), with the declaration in the xml
    file as so

    <test
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="test.xsd">
    ...
    ...
    ...
    </test>

    It doesn't seem to use the xsd file (in this case, test.xsd.) I have
    to add
    `--schema test.xsd` to the command line arguemnts, eg

    $ xmllint --valid --noout test.xml --schema test.xsd

    Is there a way to make xmllint jsut use what's declared in the xml
    document?


    2) Just one more question I can't really find any info on. Is there a
    way (hopefuly with xmllint) to do a quick check for any errors in a DTD
    or XSD file, to make sure I didn't mistype something or otherwise
    syntatical blunder?


    Thanks for any help.

    --
    Stan
    Stan R., Jun 8, 2006
    #1
    1. Advertising

  2. Stan R. wrote:
    > 2) Just one more question I can't really find any info on. Is there a
    > way (hopefuly with xmllint) to do a quick check for any errors in a DTD
    > or XSD file, to make sure I didn't mistype something or otherwise
    > syntatical blunder?


    I don't know about checking a DTD, but you can check a schema file like
    this:
    xmllint --noout -schema http://www.w3.org/2001/XMLSchema.xsd
    myschema.xsd

    If you're using Emacs as an editor, you can also have it continously
    checked while you edit, by using nxml-mode.
    Arndt Jonasson, Jun 8, 2006
    #2
    1. Advertising

  3. Arndt Jonasson wrote:
    > If you're using Emacs as an editor, you can also have it continously
    > checked while you edit, by using nxml-mode.


    "Master, does Emacs have buddha-nature?"
    "... I can't see why not. It has everything else."


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Jun 8, 2006
    #3
  4. Stan R.

    Stan R. Guest

    "Arndt Jonasson" <> wrote in
    news::

    > Stan R. wrote:
    > > 2) Just one more question I can't really find any info on. Is there
    > > a way (hopefuly with xmllint) to do a quick check for any errors in
    > > a DTD or XSD file, to make sure I didn't mistype something or
    > > otherwise syntatical blunder?

    >
    > I don't know about checking a DTD, but you can check a schema file
    > like this:
    > xmllint --noout -schema http://www.w3.org/2001/XMLSchema.xsd
    > myschema.xsd


    Thank you, but that doesn't seem to work as expected. While my xsd works
    without error against my test xml document, testing the xsd in the manner
    you desribe yields a lot of errors in the
    http://www.w3.org/2001/XMLSchema.xsd file:

    $ xmllint --noout --schema test.xsd test.xml
    test.xml validates

    $ xmllint --noout --schema http://www.w3.org/2001/XMLSchema.xsd test.xsd

    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 234
    element xs:element
    Content model of schema is not determinist:
    Unimplemented block at xmlschemas.c:3246
    Unimplemented block at xmlschemas.c:3246
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 308
    element xs:enumeration
    Schemas: type restriction 46 enumeration value unbounded invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 2148
    element xs:maxInclusive
    Schemas: type restriction 372 facet value 65535 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 2089
    element xs:minInclusive
    Schemas: type restriction 367 facet value -32768 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 2090
    element xs:maxInclusive
    Schemas: type restriction 367 facet value 32767 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 2126
    element xs:maxInclusive
    Schemas: type restriction 370 facet value 18446744073709551615 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 630
    element xs:enumeration
    Schemas: type restriction 142 enumeration value #all invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 895
    element xs:enumeration
    Schemas: type restriction 230 enumeration value 0 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 896
    element xs:enumeration
    Schemas: type restriction 230 enumeration value 1 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 1009
    element xs:enumeration
    Schemas: type restriction 251 enumeration value ##targetNamespace invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 1010
    element xs:enumeration
    Schemas: type restriction 251 enumeration value ##local invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd li
    ..
    ..
    ..
    [more similar errors]

    $ xmllint --version
    xmllint: using libxml version 20511
    compiled with: FTP HTTP HTML C14N Catalog DocBook XPath XPointer
    XInclude Iconv Unicode Regexps Automata Schemas

    Strange thing is,
    `xmllint --noout --schema http://www.w3.org/2001/XMLSchema.xsd test.xsd`
    works just fine on my windows system (the errors I get are on my linux
    system, where I need this to work:

    D:\xml> xmllint --noout --schema test.xsd test.xml
    test.xml validates

    D:\xml> xmllint --noout --schema http://www.w3.org/2001/XMLSchema.xsd
    test.xsd
    test.xsd validates

    D:\xml> xmllint --version
    xmllint: using libxml version 20623CVS2717
    compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP
    HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv
    Unicode Regexps Automata Expr Schemas Schematron Modules Debug

    ---

    So why does it work on one but not the other? (And yes the Linux system has
    full access to the internet.)

    --
    Stan
    Stan R., Jun 8, 2006
    #4
  5. Stan R.

    Stan R. Guest

    "Arndt Jonasson" <> wrote in
    news::

    > Stan R. wrote:
    > > 2) Just one more question I can't really find any info on. Is there
    > > a way (hopefuly with xmllint) to do a quick check for any errors in
    > > a DTD or XSD file, to make sure I didn't mistype something or
    > > otherwise syntatical blunder?

    >
    > I don't know about checking a DTD, but you can check a schema file
    > like this:
    > xmllint --noout -schema http://www.w3.org/2001/XMLSchema.xsd
    > myschema.xsd


    Thank you, but that doesn't seem to work as expected. While my xsd works
    without error against my test xml document, testing the xsd in the
    manner
    you desribe yields a lot of errors in the
    http://www.w3.org/2001/XMLSchema.xsd file:

    $ xmllint --noout --schema test.xsd test.xml
    test.xml validates

    $ xmllint --noout --schema http://www.w3.org/2001/XMLSchema.xsd test.xsd

    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    Unimplemented block at xmlschemas.c:1934
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 234
    element xs:element
    Content model of schema is not determinist:
    Unimplemented block at xmlschemas.c:3246
    Unimplemented block at xmlschemas.c:3246
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 308
    element xs:enumeration
    Schemas: type restriction 46 enumeration value unbounded invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 2148
    element xs:maxInclusive
    Schemas: type restriction 372 facet value 65535 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 2089
    element xs:minInclusive
    Schemas: type restriction 367 facet value -32768 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 2090
    element xs:maxInclusive
    Schemas: type restriction 367 facet value 32767 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 2126
    element xs:maxInclusive
    Schemas: type restriction 370 facet value 18446744073709551615 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 630
    element xs:enumeration
    Schemas: type restriction 142 enumeration value #all invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 895
    element xs:enumeration
    Schemas: type restriction 230 enumeration value 0 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 896
    element xs:enumeration
    Schemas: type restriction 230 enumeration value 1 invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 1009
    element xs:enumeration
    Schemas: type restriction 251 enumeration value ##targetNamespace
    invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd line 1010
    element xs:enumeration
    Schemas: type restriction 251 enumeration value ##local invalid
    compilation error: file http://www.w3.org/2001/XMLSchema.xsd li
    ..
    ..
    ..
    [more similar errors]

    $ xmllint --version
    xmllint: using libxml version 20511
    compiled with: FTP HTTP HTML C14N Catalog DocBook XPath XPointer
    XInclude Iconv Unicode Regexps Automata Schemas

    Strange thing is,
    `xmllint --noout --schema http://www.w3.org/2001/XMLSchema.xsd
    test.xsd`
    works just fine on my windows system (the errors I get are on my linux
    system, where I need this to work:

    D:\xml> xmllint --noout --schema test.xsd test.xml
    test.xml validates

    D:\xml> xmllint --noout --schema http://www.w3.org/2001/XMLSchema.xsd
    test.xsd
    test.xsd validates

    D:\xml> xmllint --version
    xmllint: using libxml version 20623CVS2717
    compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1
    FTP
    HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv
    Unicode Regexps Automata Expr Schemas Schematron Modules Debug

    ---

    So why does it work on one but not the other? (And yes the Linux system
    has
    full access to the internet.)

    --
    Stan
    Stan R., Jun 8, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Burak
    Replies:
    0
    Views:
    566
    Burak
    Jul 1, 2004
  2. Matt
    Replies:
    3
    Views:
    37,199
    MKNDK
    Sep 11, 2008
  3. Neil McNaughton

    Using xmllint and xpath without --shell

    Neil McNaughton, Jan 7, 2005, in forum: XML
    Replies:
    1
    Views:
    4,639
    grouch
    Jan 8, 2005
  4. Replies:
    2
    Views:
    1,344
  5. Acácio Centeno
    Replies:
    1
    Views:
    240
    dieter
    Feb 15, 2013
Loading...

Share This Page