• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Using double slash(//) while using XSLT

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have an XML file which i am parsing using XSLT
The sample of the XML file is like ( only small part being shown here)

The <block> element inside has its own children.
I want to check inside the block element whether a particular node

<selectValue>


exists or not

The XSLT which I have written is

Now inside <xsl:value-of select="count(//selectValue)"/> when I use count(//selectValue) it gives me all the count which are present in the whole XML structure,which i don't want

I want the count of selectValue which are there somewhere down in hierarchy of <contents> -> <block> -> <contents>

Is this achievable??I need help immediately
Thanks & Regard
 
Sheriff
Posts: 28407
101
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are looking for all selectValue elements which are descendants of the document element, as you can see. But if I understand it right, you actually only want to look for selectValue elements which are descendants of the context node. The XPath expression for the context node is "." so you do that like this:

Note that you don't need to count the elements; the expression ".//selectValue" returns a nodeset containing all the selectValue elements which are descendants of the context node, and coercing that to boolean produces false if the nodeset is empty and true if it isn't.
>
 
Daksh Mital
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Paul thanks a lot for help
Cheers
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic