This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

XSL/XPath expression


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]