[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Conditionally Sum an Attribute
Dr. Carlisle, thank you for the direction. I will be more specific with my posting and not use a Windows filepath with the xsl:result-document instruction. Recursion? So, you defined a variable "x" to capture a sequence. "x" is nested in an xsl:for-each that iterates over every <code> element's child text node? However, the for-each does NOT set the context node? The document function sets the context node to each <sku> returned against the boolean predicate "[starts-with(.,current())]"? The current() function is necessary to present each <code> element's child text node as the 2nd argument to the starts-with function? OK, so the sequence of <skus>'s that begin with a <code> found in knowledge.xml is now available (as "x")? So "x" is an index of "CP-7937G","CP-7941G", etc? I don't understand the xsl:sequence's key function. It seems like "x" is a <sku> such as "CP-7941G". How does XSLT processor know "CP-7941G"/@quantity? This does not seem like correct syntax. Wow, ...I know I'm off in the weeds. I'll keep studying. I've got 2 more books on XSLT coming in the mail. Thanks for the answer. > <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*"> > <xsl:for-each select="$skus"> > <xsl:variable name="x" select="document('mySkus.xml')/skus/sku[starts-with(.,current())]"/> > <xsl:sequence select="key('sku',current()[$x],$root)/(concat(sum($x/@quantity),' ',name))"/> > </xsl:for-each> > </xsl:variable>
|
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
|