On Thursday, 11/06/2003 at 08:32 EST, "Pramodh Peddi" > 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). This is actually more a Xerces question than a Xalan question. We let the parser do all the work of dealing with DTDs; we don't see the data until long after that's been processed. What do you mean by "just a filename"? Remember, the DTD can legitimately be specified via a Relative URI Reference. But the parser can't resolve that unless it knows where the XML document came from. In your example, > transformer.transform(new StreamSource(new StringReader(metadata), dtdURL), > new StreamResult(new OutputStreamWriter(outputStream, "UTF-8"))); you've misunderstood the StreamSource constructor. The second argument should be the URI of the *source* document (the XML file). If the DTD was pointed to via a relative URI, the parser will then be able to compute its actual URI and retrieve it. > 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". This sounds like the document has specified the DTD's location as "SonyDam.dtd". If so, then if it isn't being found you have two choices: the source document is wrong and needs to be fixed, or the server's filesystem is wrong and the file needs to be renamed. I suspect what has happened is that the customer's server and filesystem are not case-sensitive (eg, they're running on a Windows box), so they didn't notice that the URI doesn't exactly match what's in the filesystem... but you're running on one that *is* case-sensitive (eg Linux) so you're running into trouble. Either that, or when you copied SonyDam.dtd over to your test system you carelessly renamed it SonyDAM.dtd... If you really want to force the system to do something different, dig into the (Xerces?) docs re Entity Resolvers; I believe a suitable entity resolver can be used to redirect DTD references. But it sounds like the right answer really is to rename your DTD file or fix your document. > 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? See above. This is a Relative URI Reference. That actual URI is computed relative to the URI of the document that contains the reference, unless you install an Entity Resolver which does something different.