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

Re: Passing DTD as systemID into StreamSource

Subject: Re: Passing DTD as systemID into StreamSource
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Fri, 07 Nov 2003 21:41:37 +0100
streamsource systemid
Pramodh Peddi wrote:
I am just passing the dtdURL, asking it to validate using the given dtdURL.

The problem is, the parameter is *not* the URL pointing to the DTD but the URL for the *source* you are passing. It is used as base URL for resolving URLs in the XML document.

The dtdURL is "http://servername:80/dir/SonyDAM.dtd". The funky thing it is
doing is, it is resolving the name to be
"http://servername:80/dir/SonyDam.dtd". I did not understand why it is doing
that.

I guess the DOCTYPE in the source is <!DOCTYPE whatever SYSTEM "SonyDam.dtd"> instead of <!DOCTYPE whatever SYSTEM "SonyDAM.dtd">

If what I am doing is wrong, is there any other way I can do this?

A more common approach is to write a custom entity resolver (or go to http://xml.apache.org/commons/components/resolver/index.html and get James Clark's cataolg based resolver), and provide it to the parser, roughly like XMLReader parser = SAXParserFactory.newInstance().newSAXParser().getXMLReader() parser.setEntityResolver(myEntityResolver); ... transformer.transform(new SAXSource(parser,new InputStream(...),...)


One more question reg'g dtd: If we have
<!DOCTYPE SONY_PRODUCT_METADATA SYSTEM "Metadata.dtd">

in the xml source, where should the Metadata.dtd be placed when the
transformation is done inside an application server? Where does it first
look into to find the dtds?

If the software can determine an absolute URL as the base URL, the DTD system id is resolved against this base URL the usual way (should be in the relevant RFCs). If the base URL can't be determined or is a relative URL itself, a processor specific fallback is used. This is often assuming the current working directory of the process as base URL, which is most probably something you wont like to use in the case of an application server. Other fallbacks, including throwing runtime exceptions, are not unheard of. Your best bets: - always provide a proper absolute URL for any input - use an EntityResolver and perhaps URIResolvers

J.Pietschmann



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

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
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.