Subject: RE: Contexts that are atomic values
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 21 Jun 2005 23:37:27 +0100
|
More usual is to set a variable to the document node
<xsl:variable name="input" select="/"/>
and then regain your context using $input/key(...)
But yes: once you've gone into a scope where the context item is an atomic
value, you need some kind of handle to yank yourself out again. Perhaps a
current-match() would be useful - but in my view there are already far too
many current-these and current-those, and there's no crime in using
variables.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Michel Charpentier [mailto:charpov@xxxxxxx]
> Sent: 21 June 2005 23:13
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Contexts that are atomic values
>
> Hi,
>
> I need to organize a list of items by genre (@type) so that all the
> items of a given genre end up in the same file. The following code
> works:
>
> <xsl:template match="items">
> <xsl:for-each select="distinct-values(item/@type)">
> <xsl:result-document href="html/{.}.html">
> <xsl:apply-templates select="document('music.xml')/
> key('by-type',current())"/>
> </xsl:result-document>
> </xsl:for-each>
> </xsl:template>
>
> What bothers me is that I need the 'document("music.xml")' part
> ('music.xml' is the xml file I'm processing). If I don't have it,
> Saxon (8B) complains that it cannot process nodes from an atomic
> context (the string I'm currently processing, I suppose).
> Same thing
> if I use //item[@type = current()] instead of a call to key(). So,
> whether I use key() or not, I still need to start from 'document
> ("music.xml")' and I don't like it.
>
> Is this behavior normal? Is there a workaround that does not
> require
> me to refer to 'music.xml' explicitly?
>
> Thanks,
>
> MC
> --
> 2p3p[dl!d2+s!%0=@l!l^!<#]s#[s/0ds^]s@[p]s&[ddvs^3s!l#x0<&2+l.x]ds.x
|