By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,725 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,725 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jun 8 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.

Jun 8 '06 #2

P: n/a
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
Jun 8 '06 #3

P: n/a
"Arndt Jonasson" <ar************@gmail.com> wrote in
news:11*********************@f6g2000cwb.googlegrou ps.com:
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
Jun 8 '06 #4

P: n/a
"Arndt Jonasson" <ar************@gmail.com> wrote in
news:11*********************@f6g2000cwb.googlegrou ps.com:
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
Jun 8 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.