Xalan document() function finding wrong document root

Discussion in 'Java' started by Steve Carrow, Jul 28, 2003.

  1. Steve Carrow

    Steve Carrow Guest

    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
    Steve Carrow, Jul 28, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Bedford
    Replies:
    0
    Views:
    416
    Chris Bedford
    Aug 17, 2003
  2. Mark F
    Replies:
    0
    Views:
    445
    Mark F
    Mar 7, 2005
  3. Steve Carrow
    Replies:
    0
    Views:
    616
    Steve Carrow
    Jul 28, 2003
  4. Chris Bedford
    Replies:
    0
    Views:
    530
    Chris Bedford
    Aug 17, 2003
  5. cvissy
    Replies:
    0
    Views:
    600
    cvissy
    Nov 16, 2004
Loading...

Share This Page