Subject: [xsl] position() affected by xsl:strip-space From: "Cinzia" <cinzianet@xxxxxxxxxxxxx> Date: Tue, 11 Apr 2006 18:40:02 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSL-FO/FOP : Getting an e, Gowri Ratakonda | Thread | Re: [xsl] position() affected by xs, David Carlisle |
Re: [xsl] XSL-FO/FOP : Getting an e, Gowri Ratakonda | Date | Re: [xsl] position() affected by xs, David Carlisle |
Month |