tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject XSLT Filter question (slightly OT)
Date Sat, 14 Sep 2002 07:20:58 GMT

I have an XSLT filter working which filters *.xml files.  Each xml file has 
a stylesheet associated with it via an <?xml-stylesheet?> PI.  I extract 
the stylesheet like this...

TransformerFactory tf = TransformerFactory.newInstance();
SAXTransformerFactory stf = (SAXTransformerFactory)tFactory;
Source styleSource = stf.getAssociatedStylesheet(xmlSource, null, null, null);

This returns the Source object just fine.  However, it makes a difference 
how I reference the stylesheet....

1.  <?xml-stylesheet type="text/xsl" 
href="http://localhost:8080/mycontext/xml/mystylesheet.xsl"?>

This works fine as the Source knows exactly how to get the stylesheet on 
the web since it just gets it from the URL and I can do...

Transformer transformer = tf.newTransformer(xslSource);


2  1.  <?xml-stylesheet type="text/xsl" href="mystylesheet.xsl"?>

The source returned here thinks that this is a local file.  On windows, it 
uses File IO to look in C:\winnt\system32 to try to find the 
"mystylesheet.xsl" file rather than referencing the file where it actually 
exists in the current context that the filter is running in.


My question is, how can I make it so relatively referenced stylesheets get 
a reference to where they exist on the web?  That is, that they get pulled 
via a URL.  I understand that I'd have to provide the URL.  I just don't 
know how to go about setting the URL so that 
stf.getAssociatedStylesheet(xmlSource, null, null, null) returns a Source 
object which points to that source at the proper URL???

Am I going to have to do some sort of DOM manipulation and check whether a 
fully qualified URL has been set, set it if it hasn't, and then call 
stf.getAssociatedStylesheet(xmlSource, null, null, null)?  I'm hoping there 
is a simpler and more generic solution than that.

Any ideas?

Jake


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message