My XML File contents:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<Section ID="ID1" SELECTED="" />
<Section ID="ID2" SELECTED="" />
<Section ID="ID3" SELECTED="" />
<Section ID="ID4" SELECTED="" />
<Section ID="ID5" SELECTED="" />
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Now, I have a list of IDs like say ID1, ID2 and ID5, for
which I wish set
the value of the attribute 'SELECTED' to "YES" and the rest to "NO".
I am not sure as to how I can send multiple value for the
same variable at
the same time and then update the values.
Can someone please give me some kind of a pointer.
XPath 2.0 handles "lists of strings", but in XPath 1.0, the only way to
handle a list is using an XML tree structure.
So make your list:
<xsl:variable name="list">
<id>ID1</id>
<id>ID2</id>
<id>ID5</id>
</xsl:variable>
and then the transformation is:
<xsl:template match="Section">
<xsl:copy>
<xsl:copy-of select="@ID"/>
<xsl:attribute name="SELECTED">
<xsl:choose>
<xsl:when test="@ID=xx:node-set($list)/id">YES</xsl:when>
<xsl:otherwise>NO</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:copy>
</xsl:template>
Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list