[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to find out number of elements which does not

Subject: Re: How to find out number of elements which does not have a particular attribute
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 07 Jul 2004 11:50:26 -0400
find child element
Ranjan,

But I'm not sure this is going to work (have you tested it?):

count(connectivity//*[@*[not(local-name() = 'sharedsource')]])

for the stated requirement

how to find out [the] number of elments which [do] not have a particular attribute?

Parsing the XPath into English ...


count()
  counts a set of nodes

connectivity
expands to child::connectivity ('connectivity' child elements of the context node) ... this could be what you want, depending on the input and the context node being matched


connectivity//*
  expands to child::connectivity/descendant-or-self::node()/*
  namely any element descendant of the 'connectivity' children

[@*]
  "which has an attribute"

[not(local-name() = 'sharedsource')]
  "whose local name is not 'sharedsource'"

In other words, the expression returns the count of all descendants of 'connectivity' children that have an attribute whose local name is not 'sharedsource'.

This is different from all elements that have no 'sharedsource' attribute.

To cut to the chase, the latter would be

count(//*[not(@sharedsource)])

which returns the count of all element descendants of the root that have no 'sharedsource' attribute.

Its long-syntax form is

count(/descendant-or-self::node()/*[not(attribute::sharedsource)])

Cheers,
Wendell

At 08:36 AM 7/7/2004, 'twas written:
> <xsl:variable name="sharedcount1"
> select="count(connectivity//*[@*[not(local-name() =
> 'sharedsource')]])"/>


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.