|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Inlining blocks in FO
At 2009-03-07 07:55 -0700, Mark Wilson wrote:
I am trying to produce a PDF document formatted like: By thinking about grouping. You've taken a number of tangents working with axes that are not at all necessary. Things come together so much easier when using grouping, and I find my students get hung up on axes without taking a look at the bigger picture. But you said it correctly: "I need to process the entire node-set for "Philatelic news and views" simultaneously". And that you are using XSLT 2.0 makes that so much easier than XSLT 1.0. My XSLT and XML files, much abbreviated but still functional, follow. Thank you! That made it easier to hack a more appropriate solution. I also note you are using empty <fo:wrapper> elements in your XSL-FO ... empty wrapper elements not helpful in any way, so I've removed them. Finally, you need to remember the availability of position() and last() functions when dealing with the current node list ... adding the semi-colon separator and period terminator are a lot easier with these than when trying to deal with axes. You'll note below I never look at a preceding or following axis ... it isn't very often when one has to do so. I hope the code below helps. . . . . . . . . . . Ken <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:template match="/"> <fo:root> <fo:layout-master-set> <fo:simple-page-master master-name="page"> <fo:region-body region-name="body" margin-top="0.5in" margin-bottom="1in" margin-left="0.5in" margin-right="0.5in"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="page"> <fo:flow flow-name="body"> <xsl:apply-templates/> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> <!--take a look at all articles in the item-->
<xsl:template match="Item">
<!--first get the heading out of the way-->
<xsl:apply-templates select="Heading"/>
<!--now group the articles-->
<xsl:for-each-group select="Article" group-by="Title">
<!--and put all citations in one block-->
<fo:block>
<!--for a given title-->
<xsl:apply-templates select="Title"/>
<xsl:text>: </xsl:text>
<!--and for each citation-->
<xsl:apply-templates select="current-group()"/>
</fo:block>
</xsl:for-each-group>
</xsl:template> <!--format the item's heading-->
<xsl:template match="Heading">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template> <!--format a citation-->
<xsl:template match="Article">
<xsl:value-of select="IssueName,Year"/>
<xsl:text/> p.<xsl:value-of select=" Page"/>
<xsl:choose>
<xsl:when test="position()=last()">.</xsl:when>
<xsl:otherwise>; </xsl:otherwise>
</xsl:choose>
</xsl:template></xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








