- From: anandhthiyagarajan <anandhthiyagarajan@gmail.com>
- Date: Thu, 4 Feb 2010 12:16:54 -0800 (PST)
- To: www-xsl-fo@w3.org
Thanks Tony for your suggestion. But i encountered an error when i try to use <xsl:for-each select="current-group()">. The error message which i receive is javax.xml.transform.TransformerException: Could not find function: current-group The cocoon stacktrace is as follows Unable to get transformer handler for file:///home/anandh/Desktop/cocoon/cocoon-2.1.11/build/webapp/prd-doc/doc2ci.xsl context://prd-doc/sitemap.xmap - 115:46 <map:serialize type="fo2pdf"> context://prd-doc/sitemap.xmap - 114:49 <map:transform> context://prd-doc/sitemap.xmap - 113:45 <map:generate> context://sitemap.xmap - 1034:92 <map:mount> The namespace which i used is as follows <xsl:stylesheet version="2.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> Let me know if i am missing anything else. Regards Anandh Tony Graham-3 wrote: > > On Thu, Feb 04 2010 05:51:26 +0000, anandhthiyagarajan@gmail.com wrote: >> Okay i will make you clear. >> >> Consider the xml >> >> <node> >> <title> >> <ingredients> >> <name>Category</name> >> <name>Noodles</name> >> <name>Pizza</name> >> </ingredients> >> <ingredients> >> <ingredient> >> <content>Fat</content> >> <description>aaaa</description> >> </ingredient> >> </ingredients> >> <ingredients> >> <ingredient> >> <content>Fat</content> >> <description>hgjhgk</description> >> </ingredient> >> </ingredients> >> </title> >> </node> >> >> >> Consider the xsl:fo >> >> <xsl:template match="node/title"> >> <fo:block space-before="4mm" hyphenate="true"> >> <fo:table table-layout="fixed" width="7in"> >> <xsl:for-each select="ingredients/name"> >> <fo:table-column column-width="10pt" /> > > Use proportional-column-width [1]: > > <fo:table-column column-width="proportional-column-width(1)" /> > >> </xsl:for-each> >> <fo:table-header hyphenate="true"> >> <xsl:for-each select="head"> > > As Aish pointed out, you don't have <head> or <row> elements in your > XML. > > ... >> I am attaching the output file >> >> http://old.nabble.com/file/p27448047/Table.doc Table.doc >> >> >> Hope this would be clear. > > That does make it clearer, thank you. > > Your XML doesn't make it easy to achieve what you want since <name> is > separate from the rest of the information for an ingredient. > > To "wrap" (or maybe "split") the table, it would be simplest if you used > XSLT 2.0 so you could use xsl:for-each-group [2]. E.g.,: > > <xsl:template match="node/title"> > <xsl:for-each-group > select="ingredients[ingredient]" > group-starting-with="position() mod 3 = 1"> > <fo:table> > <!-- There's a "CATEGORY" column in every table. --> > <fo:table-column column-width="proportional-column-width(1)" /> > <xsl:for-each select="current-group()"> > <fo:table-column column-width="proportional-column-width(1)" /> > </xsl:for-each> > <fo:table-header> > <fo:table-row> > <fo:table-cell> > <!-- Select the "Category" name and convert to upper-case. > --> > </fo:table-cell> > <xsl:for-each select="current-group()"> > <fo:table-cell> > <!-- Select the appropriate name based on the position > of this ingredients among its siblings, not on its > position in the current group, then convert to > upper-case. --> > </fo:table-cell> > </xsl:for-each> > </fo:table-row> > </fo:table-header> > <fo:table-body> > <!-- "Within the sequence constructor, the context item is the > initial item of the relevant group", so this makes one > row for each ingredient in the first ingredients in the > current group. --> > <xsl:for-each select="ingredient"> > <xsl:variable name="content-number" select="position()"/> > <fo:table-row> > <fo:table-cell> > <!-- value of content --> > </fo:table-cell> > <xsl:for-each select="current-group()"> > <fo:table-cell> > <!-- value of "ingredient[$content-number]/description" > --> > </fo:table-cell> > </xsl:for-each> > <fo:table-row> > </xsl:for-each> > </fo:table-body> > </fo:table> > </xsl:for-each-group> > </xsl:template> > > Regards, > > > Tony Graham Tony.Graham@MenteithConsulting.com > Director W3C XSL FO SG Invited Expert > Menteith Consulting Ltd XML Guild member > XML, XSL and XSLT consulting, programming and training > Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland > Registered in Ireland - No. 428599 http://www.menteithconsulting.com > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > xmlroff XSL Formatter http://xmlroff.org > xslide Emacs mode http://www.menteith.com/wiki/xslide > Unicode: A Primer urn:isbn:0-7645-4625-2 > > [1] http://www.w3.org/TR/xsl11/#d0e5961 > [2] http://www.w3.org/TR/xslt20/#grouping > > > -- View this message in context: http://old.nabble.com/Table-Manipulation-tp27430837p27459079.html Sent from the w3.org - www-xsl-fo mailing list archive at Nabble.com.
Received on Thursday, 4 February 2010 20:17:25 UTC