tags:

views:

400

answers:

3

I am trying to set an a href that is both a link to and has the text for a link through an XSLT transformation. Here's what it looks like so far.

<xsl:element name="a">
                            <xsl:attribute name="href">
                                <xsl:value-of select="actionUrl"/>
                            </xsl:attribute>
                            <xsl:text><xsl:value-of select="actionUrl"/></xsl:text> 
                        </xsl:element>

The problem is that it says "xsl:value-of cannot be a child of the xsl:text element". Any ideas?

+1  A: 

You don't need the xsl:text element:

<xsl:element name="a">
  <xsl:attribute name="href">
    <xsl:value-of select="actionUrl"/>
  </xsl:attribute>
  <xsl:value-of select="actionUrl"/>
</xsl:element>
Oded
+2  A: 

<xsl:text> defines a text section in an XSL document. Only real, plain text can go here, and not XML nodes. You only need <xsl:value-of select="actionUrl"/>, which will print text anyways.

<xsl:element name="a">
    <xsl:attribute name="href">
        <xsl:value-of select="actionUrl"/>
    </xsl:attribute>
    <xsl:value-of select="actionUrl"/>
</xsl:element>
zneak
+2  A: 

You can also do:

<a href="{actionUrl}"><xsl:value-of select="actionUrl"/></a>
lexicore
Thanks, Dimitre, a typo. Too much EL lately.
lexicore
Actually, actionurl is not a variable -- just an element name. Therefore, thete must be no "$" sign at the start of the name.
Dimitre Novatchev