XSLTC redirect has problem with relative filenames
--------------------------------------------------

         Key: XALANJ-2288
         URL: http://issues.apache.org/jira/browse/XALANJ-2288
     Project: XalanJ2
        Type: Bug
  Components: XSLTC  
    Reporter: Stephen Suen


According the javadoc of class Redirect:
 
Filenames can be relative or absolute. If they are relative, the base directory 
will be the same as the base directory for the output document.
 
With Xalan interpretive processor, this works fine. But with XSLTC, the output 
seems to be written
into the directory relative to the current working directory.
 
Here's the stylesheet showing the problem (styles/writer.xsl):
 
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:xalan=" http://xml.apache.org/xalan "
  xmlns:redirect=" http://xml.apache.org/xalan/redirect";
  extension-element-prefixes="xalan redirect"
  version="1.0"> 

  <xsl:template name="checkExtensions">
    <xsl:if test="not(element-available('redirect:write'))">
      <xsl:message terminate="yes">
        <xsl:text>Extension element redirect:write NOT available.</xsl:text> 
        <xsl:text>XSL vendor: </xsl:text>
        <xsl:value-of select="system-property('xsl:vendor')"/>
      </xsl:message>
    </xsl:if>
    <xsl:if test="not(function-available('xalan:nodeset'))"> 
      <xsl:message terminate="yes">
        <xsl:text>Extension function xalan:nodeset NOT available.</xsl:text>
        <xsl:text>XSL vendor: </xsl:text>
        <xsl:value-of select="system-property('xsl:vendor')"/> 
      </xsl:message>
    </xsl:if>
  </xsl:template>

  <!-- =================================================================== -->

  <xsl:template name="write">
    <xsl:param name="filename"/>
    <xsl:param name="content"/>
    <xsl:param name="quiet" select="'0'"/> 

    <xsl:call-template name="checkExtensions"/>

    <xsl:if test="$quiet = '0'">
      <xsl:message>
        <xsl:text>Writing output to file: </xsl:text>
        <xsl:value-of select="$filename"/>
      </xsl:message> 
    </xsl:if>

    <redirect:write file="{$filename}">
      <xsl:copy-of select="xalan:nodeset($content)"/>
    </redirect:write>

  </xsl:template>

  <!-- =================================================================== -->

  <!-- testcase
  -->
  <xsl:template match="/">
    <xsl:message>
      <xsl:text>XSL Vendor: </xsl:text>
      <xsl:value-of select="system-property('xsl:vendor')"/> 
    </xsl:message>

    <xsl:call-template name="write">
      <xsl:with-param name="filename" select="'testout.xml'"/>
      <xsl:with-param name="content" select="/"/> 
    </xsl:call-template>
  </xsl:template>
  
</xsl:stylesheet>

I process input document against this stylesheet with the following script:
 
SETLOCAL
SET 
CLASSPATH=E:\apache\xalan-j_2_7_0\serializer.jar;E:\apache\xalan-j_2_7_0\xalan.jar;E:\apache\xalan-j_2_7_0\xercesImpl.jar;E:\apache\xalan-j_2_7_0\xml-apis.jar
rm -r build
mkdir build
java -Duser.language=en org.apache.xalan.xslt.Process -xsltc -in src/index.xml 
-xsl styles/writer.xsl -out build/main.xml
ENDLOCAL

The another output file named "testout.xml" is written out into current working 
directory.



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to