Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • [email protected] 4 posts 24 karma points
    May 21, 2012 @ 15:05
    selvakumar.kasinathan@defiance-tech.com
    0

    Error: To use a result tree fragment in a path expression

    Hi,

    I have my varialble as

     
            <xsl:variable name="Brandsqlresult" >
              <xsl:choose>
                <xsl:when test="$SqlSession=''">
                  <xsl:copy-of select="jesper.sql:SQLXml($GetBrandPagewise)"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:copy-of select="SqlSessionStage"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <xsl:choose >

     

    the variable BrandSqlresult will contain SQl result set. When i loop through the Brandsqlresult using foreach loop something like

     <xsl:for-each select="$Brandsqlresult//.">

    </xsl:for-each>

    its shows error: To use a result tree fragment in a path expression, first convert it to a node-set using the msxsl:node-set() function.

    but same for-each  loop works fine if i have my variable declaration as

    <xsl:variable name="Brandsqlresult"  select="jesper.sql:SQLXml($GetBrandPagewise)"/>

    what makes a mistake?

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    May 21, 2012 @ 15:32
    Lee Kelleher
    0

    Hi Selvakumar,

    Ah yes, the trouble with using "copy-of" is that it may result in a "tree fragment", (which means there *might* be multiple root nodes), this causes problems when you come to use it.

    So to get around this, you will need a second variable that will call the "msxml:node-set" function.  This will make the "tree fragment" into a proper node-set.

    <xsl:variable name="tempResults">
        <xsl:choose>
            <xsl:when test="$SqlSession = ''">
                <xsl:copy-of select="jesper.sql:SQLXml($GetBrandPagewise)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:copy-of select="SqlSessionStage"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="Brandsqlresult" select="msxml:node-set($tempResults)" />

    Trust me, I understand any frustrations with this! :-)

    Cheers, Lee.

  • [email protected] 4 posts 24 karma points
    May 21, 2012 @ 15:51
    selvakumar.kasinathan@defiance-tech.com
    0

    Its nice man...

    Thanks so much.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies