xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ckn...@onebox.com
Subject RE: Re: guide me
Date Sun, 09 Apr 2006 11:12:07 GMT
> From an efficiency point of view, wouldn't it be better to have a select
> (that filters odd elements) in the xsl:apply-templates so that the second
> template "gets called" 1/2 the total number of cityInstal?

If you did that, then you would have to make an empty template for the complementary set of
cityInstal elements, like so:

<xsl:template match="cityInstal[position() mod 2 = 0]" />

so that these elements would produce no output. Is that more efficient? I don't know. I may
depend on how the XSLT engine is implemented or, depending on the number of nodes to be processed,
the difference may be too small to notice. Does an elephant with a flea on his back weigh
more than the same elephant without the flea?

> Jus a note on xslt processor. I have tried the code below out of curiosity,
> and I cannot explain why, but position() always returns 2, which results in
> an empty table-body, as the xsl:if fails. (Used: saxonb 8, fop 0.20.5, j2se
> 1.4.2, winxp pro).

I've got the same setup, except that I've got Java 1.5.0_06, but I can't imagine that makes
a difference. Here's the entire stylesheet. Try it.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <xsl:output method="xml" indent="yes" />
  <xsl:strip-space elements="*" />

	<xsl:template match="/">
		<xsl:apply-templates />
	</xsl:template>
	
  <xsl:template match="genericSiteDoc">
    <xsl:apply-templates />
  </xsl:template>
  
  <xsl:template match="cityInstal">
    <xsl:if test="position() mod 2 =1">
      <fo:table-row>
      	<fo:table-cell><fo:block><xsl:value-of select="." /></fo:block></fo:table-cell>
      	<fo:table-cell><fo:block><xsl:value-of select="following-sibling::cityInstal[1]"
/></fo:block></fo:table-cell>
      </fo:table-row>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>

-- 
Charles Knell
cknell@onebox.com - email


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message