Topic: XSL grouping and XSL-FO table problem (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=30981" title="Pages that link to Topic: XSL grouping and XSL-FO table problem (Page 1 of 1)" rel="nofollow" >Topic: XSL grouping and XSL-FO table problem <span class="small">(Page 1 of 1)</span>\

 
lospalos
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Apr 2009

posted posted 04-30-2009 14:29

Hi there,
i'v got simple xml document of limited structur and making the xsl-fo template for it. This template has to groups records in xml by specified attribute in records of XML.
I tried to use 'key' but as i'm just beginner with xsl the key isn't working ;o(
The next problem is how to make for-each that spreads cell with grouping attribute over all matching records/rows in fo:table.
Attributes 'ag_name' and 'ag_id' are equal as for grouping matter - i can group by whichever of them, All other data is grouped.

Here is the xml doc:

code:
<?xml version="1.0" encoding="iso-8859-1"?>
<zwk_export>
   <record>
      <field name="AG_NAME">Mabanaft GmbH &amp; Co. KG</field>
      <field name="AG_ID">0191</field>
      <field name="TRANSACTION">Verkauf</field>
      <field name="LAST_KONTO_NR">9813197 01</field>
      <field name="LAST_BLZ">380 707 24</field>
      <field name="GUNST_KONTO_NR">9690058 00</field>
      <field name="GUNST_BLZ">500 700 10</field>
      <field name="FOND_ISIN">LU0192142908</field>
      <field name="FOND_LANG_BEZ">Institutional Euroland Equities</field>
      <field name="VERWENDUNGSZWECK">241D078415201</field>
      <field name="BETRAG">568,24</field>
      <field name="ANTEILE">87,569</field>
   </record>
   <record>
      <field name="AG_NAME">Mabanaft GmbH &amp; Co. KG</field>
      <field name="AG_ID">0191</field>
      <field name="TRANSACTION">Kauf</field>
      <field name="LAST_KONTO_NR">9813197 01</field>
      <field name="LAST_BLZ">380 707 24</field>
      <field name="GUNST_KONTO_NR">9690058 00</field>
      <field name="GUNST_BLZ">500 700 10</field>
      <field name="FOND_ISIN">LU0192144276</field>
      <field name="FOND_LANG_BEZ">Institutional Euro Gov. Bonds</field>
      <field name="VERWENDUNGSZWECK">241D078415201</field>
      <field name="BETRAG">28968,24</field>
      <field name="ANTEILE">64,569</field>
   </record>
   <record>
      <field name="AG_NAME">GMA GmbH &amp; Co. KG</field>
      <field name="AG_ID">011</field>
      <field name="TRANSACTION">Verkauf</field>
      <field name="LAST_KONTO_NR">9813254 01</field>
      <field name="LAST_BLZ">380 707 24</field>
      <field name="GUNST_KONTO_NR">9690058 00</field>
      <field name="GUNST_BLZ">500 700 10</field>
      <field name="FOND_ISIN">LU0099730524</field>
      <field name="FOND_LANG_BEZ">Institutional Money Plus</field>
      <field name="VERWENDUNGSZWECK">114D078118202</field>
      <field name="BETRAG">1268,24</field>
      <field name="ANTEILE">5877,569</field>
   </record>
   <record>
      <field name="AG_NAME">GMA GmbH CO</field>
      <field name="AG_ID">011</field>
      <field name="TRANSACTION">Verkauf</field>
      <field name="LAST_KONTO_NR">9813254 01</field>
      <field name="LAST_BLZ">380 707 24</field>
      <field name="GUNST_KONTO_NR">9690058 00</field>
      <field name="GUNST_BLZ">500 700 10</field>
      <field name="FOND_ISIN">LU0192142908</field>
      <field name="FOND_LANG_BEZ">Institutional Euroland Equities</field>
      <field name="VERWENDUNGSZWECK">114D078118202</field>
      <field name="BETRAG">57692,24</field>
      <field name="ANTEILE">77,569</field>
   </record>
   <commonData>
      <field name="ORDERDATUM">04.27.2009</field>
      <field name="KONZERN_NAME">Marquard &amp; Bahls AG</field>
   </commonData>
 </zwk_export>




and here is my xsl template:

code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
  <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:key name="groups-by-ag_id" match="record" use="field" />
<xsl:template match="zwk_export">
  
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions">
	<fo:layout-master-set >

		<fo:simple-page-master margin-right="0.5cm" margin-left="0.5cm" margin-bottom="0.5cm" margin-top="0.5cm" page-width="21cm" page-height="29.7cm" master-name="konzernOrder">

			<fo:region-body margin-bottom="2cm" margin-top="3.5cm"/>

  			<fo:region-before extent="3.5cm" />

			<fo:region-after extent="2cm" />

		</fo:simple-page-master>

	</fo:layout-master-set>

<fo:page-sequence master-reference="konzernOrder" language="de" hyphenate="false">

<fo:static-content flow-name="xsl-region-before" >
   <fo:block>
   </fo:block>
</fo:static-content>

<fo:static-content flow-name="xsl-region-after" >
				<fo:block >
				</fo:block>
</fo:static-content>



<fo:flow flow-name="xsl-region-body" margin-top="0cm" margin-bottom="0cm">
<fo:block line-height="12pt" space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always">



<fo:block space-before="0.2cm" space-after="0.3cm" >
<fo:table text-align="left" keep-together="auto" border="0.5pt solid black">

	
		
<fo:table-column column-width="5.95cm" border="0.5pt solid black" />
<fo:table-column column-width="2.05cm" border="0.5pt solid black" />
<fo:table-column column-width="5.80cm" border="0.5pt solid black" />

<fo:table-header text-align="center" border="0.5pt solid black" >
			<fo:table-cell>
				<fo:block >
               <fo:inline font-weight="bold" font-size="6pt">AG_NAME</fo:inline>
            </fo:block>
			</fo:table-cell>
			<fo:table-cell>
				<fo:block >
               <fo:inline font-weight="bold" font-size="6pt">AG_ID</fo:inline>
            </fo:block>
			</fo:table-cell>
			<fo:table-cell>
				<fo:block >
               <fo:inline font-weight="bold" font-size="6pt">ISIN</fo:inline>
            </fo:block>
			</fo:table-cell>
</fo:table-header>   
	<fo:table-body>
   
      <!-- <xsl:for-each select="record">  -->
      <xsl:for-each select="key('groups-by-ag_id', field[@name='AG_ID'])">  
  
             <fo:table-row height="auto" >
               <fo:table-cell  display-align="center" text-align="center" margin-right="2pt" margin-left="1pt" border="0.5pt solid black">
                 <fo:block font-size="6pt" line-height="auto" keep-together="auto" space-before="0.5pt" space-after="0.5pt">
                   <xsl:value-of select="field[@name='AG_NAME']"/>
                 </fo:block>
               </fo:table-cell >
               <fo:table-cell display-align="center" text-align="center" margin-right="2pt" margin-left="1pt" border="0.5pt solid black">
                 <fo:block font-size="6pt" keep-together="auto" space-before="0.5pt" space-after="0.5pt">
                   <xsl:value-of select="field[@name='AG_ID']"/>
                 </fo:block>
               </fo:table-cell>
               <fo:table-cell display-align="center" text-align="center" margin-right="2pt" margin-left="1pt" border="0.5pt solid black">
                 <fo:block font-size="6pt" keep-together="auto" space-before="0.5pt" space-after="0.5pt">
                   <xsl:value-of select="field[@name='FOND_ISIN']"/>
                 </fo:block>
               </fo:table-cell>
             </fo:table-row>
  
</xsl:for-each>  
      
      
</fo:table-body>
</fo:table>
</fo:block>   
</fo:block>

<fo:block id="last-page"/>

</fo:flow>



Can anyone help?

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 05-02-2009 10:23

hey, I think the xsl:for-each-group element is what you're looking for.

so long,

->Tyberius Prime

spammhatter
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Oct 2010

posted posted 10-14-2010 16:36

Thanks for these instructions. They were very helpful, and I appreciate you going to the effort of creating this page.
Edit: TP spam removed - oh the irony...

(Edited by Tyberius Prime on 10-14-2010 19:14)



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu