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

using every inside a predicate

Subject: using every inside a predicate
From: "Kevin Bird" <kevin.bird@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 23 May 2006 09:22:56 +0100
inside the predicate
Hi

I am having trouble implementing a solution kindly offered on this list.

The following variable should return a sequence of names that only
appear in EVERY section.

	<xsl:variable name="ubiquitous-names"
			  select="distinct-values(sections/section/name
			  [not(contains(., 'new entry'))]
			  [every $s in sections/section satisfies
$s/name = .])" />

When tested on the XML below I get:

	<result>Kevin Bill Fred Ollie Harry</result>

Which is a list of distinct values, which I can get by:

	<xsl:variable name="ubiquitous-names"
			  select="distinct-values(sections/section/name
			  [not(contains(., 'new entry'))])" />

What I am after is:

	<result>Kevin Bill</result>

As these are the only names that appear in every section.

So  [every $s in sections/section satisfies $s/name = .] doesn't seem to
have any effect.

Can someone please point me in the right direction.

-------
XML
-------

<?xml version="1.0"?>
<sections>
	<section name="North">
		<name>Kevin</name>
		<name>Bill</name>
		<name>Fred</name>
		<name>Ollie</name>
		<name>Frank - new entry</name>
		<name>Bob - new entry</name>
	</section>
	<section name="South">
		<name>Fred</name>
		<name>Kevin</name>
		<name>Bill</name>
		<name>Frank - new entry</name>
		<name>Bob - new entry</name>
	</section>
	<section name="West">
		<name>Kevin</name>
		<name>Frank - new entry</name>
		<name>Bill</name>
		<name>Ollie</name>
		<name>Bob - new entry</name>
		<name>Fred</name>
	</section>
	<section name="East">
		<name>Harry</name>
		<name>Bob - new entry</name>
		<name>Bill</name>
		<name>Frank - new entry</name>
		<name>Kevin</name>
		<name>Ollie</name>
	</section>
</sections>

-----
XSL
-----

<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="xml"/>
	<xsl:strip-space elements="*"/>

<xsl:template match="/">

		<xsl:variable name="ubiquitous-names"

select="distinct-values(sections/section/name
					  [not(contains(., 'new
entry'))]
					  [every $s in sections/section
satisfies $s/name = .])" />

		<result>
			<xsl:copy-of select="$ubiquitous-names" />
		</result>
</xsl:template>

Thanks.

--
Kevin

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.