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(_at_)acm(_dot_)org]
Sent: 21 June 2005 23:13
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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[(_at_)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=(_at_)l!l^!<#]s#[s/0ds^]s(_at_)[p]s&[ddvs^3s!l#x0<&2+l.x]ds.x
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--