Re: Basic FO questions

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:

   <xsl:apply-templates/>

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

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


In:

<List ordered="yes">
<Item>text</Item>
...
<Item>text</Item>
</List>

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

Regards,


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