[xsl] document() vs. current()

Subject: [xsl] document() vs. current()
From: "Marco Plum" <m.plum@xxxxxxxxxxxx>
Date: Thu, 22 Jun 2006 18:47:23 +0200
I hope that this hasn't been asked here before - at least I did not find a
solution searching through the list archive:

My XSL contains a lookup table im accessing via document(''). In order to
know, which value I need to look up, I have to get another value from my input
XML. Im trying something like that:

INPUT:

<dd>
	<vd name="aName" val="aValue"/>
	<vd name="anotherName" val="anotherValue"/>
	<vd name="x" val="1"/>
</dd>


XSL:

<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:date="My Date Namespace">
	<xsl:template match="/">
		<xsl:value-of select="document('')//date:months/date:month[@nr =
/dd/vd[@name ='x']/@val]/@name"/>
	</xsl:template>
	<date:months>
		<date:month nr="1" name="Januar"/>
		<date:month nr="2" name="Februar"/>
		<date:month nr="3" name="Mdrz"/>
		<!-- and so on -->
	</date:months>
</xsl:stylesheet>


If I change

/dd/vd[@name ='x']/@val

into its actual value (1), everything works fine...

So I thought that perhaps the function document() changes the context and I
have to use the function current(), but I did not get the result I
expected...

What am I doing wrong?

Best regards,
Marco Plum

*****************************************
Marco Plum
s<e>mantics Kommunikationsmanagement GmbH
Theaterstra_e 106 D - 52062 Aachen
Tel: +49 241 89498944
Fax: +49 241 89498930
eMail: m.plum@xxxxxxxxxxxx
Web: www.semantics.de

Current Thread