[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|