Reputation: 45
I have a base xml file like:
<base>
...
<s l="something" />
<s l="somethingelse" />
<s>
...
</base>
In my xslt, I use the document()
function on each <s>
to pull in another file structured like:
<otherbase>
...
<r l="something" />
<r l="somethingelse" />
<r l="evenmore" />
...
</otherbase>
At <s>
in the base file, I am trying to select all <r>
s whose @l
does not match any preceding-sibling::*/@l
of the current <s>
. Thus for the third <s>
with no attribute, it would match <r l="evenmore" />
etc.
Something like:
<xsl:for-each select="document('mydoc.xml')//r[@l != preceding-sibling::*/@l]">
...
</xsl:for-each>
would work if I were matching within the <r>
attributes I believe, but I need preceding-siblings of current()
... I haven't been able to figure out the syntax.
Unfortunately there are no 2.0 processors in my environment, stuck in xslt 1.0.
Upvotes: 1
Views: 544
Reputation: 116992
You need to use the current()
function when you want to refer to the current s
node within a predicate. Try:
select="document('mydoc.xml')//r[not(@l = current()/preceding-sibling::s/@l)]"
Note also the difference between $a != $b
and not($a = $b)
.
Upvotes: 1