|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Process node set generated by EXSLT tokenize
Mat, You were on the right track using the tokenize function, you just need to capture the result of the template call. What you need to do is wrap your call-template call in a variable and then use the node-set extension function to do work on those newly created nodes. For example, <xsl:variable name="siteNodes"> <xsl:call-template name="tokenize"> <xsl:with-param name="string" select="@exsites" /> <xsl:with-param name="delimiters" select="','" /> </xsl:call-template> </xsl:variable> Will create a variable with the structure: <exsite>17</exsite> <exsite>21</exsite> <exsite>32</exsite> You then need to use the node-set extenstion function of your XSLT processor. If you are using MSXML it would look like: <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt"> ... <xsl:for-each select="msxml:node-set($siteNodes)/exsite"> Do something here </xsl:for-each> </xsl:stylesheet> If you're on a different processor you'll have to look up the correct namespace URI for the processor. Hope this helps. -Peter -----Original Message----- From: Mat Bergman [mailto:matbergman@xxxxxxxxx] Sent: Thursday, June 09, 2005 1:12 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Process node set generated by EXSLT tokenize I built a simple XSL stylesheet for a css-based sidebar navigation. The navigation will appear on several co-branded sites, so each link's XML element has an attribute that specifies the link's display status. For example: <menu name="name" url="" includeSites="0"/> I use an <xsl:if> statement to compare the attribute against a "siteID" parameter. If there's a match, then the link is displayed. A <xsl:for-each> iterates through each link. No problem. My project has a new requirmenet. The includeSites attribute may have muliple, comma-delimited values. For example: <menu name="name" url="" includeSites="17,21,32"/> I utilized the EXSLT tokenize() template to build a node set out of the delimited attributes. However, I'm new to XSLT and I can't grasp how to process that node set. This is the XHTML that my stylesheet is currently generating: <ul><includeSite>0</includeSite><li><a href="">Link 1</a></li><includeSite>17</includeSite><li><a href="">Link 2</a></li>...</ul> What I want is for the node set values to be passed to an <xsl:if> statement that's iterated by an <xsl:for-each>, like I have in my single-attribute version. If this were JavaScript, I would pass the node value as a variable, but that doesn't seem possible in XSLT. I have examples of my code posted if my language isn't clear: http://www.matbergman.com/misc/xmlNav/ Is this task even within the capabilities of XSLT 1.0? Thanks, -Mat
|
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








