[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

position() affected by xsl:strip-space

Subject: position() affected by xsl:strip-space
From: "Cinzia" <cinzianet@xxxxxxxxxxxxx>
Date: Tue, 11 Apr 2006 18:40:02 +0100
table position
This thread originated from postings to fop-users list and it deranged.... The problem that
emerged was the following: position() seems to give results (which seem wrong) according
to the presence or absence of xsl:strip-space, but maybe someone can exaplain.
I've used for these examples saxonb 8, fop 0.20.5, j2se 1.4.2, winxp pro.

One example, fortest3 produces the desired results. It contains xsl:strip-space, and the xml
contains line-feeds which are removed by it. (There are no xsl:text elements).
The second example, fortest3b, doesn't. It does not contain xsl:strip-space, nor the xml
contains line feeds. So what's its issue? Might this be a bug?

Cinzia
p.s. see code below (xml, xsl, 'output pdf') for both fortest3 and fortest3b.


-- contains <xsl:strip-space elements="*" />  --
-- filtered by "position() mod 2 =1"   --
=============
fortest3 pdf output
=============
India, 1                  UK
USA , 3                 Canada
Australia , 5

-- omits <xsl:strip-space elements="*" />    --
-- not filtered because I'd get an empty output, so just print all
for testing and what I find out? position() is always even, why escapes me ;) --
==============
fortest3b pdf output
==============
India, 2                  UK
UK , 4                   USA
USA , 6                 Canada
Canada , 8             Australia
Australia , 10


========
fortest3.xml
========
<?xml version="1.0" encoding="utf-8" ?>
<genericSiteDoc>
 <cityInstal>India</cityInstal>
 <cityInstal> UK </cityInstal>
 <cityInstal> USA </cityInstal>
 <cityInstal> Canada </cityInstal>
 <cityInstal> Australia </cityInstal>
</genericSiteDoc>

========
fortest3.xsl
========
<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
=========
<?xml version="1.0" encoding="utf-8" ?>
<genericSiteDoc>
 <cityInstal>India</cityInstal><cityInstal> UK </cityInstal><cityInstal> USA </cityInstal><cityInstal> Canada
</cityInstal><cityInstal> Australia </cityInstal>
</genericSiteDoc>

=========
fortest3b.xsl
=========
<?xml version="1.0" encoding="utf-8" ?>
<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-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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.