Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XSLT: Relative URI "my.dtd" can not be resolved without a base URI

From: olgt-nospam@-------.--- (-----)
To: NULL
Date: 8/2/2004 1:50:00 PM
Greetings to all -

I'm having a problem processing xml with relative dtd URI specified
using XSLT:

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mydoc SYSTEM "my.dtd">
<mydoc>
...
</mydoc>

I do not have a control over the original xml but I have my.dtd in the
app classpath. I'm getting the TransformerException: Relative URI
"my.dtd" can not be resolved without a base URI.

How do I tell to javax.xml.transform.Transformer where to find the dtd
file w/out specifying the base URI (or any other modifications of the
original xml)?

Here is how I call the xsl transformer:

//  1. Instantiate a TransformerFactory.
javax.xml.transform.TransformerFactory tFactory =
	javax.xml.transform.TransformerFactory.newInstance();

//  2. Use the TransformerFactory to process the stylesheet Source and
//     generate a Transformer.
javax.xml.transform.Transformer transformer =
	tFactory.newTransformer(new
javax.xml.transform.stream.StreamSource(xsl));

//transformer.setURIResolver(new RelativeURIResolver());

//  3. Use the Transformer to transform an XML Source and send the
//     output to a Result object.
transformer.transform(
	new javax.xml.transform.stream.StreamSource(xml),
	new javax.xml.transform.stream.StreamResult(out));

As you can see above, I've tried to use URIResolver() but it does not
appear to be used by the transformer to resolve the DTD.

I'm using Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.2_03-b02) and default xslt processor and xml parser from there
("org.apache.xalan.processor.TransformerFactoryImpl" and
"org.apache.crimson.jaxp.DocumentBuilderFactoryImpl" I assume).

Of course, I could use java.util.regex to either remove
<!DOCTYPE[a-zA-Z0-9\". ]*> completely or to add the base url there.
But I wonder if there is more elegant solution to this.

Any suggestions are very appreciated.
Thanks
Pavel


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent