xsl-list
[Top] [All Lists]

RE: preceding-sibling

2004-08-11 02:43:45
The general syntax for steps in a path expression is

axis::nodetest[predicate]

Examples of axes are "self", "child", and "preceding-sibling"

When you write self::preceding-sibling it is looking for elements named
"preceding-sibling" on the self axis, and there aren't any elements with
that name.

Michael Kay 

-----Original Message-----
From: Kaarle Kaila [mailto:kaarle(_dot_)kaila(_at_)iki(_dot_)fi] 
Sent: 11 August 2004 10:30
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] preceding-sibling

I have tried to understand how the preceding-sibling axes 
functions but
without success.


I have an xml-file with contents like this:


<table>
<section gen="1">
<person>John</person>
</section>
<section gen="2">
<person>Mary</person>
</section>
<section gen="3">
<person>William</person>
</section>
</table>


Here Mary is Johns mother and William is Marys father.

I have as xslt file where I want to connect parent to child like this:

<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'


<xsl:template match="table">
<xsl:apply-templates select="section"/>
</xsl:template>

<xsl:template match="section">
<xsl:if test="position()>1">
Parent:<xsl:value-of select="person"/>, child::<xsl:value-of
select="self::preceding-sibling/person"/>.
</xsl:if>
</xsl:template>
</xsl:stylesheet>

=================
What am I doing wrong as the result I get is:
<?xml version="1.0"?>
Parent:Mary, child::.
Parent:William, child::.
=====================
I have tried to write the expression with the preceding 
sibling in may ways
but never get any values from it.

What would be the correct way to use this:

regards
Kaarle Kaila



--+------------------------------------------------------------------
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>