• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using double slash(//) while using XSLT

 
Daksh Mital
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi
Paul thanks a lot for help
Cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic