S
Steve Carrow
Hello,
I'm trying to write a web app where an XML source file is transformed
by an XSL document via a Java 1.4.1 servlet. Development is under WSAD
5 on Windows 2000. The XSL document refers to another XML file in the
same directory as the source; that is done via a:
"document(concat($other_file, ''), .)" call, where $other_file was
defined by:
<xsl
aram name="other_file">other_file.xml</xsl
aram>
My reading has led me to believe that that is the way to access the
XML file if it is in the same directory as the source. This did work
under XMLSPY (only after I added the "concat" call; didn't seem to
like RTFs), but under the Websphere Application Development
environment, 'other_file.xml' is searched for under the installation
directory. This also occurs under Tomcat 4.1. This seems just wrong
and may be linked to the Java code invoking the transformation, a
synopsis of which follows:
URL xslURL = getServletContext().getResource("/xsl/subdir/file.xsl");
StreamSource xslSource = new StreamSource(xslURL.openStream());
URL xmlURL = getServletContext().getResource("/xml/file.xml");
StreamSource xmlSource = new StreamSource(xmlURL.openStream());
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xslSource);
//
// (Parameter fill-in)
//
transformer.setParameter("other_file", "other_file.xml");
//
//
transformer.transform(xmlSource, new StreamResult(out));
My guess is that not enough info to truly establish a base URI is
being passed into the transformer. If so, my question has two parts:
- How can I pass the URI info in?
- Why is that not the default behavior? As it stands, the document()
function behavior clearly seems to contradict both the standard and
Michael Kay.-))
Thanks for any help on this,
Steve Carrow
I'm trying to write a web app where an XML source file is transformed
by an XSL document via a Java 1.4.1 servlet. Development is under WSAD
5 on Windows 2000. The XSL document refers to another XML file in the
same directory as the source; that is done via a:
"document(concat($other_file, ''), .)" call, where $other_file was
defined by:
<xsl
My reading has led me to believe that that is the way to access the
XML file if it is in the same directory as the source. This did work
under XMLSPY (only after I added the "concat" call; didn't seem to
like RTFs), but under the Websphere Application Development
environment, 'other_file.xml' is searched for under the installation
directory. This also occurs under Tomcat 4.1. This seems just wrong
and may be linked to the Java code invoking the transformation, a
synopsis of which follows:
URL xslURL = getServletContext().getResource("/xsl/subdir/file.xsl");
StreamSource xslSource = new StreamSource(xslURL.openStream());
URL xmlURL = getServletContext().getResource("/xml/file.xml");
StreamSource xmlSource = new StreamSource(xmlURL.openStream());
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xslSource);
//
// (Parameter fill-in)
//
transformer.setParameter("other_file", "other_file.xml");
//
//
transformer.transform(xmlSource, new StreamResult(out));
My guess is that not enough info to truly establish a base URI is
being passed into the transformer. If so, my question has two parts:
- How can I pass the URI info in?
- Why is that not the default behavior? As it stands, the document()
function behavior clearly seems to contradict both the standard and
Michael Kay.-))
Thanks for any help on this,
Steve Carrow