Hi Erin,
Hi Stephen,
This looks like a bug. It was fixed for interpreted: https://issues.apache.org/jira/browse/XALANJ-647 but not for compiled. Please open a new jira issue against the XalanJ2 project: http://issues.apache.org/jira
One workaround would be to specify a parameter so the stylesheet would now have a top level param declaration:
<xsl:param name="dirname" select="'.'"/>
And the call to write could be changed to:
<xsl:template match="/">
<xsl:call-template name="write"><xsl:with-param name="filename" select="concat($dirname, '/testout.xml')"/>
<xsl:with-param name="content" select="/"/>
</xsl:call-template>
</xsl:template>Then on the command line for xsltc you can add:
-param dirname build
Erin Harris
"Stephen Suen" < [EMAIL PROTECTED]>03/31/2006 02:47 AM
Please respond to
stephen.suen
Toxalan-j-users@xml.apache.org cc SubjectXSLTC redirect function has problem with relative filenames
Hi,
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
ENDLOCALThe another output file named "testout.xml" is written out into current working directory.
How can I work around this problem, or just fall back to the interpretive processor?
Any help will be appreciated.
--
Stephen Suen
[EMAIL PROTECTED]
--
Stephen Suen
[EMAIL PROTECTED]