Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Re: Conditionally Sum an Attribute

From: "Ronnie Royston" <rhroyston@--------->
To:
Date: 6/1/2008 5:00:00 PM
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>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent