test of following-sibling[2] does not work

  • Thread starter Petterson Mikael
  • Start date
P

Petterson Mikael

Hi,

If sibling # 2 is enumRef, in xsl, I will call enumNameString template.
In my example, xml, it is an enumRef but still the call to enumNameString
is not performed. The otherwise is performed :)

Any ideas why?

cheers,

//mikael


xml
===

<structMember name="aichTiming">
<description>Timing sensor
</description>
<enumRef name="Aich_Timing">
</enumRef>
</structMember>

xsl
===
<xsl:for-each select="structMember">
<xsl:choose>
<xsl:when test="following-sibling[2][name(.) = 'enumRef']">
<xsl:call-template name="enumNameString">
<xsl:with-param name="enumRefName" select="@name"/>
</xsl:call-template>"</xsl:when>
<xsl:eek:therwise>
<xsl:text>"</xsl:text><xsl:value-of select="@name"/>"
</xsl:eek:therwise>
</xsl:choose>
<xsl:if test="not(position()=last())">,</xsl:if>
</xsl:for-each>
 
G

George Bina

Hi Mikael,

What you want is not the a sibling of structMember, you want to check
the second child of structMember and for that you should use the child
axes like below. Also the test does not change the context node so
@name will select the structMember name and if you want the
enumRef/@name then you should first get to that node:

<xsl:when test="child::*[2][self::enumRef]">
<xsl:call-template name="enumNameString">
<xsl:with-param name="enumRefName"
select="child::*[2][self::enumRef]/@name"/>
</xsl:call-template>"</xsl:when>

Best Regards,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top