 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 23rd, 2008, 07:12 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Group_list
I need to find group_list from the input xml file such as ,
group_list = list of access charges (Document/Invoice/InvoiceItem[@CT='A']), grouped by aggregation set attribute TM, SP, SN, Tax/@Tax, Price/@Price
Could any one help.?
[u]Input xml</u>:
<?xml version='1.0' encoding="UTF-8"?>
<Document Sender="test" Id="080428BA00000000913" BAId="BA0000000091">
<Invoice BillingMode="REG" InvType="INV" >
<Date Type="INV" Date="20080428" />
<Date Type="START" Date="20060101" />
<Date Type="END" Date="20080427" HH="23" MM="59" SS="59" />
<Date Type="DUE_DATE" Date="20080518" />
<CashDiscount Days="0" >
<Charge Id="12" Amount="0.0000" CurrCode="EUR" Type="9" PT="P" />
<Date Type="DISCOUNT" Date="20080428" />
</CashDiscount>
<InvoiceItem NumItem="1" ArticleString="16.4.15.1.A.AC.F.P" CT="A" CollInd="N">
<AggSet>
<Att Ty="TM" Id="WLCO" />
<Att Ty="SP" Id="WLSC" />
<Att Ty="SN" Id="GTEL" />
<Att Ty="MRKT" Id="GSM" />
</AggSet>
<Charge Id="99" Amount="136.7700" CurrCode="EUR" Type="9" PT="P" />
<Charge Id="125" Amount="136.7700" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="203" Amount="164.1200" CurrCode="EUR" Type="9" PT="P" />
<Price Price="5.0000" CurrCode="EUR" />
<Tax ItemType="1" Cat="Normal VAT (20%)" Name="Normal VAT (20%)" LegalCode="Normal Tax" Rate="20.00000" CalcMethod="R" Exemption="S">
<Charge Id="124" Amount="27.35" CurrCode="EUR" Type="9" PT="P" />
</Tax>
</InvoiceItem>
<InvoiceItem NumItem="1" ArticleString="4.2.4.52.O" CT="S" CollInd="N">
<AggSet>
<Att Ty="TM" Id="OCCRP" />
<Att Ty="SP" Id="OS" />
<Att Ty="SN" Id="ADMIN" />
<Att Ty="MRKT" Id="EDS" />
</AggSet>
<Charge Id="99" Amount="0.0000" CurrCode="EUR" Type="9" PT="P" />
<Charge Id="125" Amount="126.5000" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="203" Amount="0.0000" CurrCode="EUR" Type="9" PT="P" />
<Txt>user event (OCC) 1</Txt>
<Price Price="0.0000" CurrCode="EUR" />
<Tax ItemType="1" Cat="Normal VAT (20%)" Name="Normal VAT (20%)" LegalCode="Normal Tax" Rate="20.00000" CalcMethod="R" Exemption="S">
<Charge Id="124" Amount="99.50" CurrCode="EUR" Type="9" PT="P" />
</Tax>
<PromoItem>
<Charge Id="12" Amount="10.00" CurrCode="EUR" Type="9" PT="P" />
<PromoElemRef PackId="HUDIS"/>
</PromoItem>
</InvoiceItem>
<InvoiceItem NumItem="1" ArticleString="4.2.4.53.O" CT="O" CollInd="N">
<AggSet>
<Att Ty="TM" Id="OCCRP" />
<Att Ty="SP" Id="OS" />
<Att Ty="SN" Id="DUNN" />
<Att Ty="MRKT" Id="EDS" />
</AggSet>
<Charge Id="99" Amount="0.0000" CurrCode="EUR" Type="9" PT="P" />
<Charge Id="125" Amount="0.0000" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="203" Amount="0.0000" CurrCode="EUR" Type="9" PT="P" />
<Txt>1.Dunning,Fee,Inv.# 0000000017</Txt>
<Price Price="0.0000" CurrCode="EUR" />
<Tax ItemType="1" Cat="Normal VAT (20%)" Name="Normal VAT (20%)" LegalCode="Normal Tax" Rate="20.00000" CalcMethod="R" Exemption="S">
<Charge Id="124" Amount="0.00" CurrCode="EUR" Type="9" PT="P" />
</Tax>
</InvoiceItem>
<InvoiceItem NumItem="1" ArticleString="4.2.4.57.O" CT="O" CollInd="N">
<AggSet>
<Att Ty="TM" Id="OCCRP" />
<Att Ty="SP" Id="OS" />
<Att Ty="SN" Id="LATEF" />
<Att Ty="MRKT" Id="EDS" />
</AggSet>
<Charge Id="99" Amount="0.0000" CurrCode="EUR" Type="9" PT="P" />
<Charge Id="125" Amount="0.0000" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="203" Amount="0.0000" CurrCode="EUR" Type="9" PT="P" />
<Txt>1.Dunning,Interest,Inv.# 0000000017</Txt>
<Price Price="0.0000" CurrCode="EUR" />
<Tax ItemType="1" Cat="Normal VAT (20%)" Name="Normal VAT (20%)" LegalCode="Normal Tax" Rate="20.00000" CalcMethod="R" Exemption="S">
<Charge Id="124" Amount="0.00" CurrCode="EUR" Type="9" PT="P" />
</Tax>
</InvoiceItem>
<InvoiceTotals>
<Charge Id="76" Amount="0.00" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="978" Amount="0.00" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="977" Amount="136.77" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="79" Amount="136.77" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="79" Amount="136.7700" CurrCode="EUR" Type="19" PT="P" />
<Charge Id="79" Amount="0.00" CurrCode="EUR" Type="9" PT="A" />
<Charge Id="79" Amount="0.0000" CurrCode="EUR" Type="19" PT="A" />
<Charge Id="77" Amount="164.1200" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="77" Amount="164.1200" CurrCode="EUR" Type="19" PT="P" />
<Charge Id="77" Amount="0.0000" CurrCode="EUR" Type="9" PT="A" />
<Charge Id="77" Amount="0.0000" CurrCode="EUR" Type="19" PT="A" />
<Charge Id="980" Amount="0.00" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="980" Amount="0.0000" CurrCode="EUR" Type="9" PT="A" />
<Charge Id="178" Amount="164.12" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="969" Amount="40.24" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="961" Amount="40.24" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="11" Amount="0.00" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="700" Amount="0.00" CurrCode="EUR" Type="9" PT="A" />
<Charge Id="701" Amount="0.00" CurrCode="EUR" Type="9" PT="A" />
<Charge Id="702" Amount="0.0000" CurrCode="EUR" Type="9" PT="A" />
<Charge Id="703" Amount="164.12" CurrCode="EUR" Type="9" PT="P" />
<Charge Id="704" Amount="0.00" CurrCode="EUR" Type="9" PT="P" />
<Charge Id="78" Amount="164.12" CurrCode="EUR" Type="9" PT="P" />
</InvoiceTotals>
<Tax ItemType="3" Cat="Normal VAT (20%)" Name="" LegalCode="Normal Tax" Rate="20.00000" CalcMethod="R" Exemption="S">
<Charge Id="124" Amount="27.35" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="125" Amount="136.77" CurrCode="EUR" Type="9" PT="P" />
</Tax>
</Invoice>
</Document>
|
|

