<xsl:template match="HtmlCode">
<xsl:copy-of select="child::*|text()"/>
</xsl:template>
<xsl:call-template name="HappyFriend">
<xsl:with-param name="text" select="'i am a friggin' RRRRROOOOOOOVVVERRRRR~~'"/>
</xsl:call-template>
<xsl:template name="HappyFriend">
<xsl:param name="text"/>
<HtmlCode>
<span> <%="text"%> </span>
</HtmlCode>
<xsl:template>
somehow i keep getting XSLT issues...all i am trying to do is to get the value of the variable "text" which is "i am a frigggin RRROVERRR" to appear into a i am a frigggggin' RRROOOVVVERRRR~~ in the "HappyFriend" template.
What am i doing wrong?
Several problems:
-- The string literal 'i am a friggin' RRRRROOOOOOOVVVERRRRR~~'
contains unbalanced single quotes. You probably want
<xsl:with-param name="text" select='"i am a friggin' RRRRROOOOOOOVVVERRRRR~~"'/>
-- The call-template
cannot occur outside of a template definition.
-- To refer to the parameter you should be using value-of-select
, as in
<span> <%="<xsl:value-of select="$text"/>"%> </span>
Here is one correct way to do what I guess you want:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="HtmlCode">
<xsl:copy-of select="child::*|text()"/>
<xsl:call-template name="HappyFriend">
<xsl:with-param name="text" select='"i am a friggin' RRRRROOOOOOOVVVERRRRR~~"'/>
</xsl:call-template>
</xsl:template>
<xsl:template name="HappyFriend">
<xsl:param name="text"/>
<HtmlCode>
<span><xsl:value-of select="$text"/></span>
</HtmlCode>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the following XML document (none has been provided!!!):
<HtmlCode/>
The wanted, correct result is produced:
<HtmlCode>
<span>i am a friggin' RRRRROOOOOOOVVVERRRRR~~</span>
</HtmlCode>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With