Subject: RE: Problem with Saxon 7.9.1 xsl:variable and selecting additional elements from variable value
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 12 Oct 2005 10:52:23 +0100
|
I'm seeing an increasing number of questions caused by the fact that XMLSpy
has apparently implemented XSLT 2.0 temporary trees incorrectly.
When you write this:
<xsl:variable name="thissection" >
<xsl:sequence select="../myns:section"/>
</xsl:variable>
the value of $thissection is a document node, whose element child is a
myns:section element (a copy of the element selected by the select
expression. Therefore the expression
$thissection/myns:id
selects nothing (because the document node has no child called myns:id).
In this situation I can't see why you want to make a copy of the original
node. Why not just do:
<xsl:variable name="thissection" select="../myns:section"/>
And please report the problem to Altova. I'm sure they know about it, but it
may help to raise the priority on getting it fixed.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Olaf Meske [mailto:omeske@xxxxxxxxxxx]
> Sent: 12 October 2005 10:37
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Problem with Saxon 7.9.1 xsl:variable and
> selecting additional elements from variable value
>
> 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>
>
> ============================
|