[xsl] Problem with Saxon 7.9.1 xsl:variable and selecting additional elements from variable value

Subject: [xsl] Problem with Saxon 7.9.1 xsl:variable and selecting additional elements from variable value
From: Olaf Meske <omeske@xxxxxxxxxxx>
Date: Wed, 12 Oct 2005 11:36:51 +0200
Hi,

I'm using Saxon 7.9.1 to transform some xml. Within this transformation
I set a variable to a node. Somewhat later I try to select a value from
a subnode of this variable node, but it gives me nothing. With the
XML-Spy engine this works for me, but not with Saxon 7.9.1 (which I have
to use for some other reasons).
So If someone could give me an advice how to do this with saxon 7.9.1 or
what else to do.
I would be very grateful if someone could help me.

Regards
Olaf


This is my XML file: -------------------- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml-stylesheet type="text/xsl" href="tinytest.xsl"?> <document xmlns="http://www.example.com/NameSpace"; > <main> <section> <name>my section</name> <id>100</id> </section> <content> <id>contentid 2</id> <text>the content itself</text> </content> </main> </document>

======================
This is the tinytest.xsl xml style sheet:
-----------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
	xmlns:myns="http://www.example.com/NameSpace";>
	<xsl:template match="/">
		<myNexDoc>
		<version>
		version: <xsl:value-of select="system-property('xsl:version')" />
		vendor: <xsl:value-of select="system-property('xsl:vendor')" />
		vendor-url: <xsl:value-of select="system-property('xsl:vendor-url')" />
		product: <xsl:value-of select="system-property('xsl:product')" />
		product-version: <xsl:value-of
select="system-property('xsl:product-version')" />
		</version>
		<xsl:apply-templates select="//myns:content" mode="content" />
		</myNexDoc>
	</xsl:template>	
	
	<xsl:template match="myns:content" mode="content">
		<xsl:variable name="thissection" >
			<xsl:sequence select="../myns:section"/>
		</xsl:variable>
		<mysection>
			<xsl:attribute name="origSectionId">
				<xsl:value-of select="$thissection/myns:id"/>
			</xsl:attribute>
		</mysection>
		<somedummy>dummy content</somedummy>
	</xsl:template>
	
</xsl:stylesheet>

==========================
Here is the XML-Spy result (pritty print)(which is what I'm expecting):
With the right value for mysection/@origSectionId
---------------------------
<?xml version="1.0" encoding="UTF-8"?>
<myNexDoc xmlns:myns="http://www.example.com/NameSpace";>
	<version>
		version: 2.0
		vendor: Altova GmbH
		vendor-url: http://www.altova.com
		product:
		product-version: </version>
	<mysection origSectionId="100" />
	<somedummy>dummy content</somedummy>
</myNexDoc>

===========================
Here is the Saxon result (pritty print)
With the empty value for mysection/@origSectionId
--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<myNexDoc xmlns:myns="http://www.example.com/NameSpace";>
	<version>
		version: 2.0
		vendor: SAXON 7.9.1 from Saxonica
		vendor-url: http://saxon.sf.net/
		product:
		product-version: 7.9.1</version>
	<mysection origSectionId=""/>
	<somedummy>dummy content</somedummy>
</myNexDoc>

============================

Current Thread