Parameters in stylesheets

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">
<xsl:param 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,838
Latest member
KandiceChi

Latest Threads

Top