[xsl] Passing DTD as systemID into StreamSource

Subject: [xsl] Passing DTD as systemID into StreamSource
From: "Pramodh Peddi" <peddip@xxxxxxxxxxxxxxxx>
Date: Thu, 6 Nov 2003 20:17:13 -0500
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


Current Thread