Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Xpath - more doubts....

 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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 ]
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. 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
 
Steven Broadbent
Ranch Hand
Posts: 400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic