Re: [xsl] would like to simplify my XSLT

Subject: Re: [xsl] would like to simplify my XSLT
From: Abel Braaksma <>
Date: Tue, 30 Jan 2007 15:08:57 +0100
Glen Mazza wrote:
The only problem is that if Chris has [1] and [6] as
documents, he will still be shown because he has one
document ([1]) that matches.  Only if Chris has *no*
matches at all was I trying to get this name to be

Aha, I see. I misunderstood that demand. I thought the requirement was "if one or more @rel-id were not found". Here are two options that work with my solution (the first is just a change of parameters, actually).

<!-- xslt 1 and 2 -->
<xsl:template match="person[not(document[@rel-id = ../../../documents/document/@id])]">
<person name="{name}" />

<!-- xslt 2 only, a bit obfuscated perhaps... -->
<xsl:template match="person[not(some $i in //document/@id satisfies $i = document/@rel-id)]">
<person name="{name}" />

I hoped to do the following, which reads much clearer in XSLT 2, but it won't work, because 'rel-id' and 'id' do not share the same name (hence there identity is not equal etc etc). And an attribute does not have a text() child node... :S

<xsl:template match="person[empty(//documents/document/@id intersect document/@rel-id)]">
<person name="{name}" />

if 'rel-id' were written 'id' in the source tree (and you change the match accordingly) this would work. Unfortunately, the operator 'intersect' is defined to compare nodes only, and cannot compare sequences of strings... :S

-- Abel Braaksma

Current Thread