[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Re: Re: A question about the expressive power and limitations of XPath 2.0
Subject: Re: [xsl] Re: Re: A question about the expressive power and limitations of XPath 2.0 From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Sun, 13 Jan 2002 10:27:31 +0000 |
Hi Dimitre, >> OK, let me think... a higher-order distinct function is an example. >> You have structured identifiers of the form "group.subgroup" and >> you want to return a unique set of nodes based on the "group" part >> of the identifier (note that Mike said they were discussion how to >> support this already, so perhaps there'll be a new 'distinct' >> clause added to the for expression to solve it). A recursive >> solution would be: >> >> <xsl:function name="my:distinct"> >> <xsl:param name="nodes" type="node*" select="()" /> >> <xsl:param name="distinct" type="node*" select="()" /> >> <xsl:variable name="new-distinct" >> select="if ($nodes[1] and >> some $n in ($distinct) >> satisfies (substring-before($n/@id, '.') = >> substring-before($nodes[1]/@id, '.'))) >> then ($distinct | $n) >> else $distinct" /> >> <xsl:result select="if ($nodes) >> then my:distinct($nodes[position() > 2], >> $new-distinct) >> else $distinct >> </xsl:function> > > I'm sorry, but it's not absolutely obvious. Let's have an example: Sorry. I was imagining $nodes contains: <function id="str.concat">...</function> <function id="regexp.match">...</function> <function id="math.power">...</function> <function id="math.sin">...</function> <function id="str.tokenize">...</function> <function id="str.pad">...</function> You need to group the functions by the initial part of their @id, and get back a sequence of function elements that have unique values for that part of their @id. You can do it if you're generating a result using xsl:for-each-group: <xsl:for-each-group select="function" group-by="substring-before(@id, '.')"> ... </xsl:for-each-group> But this doesn't help if you need to get hold of the function elements themselves (because you need to select the first two in document order, for example). Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: Re: A question about the , Dimitre Novatchev | Thread | [xsl] Re: Re: A question about the , Dimitre Novatchev |
[xsl] Re: Re: A question about the , Dimitre Novatchev | Date | Re: Regular expression functions (W, Jeni Tennison |
Month |