|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Mutiple values for variable
>
> 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.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








