logo       

data() function working correctly?: msg#00118

Subject: data() function working correctly?
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


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe