XSL Tranform error in C#, working in IE (error {"Objects of type 'Script2' do not have such a member"})

질문 XSL Tranform error in C#, working in IE (error {"Objects of type 'Script2' do not have such a member"})

  • 2012년 8월 18일 토요일 오후 4:55
     
     

    Hi folk,

    I have an issue with the applying an xsl transformation to an xml in C#. The transformation is working well in IE 8.

    Here is the code I have:

    XslCompiledTransform transform = new XslCompiledTransform();
    XsltSettings xslt_set = new XsltSettings();
    xslt_set.EnableScript = true;
    XmlReader myreader = XmlReader.Create(new StringReader(File.ReadAllText(<path to xsl>)));
    transform.Load(myreader, xslt_set, new XmlUrlResolver());
    XmlReader xr = XmlReader.Create(@"C:\TE Connectivity\Inbound\Cables\170-1951-xx\TDR\TDR_Report[2 29 51 PM][8 16 2012].xml");
    StringBuilder htmlContent = new StringBuilder();
    XmlWriter result = XmlWriter.Create(htmlContent);
    transform.Transform(xr, result);

    and the error I get is:

    {"Objects of type 'Script2' do not have such a member"}

    that comes from this section of the xsl file:

     function GraphArray(sLBound, sHBound)
     {
      this.LBoundElements = (sLBound.substring(1).replace(/]/g,"")).split("[");  //error comes here
      this.HBoundElements = sHBound.substring(1).replace(/]/g,"").split("[");
      this.Dimensions = sLBound.split("[").length - 1;
    ... 
    }

    I didn't write the script and I'm not very familiar with xsl, but what bugs me it that it works with IE.

    I read somewhere that IE uses MSXML 3.0 to do transform, so could it be a change in MSXML 6.0 that makes that xsl not compliant anymore? if so, is there a way to make it compliant or is ther a way in C# to make the same transform as IE does?

    Thanks for your help


    • 편집됨 BenFr 2012년 8월 18일 토요일 오후 4:56
    •  

모든 응답

  • 2012년 8월 18일 토요일 오후 6:01
     
     

    Ok, at least I found a work around.

    I'm using the MSXML 3.0 activeX to transform my xml (as IE does I think) and that works.