Alex Rivera | Logout

Printing Out The Value Of An XSL Variable

Asked 2009-04-02T12:57:16.917
18

Can someone please tell me how to print out a variable in my XSL transform? Seems like an easy enough thing to do but I just can't seem to do it. Here's the code I have:

<?xml version='1.0' encoding='UTF-8' ?>
<xsl:stylesheet version="1.0"
  xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template name="ControlledListStructure">
    <xsl:param name="xmlElem" />
    <xsl:param name="dataName" />

    <xsl:element name="{$xmlElem}">
      1: <xsl:text>{$xmlElem}</xsl:text>.
      2: {$xmlElem}.
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>

If I called this template with a value for xmlElem of "Wibble" (a string - not a node), I would get the following output:

<Wibble>
      1: {$xmlElem}.
      2: {$xmlElem}.
</Wibble>

So my parameter is coming over properly, I just can't access it properly. Can someone tell me how I can get $xmlElem to print out properly so that I see:

<Wibble>
      1: Wibble.
      2: Wibble.
</Wibble>

Thanks for any input.

Edit
Report

1 Answer

4

You can use:

<xsl:value-of select="$xmlElem" />
answered 2009-04-02T12:59:48.470

Your Answer