xsl descendants,xsl count descendants,joshua gough,xsl count entries,xsl count descendant,select count union,count descendant xsl,using count and union,count descendants xsl,value of select count, xml%%%xsl descendants - Union and descendants: count(.//name1

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

Union and descendants: count(.//name1|name2) ? Doesn't perfo

Subject: Union and descendants: count(.//name1|name2) ? Doesn't perform Union?
From: Joshua Gough <exv@xxxxxxxxxxx>
Date: Mon, 12 Jul 1999 19:13:12 -0400 (EDT)
xsl descendants
Hi, 
  I've run into a problem using LotusXSL 0.17.3 as well as the 7/08
release of XT with the use of .// or // in conjunction with the |
operator.

For example:

count(.//entry|e) 

Returns only the number of "entry" elements without adding the number of e
matches to the result. 

Similarly,

count(.//e|entry) 

returns the number of e.

However:

count(./e|entry) 

Works fine, counting both, when in fact the context node contains those
children.  I figured that the former would work the same way with the |
operator. 

I can achieve the desired result using this long-winded syntax:

count(//*[qname() = 'entry' or qname() = 'e'])

But, I still figure the | operator should work. Can someone explain why
this is not so?

Here is some quick copy and paste sample code to see the results:

XML:

<?xml version="1.0"?>
<!DOCTYPE Section >
<Section>
  <SubSection>
   <entry>Blah</entry>
   <e>Blah as well</e>
   <entry>BLar blah</entry>
   <entry>Blahsdfdsafs </entry>
  </SubSection>
</Section>


XSL:

<?xml version="1.0"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
       xmlns:lxslt="http://xsl.lotus.com/"
       xmlns="http://www.w3.org/TR/REC-html40"			
       result-ns=""
>

<xsl:template match="/">
<h2>| operator and .// ?</h2>
<p>

The total number of e and entry (e|entry) in this document is:
<xsl:value-of select="count(//e|entry)" /><br />
The total number of entry and e (entry|e) in this document is:
<xsl:value-of select="count(//entry|e)" /><br />
Using //*[qname() = 'entry' or qname() = 'e'], the total is: <xsl:value-of
select="count(//*[qname() = 'entry' or qname() = 'e'])" /><br />

<br />

<xsl:for-each select="//*[not (qname() = 'entry') and not (qname() = 'e')
]">
	Name: <xsl:value-of select="qname(.)" /><br />
	Descendants <b>count(.//e|entry)</b>: <xsl:value-of
select="count(.//e|entry)" /><br />
	Descendants <b style="background: beige">count(.//entry|e)</b>:
<xsl:value-of select="count(.//entry|e)" /><br />
	Children <xsl:value-of select="count(./e|entry)" /><br />
	<br />
</xsl:for-each>

</p>

</xsl:template>

</xsl:stylesheet>


Text Output:

| operator and .// ?

The total number of e and entry (e|entry) in this document is: 1
The total number of entry and e (entry|e) in this document is: 3
Using //*[qname() = 'entry' or qname() = 'e'], the total is: 4

Name: Section
Descendants count(.//e|entry): 1
Descendants count(.//entry|e): 3
Children 0

Name: SubSection
Descendants count(.//e|entry): 4
Descendants count(.//entry|e): 4
Children 4


(I don't understand why the .// actually works once it got into SubSection
either)

Thanks,

Josh Gough



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.