Passing html tags with with-param?

Hi.

I suppose this is a simple solution for this, but I can't make it work.

I want to transform xml to html via an xslt transform. In the html there is supposed to be several identical links to the same page, but with different content inside the <a></a> tags. Sometimes there must be text, sometimes an image.

I made a xsl template for these links, similar to this:

<xsl:template name="DoLink">
<xsl:param name="seqNo" />
<xsl:param name="content" />
<a>
<xsl:attribute name="href">javascript:OpenDetails('Analysis', <xsl:value-of select="$seqNo" />,'', '', '');
</xsl:attribute>
<xsl:value-of select="$content" />
</a>
</xsl:template>

This is called via:

<xsl:call-template name="DoLink">
<xsl:with-param name="seqNo" select="SeqNo" />
<xsl:with-param name="content">
<
xsl:value-of select="SomeTextData" />
</xsl:with-param>
</
xsl:call-template>

Which works just fine, but:

<xsl:call-template name="DoLink">
<xsl:with-param name="seqNo" select="SeqNo" />
<xsl:with-param name="content">
<img src="someimage.gif" />
</xsl:with-param>
</
xsl:call-template>

does not.

If I escape the <>:s of the img tag, I end up with &lt;img &gt; in my html. If I don't, the image tag is stripped away completly.

Does anybody have some elegant solution to this

Best regards

/Gustav



Answer this question

Passing html tags with with-param?

  • Steven Ts

    Of course! Thanks.


  • Dumpster

    Use xsl:copy-of instead of xsl:value-of.

    <xsl:template name="DoLink">
    <xsl:param name="seqNo"
    />
    <xsl:param name="content"
    />
    <a
    >
    <xsl:attribute name="href">javascript:OpenDetails('Analysis', <xsl:value-of select="$seqNo" />,'', '', '');
    </xsl:attribute
    >
    <xsl:copy-of select="$content"
    />
    </a
    >
    </xsl:template>

    --VV [MS]
    vascov@microsoft.com


  • Passing html tags with with-param?