Sadly I'm posting to myself. Here's a solution.
Add the following to the top of the schema file.
<?xml version="1.0"?>
<!DOCTYPE xsd:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN"
"http://www.w3.org/2001/XMLSchema.dtd" [
<!ENTITY % p 'xsd:'><!-- overriden, default namespace is xs -->
<!ENTITY % s ':xsd'>
]>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
...
$ xerces.sh po.xsd -v
po.xsd: 2864 ms (37 elems, 61 attrs, 1061 spaces, 145 chars)
This will validate. BTW xerces.sh is just a shell script that add
the
xerces.jar and xercesSamples.jar to the classpath and calls java
sax.SAXCount. Other ideas welcome.
Eric
Eric Richardson wrote:
>
> Hi,
>
> I was trying to parse the po.xsd from
> http://www.w3.org/TR/xmlschema-0/#po.xsd. I'm using xerses1.4.1 for
> java.
>
> usage: java sax.SAXCount (options) uri ...
>
> options:
> -p name Specify SAX parser by name.
> -n | -N Turn on/off namespace [default=on]
> -v | -V Turn on/off validation [default=off]
> -s | -S Turn on/off Schema support [default=on]
> -f | -F Turn on/off Schema full consraint checking [default=off]
> -d | -D Turn on/off deferred DOM [default=on]
> -l | -L Turn on/off external DTD loading [default=on]
> -w Warmup the parser before timing.
> -h This help screen.
>
> Here is the command I'm using.
>
> $ java sax.SAXCount po.xsd -v
> [Error] purchase-order.xsd:2:58: General Schema Error: Grammar with uri
> 2: http://www.w3.org/2001/XMLSchema , can not be found.
> [Error] po.xsd:2:58: Element type "xsd:schema" must be declared.
> ......
>
> Does anybody know what the correct url is for the following?
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>
> Or am I totally in left field and you can't validate an XML file that
> contains schema?
>
> Eric