You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Spectron International, Inc." <sp...@coqui.net> on 2002/05/14 19:30:37 UTC
xsl:apply-templates bug?
I have noticed something with xsl:apply-templates I don't know if it is a
bug but it seems to me that it shouldn't work that way. I have the following
xml:
<header>
<column>
<column>
<column>
<column>
</header>
And the following templates:
<xsl:template match="column">
<xsl:value-of select="position()"/>
</xsl>
If I use <xsl:apply-templates select="column"/> it will return the expected
numbers (1,2,3,4) if I only use <xsl:apply-templates/> it returns (2,3,4,5).
Why is that?
Fawzib Rojas
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: xsl:apply-templates bug?
Posted by Mike Dewar <mi...@nag.co.uk>.
If you select just the column nodes then they are indeeed in positions
1 to 4. However if you select all nodes then your "header" is in
position 1, and your "columns" in 2-5.
Mike.
On Tue, May 14, 2002 at 08:47:57PM +0200, J.Pietschmann wrote:
> Spectron International, Inc. wrote:
> > I have noticed something with xsl:apply-templates I don't know if it is a
> > bug but it seems to me that it shouldn't work that way. I have the following
> > xml:
> >
> > <header>
> > <column>
> > <column>
> > <column>
> > <column>
> > </header>
> ...
> > <xsl:template match="column">
> > <xsl:value-of select="position()"/>
> > </xsl>
> >
> > If I use <xsl:apply-templates select="column"/> it will return the expected
> > numbers (1,2,3,4) if I only use <xsl:apply-templates/> it returns (2,3,4,5).
> > Why is that?
>
> This is an XSLT question which should better have asked on the
> XSL list.
> As for the problem itself: the behaviour is probably correct.
> When using <xsl:apply-templates/>, templates are applied to all
> child nodes, including text nodes which consist of whitespace
> only (usually to format the source XML) and comments. If you
> have a comment before your first column element, it is at
> position 1. Look hard at your source.
>
> J.Pietschmann
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
>
> _____________________________________________________________________
> This message has been checked for all known viruses by Star Internet
> delivered through the MessageLabs Virus Scanning Service. For further
> information visit http://www.star.net.uk/stats.asp or alternatively call
> Star Internet for details on the Virus Scanning Service.
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: xsl:apply-templates bug?
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Spectron International, Inc. wrote:
> I have noticed something with xsl:apply-templates I don't know if it is a
> bug but it seems to me that it shouldn't work that way. I have the following
> xml:
>
> <header>
> <column>
> <column>
> <column>
> <column>
> </header>
...
> <xsl:template match="column">
> <xsl:value-of select="position()"/>
> </xsl>
>
> If I use <xsl:apply-templates select="column"/> it will return the expected
> numbers (1,2,3,4) if I only use <xsl:apply-templates/> it returns (2,3,4,5).
> Why is that?
This is an XSLT question which should better have asked on the
XSL list.
As for the problem itself: the behaviour is probably correct.
When using <xsl:apply-templates/>, templates are applied to all
child nodes, including text nodes which consist of whitespace
only (usually to format the source XML) and comments. If you
have a comment before your first column element, it is at
position 1. Look hard at your source.
J.Pietschmann
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>