You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Albert Tsun <al...@excel.com.hk> on 2001/02/15 10:28:47 UTC

Compatiable % xalan-j_1_2_D02 & new Xalan-Java2 : redirect, entity ref, thread-safe


Hi Xalan Developer,

I have downloaded the new Xalan-Java2, there is some difference from the
one I used xalan-j_1_2_D02.

(1)  In my old java program,
processor.setStylesheetParam("outputpath", "'file:\\d:\\output'");
processor.setStylesheetParam("gendate", "'20001129'");

stylesheet :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:SetReport2="
http://www.excelhk.com/settlement/report2/"
                xmlns:xalan="http://xml.apache.org/xslt"
                xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
                extension-element-prefixes="redirect"
                version="1.0">

<xsl:param name="outputpath"
select="'file:\d:\setproject\settlement\output'"/>
<xsl:param name="gendate" select="'20001231'"/>

<xsl:template match="SetReport2:Header">
    <xsl:variable name="file" select="concat('header_',$gendate,'.xml')"/>
    <redirect:write file="{$outputpath}/{$file}">
        <xsl:call-template name="print-header"/>
    </redirect:write>
</xsl:template>

I works fine for xalan-j_1_2_D02..

However, when I use the new API (Transformer)

     transformer = tFactory.newTransformer(new StreamSource(xslfile));

provided by Xalan-Java2 and pass "file:/d:/SETProject/output/" as
outputpath parameter into the stylesheet, the xalan XSLT transformer make
the string value I passed to XSL quoted with "'" which makes the file path
construction logic making an invalid file path.

(2) Besides, in my previously worked XSL, I usually put below section at
the begining of each file

<!DOCTYPE xsl:stylesheet [
<!ENTITY nl "<xsl:text>&#xA;</xsl:text>">
<!ENTITY nbsp "<xsl:text>&#x20;</xsl:text>">
]>

and I use
     &nl;
     &nbsp;
in somewhere inside the XSL.

However, when I use transform
        transformer = tFactory.newTransformer(new StreamSource(xslfile));

The parser seems to treat it as invalid syntax and shows error. However, it
 was OK when I use xalan-j_1_2_D02..

(3) Anyway,  I want to check that if the follow call is THREAD-SAFE in
multi-thread env.

     transformer.transform(new StreamSource(xmlfile), new StreamResult(new
FileOutputStream(datafile)));

     Because I find that the previous version seems to have multi-thread
problems.


     XSLTProcessor.process(new XSLTInputSource(xmlfile),
                      new XSLTInputSource(xslfile),
                      new XSLTResultTarget(new FormatterToText(fw)));

Is there any ways I can solve it if I want to use the new Xalan-Java2 API ?

Thanks in advance.