473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

XSLT ::Get Count of nodes in xml matching certain condition

26
Hi

I have simple xml .Here in XSL1.0 ,I want to get count of all speciality tag where attribute isSpecialist= false. Similarily count of all speciality tag with isspecialist attribute value as true.

I used this but this doesn't work
count(/test/SpecialtyInfo/Specialty/@isSpecialist['true'])


Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <test lastActivityTime="9/24/2008 9:34:40 AM">
  3.   <SpecialtyInfo>
  4.     <Specialty name="Outdoor" id="3" isSpecialist="false"  ></Specialty>
  5.     <Specialty name="Shopping" id="4" isSpecialist="false" ></Specialty>
  6.     <Specialty name="Shopping" id="5 isSpecialist="true" ></Specialty>
  7.   </SpecialtyInfo>
  8. </test>




Thanks
Jalaj
Oct 5 '08 #1
3 22832
Dormilich
8,658 Expert Mod 8TB
just put the whole condition in square brackets

count(//Specialty/[@isSpecialist = 'true'])

regards
Oct 6 '08 #2
gagonm
26
Hey It didn't work out. It always give me same result.
below is snippet of my xslt.


Expand|Select|Wrap|Line Numbers
  1. <xslt:value-of select="count(//Specialty/Specialty[@isSpecialist=true])"/>
  2.  
  3.       <xslt:choose>        
  4.         <xslt:when test="count(//Specialty/Specialty[@isSpecialist='true'])>0">
  5.  
  6.           <xslt:apply-templates select="/Testing/SpecialtyInfo/Specialty"></xslt:apply-templates>
  7.         </xslt:when>
  8.         <xslt:otherwise>
  9.  
  10.           <xslt:text>None identified as yet </xslt:text>  
  11.         </xslt:otherwise>        
  12.       </xslt:choose>
just put the whole condition in square brackets

count(//Specialty/[@isSpecialist = 'true'])

regards
Oct 7 '08 #3
Dormilich
8,658 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. <xslt:value-of select="count(//Specialty/Specialty[@isSpecialist='true'])"/>
this won't work since there are no <Specialty> elements inside <Specialty>.

try this one
Expand|Select|Wrap|Line Numbers
  1. <xslt:value-of select="count(//Specialty[@isSpecialist='true'])"/>
regards
Oct 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Lizard | last post by:
OK, total newbie here, so this may be a mind-numbingly dumb question AND I may be phrasing it badly. I have an xsl:template which looks like this: <xsl:template match="LoanRecord"> <hr>...
5
by: Marcel Akkerman | last post by:
Hi, Does anyone have a clue how to reduce the number of nodes using XSLT? When outputing all nodes in order I could just use <xsl:for-each select="name"> But what if I, besides sorting and...
5
by: inquirydog | last post by:
Hi- Does anyone know a way to compare whether two nodes contain the same information in xslt (the name, attributes, and all content recursivly should be the same. I am interested in the case...
4
by: gualtmacchi | last post by:
I'm processing an XML input file getting a plain text file where from M nodes I got N output lines... It's not relevant but the input file is a recordset coming from a database and the output is...
6
by: Neal | last post by:
Hi All, I used an article on XSLT and XML and creating a TOC written on the MSDN CodeCorner. ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/dncodecorn/html/corner042699.htm However, it did'nt...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
3
by: abhishek.smu | last post by:
Given an XML like: <root> <node>8</node> <node>21</node> <node>-7</node> <node>13</node> <node>43</node> <node>2</node> </root>
4
by: raghunandanbasf | last post by:
Hi friends, I am new to the xslt when i am doing ,I have struck in middle. Q.As per example:we are having the xml structure like this <a> <b>-----</b> <c>-----</c> <d>-----</d> </a>
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.