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

S

Stan R.

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.
 
A

Arndt Jonasson

Stan said:
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.
 
J

Joe Kesselman

Arndt said:
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."
 
S

Stan R.

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
 
S

Stan R.

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top