A
Alexey Dmitriev
Hi all...
I set parameter for transformer, but actual output is not valid as expected.
Scrap of code
--------------
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new
StreamSource("foo.xsl"));
transformer.setParameter("param1", ".");
transformer.transform(new StreamSource("foo.xml"), new StreamResult(new
OutputStreamWriter(System.out)));
Input xml
------------
<doc>Hello</doc>
Input xsl
------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslaram name="param1" select="'default value'"/>
<xsl:template match="doc">
<out><xsl:value-of select="$param1"/></out>
</xsl:template>
</xsl:stylesheet>
Actual output
------------
<out/>
Expected output (in my mind)
-----------------------------
<out>Hello</out>
What's wrong? Why actual output don't contain "Hello"?
Environment: j2sdk1.4.2_04
I set parameter for transformer, but actual output is not valid as expected.
Scrap of code
--------------
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new
StreamSource("foo.xsl"));
transformer.setParameter("param1", ".");
transformer.transform(new StreamSource("foo.xml"), new StreamResult(new
OutputStreamWriter(System.out)));
Input xml
------------
<doc>Hello</doc>
Input xsl
------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslaram name="param1" select="'default value'"/>
<xsl:template match="doc">
<out><xsl:value-of select="$param1"/></out>
</xsl:template>
</xsl:stylesheet>
Actual output
------------
<out/>
Expected output (in my mind)
-----------------------------
<out>Hello</out>
What's wrong? Why actual output don't contain "Hello"?
Environment: j2sdk1.4.2_04