xsl-list
[Top] [All Lists]

Re: [xsl] position() question

2008-09-26 07:19:14
I just came across an example where I am wondering about the value that is
calculated by position().

Please have a look at:
http://msdn.microsoft.com/de-de/library/ms256214.aspx

In my enviromnent (saxon 8) I dont get the desired result as in the example.
My value of position() is 2,4,6,...,22 instead of 1,2,3,...,11. So every
item gets the color yellow. But I dont know why, because the iteration goes
over the 11 "item" elements. Where do the other elements come from that are
counted?


In between each <item> element is a whitespace only text node which
gets included in the list of nodes to process by the apply-templates
call, so it goes:

[whitespace] 1
<item> 2
[whitespace] 3
<item> 4

etc

The Microsoft XML parser strips those whitespace only nodes by default
(incorrectly assuming they are just presentational markup from the
indentation of the XML) so the list of nodes to process becomes:

<item> 1
<item> 2
<item> 3

The "solution" to the problem is either:

a) tell the Microsoft parser not strip the whitespace only text nodes

or

b) be more explicit in the apply-templates call to only process
elements eg <xsl:apply-templates select="*"/>


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>