This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
XSL/XPath expression
- To: "'XSL-List at lists dot mulberrytech dot com'" <XSL-List at lists dot mulberrytech dot com>
- Subject: [xsl] XSL/XPath expression
- From: Eriksson Magnus <Magnus dot eriksson at softronic dot se>
- Date: Wed, 16 May 2001 13:40:12 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi all!
I have the following XML data:
<ElementList>
<Element Type="1">1</Element>
<Element Type="1">2</Element>
<Element Type="2">3</Element>
<Element Type="2">4</Element>
</ElementList>
To match only the 1st Element element with Type="2" when in the ElementList
context node I could write:
<xsl:if test="Element[@Type='2'][position()=1]">
do something
</xsl:if>
This seems to be working. What I really want to do, however, is to have this
test inside the Element context node, but I have no clue how to express
this:
<xsl:template match="ElementList">
<xsl:apply-templates select="Element"/>
</xsl:template>
<xsl:template match="Element">
<xsl:if test="???[@Type='2'][position()=1]">
do something
</xsl:if>
</xsl:template>
Thanks in advance for any help.
/Magnus Eriksson
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list