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 23:10:27 GMT
Your XSLT processor still has to examine each "cityInstal" element to select only those that
match the select statement. Without empirical testing we still don't know which is more efficient
(faster).
-- 
Charles Knell
cknell@onebox.com - email



-----Original Message-----
From:     Cinzia <cinzianet@dsl.pipex.com>
Sent:     Sun, 9 Apr 2006 14:42:00 +0100
To:       <fop-users@xmlgraphics.apache.org>
Subject:  Re: guide me

> > 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]" />

This is not necessary, in the same way as it is not necessary in your
example, see code fortest below.

> > 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.
>

Thanks for that Charles, what made the difference to the result seemed to be
the line with <xsl:strip-space elements="*" />, a mistery. I get position()
1,2,3,..., with xsl:strip-space (see code fortest3), and 2,4,6,..., without
xsl:strip-space (see code fortest3b).

Cinzia

=== fortest
=== <?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet version="2.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:template match="genericSiteDoc">
     <fo:root font-family="Verdana" font-size="6pt" color="#666666">
        <fo:layout-master-set>
          <fo:simple-page-master master-name="A4Portrait"
page-height="29.7cm" page-width="21cm">
          <fo:region-body margin="1cm" region-name="body"/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="A4Portrait">
        <fo:flow flow-name="body">
          <fo:block text-align="left">
          <fo:table table-layout="fixed" width="254pt">
            <fo:table-column column-width="127pt"/>
            <fo:table-column column-width="127pt"/>
            <fo:table-body background-color="#ffffff">
              <xsl:apply-templates select="cityInstal[position() mod 2  1]"/>
            </fo:table-body>
          </fo:table>
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
   </xsl:template>

   <xsl:template match="cityInstal">
     <fo:table-row>
       <fo:table-cell><fo:block><xsl:value-of select="." />,
        <xsl:value-of select="position()"/></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:template>

</xsl:stylesheet>


==== fortest3
==== <?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet version="2.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:strip-space elements="*" />

   <xsl:template match="genericSiteDoc">
     <fo:root font-family="Verdana" font-size="6pt" color="#666666">
        <fo:layout-master-set>
          <fo:simple-page-master master-name="A4Portrait"
page-height="29.7cm" page-width="21cm">
          <fo:region-body margin="1cm" region-name="body"/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="A4Portrait">
        <fo:flow flow-name="body">
          <fo:block text-align="left">
          <fo:table table-layout="fixed" width="254pt">
            <fo:table-column column-width="127pt"/>
            <fo:table-column column-width="127pt"/>
            <fo:table-body>
              <xsl:apply-templates/>
            </fo:table-body>
          </fo:table>
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </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="." />,
          <xsl:value-of select="position()"/></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>

===== fortest3b
===== <?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet version="2.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:template match="genericSiteDoc">
     <fo:root font-family="Verdana" font-size="6pt" color="#666666">
        <fo:layout-master-set>
          <fo:simple-page-master master-name="A4Portrait"
page-height="29.7cm" page-width="21cm">
          <fo:region-body margin="1cm" region-name="body"/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="A4Portrait">
        <fo:flow flow-name="body">
          <fo:block text-align="left">
          <fo:table table-layout="fixed" width="254pt">
            <fo:table-column column-width="127pt"/>
            <fo:table-column column-width="127pt"/>
            <fo:table-body>
              <xsl:apply-templates/>
            </fo:table-body>
          </fo:table>
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>

   <xsl:template match="cityInstal">
      <fo:table-row>
        <fo:table-cell><fo:block><xsl:value-of select="." />,
          <xsl:value-of select="position()"/></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:template>

</xsl:stylesheet>


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




---------------------------------------------------------------------
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