• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Xpath - more doubts....

 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[url=http://"https://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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I don't even know how to spell CIA. But this tiny ad does:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic