Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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
 
Old September 7th, 2010, 11:21 AM
Registered User
 
Join Date: Aug 2010
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Question I've used XSLT1.0 for grouping.

Thanks to Martin Honnen, and mhkay,
I tried to do as you people told but licencing comes as a disadvantage .
Then I tried with only XSLT1.0
I don’t know JAXP or other we are using for the FOP.
But now its working some how, but I am not able to subgroup it. I tried but did not get success.
I did as following:
Code:
<?xml version="1.0" encoding="UTF-8"?> 
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~ Copyright (c)  2010.  PharmApps, LLC                                      ~
  ~ This software is the confidential and proprietary information of PharmApps, LLC.
  ~ ("Confidential Information").                                             ~
  ~ 
  ~ File Name : noncurrentterms_eng.xsl                                       ~
  ~ Created By: Narendra Mohan  "Employed by Aris global Software Pvt Ltd."   ~
  ~ Date: 06 Sep  2010                                                        ~
  ~ Description	: Audit trail report generation xsl                           ~
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<!-- $Id$ -->
<xsl:stylesheet version="2.0" 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:param name="auditTitle" select="'agEncoder Audit Trail Report'"/>
    <xsl:param name="fieldName" select="'Field Name'"/>
    <xsl:param name="functionType" select="'Function Type'"/>
    <xsl:param name="operationType" select="'Operation Type'"/>
    <xsl:param name="oldVal" select="'Old Value'"/>
    <xsl:param name="newVal" select="'New Value'"/>
    <xsl:param name="entityName" select="'Entity Name'"/>
    <xsl:param name="transactionId"  select="'Transaction ID'"/>
    <xsl:param name="modifiedBy" select="'Modified By'"/>
    <xsl:param name="modifiedDate" select="'Modified Date'"/>
    <xsl:param name="moduleName" select="'Module Name'"/>
    <xsl:param name="sessionInfoLabel" select="'Session Information'"/>
    <xsl:param name="userID" select="'user ID'"/>
    <xsl:param name="useFont" select="'Courier, monospace'"/>
    <xsl:param name="opDate" select="'Date of Operation'"/>
    <xsl:param name="sessID" select="'Session ID'"/>
    <xsl:param name="fontSize" select="8"/>
    <!-- ========================= -->
    <!-- root element: projectteam -->
    <!-- ========================= -->
    <xsl:key name="rowset-by-row" match="ROW" use="COL9" />
    
    <xsl:template match="ROWSET">
        <xsl:param name="totalno" select="''"/>
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            
            <fo:layout-master-set>

                <fo:simple-page-master page-height="28cm"  page-width="21cm" 
                		margin-top="1cm" margin-bottom="1cm" margin-left="1.5cm" margin-right="1cm"
                        master-name="simpleA4">
                        <fo:region-body region-name="frame-body" margin="1cm"/>
  						<fo:region-before extent="0.75cm" region-name="frame-before"/>
  						<fo:region-after extent="0.75cm" region-name="frame-after"/>
  						<fo:region-start extent="0.75cm"/>
  						<fo:region-end extent="0.75cm"/>
                </fo:simple-page-master>
                    <fo:simple-page-master master-name="cover"
				        page-height="28cm"
				        page-width="21cm"
				        margin-top="0.5cm"
				        margin-bottom="0.5cm"
				        margin-left="1cm"
				        margin-right="0.5cm">
				        <fo:region-body region-name="frame-body"
                			margin-top="12cm" />
				    </fo:simple-page-master>
				                    
                <fo:page-sequence-master master-name="reportpage" >
                    <fo:repeatable-page-master-alternatives >
                        <fo:conditional-page-master-reference  master-reference="simpleA4"/>
                    </fo:repeatable-page-master-alternatives>
                </fo:page-sequence-master>
                
            </fo:layout-master-set>
		<fo:page-sequence master-reference="cover">
		 <fo:flow flow-name="frame-body">
		     <fo:block font-family="Helvetica" font-size="18pt"
		         text-align="center"> 
		         <xsl:value-of select="$auditTitle"/>
		     </fo:block>
		     <fo:block font-family="Helvetica" font-size="12pt"
		         text-align="center" space-after="36pt">
		         <xsl:value-of select="$auditTitle"/>
		     </fo:block>
		     <fo:block text-align="end">
		         A Catcode Production
		     </fo:block>
		 </fo:flow>
		 </fo:page-sequence>             
 		<fo:page-sequence master-reference="reportpage" >
   		<fo:static-content flow-name="frame-before" >
		    <fo:block font-size="10pt" font-weight="normal" border-end-width="1pt" border-color="black" font-family="{$useFont}" text-align="center">
		      <fo:leader rule-thickness="0pt" />  <xsl:value-of select="$auditTitle"/>
		    </fo:block>
		</fo:static-content>
 		 
   		<fo:static-content flow-name="frame-after" >
		    <fo:block font-size="10pt" text-align="center" border-top-width="1pt" border-top-color="black" font-weight="normal" font-family="{$useFont}">
		      <fo:leader rule-thickness="0pt" />  <fo:page-number  initial-page-number="0"/>
		    </fo:block>
		</fo:static-content>
 		
        <fo:flow flow-name="frame-body" >
        
		<xsl:for-each select="ROW[count(. | key('rowset-by-row',COL9)[1]) = 1]">
			<xsl:sort select="COL9" />
			
			<xsl:key name="row-by-opType" match="rowset-by-row" use="COL1" />
				
				<fo:block font-size="9pt" font-family="{$useFont}" font-weight="bold">
					<xsl:value-of select="$sessionInfoLabel"/>
				</fo:block>
				
				<fo:block font-size="9pt" font-family="{$useFont}">
					&#x00A0;
					<xsl:value-of select="$sessID"/>:&#x00A0; <xsl:value-of select="COL9" />
					&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;
					<xsl:value-of select="$userID"/>:&#x00A0; <xsl:value-of select="COL7" />
					&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;
					<xsl:value-of select="$opDate"/>:&#x00A0; <xsl:value-of select="COL8" />
					
				</fo:block>
				<fo:block font-size="8pt">
					&#x00A0;<xsl:value-of select="$moduleName"/>:&#x00A0;<xsl:value-of select="COL12" />
					&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;
					<xsl:value-of select="$operationType"/>:&#x00A0; <xsl:value-of select="COL1" />
				</fo:block>
				<fo:block>
				&#x00A0;
				</fo:block>
				 <fo:block font-size="10pt" space-after="5mm">
                        <fo:table table-layout="fixed" width="100%" border-collapse="separate">
                            <fo:table-column column-width="4cm"/>
                            <fo:table-column column-width="6cm"/>
                            <fo:table-column column-width="6cm"/>

                            <fo:table-header>
                                <fo:table-row display-align="center">
                                    <fo:table-cell number-columns-spanned="1" margin-right="1pt" border-width="0.500pt" border-style="solid" border-color="rgb(0,0,0)" margin-left="1pt" margin-bottom="1pt" margin-top="1pt" space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always" height="15pt">
                                        <fo:block font-family="{$useFont}" font-weight="bold" font-style="bold" text-align="center" font-size="{$fontSize}">
                                            <xsl:value-of select="$fieldName"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    
                                    <fo:table-cell number-columns-spanned="1" margin-right="1pt" border-width="0.500pt" border-style="solid" border-color="rgb(0,0,0)" margin-left="1pt" margin-bottom="1pt" margin-top="1pt" space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always" height="15pt">
                                        <fo:block font-family="{$useFont}" font-weight="bold" text-align="center" font-size="{$fontSize}">
                                            <xsl:value-of select="$oldVal"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell number-columns-spanned="1" margin-right="1pt" border-width="0.500pt" border-style="solid" border-color="rgb(0,0,0)" margin-left="1pt" margin-bottom="1pt" margin-top="1pt" space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always" height="15pt">
                                        <fo:block font-family="{$useFont}" font-weight="bold" text-align="center" font-size="{$fontSize}">
                                            <xsl:value-of select="$newVal"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    
                                </fo:table-row>
                            </fo:table-header>
                            <fo:table-body>
					 		  <xsl:for-each select="key('rowset-by-row', COL9)"> <!-- select="ROW">-->
					 		    <fo:table-row display-align="auto">
						            <fo:table-cell number-columns-spanned="1" margin-right="1pt" margin-left="1pt" border-width="0.500pt" border-style="solid" border-color="rgb(0,0,0)" margin-bottom="1pt" margin-top="1pt" space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always" height="15pt">
						                <fo:block font-family="{$useFont}" font-weight="normal" font-size="{$fontSize}">
						                    <xsl:value-of select="COL2" />
						                </fo:block>
						            </fo:table-cell>
						            
						            <fo:table-cell number-columns-spanned="1" margin-right="1pt" margin-left="1pt" margin-bottom="1pt" border-width="0.500pt" border-style="solid" border-color="rgb(0,0,0)" margin-top="1pt" space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always" height="15pt">
						                <fo:block font-family="{$useFont}" font-weight="normal" font-size="{$fontSize}">
						                    <xsl:value-of select="COL4"/>
						                </fo:block>
						            </fo:table-cell>
						
						            <fo:table-cell number-columns-spanned="1" margin-right="1pt" margin-left="1pt" margin-bottom="1pt" border-width="0.500pt" border-style="solid" border-color="rgb(0,0,0)" margin-top="1pt" space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always" height="15pt">
						                <fo:block font-family="{$useFont}" font-weight="normal" font-size="{$fontSize}">
						                    <xsl:value-of select="COL5"/>
						                </fo:block>
						            </fo:table-cell>
					 		    </fo:table-row>
							</xsl:for-each>
						</fo:table-body>
                        </fo:table>
                    </fo:block>
			</xsl:for-each>
					             
            </fo:page-sequence>	


        </fo:root>
    </xsl:template>

