Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Is this possible to do in XSL? [Thread Next] Re: Is this possible to do in XSL?To: NULL Date: 8/4/2005 8:45:00 AM Hi,
Tempore 04:46:18, die Thursday 04 August 2005 AD, hinc in foro {microsoft.public.xsl} scripsit Sarah_Lund <Sarah_Lund@d...>:
> I have what I think is a horrible xml file to work with and don't know how I
> can do this with xsl. Using the xml file excerpt below I need to sum the
> price for each /Order/Prod/Prod/@nID that is equal to
> /Order/Summary/Report/Record/AssocProductID where (SelNo=0 and @tID=0) or
> (@nID=2 and @tID=9).
Take a look at this stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="price"
match="Record[(SelNo=0 and @tID=0) or (@nID=2 and @tID=9)]/Price/@pvalue"
use="ancestor::Record/AssocProductID" />
<xsl:output method="xml"/>
<xsl:template match="Prod">
Flavour #1: using Xpath:
<xsl:value-of select="sum(
../Summary/Report/Record
[(SelNo=0 and @tID=0) or (@nID=2 and @tID=9)]
[AssocProductID=current()/Prod/@nID]
/Price/@pvalue
)"/>
Flavour #2: using a key:
<xsl:value-of select="sum(key('price',Prod/@nID))"/>
</xsl:template>
<xsl:template match="Summary"/>
</xsl:stylesheet>
regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
«Η αλήθεια και το λάδι πάντα βγαίνουν από πάνω»
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
