Project

Profile

Help

samples/java/SchemaValidatorHandlerExample.ja

Added by Anonymous over 18 years ago

Legacy ID: #3378081 Legacy Poster: Kevin Rodgers (notorious_kev)

Can the SchemaValidatorHandlerExample class be modified to access the schema via the XML document's xsi:schemaLocation attribute? I've tested the class as distributed by downloading the schema to a local directory and specifying it on the command line, but validating an XML document against it generates this error message: At line 4 of file:/home/kevinr/GooglePremium/./esdu_test.xml: http://www.w3.org/TR/xml-schema-1#SchemaLocation?http://www.google.com/schemas/sitemap/0.84/sitemap.xsd followed by some normal output: Element urlset of type {http://www.google.com/schemas/sitemap/0.84}#AnonType_urlset Attribute xsi:schemaLocation (specified) of type {http://www.w3.org/2001/XMLSchema-instance}anonymousSimpleType48 Here's what the XML looks like: <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84/sitemap.xsd"> ... </urlset> Thanks! -- Kevin


Replies (1)

RE: samples/java/SchemaValidatorHandlerExampl - Added by Anonymous over 18 years ago

Legacy ID: #3378948 Legacy Poster: Michael Kay (mhkay)

(a) yes, you can easily modify the sample application to take the schema from xsi:schemaLocation (or xsi:noNamespaceSchemaLocation). Just remove the code that deals with the first argument, and call factory.newSchema() with no parameters. This code is provided as a sample for writing your own applications. If you just want to validate a source document, use the com.saxonica.Validate command: see http://www.saxonica.com/documentation/schema-processing/commandline.html (b) your document appears to be invalid. The value of xsi:schemaLocation should be a list of URI pairs - first the namespace URI, then the location of the schema for that namespace.

    (1-1/1)

    Please register to reply