Xalan document() function finding wrong document root

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Carrow

    #1

    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(conca t($other_file, ''), .)" call, where $other_file was
    defined by:

    <xsl:param name="other_fil e">other_file.x ml</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 = getServletConte xt().getResourc e("/xsl/subdir/file.xsl");
    StreamSource xslSource = new StreamSource(xs lURL.openStream ());
    URL xmlURL = getServletConte xt().getResourc e("/xml/file.xml");
    StreamSource xmlSource = new StreamSource(xm lURL.openStream ());
    TransformerFact ory tFactory = TransformerFact ory.newInstance ();
    Transformer transformer = tFactory.newTra nsformer(xslSou rce);
    //
    // (Parameter fill-in)
    //
    transformer.set Parameter("othe r_file", "other_file.xml ");
    //
    //
    transformer.tra nsform(xmlSourc e, new StreamResult(ou t));

    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
Working...