Test first subnode from node.

Posted by Kalinin on Stack Overflow See other posts from Stack Overflow or by Kalinin
Published on 2010-04-23T12:31:39Z Indexed on 2010/04/23 12:33 UTC
Read the original article Hit count: 550

Filed under:
|
|

XML:

<cont>
    <mode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
    </mode>
    <mode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
    </mode>
    <mode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
        <submode>lorem ipsum</submode>
    </mode>
</cont>

How to test first <submode> from each <mode> in such construction:

<xsl:template match="submode">
    <xsl:if test="(parent::mode) and (...what?...)">
        ...
    </xsl:if>
    ...
</xsl:template>

I do not understand how use position() here.

© Stack Overflow or respective owner

Related posts about xslt

Related posts about parent