System.Xml.Xsl.XsltException: Cannot convert the operand to 'Result tree fragment'.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • partheepan
    New Member
    • Jan 2009
    • 1

    System.Xml.Xsl.XsltException: Cannot convert the operand to 'Result tree fragment'.

    Hi,
    This is Parthy.

    Am getting this error in XSLT.

    Am trying to search the rows by passing parameter from C# 2.0 to XSLT.

    Can anyone give me a solution for this prob...

    The coding follows:

    CS Page:-

    Code:
    XsltArgumentList xslArg = new XsltArgumentList();
            xslArg.AddParam("firstName", "", txtCustomerName.Text);
    
    
            string xmlPath = @"D:\Project\Parthy\XML_Samples\XML_XSLT\OrdersXML.xml";
            ds.WriteXml(xmlPath);
    
           
            Xml1.TransformSource = @"D:\Project\Parthy\XML_Samples\XML_XSLT\SearchXSL.xsl";
            Xml1.TransformArgumentList = xslArg;
            Xml1.DocumentSource = xmlPath;
            Xml1.DataBind();



    XSLT :

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="urn:schemas-microsoft-com:xslt"
      extension-element-prefixes="exsl">
     
      <xsl:param name="firstName" select="//Table"/>
    
      <xsl:template match="/">
    
        <html>
          <body>
            <h2>Orders</h2>
            <table border="1">
              <tr bgcolor="blue">
                <th align="center">Order No</th>
                <th align="center">Order Date</th>
                <th align="center">First Name</th>
                <th align="center">Last Name</th>
                <th align="center">Order Amount</th>
                <th align="center">Shipping Charge</th>
                <th align="center">Shipping Service</th>
                <th align="center">Payment Type</th>
                <th align="center">Payment Status</th>
                <th align="center">Order Status</th>
                <th align="center">Phone Verify</th>
              </tr>
    
              <xsl:for-each select="exsl:node-set($firstName)/First_x0020_Name">
                <tr>
                  <td>
                    <xsl:value-of select="Order_x0020_No"/>
                  </td>
                  <td>
                    <xsl:value-of select="Order_x0020_Date"/>
                  </td>
                  <td>
                    <xsl:value-of select="First_x0020_Name"/>
                  </td>
                  <td>
                    <xsl:value-of select="Last_x0020_Name"/>
                  </td>
                  <td>          
                    <xsl:value-of select="Order_x0020_Amount"/>
                  </td>
                  <td>
                    <xsl:value-of select="Shipping_x0020_Charge"/>
                  </td>
                  <td>
                    <xsl:value-of select="Payment_x0020_Type"/>
                  </td>
                  <td>
                    <xsl:choose>
                      <xsl:when test="./Payment_x0020_Status=&quot;Y&quot;">
                        <span style="color:red">
                          <xsl:value-of select="Payment_x0020_Status"/>
                        </span>
                      </xsl:when>
                      <xsl:otherwise>
                        <span style="color:green">
                          <xsl:value-of select="Payment_x0020_Status"/>
                        </span>
                      </xsl:otherwise>
                    </xsl:choose>
    
                  </td>
                  <td>
                    <xsl:value-of select="Order_x0020_Status"/>
                  </td>
                  <td>
                    <xsl:value-of select="Phone_x0020_Verify"/>
                  </td>
                </tr>
              </xsl:for-each>
            </table>
          </body>
        </html>
      </xsl:template>
    
    </xsl:stylesheet>
    Last edited by acoder; Jan 19 '09, 10:57 AM. Reason: Added [code] tags + moved to C# forum
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Is this a runtime error or a build error?
    What type of object is Xml1?

    Comment

    Working...