[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: RE: Muenchian technique, was (Keys on multiple el

Subject: Re: RE: Muenchian technique, was (Keys on multiple element types)
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 6 Feb 2002 09:57:33 +0000
Re:  RE: Muenchian technique
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.