wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Xpath - more doubts.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Xpath - more doubts...." Watch "Xpath - more doubts...." New topic
Author

Xpath - more doubts....

Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
[url=http://"http://www.coderanch.com/t/125529/XML/xpath-exp-conventions-or-just"]Continuing my earlier thread[/url]....
I have yet another question on selecting a node using the "." dot. This is what I have read in a paper and it is true. Could somebody explain me the rule for selecting the variable "b"...please.
Thanks.
XML File:

XSL File:

The result file:

Sorry for the long post, just wanted to be detailed...
The rule for "SET B" is based on:
<xsl:variable name="b" select="/Root/Numbers[1]/Integer/@value[. > 2]" />
What is being selected here by the use of "."?
Is it the value of attribute "value" ?

Thanks for any help.
- madhav
[ January 24, 2003: Message edited by: Madhav Lakkapragada ]

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
knock....knock...kncok....
Can somebody please explain....

<xsl:variable name="b" select="/Root/Numbers[1]/Integer/@value[. > 2]" />
What is being selected here by the use of "."?
Is it the value of attribute "value" ?

Thanks.
- madhav
Steven Broadbent
Ranch Hand

Joined: Dec 10, 2002
Posts: 400
. is used to refer to the current context node
which is the attribute so this xpath rule selects both the elements:-
value =4 and value = 3
you can get very help tools like xpath explorer from purple technology which show you the
result of an xpath expression


"....bigmouth strikes again, and I've got no right to take my place with the human race...."<p>SCJP 1.4
Steven Broadbent
Ranch Hand

Joined: Dec 10, 2002
Posts: 400
and this xpath rule will select the Integer elements that have a value attribute with
value > 2

/Root/Numbers[1]/Integer[@value > 2]
selects:-
the two Integer elements with values 3 and 4
xpath tool available at: -

http://www.purpletech.com/xpe/index.jsp
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Thanks, Steve.
For whatever reason, I always thought, "." can only select "elements" not "attributes". I guess I alaways assume that a "Node" in DOM is equal to an "Element" in XML, which is wrong.
- madhav
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Xpath - more doubts....