This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RE: Muenchian technique, was (Keys on multiple element types)


Hi Dave,

>> > I had this last week with
>> >
>> > $variable[generate-id(.) = generate-id(key('rows', name)[1])]
>> >
>> > so here the ndl in $variable is 'searched' for the first node for
>> > which the predicate is true? Then returned as the value of the
>> > expression?
>> 
>> Obviously it depends on the data, but the above expression should
>> return more than one node in some circumstances - all those nodes in
>> the $variable node set that are the first node (in document order)
>> returned by calling the key with their name element child as the key
>> value. 
>
> Just testing understanding here. If it returns more than one node,
> it implies that two (unique) id value pairs are equal, which (as you
> say) implies that in two places in the source document the predicate
> is true, which implies that the $variable has 'duplicates'
> (definition dependent on source file).

I don't think that's right. For example, say $variable simply held the
two elements:

  <record><name>Fred</name></record>
  <record><name>Barney</name></record>

The $variable doesn't have any duplicates - each record has a unique
name.

Of course we're assuming a key that looks like:

<xsl:key name="rows" match="record" use="name" />

As the processor goes through $variable, looking at one record at
time, the predicate will return true twice - once for the first record
(because the first record is the first record returned by the key when
it's accessed with the value 'Fred') and once for the second record
(because the second record is the first record returned by the key
when it's accessed with the value 'Barney').

On the other hand, if $variable held the two elements:

  <record><name>Fred</name></record>
  <record><name>Fred</name></record>

Then $variable does have a duplicate - both records have the name
'Fred' - so the expression will only return one node, the first record
(because the first record is the first record returned by the key when
it's accessed with the value 'Fred', but the second record isn't the
first record returned by the key when it's accessed with the value
'Fred').

In other words, the expression will return more than one node if
it's not the case that all the names of the records are the same.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]