AVT / Curly braces : why don't they work for me ?

G

Geathaa

Hello everyone,

I'm using Xalan for some XSLT transformations. I could have sworn that
some template I wrote worked some time ago, but suddenly it doesnt
seem to work any more ...? Whatever the reason, I wrote the following
simple example to verify the strange behavior of my XSLT
Transformator:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:eek:utput method="html"/>

<xsl:template match="/">
<xsl:call-template name="Header">
<xsl:with-param name="param1" select="'HelloWorld'"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="Header">
<xsl:param name="param1" select="''"/>
<html><body>

<!-- This prints {$param1} - but why? -->
<h1>{$param1}</h1>
<!-- This prints Hello World - as expected -->
<h1><xsl:value-of select="$param1"/></h1>

</body></html>
</xsl:template>

</xsl:stylesheet>

For all I know, after the transformation both <h1> tags should contain
the String HelloWorld, shouldn't they ? Or am I making some horribly
simple error I'm just too blind to see ;o) ?

Thx for your help.
 
M

Martin Honnen

Geathaa said:
Hello everyone,

I'm using Xalan for some XSLT transformations. I could have sworn that
some template I wrote worked some time ago, but suddenly it doesnt
seem to work any more ...? Whatever the reason, I wrote the following
simple example to verify the strange behavior of my XSLT
Transformator:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:eek:utput method="html"/>

<xsl:template match="/">
<xsl:call-template name="Header">
<xsl:with-param name="param1" select="'HelloWorld'"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="Header">
<xsl:param name="param1" select="''"/>
<html><body>

<!-- This prints {$param1} - but why? -->
<h1>{$param1}</h1>
<!-- This prints Hello World - as expected -->
<h1><xsl:value-of select="$param1"/></h1>

</body></html>
</xsl:template>

</xsl:stylesheet>

For all I know, after the transformation both <h1> tags should contain
the String HelloWorld, shouldn't they ? Or am I making some horribly
simple error I'm just too blind to see ;o) ?

AVT means attribute value template so your curly braces have no meaning
outside of an attribute value.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top