Re: AW: [xsl] Using key() from outside the default namespace

Subject: Re: AW: [xsl] Using key() from outside the default namespace
From: Peter Flynn <peter@xxxxxxxxxxx>
Date: 06 Aug 2003 00:21:17 +0100
On Tue, 2003-08-05 at 02:16, Peter Flynn wrote:
> I'll sort out a minimal instance to demonstrate this.

This is in http://www.silmaril.ie/xslt/minimal.zip

 Length   Method    Size  Ratio   Date   Time   CRC-32    Name
--------  ------  ------- -----   ----   ----   ------    ----
     198  Defl:N      138  30%  08-05-03 23:40  8e998f3c  styles.xml
     952  Defl:N      367  61%  08-05-03 23:42  8b778bd3  bibstyle.css
      67  Defl:N       52  22%  08-06-03 00:06  73f11633  demo.css
     820  Defl:N      428  48%  08-06-03 00:15  d198d1a9  README
    1113  Defl:N      295  74%  08-06-03 00:16  270ec157  doc.html
    3611  Defl:N     1102  70%  08-06-03 00:16  b8c75731  doc2htm.xsl
     273  Defl:N      184  33%  08-06-03 00:16  66c1701f  doc.xml
--------          -------  ---                            -------
    7034             2566  64%                            7 files

README says:

This is a minimal set of files to reproduce the problem:

    How do you use a key which indexes nodes in the
    main document, when processing nodes from an
    auxiliary document via for-each using document()?

The canonical answer is to set a global variable to the document root
and then within the for-each of the document(), set a variable to hold
the desired key node, containing a dummy for-each to process the
global variable (which sets the context back to the main document),
within which you make the call to key().

This set of files does exactly that, and shows that this procedure
of using the global variable causes the document root template to
be fired, outputting unwanted nested literal result elements.

To run this, use something like

	$ saxon doc.xml doc2htm.xsl doc.html

<peter@xxxxxxxxxxx>
 




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread