The context node in the last predicate is <name> so its not doing
anything, you either need
every $s in /sections/section (to make it from the root)
or
every $s in ancestor::sections/section (to walk back up the tree)
depending on your real xml.
cheers
andrew
On 5/23/06, Kevin Bird
<kevin(_dot_)bird(_at_)matrixdigitaldata(_dot_)co(_dot_)uk> wrote:
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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--