Subject: Re: [xsl] Seeking help on Grouping distingt sub-elements From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 06 May 2002 11:54:37 -0400 |
I have tried various implemenations of 'Meunchian' groupings,
In the end, I think its coming down to a lack of sufficient understanding of the <xsl:key> tag on my part.
T:\ftemp>type stoll.xml <order> <company> <name>company1</name> <shipment> <shiptoid>1</shiptoid> <chassis> <commonid>19</commonid> <commonelement>c191</commonelement> <specificelement>s191</specificelement> </chassis> <chassis> <commonid>17</commonid> <commonelement>c171</commonelement> <specificelement>s171</specificelement> </chassis> <chassis> <commonid>19</commonid> <commonelement>c192</commonelement> <specificelement>s192</specificelement> </chassis> <chassis> <commonid>17</commonid> <commonelement>c172</commonelement> <specificelement>s172</specificelement> </chassis> </shipment> <shipment> <shiptoid>2</shiptoid> <chassis> <commonid>18</commonid> <commonelement>c181</commonelement> <specificelement>s181</specificelement> </chassis> <chassis> <commonid>16</commonid> <commonelement>c161</commonelement> <specificelement>s161</specificelement> </chassis> <chassis> <commonid>18</commonid> <commonelement>c182</commonelement> <specificelement>s182</specificelement> </chassis> <chassis> <commonid>16</commonid> <commonelement>c162</commonelement> <specificelement>s162</specificelement> </chassis> </shipment> </company> <company> <name>company2</name> <shipment> <shiptoid>3</shiptoid> <chassis> <commonid>29</commonid> <commonelement>c291</commonelement> <specificelement>s291</specificelement> </chassis> <chassis> <commonid>27</commonid> <commonelement>c271</commonelement> <specificelement>s271</specificelement> </chassis> <chassis> <commonid>29</commonid> <commonelement>c292</commonelement> <specificelement>s292</specificelement> </chassis> <chassis> <commonid>27</commonid> <commonelement>c271</commonelement> <specificelement>s271</specificelement> </chassis> </shipment> <shipment> <shiptoid>4</shiptoid> <chassis> <commonid>28</commonid> <commonelement>c281</commonelement> <specificelement>s281</specificelement> </chassis> <chassis> <commonid>26</commonid> <commonelement>c261</commonelement> <specificelement>s261</specificelement> </chassis> <chassis> <commonid>28</commonid> <commonelement>c282</commonelement> <specificelement>s282</specificelement> </chassis> <chassis> <commonid>26</commonid> <commonelement>c262</commonelement> <specificelement>s262</specificelement> </chassis> </shipment> </company> </order>
T:\ftemp>type stoll.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="order|company|name|shiptoid"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template>
<xsl:template match="shipment"> <shipment> <xsl:apply-templates select="shiptoid"/> <xsl:variable name="chassis" select="chassis"/> <xsl:for-each select="chassis"> <xsl:if test="generate-id(.)= generate-id($chassis[commonid=current()/commonid])"> <xsl:variable name="specifics" select="$chassis[commonid=current()/commonid]"/> <chassis> <commonid><xsl:value-of select="commonid"/></commonid> <commonelement> <xsl:value-of select="$specifics[last()]/commonelement"/> </commonelement> <newtag> <xsl:for-each select="$specifics"> <specificelement> <xsl:value-of select="specificelement"/> </specificelement> </xsl:for-each> </newtag> </chassis> </xsl:if> </xsl:for-each> </shipment> </xsl:template>
T:\ftemp>type stoll.out <?xml version="1.0" encoding="utf-8"?> <order>
<shipment> <shiptoid>1</shiptoid> <chassis> <commonid>19</commonid> <commonelement>c192</commonelement> <newtag> <specificelement>s191</specificelement> <specificelement>s192</specificelement> </newtag> </chassis> <chassis> <commonid>17</commonid> <commonelement>c172</commonelement> <newtag> <specificelement>s171</specificelement> <specificelement>s172</specificelement> </newtag> </chassis> </shipment>
<shipment> <shiptoid>2</shiptoid> <chassis> <commonid>18</commonid> <commonelement>c182</commonelement> <newtag> <specificelement>s181</specificelement> <specificelement>s182</specificelement> </newtag> </chassis> <chassis> <commonid>16</commonid> <commonelement>c162</commonelement> <newtag> <specificelement>s161</specificelement> <specificelement>s162</specificelement> </newtag> </chassis> </shipment>
<shipment> <shiptoid>3</shiptoid> <chassis> <commonid>29</commonid> <commonelement>c292</commonelement> <newtag> <specificelement>s291</specificelement> <specificelement>s292</specificelement> </newtag> </chassis> <chassis> <commonid>27</commonid> <commonelement>c271</commonelement> <newtag> <specificelement>s271</specificelement> <specificelement>s271</specificelement> </newtag> </chassis> </shipment>
<shipment> <shiptoid>4</shiptoid> <chassis> <commonid>28</commonid> <commonelement>c282</commonelement> <newtag> <specificelement>s281</specificelement> <specificelement>s282</specificelement> </newtag> </chassis> <chassis> <commonid>26</commonid> <commonelement>c262</commonelement> <newtag> <specificelement>s261</specificelement> <specificelement>s262</specificelement> </newtag> </chassis> </shipment>
-- Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO: June 17-21, 2002 - : 3-days XML Information Modeling: July 31-August 2, 2002
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-07-1 Practical Formatting Using XSLFO XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed), articles, training(instructor-live,Internet-live,web/CD,licensed) Next public training: 2002-05-06,07,09,10,13,15,20, - 06-04,07,10,11,13,14,17,20,07-31,08-05,27,30
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Seeking help on Grouping , Jeni Tennison | Thread | Re: [xsl] Seeking help on Grouping , jestoll |
Re: [xsl] Seeking help on Grouping , Jeni Tennison | Date | RE: [xsl] XSl, sorting, namespaces , Stuart Celarier |
Month |