[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] starts-with on more than one item
Dr. Carlisle, Dr, Kay, I am soooo excited. Check this out. I did it all on my own (with help from Michael's book). So, I needed to output, "Your proposal includes this, that, and the other." David got me on the right track with outputting the name of all the skus retrieved from the document() function. Well, I needed to put the commas and an "and, " before the last thing in the series. Well, below is what I put together and it works! Maybe you have a more efficient way to do this? I am just so excited that I could do this! Woo Hoo!!! My output is - Your proposal includes Cisco routers, Cisco switches, and Cisco Linecards." I can change the mySkus.xml file to include other parts and doggonit it works! Way cool. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0" > <xsl:key name="sku" match="knowledge/part" use="code" /> <xsl:variable name="root" select="/"/> <xsl:variable name="skus" as="xs:string*" select="distinct-values(/knowledge/part/code)" /> <xsl:variable name="names" as="xs:string*" select="for $s in $skus return key('sku',$s[document('mySkus.xml')/skus/sku[starts-with(.,$s)]],$root)/name" /> <xsl:template match="/"> <html> <head> <title>Test Document</title> </head> <body> <H1>Executive Summary</H1> <p>Your proposal includes <xsl:for-each select="$names"> <xsl:choose> <xsl:when test="position()=last()"> <xsl:value-of select="concat(', and ', ., '.')"/> </xsl:when> <xsl:when test="position()=1"> <xsl:value-of select="concat(' ', .)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat(', ', .)"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </p> </body> </html> </xsl:template> </xsl:stylesheet> OK, I'll stop boring you guys with my elementary work now... But I'll be back with some more difficult questions!
|
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
|