V
Vince C.
Hi, all.
I'd like to know if there's a way to simplify writing attribute values in XSLT.
The case is the following:
<xsl:template ...>
<div id="{ if (@id) @id else generate-id() }">Div Text</div>
</xsl:template>
If context node has an @id then I want that id for output. Otherwise I want to
generate an id if there is none. I know the "long" method which is:
<xsl:attribute name="id">
<xsl:choose>
<xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
<xsltherwise><xsl:value-of select="generate-id()"/></xsltherwise>
</xsl:choose>
</xsl:attribute>
But it's too long to me. Is there a shortcut? Note as I'm using MSXML4 I can use
MS XSL extensions too.
Thanks for any hint/suggestion,
Vince C.
I'd like to know if there's a way to simplify writing attribute values in XSLT.
The case is the following:
<xsl:template ...>
<div id="{ if (@id) @id else generate-id() }">Div Text</div>
</xsl:template>
If context node has an @id then I want that id for output. Otherwise I want to
generate an id if there is none. I know the "long" method which is:
<xsl:attribute name="id">
<xsl:choose>
<xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
<xsltherwise><xsl:value-of select="generate-id()"/></xsltherwise>
</xsl:choose>
</xsl:attribute>
But it's too long to me. Is there a shortcut? Note as I'm using MSXML4 I can use
MS XSL extensions too.
Thanks for any hint/suggestion,
Vince C.