I have this XML file:
Consorcio W3C
Almost correct.
<xsl:if test="preceding-sibling::recurso[1]/unidad != unidad">
</xsl:if>
The :: is for axes, not for moving along a path ("making a location step"). In XPath terminology:
preceding-sibling::recurso[1]/unidad != unidad
''''''''''''''''' ++++++++++ ++++++
###
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
' = axis name (optional, defaults to "child")
+ = node test (required)
# = predicate (optional, for filtering)
~ = location step (required at least once per select expression)
The [1] is a shorthand for [position()=1].
The child axis is implicit in a location step, so this
preceding-sibling::recurso[1]/unidad != unidad
is equivalent to this:
preceding-sibling::recurso[1]/child::unidad != unidad