You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Sc...@lotus.com on 2001/03/13 17:29:55 UTC

Re: Xalan 2.0.0

Do:

      Transformer transformer = tFactory.newTransformer(new
StreamSource(new
File("/dir1/dir2/toplevel.xsl")));

or:

StreamSource source = new StreamSource(new FileReader
("/dir1/dir2/toplevel.xsl")));
source.setSystemId("/dir1/dir2/toplevel.xsl");
Transformer transformer = tFactory.newTransformer(source);

As you have it, there is no way for the system to get the base URL of the
input reader, so it uses the current directory.

By the way, you are much better off using an InputStream rather than a
Reader.  With a Reader, the parser can't do the proper character decoding
from whatever the encoding is specified in the XML document.

-scott




                                                                                                                    
                    "Samson,                                                                                        
                    Lyndon [IT]"          To:     "'general@xml.apache.org'" <ge...@xml.apache.org>               
                    <lyndon.samson        cc:     (bcc: Scott Boag/CAM/Lotus)                                       
                    @ssmb.com>            Subject:     Xalan 2.0.0                                                  
                                                                                                                    
                    03/13/01 12:10                                                                                  
                    PM                                                                                              
                    Please respond                                                                                  
                    to general                                                                                      
                                                                                                                    
                                                                                                                    





Hi Groovy XML people!

I have a situation where I have a Stylesheet which includes others like;

<xsl:include href="feature1.xsl"/>
<xsl:include href="feature2.xsl"/>

The w3c docs say that the included files are relative to the base URI, that
is
the URI of the top level document.

I have some simple code which looks like this

           StreamSource s = ...; // Some Streamsource
           TransformerFactory tFactory = TransformerFactory.newInstance();
      Transformer transformer = tFactory.newTransformer(new
StreamSource(new
FileReader("/dir1/dir2/toplevel.xsl")));
      StringWriter xmlOut = new StringWriter();
      transformer.transform(s, new StreamResult(xmlOut));

Any files 'included' in the toplevel.xsl stylesheet are relative to the
current directory ( System.getProperties.getProperty("user.dir") ) rather
than the base URI of the toplevel style sheet as expected.

Is this meant to happen? What's a way around it?

thx
lyndon


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org






---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org