I suspect in one case your variable is being treated as a virtual document node and in the other case it is being treated as a sequence of nodes. This is an important nuance I only recently discovered myself.

You can see the difference by comparing the following:
<xsl:variable name="testme">
<xsl:sequence select="a"/>
<xsl:sequence select="b"/>


<xsl:variable name="testme" as="xs:string*">
<xsl:sequence select="a"/>
<xsl:sequence select="b"/>

The only difference here is the "as="xs:string*" attribute, which tells xsl to store the results as sequence rather than a temporary document.
My guess is something similar is at work here. In one case $gi is seen as a document node which has the 2 items as children, so count($gi)=1. In the other case $gi is a sequence of two items, so it has a count of 2.


On Thu, May 17, 2012 at 2:48 PM, Paul M <pjmaip@yahoo.com> wrote:
I have following xslt

    <xsl:variable name="testme">

 <!--          <xsl:variable name ="gi" select="$testme/a"/> -->
       <xsl:variable name ="gi" >
                <xsl:when test="2 = 1">
                    <xsl:sequence select="$testme[1]"/>              
                    <xsl:copy-of select="$testme/a"/>
            <xsl:copy-of select="$gi"/>
            <xsl:value-of select="count($gi)"></xsl:value-of>

when I use the commented out method shown above, I have a sequence of two.
when I use the choose method shown above, I have a sequence of one.
I tried sequence instead of copy-of, same results.

-Thanks for any insight?

Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
saxon-help mailing list archived at http://saxon.markmail.org/


"A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.