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

Subject: Re: [xsl] Problem with Saxon 7.9.1 xsl:variable and selecting additional elements from variable value
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 12 Oct 2005 10:57:07 +0100
> I'm using Saxon 7.9.1 to transform some xml. 

You should probably switch to saxon 8 as soon as possible, saxon 7
implements some early draft of xslt2 but it is very hard for anyone to
remember quite how the language was specified that long ago (saxon 8 has
been out some years now, I think). So any answers you receive will
probably be based on the current xslt2 draft, which is different in
several respects.


		<xsl:variable name="thissection" >
			<xsl:sequence select="../myns:section"/>
		</xsl:variable>

Just as in xslt1 you don't want to do that, which forces the creation of
a new temporary document and foirces all the nodes to be copied.

Just do

<xsl:variable name="thissection" select="../myns:section"/>

so that $thissection just selects the elements that you want.

Without seeing your input I can't say if this is right or not
<xsl:value-of select="$thissection/myns:id"/>
but as you have it defined $thissection is a document node (/) so
"$thissection/myns:id is the top level element of that document if it is
myns:id, and empty otherwise.

As I defined it $thissection is element node, myns:section, so
$thissection/myns:id is the myns:id child of that element.

It doesn't look like you want a variable at all, just:

	<xsl:template match="myns:content" mode="content">
            <mysection origSectionId={../myns:section/myns:id}"/>
            <somedummy>dummy content</somedummy>
	</xsl:template>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread