Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: XPath Node Reference Question XPath Node Reference QuestionTo: NULL Date: 3/1/2006 8:57:00 AM Hi all,
I am having a bit of trouble identifying the first element of a set of
children. I had an answer that worked for a while until the case where
there was an element that was identical to the first element. Here is
what I had before:
XML Document
==================
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<A>
<B>Some Paragraph 1</B>
<B>Some Paragraph 2</B>
<B>Some Paragraph 3</B>
<B>Some Paragraph 1</B>
<B>Some Paragraph 5</B>
</A>
</ROOT>
XSL Transform
==================
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml"/>
<xsl:template match="B">
<xsl:choose>
<xsl:when test="../B[1]=.">
<xsl:text>first B</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>next B</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
The output for this now is:
first B
next B
next B
first B
next B
I realize that the test in the xsl above is comparing the value of the
element and whenever the value of the current node is equal to the
value of B[1] the test passes and outputs "first B". In reality
however, I need to only identify the actual first child and would like
the output to look like:
first B
next B
next B
next B
next B
Any thoughts?
Thanks in advance,
Andy
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
