xsl-list
[Top] [All Lists]

RE: Anyone can explain me this syntax?

2004-01-13 11:20:57
Jaime,

At 02:01 PM 1/13/2004, you wrote:
Thanks Wendell for your complete explanation. While reading your help, I tested another alternative:

ROW[. = key('relacion_x_cobertura', REL_ID)[1]]

and it worked too. The actual XML structure has 35 ROW's, the first 7 ROW's has REL_ID = 1, the following 7 ROW's has REL_ID = 2, and so on (this was a particular case where exist 7 ROW's for each REL_ID).

I think that the new way above worked because all of the ROW's are different (besides REL_ID, the ROW has other fields), and since key('relacion_x_cobertura', REL_ID)[1] returns only 1 node where the key is equal to REL_ID, by comparing . with the key value, returns only 1 ROW, the ROW that allows me to group by REL_ID=1, REL_ID=2, until REL_ID = 5.

I think that case is equivalent to generate-id method since all ROW's has at least 1 field different, making the whole ROW different. Is that true?

Yes, if the *value* of each ROW is unique, it can likewise be used to deduplicate. Note however this is a big IF, and isn't a reliable assumption to make.

To understand this you need to know that $node1 = $node2 is true if the (string) value of $node1 is the same as the string value of $node2 -- and likewise, $nodeset1 = $nodeset2 is true if the value of *any* of the nodes in $nodeset1 is the same as the value of any of the nodes in $nodeset2. This is quite a loose and permissive way of construing node-set equality, which is actually very useful sometimes. But it means that the "=" equality test is not useful for testing node identity unless every node concerned has a unique value -- which is rarely the case.

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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