[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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.
On 5/23/06, Kevin Bird <kevin.bird@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
Re: [xsl] using every inside a predicate
Subject: Re: [xsl] using every inside a predicate From: "andrew welch" <andrew.j.welch@xxxxxxxxx> Date: Tue, 23 May 2006 09:41:01 +0100 |
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.bird@xxxxxxxxxxxxxxxxxxxxxxx> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] using every inside a predicat, Kevin Bird | Thread | RE: [xsl] using every inside a pred, Kevin Bird \(Matrix\ |
RE: [xsl] Sorting an xml, Michael Kay | Date | RE: [xsl] Evaluation of predicates , Michael Kay |
Month |