- From: Victor Porton <porton@narod.ru>
- Date: Thu, 23 Aug 2001 08:25:22 -0400 (EDT)
- To: www-xpath-comments@w3.org
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 Thursday, 23 August 2001 11:51:01 UTC