[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Double muenchian grouping...

Subject: Double muenchian grouping...
From: "batis batuus" <batis.04@xxxxxxxxx>
Date: Wed, 12 Dec 2007 15:33:30 +0100
 Double muenchian grouping...
I have an xml file which i use to generate PDF document:
<?xml version="1.0"?>
<library>
   <!--math books-->
   <book>
       <writers>Henry VANDEN, Christina MONAY, Jarod SITH</writers>
       <title>The National Council of Teachers of Mathematics:
Teaching of Arithmetic (10th yearbook)</title>
       <year>2002a</year>
       <publisher>Hermes</publisher>
       <pages>231</pages>
       <field>math</field>
   </book>
   <book>
       <writers>Ronald Staszkow</writers>
       <title>Developmental Mathematics: Basic Arithmetic with
Introductions to Algebra and Geometry</title>
       <year>2002b</year>
       <publisher>Danaroom</publisher>
       <pages>156</pages>
       <field>math</field>
   </book>
   <book>
       <writers>B.S.S, D.M.</writers>
       <title>Basic Arithmetic</title>
       <year>2002b 2002a</year>
       <publisher>Zebruje</publisher>
       <pages>120</pages>
       <field>math</field>
   </book>
   <!--history books-->
   <book>
       <writers>Boray Dim, Jessica FOLGHenry VANDEN, Christina MONAY,
Jarod SITH</writers>
       <title>History of europe</title>
       <year>2002a</year>
       <publisher>Gouray</publisher>
       <pages></pages>
       <field>history</field>
   </book>
   <book>
       <writers>A.C., B.D.</writers>
       <title>history example 1</title>
       <year>2002a 2002b</year>
       <publisher>Hermes</publisher>
       <pages></pages>
       <field>history</field>
   </book>
   <book>
       <writers>corray Stakovic</writers>
       <title>The 1st world war 1914-1918</title>
       <year>2002a</year>
       <publisher>Hermes</publisher>
       <pages></pages>
       <field>history</field>
   </book>
</library>

First i liked to group using 'field' and it works:

<?xml version="1.0"?>
<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">
<!--Using Muenchian Grouping-->
<xsl:key name="byField" match="book" use="field" />
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>

   <xsl:template match="library">
       <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format ">
           <fo:layout-master-set>
               <fo:simple-page-master master-name="simpleA4"
page-height="29.7cm" page-width="21cm" margin-top="2cm"
margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
                   <fo:region-body />
               </fo:simple-page-master>
           </fo:layout-master-set>
           <fo:page-sequence master-reference="simpleA4"
initial-page-number="1">

               <fo:flow flow-name="xsl-region-body">
                   <fo:block text-align="center" wrap-option="wrap"
font-size="10pt" font-weight="bold" space-after="5mm">
                       <fo:inline text-decoration="underline">
                           <xsl:text>Publication list :</xsl:text>
                       </fo:inline>
                   </fo:block>
                   <fo:block font-size="10pt">
                       <xsl:apply-templates
select="book[generate-id(.) = generate-id(key('byField', field)[1])]"
/>
                   </fo:block>
               </fo:flow>
           </fo:page-sequence>
       </fo:root>
   </xsl:template>


   <xsl:template match="book">
       <fo:block space-before=" 0.25">

               <xsl:choose>
                   <xsl:when test="field = 'math'">
                       <fo:inline text-decoration="underline">
                           <xsl:text>Mathematics :</xsl:text>
                       </fo:inline>

                       <xsl:for-each select="key('byField', field)">
                           <fo:block space-before="0.25cm"
space-after="0.25cm" intrusion-displace="line" text-align="justify">
                               <xsl:text>-&#171;</xsl:text>
                               <xsl:value-of select="title"/>
                               <xsl:text>&#187;, </xsl:text>

                               <xsl:value-of select="writers"/>
                               <xsl:text>. Publisher : </xsl:text>

                               <xsl:value-of select="publisher"/>
                               <xsl:text>. Pages : </xsl:text>

                               <xsl:value-of select="publisher"/>
                               <xsl:text>.</xsl:text>
                           </fo:block>
                       </xsl:for-each>
                   </xsl:when>

                   <xsl:when test="field = 'history'">
                       <fo:inline text-decoration="underline">
                           <xsl:text>Hitory :</xsl:text>
                       </fo:inline>

                       <xsl:for-each select="key('byField', field)">
                           <fo:block space-before="0.25cm"
space-after="0.25cm" intrusion-displace="line" text-align="justify">
                               <xsl:text>-</xsl:text>
                               <xsl:value-of select="writers"/>
                               <xsl:text>, </xsl:text>

                               <xsl:text>&#171;</xsl:text>
                               <xsl:value-of select="title"/>
                               <xsl:text>&#187;. Publisher : </xsl:text>

                               <xsl:value-of select="publisher"/>
                               <xsl:text>.</xsl:text>
                           </fo:block>
                       </xsl:for-each>
                   </xsl:when>

                   <xsl:otherwise>
                       <fo:inline text-decoration="underline">
                           <xsl:text>Others:</xsl:text>
                       </fo:inline>

                       <xsl:for-each select="key('byField', field)">
                           <fo:block space-before="0.25cm"
space-after=" 0.25cm " intrusion-displace="line" text-align="justify">
                               <xsl:text>-</xsl:text>
                               <xsl:value-of select="writers"/>
                               <xsl:text>.</xsl:text>

                               <xsl:text>&#171;</xsl:text>
                               <xsl:value-of select="title"/>
                               <xsl:text>&#187;, </xsl:text>
                           </fo:block>
                       </xsl:for-each>
                   </xsl:otherwise>

               </xsl:choose>
       </fo:block>
   </xsl:template>
</xsl:stylesheet>

It gives me something like this:

Publication list :
Mathematics :
.....
.....
History :
.....
.....
Others :
.....
.....

Now i want to add grouping using 'year' , i want to get  something like:

Publication list :
2002a:
Mathematics :
.....
.....
History :
.....
.....
Others :
.....
.....

2002b:
Mathematics :
.....
.....
History :
.....
.....
Others :
.....
.....

Which mean using double grouping....
I tried to do the same thing but i doesn't work... and it's more complicated...
perhaps there's another way to do that..
Please can someone help me...

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.