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

RE: key and document()

From: Kay Michael <Michael.Kay@icl.com>
Date: Tue, 24 Aug 1999 14:30:10 +0100
Message-ID: <93CB64052F94D211BC5D0010A800133170F065@wwmess3.bra01.icl.co.uk>
To: "'xsl-list@mulberrytech.com'" <xsl-list@mulberrytech.com>
Cc: xsl-editors@w3.org
> 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.

That's my reading of the spec: "[The key() function] 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?

Not quite, that isn't a valid path expression: there's no axis for keys. You
have to do a for-each or apply-templates to change the context node and then
execute the key() function.

> Does it not follow from this that I can never have a key that contains
> nodes from multiple documents?

Yes (or should I say no), It does follow from this.
> 
> 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').
> 
Yes, I think so.

And note also that there is nothing in the spec to say whether invoking
document('db.xml') repeatedly will return the same node set each time or a
new node set each time, nor is there anything to say whether in your example
document('db.xml') is invoked when the variable is declared, the first time
it is referenced, or each time it is referenced.

(In SAXON each call on document() returns a new node set, but if you call it
in a global variable declaration, it will be invoked exactly once).

Mike Kay
Received on Tuesday, 24 August 1999 09:30:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:59:49 GMT