This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: JAXP URIResolver is being called twice?
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] JAXP URIResolver is being called twice?
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Tue, 18 Sep 2001 17:54:00 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
The XSLT processor you are using is Xalan; I suggest you raise this on the
Xalan list.
Mike Kay
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of
> Taras Tielkes
> Sent: 18 September 2001 17:13
> To: Xsl-List (E-mail)
> Subject: [xsl] JAXP URIResolver is being called twice?
>
>
> Hi,
>
> I'm registering a custom URI resolver in the XSLT processor
> that shipped
> with JAXP 1.1(.1?).
>
> Here's the source:
> ------------------------
> import java.io.StringReader;
> import java.io.FileOutputStream;
>
> import javax.xml.transform.stream.StreamSource;
> import javax.xml.transform.stream.StreamResult;
> import javax.xml.transform.*;
> import javax.xml.transform.dom.*;
>
> public class CustomURIResolver implements URIResolver
> {
> public static void main(String[] args)
> {
> try
> {
> String sourceXML = "<x/>";
>
> StreamSource xsl = new
> StreamSource("resolve.xsl");
> StreamSource xml = new StreamSource(new
> StringReader(sourceXML));
>
> TransformerFactory tf =
> TransformerFactory.newInstance();
>
> Transformer t = tf.newTransformer(xsl);
> t.setURIResolver(new CustomURIResolver());
>
> StreamResult r = new StreamResult(new
> FileOutputStream("c:\\out.xml"));
>
> t.transform(xml, r);
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> }
>
> public Source resolve(String relURI, String base)
> {
> System.err.println("[resolve] relURI = " +
> relURI + " + base
> = " + base);
>
> return null;
> }
> }
> ------------------------
>
> The XSL is very simple:
> ------------------------
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:template match="/">
> <xsl:apply-templates select="document('dummy')"/>
> </xsl:template>
>
> </xsl:stylesheet>
> -------------------------
>
> The output however, is unexpected:
> -------------------------
> [resolve] relURI = dummy + base = file:/C://resolve.xsl
> [resolve] relURI = dummy + base = file:/C://resolve.xsl
> file:/C://resolve.xsl; Line 5; Column -1; Can not load requested doc:
> C:\dummy (The system cannot find the file specified)
>
> Of course, I understand the last line, but why is my resolver
> called twice?
> Even when I actually return a valid Source subclass instance, the same
> behaviour can be observed.
>
> Am I missing something abvious?
>
> Thanks in advance,
> Taras Tielkes
>
>
>
>
>
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list