Xalan document() function finding wrong document root

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:param name="other_file">other_file.xml</xsl:param>

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,187
Latest member
RosaDemko

Latest Threads

Top