You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Anthony Ikeda <an...@proxima-tech.com.au> on 2001/05/04 02:25:07 UTC
Re: How do I use a URIResolver?
So far I've just created a basic XML/XSL convertor from scratch in XalanJ2
(changing from Xalanj1) so I can make using imports and includes a bt easier
to handle.
Here is what I've done so far:
public void transformText(String xmlString, URL xslLocation,
String[] parameters, PrintWriter out){
StringReader strrdXml = new StringReader(xmlString);
Source xmlSource = null;
Source xslSource = null;
try{
xmlSource = new StreamSource(strrdXml);
xslSource = new StreamSource(xslLocation.openStream());
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = null;
transformer = tFactory.newTransformer(xslSource);
if(parameters!=null){
for(int i=0;i<parameters.length;i++){
String pair = parameters[i];
String parmName = pair.substring(0,pair.indexOf("="));
String parmValue = pair.substring(pair.indexOf("=")+1,pair.length());
transformer.setParameter(parmName,parmValue);
}
}
transformer.transform(xmlSource, new StreamResult(out));
} catch(Exception e){
DebugListener.printOut(e);
}
}
When I run a stylesheet everything is fine, but any with an include will
return:
javax.xml.transform.TransformerConfigurationException: File
"file:///styleSheets/login.xsl" not found.
Each URL I pass to the above method (from a servlet) is constructed as
follows:
URL xslUrl = new URL("http",request.getServerName(),
request.getServerPort(), altStyleFile);
I've never used a URL to this extent before, so it may be possible that the
protocol value is set incorrectly, then again I can't find any examples that
I can compare against.
Cheers,
Anthony Ikeda
Web Application Developer,
Proxima Technology Pty. Ltd.
----- Original Message -----
From: <My...@lotus.com>
To: <ge...@xml.apache.org>
Sent: Thursday, May 03, 2001 11:20 PM
Subject: Re: How do I use a URIResolver?
>
> Before looking into URIResolvers, which Source are you using? Are you
> calling setSystemID() to set the base where URI's are to be resolved??
> BTW, this is probably a better question for the Xalan list.
>
> Myriam
>
>
>
> "Anthony Ikeda"
> <anthony.ikeda@proxima-te To: "XML General @
Apache"
> ch.com.au>
<ge...@xml.apache.org>
> cc: (bcc: Myriam
Midy/CAM/Lotus)
> 05/03/01 01:40 AM Subject: How do I
use a URIResolver?
> Please respond to general
>
>
>
>
>
>
> I've set up a class to do my transformations with Xalan 2 (which is much
> easier than Xalan 1) but the includes in my stylesheets are being
> referenced from the working folder rather than the server root.
>
> I came across the URIResolver which should correct this problem but there
> isn't any documentation on how to really use it.
>
> Would anyone have any examples?
>
> Cheers,
> Anthony Ikeda
> Web Application Developer,
> Proxima Technology Pty. Ltd.
>
>
>
>
> ---------------------------------------------------------------------
> 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
>