W3C home > Mailing lists > Public > xsl-editors@w3.org > July to September 1999

Re: key and document()

From: James Clark <jjc@jclark.com>
Date: Tue, 24 Aug 1999 08:15:24 +0700
Message-ID: <37C1F22C.D9C4C38B@jclark.com>
To: Denys Duchier <Denys.Duchier@ps.uni-sb.de>
CC: xsl-list@mulberrytech.com, xsl-editors@w3.org

Denys Duchier wrote:
> Kay Michael <Michael.Kay@icl.com> writes:
> > > 1. the description of xsl:key fails to specify where the nodes that
> > >    are being matched come from.  I assume that they are all the nodes
> > >    in the `primary' source document (does this also include attribute,
> > >    namespace, text and processing instruction nodes?)
> >
> > No, they are the nodes of the document that contains the current node when
> > the key() function is invoked. But yes, they can be nodes of any type.
> If I understand you correctly, then each document, whether it is the
> `primary' one being transformed or a `secondary' one referred to by
> means of the document() function, has its own collection of keys.

Right.  The description of the key() function says:

"...it returns a node-set
containing the nodes ***in the same document as the context node*** that
have a value for the named key equal to this string"

> Thus assuming the following variable declaration:
>         <variable name="db" select="document('db.xml')"/>
> In order to get keys from secondary document $db, I must use an
> expression of the form:
>         $db/key($name,$value)
> is that the intention?

Unfortunately, that's not allowed by the syntax.  You have do do
something like:

  <xsl:for-each select="document('db.xml')">
     <xsl:apply-templates select="key($name,$value)"/>
> Does it not follow from this that I can never have a key that contains
> nodes from multiple documents?
> If a multi-document spanning key is desired, then it must be simulated
> by means of union expressions (thus forcing database merging to be
> expressed at each point of use rather than at the point of
> `definition').

Right.  In this respect, key() is just like id().

Received on Monday, 23 August 1999 21:47:57 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:17:45 UTC