XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
- Stylus Studio Technical Forum (14621)
-> + Connect to Informix DB 7.31.FD... (2)
-> + Unable to download stylus stud... (5)
-> + conversion CSV to XML (2)
-> + Please help to create a XSL to... (2)
-> + Stylus Studio 2009 unresponsiv... (3)
-> + Stylus Studio 2009 and IBM Jav... (2)
-> + separate one record to two lin... (3)
-> + error when running xquery comm... (6)
-> + Convert ebcdic-cp-us to utf-8 (8)
-> - hi urgent plz (1)
-> + Java compile problem (7)
-> + How to set pattern match on th... (3)
-> + Adobe Illustrator CS4 xml not ... (3)
-> + validating XSD with W3c stand... (2)
-> - Count function with condition ... (2)
-> ->Count function with condi...
-> + [Context] variable (4)
-> + Batch process HTML to XML docu... (2)
-> + Need help with adding logiic ... (2)
-> - BUG when editing File Types (1)
-> + Is Stylus Studio XML authoring... (2)
-- Previous [841-860] [861-880] [881-900] Next
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Dhivya JSubject: Count function with condition including atleast
Author: Dhivya J
Date: 03 Feb 2009 07:32 AM
Hi,
Below is my XML :
<ex>
<a>
<b>
<b>
</a>
<a>
<b>
</a>
<a></a>
</ex>

I need to count the number of <a> tas with atleast one sub element b tag.
i.e) for the above xml i should be getting the count as 2(Though I have 3 <a> tags in the XML the third <a> does not have b in it)

I tried the below function :
Count(\ex\a\b[some conditions for b tags attribute])--->but this gives me the number of b tags and not the count of a tags with atleast one btag

Can any one help on this ?

Thanks in advance,
Dhivya

Posttop
John BamptonSubject: Count function with condition including atleast
Author: John Bampton
Date: 10 Feb 2009 07:10 AM
Very simple...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<count>
<xsl:value-of select="count(//b/parent::a)"></xsl:value-of>
</count>
</xsl:template>
</xsl:stylesheet>

Cheers. John Bampton.

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.