[
Lists Home |
Date Index |
Thread Index
]
Hi Mike,
>I just read today that "SAX specifically disallows relative URIs." [1] %^}
>
Thanks for the link. Ok, so from what I can understand you can't specify
relative URIs when parsing an XML document. However, this is not really
the case for me. Here is the code snippet I'm using:
// Get an XMLReader instance
XMLReader reader =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
// Register the Error handler
reader.setErrorHandler(errorHandler);
// Set the features on the parser
noErrorMessage = setParserFeatures(reader);
// Create the input source
InputSource inputSource = new InputSource(new
StringReader(data.toString()));
inputSource.setSystemId(fileLocation);
reader.parse(inputSource);
So, the data is passed to the InputSource object and then the systemId
is set. Note that at this stage the fileLocation is an absolute path and
NOT a relative path.
Now, if the data I'm parsing contains an xsi:schemaLocation attribute
with a relative path it fails which seems a bit strange to me since I
believe the parser should be able to determine the location based on the
base systemId that is provided?
Anyway, even if this is not the case it seems like I can work around the
problem by creating an EntityResolver that will resolve the relative
URIs as specified in the xsi:schemaLocation attribute. However, the main
question still exists:
What is the correct syntax for a relative URI using the file schema?
Cheers,
/Eddie
>
>Mike
>
>[1] http://www.oreilly.com/catalog/sax2/chapter/ch03.html
>
>Eddie Robertsson wrote:
>
>
>>I've run into a problem using Xerces (2.2.0) for W3C XML Schema
>>validation when it comes to specifying relative paths to the schema
>>document. Here is the scenario:
>>
>>
>
>
>
|