[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Relative URLs using the file scheme?


xsi schemalocation relative path
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:
>>    
>>
>
>  
>


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.