</xsl:stylesheet>
 
Old September 7th, 2010, 11:33 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Well xsl:key is a top-level element, it is only allowed as a child of xsl:stylesheet, Putting it inside other elements does not make sense and is not allowed as far as I know but as you seem to have version="2.0" but use an XSLT 1.0 processor it might not be reported as an error.
And if you want to use multi-level grouping with XSLT 1.0 then you need to chain your key values as shown in http://www.biglist.com/lists/xsl-lis.../msg00070.html
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
narendra_mohan (September 7th, 2010)
 
Old September 7th, 2010, 11:41 AM
Registered User
 
Join Date: Aug 2010
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Thanks for your quick reply I will try it and let you know too.
:)
 
Old September 7th, 2010, 11:41 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Saxon is a good XSLT 2.0 processor, and an open source version is available, so not sure what you mean by 'licensing comes as a disadvantage'.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old September 7th, 2010, 12:18 PM
Registered User
 
Join Date: Aug 2010
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Default

I think it is not GPL licence, company has to purchase licensing.
 
Old September 7th, 2010, 12:39 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

It is the Mozilla Public license, a standard open source license. http://saxon.sourceforge.net/
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT grouping - need help Half-Saint XSLT 9 January 23rd, 2009 11:10 AM
Grouping with XSLT 1.0 rodmcleay XSLT 1 January 14th, 2008 11:42 PM
XSLT Grouping vernc XSLT 2 October 2nd, 2007 03:59 AM
XSLT 1.0 Grouping kwilliams XSLT 0 January 11th, 2006 06:30 PM
XSLT Grouping Help Missy XSLT 0 December 14th, 2005 10:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.