• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

XSL tranforms in .NET

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    XSL tranforms in .NET

    Anyone else used XSL transforms in .NET? It appears that fking thing (Tranform function of XslCompiledTransform) walks the whole XML document BEFORE actually running bloody template, instead of just running specific XPath statements found in XSL template, ffs, anyone who tried XSL in .NET please post here on your experience.

    #2
    Originally posted by AtW
    Anyone else used XSL transforms in .NET? It appears that fking thing (Tranform function of XslCompiledTransform) walks the whole XML document BEFORE actually running bloody template, instead of just running specific XPath statements found in XSL template, ffs, anyone who tried XSL in .NET please post here on your experience.
    What makes you think this, I've reflected the internal framework methods and cant see this going on.
    whats the lowest you can do this for?

    Comment


      #3
      I've got running test here that made me certain it happens - I pass XPathNavigator object to it, if I run XPath directly on that object then it only touches bits that have to be touched, when I put same XPath into XSL document I can see that whole object is walked, in fact if I have empty (!) XSL template the fking thing still walks the whole object. How do I know? Because I've got XPathNavigator over normal live .NET object and can see that its being walked over.

      To add insult to injury it appears that XSL POS adds some junk into output that should not be there - its junk and some searches on the Net seems to confirm that.

      Comment


        #4
        This should be posted in the technical forums.

        What are you using, an XmlDocument or XPathDocument or XmlDataDocument?

        How are your XPath queries formulated? Do by their nature have to traverse the whole document to find the required node(s)?

        Please read http://support.microsoft.com/kb/325689/EN-US/

        PS V1.1 of the framework has a lot of issues processing XSLT on large XML documents. I believe V2.0 is much better in this respect.

        Comment


          #5
          Originally posted by AtW
          I've got running test here that made me certain it happens - I pass XPathNavigator object to it, if I run XPath directly on that object then it only touches bits that have to be touched, when I put same XPath into XSL document I can see that whole object is walked, in fact if I have empty (!) XSL template the fking thing still walks the whole object. How do I know? Because I've got XPathNavigator over normal live .NET object and can see that its being walked over.

          To add insult to injury it appears that XSL POS adds some junk into output that should not be there - its junk and some searches on the Net seems to confirm that.
          Seems i didnt dig deep enough into the wrath of the internal methods. From the horses mouth an explanation as to what goes on under the hood. Good article
          Compiled XSLT explained
          whats the lowest you can do this for?

          Comment


            #6
            I use FX 2.0.

            I have got a custom object that implements XPathNavigator - this allows to run XPath queries and those work just fine, no problems there.

            Then I thought to use XSL to run those XPath statements, here is how I do it:
            Code:
                   public string ExecXSLT(string sFileName,XsltArgumentList oList)
                    {
                        XslCompiledTransform oXsl=new XslCompiledTransform();
            
                          // loads XSL template
                        oXsl.Load(sFileName); 
            
                        return ExecXSLT(oXsl,oList);
                    }
            
                public string ExecXSLT(XslCompiledTransform oXsl,XsltArgumentList oList)
                    {
                        StringBuilder oSB=new StringBuilder();
            
                        XmlWriterSettings oWS=new XmlWriterSettings();
            
                        oWS.Indent=true;
                        oWS.NewLineHandling=NewLineHandling.None;
                        oWS.Encoding=Encoding.UTF8;
                        oWS.OmitXmlDeclaration=false;
                        oWS.ConformanceLevel=ConformanceLevel.Auto;
            
                        XmlWriter oWriter=XmlWriter.Create(oSB,oWS);
                  
                        // Xnav is XPathNavigator object that controls actual data document that should be dealt with by XSL
                        oXsl.Transform(Xnav,oList,oWriter);
                       
                        return oSB.ToString();
                    }
            The POS XSL implementation walks whole XPathNavigator object even is XSL template is empty! This is bad enough to disqualify it because whole purpose of XPathNavigator is to avoid performance hit of having to deal with whole document - note that separate XPath statements run directly work just fine, they dont walk whole object, only parts necessary.

            Comment


              #7
              Oi!

              Put this in technical Webby,FFS!
              The general forum is reserved for mindless tosh, not this IT-related geek-speak.
              We must strike at the lies that have spread like disease through our minds

              Comment


                #8
                As you can see from code above I use XPathNavigateable object, which should ensure tranformations are fast. XPath queries directly on that object work fast and nice. However giving it to Transform function of XSL is slow even when XSL document is empty - ie no queries there at all, none zero zilch. I can see from debugger that the damn thing walks whole tree of the XPathNavigeable object even though nobody asked it to do it - I can see it in debugger that they do it ffs. What's worse is that the damn thing adds to transformed results some junk that should not be there.

                Comment


                  #9
                  I guess your code is just tulip then AtW.

                  If .NET hurts, you ain't doing it right.

                  Comment


                    #10
                    Originally posted by DimPrawn
                    I guess your code is just tulip then AtW.

                    If .NET hurts, you ain't doing it right.

                    Comment

                    Working...
                    X