This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
AW: XSL/XPath expression
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: AW: [xsl] XSL/XPath expression
- From: "Mengel Andre (FV/SLM) *" <Andre dot Mengel at de dot bosch dot com>
- Date: Wed, 16 May 2001 15:59:58 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
Dear Magnus
I am not quite sure (because I am not an XSLT-Expert)
but maybe this is also a solution:
<xsl:template match="ElementList">
<xsl:apply-templates select="Element"/>
</xsl:template>
<xsl:template match="Element">
<xsl:if test="@Type[string(.)='2'][position()=1]">
do something
</xsl:if>
</xsl:template>
regards
André
> -----Ursprüngliche Nachricht-----
> Von: Eriksson Magnus [mailto:Magnus.eriksson@softronic.se]
> Gesendet: Mittwoch, 16. Mai 2001 13:40
> An: 'XSL-List@lists.mulberrytech.com'
> Betreff: [xsl] 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
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list