Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: "Daniel Parker" <danielaparker@----?--------.----------.--->
To: NULL
Date: 8/2/2004 11:41:00 PM
"Pavel" <olgt-nospam@c...> wrote in message
news:e14b235c.0408021249.6478d7eb@p......
> 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)?
>
Hi Pavel,

Setting a custom URIResolver on the transformer won't help, since this URI
resolver is used only for resolving relative URI's passed to the XSLT
document function.

What you need to do instead is, on an XMLReader that is reading the XML
file, call the setEntityResolver method to set a custom EntityResolver.
Your custom EntityResolver needs to provide a resolveEntity method that will
do the job of substituting the absolute URL for the relative URL, see the
example of an EntityResolver in the java api docs.

So, instead of using a StreamSource to read the document, create an
XMLReader using an XMLReaderFactory, and set the EntityResolver to your
custom resolver, also create an InputSource object with the file URL, and
finally create a SAXSource object with the XMLReader and the InputSource.
That should do it.

Regards,
Daniel Parker
http://servingxml.sourceforge.net/




transparent
Print
Mail
Digg
delicious
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