XSLT - Comparing preceding-sibling's elements with current's node element

Posted by siondream on Stack Overflow See other posts from Stack Overflow or by siondream
Published on 2010-06-07T14:21:22Z Indexed on 2010/06/07 14:32 UTC
Read the original article Hit count: 216

Filed under:
|
|

Hello,

I have this XML file:

<recursos>
    <recurso url="http://w3c.com">
        <descripcion>Consorcio W3C</descripcion>
        <tipo>externo</tipo>
        <idioma>ingles</idioma>
        <contenido>General</contenido>
        <unidad>Unidad 2</unidad>
    </recurso>
    <recurso url="http://html.com">
        <descripcion>Especificación HTML</descripcion>
        <tipo>externo</tipo>
        <idioma>castellano</idioma>
        <contenido>HTML</contenido>
        <version>4.01</version>
        <unidad>Unidad 3</unidad>
    </recurso>
</recursos>

I want to compare one "recurso"'s preceding sibling element "unidad" with the "unidad" of the current "recurso" to check if they're different.

I was trying:

<xsl:if test="preceding-sibling::recurso[position()=1]::unidad != unidad">
</xsl:if>

But I know it's horribly wrong :( I hope you could help me, thank you very much.

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xslt