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

Re: Conditionally Sum an Attribute

Subject: Re: Conditionally Sum an Attribute
From: "Ronnie Royston" <rhroyston@xxxxxxxxx>
Date: Sun, 1 Jun 2008 11:59:25 -0500
 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>

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.