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

RE: Anyone can explain me this syntax?

Subject: RE: Anyone can explain me this syntax?
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 13 Jan 2004 17:32:37 +0200
node explain
Hi,

> From Muenchian method of grouping, I always use something like this:
> 
> ROW[count(. | key('relacion_x_cobertura', REL_ID)[1]) = 1]

  key('relacion_x_cobertura', REL_ID)

will return a node-set whose "relacion_x_cobertura" key value is the same as the string value of REL_ID element,
 
  key('relacion_x_cobertura', REL_ID)[1]

of that node-set, select the first,

  . | key('relacion_x_cobertura', REL_ID)[1]

create an union of that node-set with the current node. Remember that a node-set will *not* contain dublicates, so if the current node is same node as the first one returned by the key, the resulting set will only contain the current node.

  count(. | key('relacion_x_cobertura', REL_ID)[1])

count the number of nodes in the union set,

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

and if the count is equal to one, return boolean true. In effect, check if the current node is the same node as the first one returned by the key.

> - Why the . (dot) is used? why if I omit it, it doesn't work 
> (it returns all elements)?

The current node. See <http://www.w3.org/TR/xpath#NT-AbbreviatedStep>.

> - What's the meaning of the | (pipe)?

You haven't read the XPath 1.0 spec, have you? See <http://www.w3.org/TR/xpath#NT-UnionExpr>.

> - What's the meaning of [1]? I have always used things like 
> [FIELD_NAME=some_value]. I understand that perfectly, but 
> what about placing only that number in the brackets? I tried 
> by using [2] and it worked too... or, perhaps I was lucky?

Read the XPath 1.0 spec, you'll feel better in the morning.

Cheers,

Jarno

 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.