Hi Michael,
Below is an example that suggests to me that the data() function is not
working correctly in Saxon 8.4. In my example I call a function, ex:Test,
which returns a text() node. The first time that I call the function it
returns a text node that contains the integer 5. It is my understanding
that by invoking the data() function on that text node it should return the
atomic (integer) value 5. Then, the "instance of" operator should indicate
that the value is an xs:integer. Correct? The data() function seems to do
nothing. The output of my example is always text(). Is this a bug, or
(most likely) am I misunderstanding how the data() function works? /Roger
<xsl:function name="ex:Test">
<xsl:param name="letter"/>
<xsl:choose>
<xsl:when test="$letter eq 'A'">
<xsl:variable name="num" select="5" as="xs:integer"/>
<xsl:value-of select="$num"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="message" select="'Error'"
as="xs:string"/>
<xsl:value-of select="$message"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:template match="/">
<!-- TEST #1 -->
<xsl:variable name="test1" select="'A'"/>
<xsl:variable name="result" select="ex:Test($test1)"/>
<xsl:choose>
<xsl:when test="data($result) instance of xsd:integer">
<xsl:message>INTEGER</xsl:message>
</xsl:when>
<xsl:when test="data($result) instance of xsd:string">
<xsl:message>STRING</xsl:message>
</xsl:when>
<xsl:when test="$result instance of text()">
<xsl:message>text()</xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:message>OTHER</xsl:message>
</xsl:otherwise>
</xsl:choose>
<!-- TEST #2 -->
<xsl:variable name="test2" select="'B'"/>
<xsl:variable name="result" select="ex:Test($test2)"/>
<xsl:choose>
<xsl:when test="data($result) instance of xsd:integer">
<xsl:message>INTEGER</xsl:message>
</xsl:when>
<xsl:when test="data($result) instance of xsd:string">
<xsl:message>STRING</xsl:message>
</xsl:when>
<xsl:when test="$result instance of text()">
<xsl:message>text()</xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:message>OTHER</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Output:
text()
text()
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
|