RE: Proposal: relative node set type

A personal response, not endorsed by the working groups:

I think the clean way of implementing this kind of thing is for XPath
expressions or functions to become a first-class data type, so that the
value of a variable can be an XPath expression. This would be consistent
with many other functional programming languages, and would also reflect the
way many SQL users construct SQL statements dynamically from strings. You
might like to look at the way Saxon does this with its saxon:evaluate
extension (it's also available in Xalan).

Such a facility is not in the requirements list for XPath 2.0, largely
because extending the XPath type system to support XML Schema is quite
enough of a challenge for one release.

Mike Kay

> -----Original Message-----
> From: w3c-xsl-wg-request@w3.org [mailto:w3c-xsl-wg-request@w3.org]On
> Behalf Of Victor Porton
> Sent: 23 August 2001 13:25
> To: www-xpath-comments@w3.org
> Subject: Proposal: relative node set type
>
>
> Hello XPath group,
>
> I propose to introduce a new data type in XPath, 'relative node
> set'.
>
> Proposed syntax of relative node set is & followed by a relative
> location path.
>
> A node set may be concatenated with a relative node set. Also a
> relative node set may be concatenated with an other relative node
> set.
>
> The syntax of such concatenating is
>
> X/Y | X//Y
>
> where X is a node set or a relative node set, and Y is a relative
> node set. The result of concatenating is the node set or relative
> node set. which is X followed by / or // respectively and followed
> by Y with removed leading &.
>
> Concatenating of a node set with a relative node set produces a node
> set. Concatenating of two relative node sets produces a relative
> node set.
>
> Example:
>
> After the following variable declaration:
>
> <xsl:variable name="relative" select="&table/tr"/>
>
> the element
>
> <xsl:template match="float/$relative">
> ...
> </xsl:template>
>
> becomes the same as
>
> <xsl:template match="float/table/tr">
> ...
> </xsl:template>
>
> Rationale:
>
> I encountered practical need of relative node sets, passing
> parameters to templates. I need such parameters with which it
> is possible to express the trailing part of node sets.
>
> The real example, as it could be used:
>
> <xsl:param name="name"  select="'id'"/>
> <xsl:param name="match" select="&.//*[@id]"/>
> <xsl:param name="use"   select="&@id"/>
>
> <xsl:template match="uri">
>     <xsl:variable name="href" select="@href"/>
>     <xsl:for-each select="document(@href)/$match">
>         <key>
>             <xsl:attribute name="name">
>                 <xsl:value-of select="$name"/>
>             </xsl:attribute>
>             <xsl:attribute name="value">
>                 <xsl:value-of select="./$use"/>
>             </xsl:attribute>
>             <xsl:attribute name="href">
>                 <xsl:value-of select="$href"/>
>             </xsl:attribute>
>         </key>
>     </xsl:for-each>
> </xsl:template>
>
> This example produces 'listing of keys' like:
>
> <key name="id" value="s" href="a.xml"/>
> <key name="id" value="a1" href="a.xml"/>
> <key name="id" value="s" href="b.xml"/>
> <key name="id" value="b1" href="b.xml"/>
>
> from uri elements like:
>
> <uri href="a.xml"/>
> <uri href="b.xml"/>
>
> This listing is used for linking between multiple XML
> documents.
>
> P.S. I am not subscribed to www-xpath-comments@w3.org (Sorry,
> I have problems with Internet access now and cannot subscribe.)
> Please answer me through the email porton@narod.ru.
>
> --
> Victor Porton (porton@narod.ru)
> Extreme Code Software (http://e-code.fateback.com/)
> * Client Side SSI program (converts SHTML->HTML)
> * FoldersTree control (to be released soon)
>

Received on Tuesday, 11 September 2001 14:23:32 UTC