July 23rd, 2008, 08:04 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
With the help of the link, http://www.biglist.com/lists/xsl-lis.../msg00070.html
Could you please correct the same...
<xsl:key name="by-tm" match="Att[@Ty='TM']" use="@Id"/>
<xsl:key name="by-sp" match="Att[@Ty='SP']" use="@Id"/>
<xsl:key name="by-sn" match="Att[@Ty='SN']" use="@Id"/>
<xsl:variable name="result" select="key('b y-tm', @Id)" />
<xsl:for-each select="$result[generate-id() = generate-id(key(????????????????)]">
<xsl:value-of select=""/>
</xsl:for-each>
</xsl:variable>
|
|

July 23rd, 2008, 08:49 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Huh?
You are not showing us what you want the XML output to look like, nor are you providing context for your XSLT examples (e.g. in the above snippet your 'result' variable depends on @Id - but there is no surrounding context for this so @Id doesn't match anything).
You provide 4 different key's - two of which are actually the same. Then expect us to guess what you want in the next bit. We are not mind readers.
'Helping' is one thing - doing everything for you is another (something people on this forum are not prepared to do).
/- Sam Judson : Wrox Technical Editor -/
|
|

July 23rd, 2008, 11:55 PM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
My question is beginners point of view.. and i am not clearely explained as you expect.I agreed.
Hope i have explained you in my first post...such as "group_list = list of access charges (Document/Invoice/InvoiceItem[@CT='A']), grouped by aggregation set attribute TM, SP, SN, Tax/@Tax, Price/@Price"
I am prepare the fullfilled input xml file and expected output. Once its completed, will send to you.
Note: i have corrected the mistakes in my previous post.
|
|

July 24th, 2008, 09:34 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
I don't understand what you mean by an "aggregation set attribute". Generally when multiple keys are involved there are two possible requirements:
(a) two elements are in the same group if all the key values are equal, otherwise they are in different groups. For this requirement, concatenate the key values (perhaps with a separator such as "~") and then use the concatenation as the grouping key.
(b) group first by one key, then by another key, then by a third, and so on. For this, just use nested xsl:for-each-group instructions (if you are in XSLT 2.0). It can be trickier if for some reason you are stuck with 1.0, but Jeni Tennison has a section on multi-level grouping at http://www.jenitennison.com/xslt/grouping.
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
|
|

July 29th, 2008, 10:49 PM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for your reply. Please note that its not multiple level grouping, its just only 1 level grouping.
I would like to know how to use aggregation function in XSL1.0 such as
- 1 level of grouping,
- aggregation => all criteria together, like a group by in sql
Please find the contrainsts as i mentioned below,
group_list = list of access charges (Document/Invoice/InvoiceItem[@CT='A']), grouped by [u]aggregation </u>set attribute TM, SP, SN, Tax/@Tax, Price/@Price
|
|
 |