W3C home > Mailing lists > Public > www-xpath-comments@w3.org > July to September 2001

Proposal: relative node set type

From: Victor Porton <porton@narod.ru>
Date: Thu, 23 Aug 2001 08:25:22 -0400 (EDT)
To: www-xpath-comments@w3.org
Message-Id: <20010823121824.1E513131B3@localhost.narod.ru>
Hello XPath group,

I propose to introduce a new data type in XPath, 'relative node

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

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.


After the following variable declaration:

<xsl:variable name="relative" select="&table/tr"/>

the element

<xsl:template match="float/$relative">

becomes the same as

<xsl:template match="float/table/tr">


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">
            <xsl:attribute name="name">
                <xsl:value-of select="$name"/>
            <xsl:attribute name="value">
                <xsl:value-of select="./$use"/>
            <xsl:attribute name="href">
                <xsl:value-of select="$href"/>

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

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 Thursday, 23 August 2001 11:51:01 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:02:14 UTC