Go Back   Velocity Reviews > Newsgroups > XML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

XML - Xalan document() function finding wrong document root

 
Thread Tools Search this Thread
Old 07-28-2003, 03:28 AM   #1
Default Xalan document() function finding wrong document root


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:

<xslaram name="other_file">other_file.xml</xslaram>

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


Steve Carrow
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump