Passing DTD as systemID into StreamSource
Hi, I am transforming an xml source which has a DTD reference inside it (passing as systemID). The wierd thing is, the DTD is referenced with just a filename (which is very unusual and stupid!, but thats cutomer's feed and we do not have control in it). And fortunately that file is in a http accessible location. So, I am doing this: (I am using Java1.4's API for Transformation) transformer.transform(new StreamSource(new StringReader(metadata), dtdURL), new StreamResult(new OutputStreamWriter(outputStream, "UTF-8"))); I am just passing the dtdURL, asking it to validate using the given dtdURL. 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. And when we rename the SonyDAM.dtd to SonyDam.dtd, it worked. Can any one tell why it is doing that? If what I am doing is wrong, is there any other way I can do this? What is the usual and best way to pass in a dtd url, though the xml source has dtd reference - asking it to use the dtd url which we give while parsing, but not the dtd which is there in the xml source (because, in my case, the dtd reference is just a filename). 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? I would appreciate any suggestions and help. Thanks, Pramodh. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format