xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott_B...@lotus.com
Subject Re: Xalan 2.0.0
Date Tue, 13 Mar 2001 16:29:55 GMT

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'" <general@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


Mime
View raw message