| Subject: RE: [xsl] Mutiple values for variable From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Fri, 20 Sep 2002 10:17:21 +0100 | 
> 
> 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
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: [xsl] Mutiple values for variab, David Carlisle | Thread | [xsl] NaN?, thomas | 
| RE: [xsl] Calculation using the pos, Jarno . Elovirta | Date | RE: [xsl] Calculation using the pos, Clifford, Karen | 
| Month |