[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Mutiple values for variable

Subject: RE: Mutiple values for variable
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 20 Sep 2002 10:17:21 +0100
xpath mutiple node values
> 
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.