W3C home > Mailing lists > Public > www-xsl-fo@w3.org > November 2007

Re: Basic FO questions

From: Tony Graham <Tony.Graham@MenteithConsulting.com>
Date: Wed, 07 Nov 2007 17:49:15 +0000
To: www-xsl-fo@w3.org
Message-ID: <874pfyymhw.fsf@zako.menteithconsulting.com>

On Wed, Nov 07 2007 17:20:20 +0000, ka.aly@luxsci.net wrote:
> Yes, I guess this one is an xslt issue, but what you wrote below sounds
> relevant, because some every-other-node that is not meant for display seems
> always counted. So, I get the list numbered: 2, 4, 6, ... this is apart from
> the extra white space pbm). The position() function should return a number
> equal to the position of the current node in the context node-set, which is
> "List".

Putting each <Item> on a separate line creates a text node before each
<Item>.  If the template rule for <List> processes its child nodes with:


then those text nodes are also part of the context node-set.

> The XML:
> <List ordered="yes">
> <Item>text</Item>
> ...
> <Item>text</Item>
> </List>


<List ordered="yes">

The first child of your <List> is the text "
" (i.e., "&#xA;"), and the second child of the <List> is the first
<Item>, and so on.  You and I find it easy to gloss over the added
whitespace when looking at the markup, but the XSLT processor is rather
more literal minded.

If you put:

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

at the top of your stylesheet (after any xsl:import), then the
whitespace-only text node children of <List> will be stripped when the
XSLT processor builds a tree from your XML file, and the first child
from your example <List> will be an <Item>.

Alternatively, the template rule for <List> could select only its <Item>
children with:

   <xsl:apply-templates select="Item"/>


Tony Graham.
Tony.Graham@MenteithConsulting.com   http://www.menteithconsulting.com

Menteith Consulting Ltd             Registered in Ireland - No. 428599
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
Menteith Consulting -- Understanding how markup works
Received on Wednesday, 7 November 2007 17:49:59 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:58:31 UTC