Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: "Chains" of xslt transformations >Thread Next - Re: "Chains" of xslt transformations Re: "Chains" of xslt transformationsTo: NULL Date: 7/7/2005 2:43:00 AM thank you Chris, nice, but since i use cached sourse xml - can you tell me the easiest (i mean processor time - not lines of code) way to get XPathDocument (which to be stored in cache) as result of xslt transfomation, if using of it give significant perfomance gain on transformation then i`ll better spend some extra time once, but get much more benefits on 1 000 000 of future transformations. yours, Slav "Chris Lovett" wrote: > The non-compiled XslTransform supports XmlReader pull model, so you could do > this: > > XslTransform transform = new XslTransform(); > XmlDocument doc = new XmlDocument(); > doc.Load( transform.Transform(...)); > > But for high throughput transformations you really want to use > XslCompiledTransform in which case I would suggest using Oleg's suggestion > about using XmlWriter to build an XmlDocument as follows: > XslCompiledTransform tran = new XslCompiledTransform(); > tran.Load("xsl1.xslt"); > XmlDocument doc = new XmlDocument(); > doc.PreserveWhitespace = true; > XmlWriter writer = doc.CreateNavigator().AppendChild(); > tran.Transform("xml1.xml", null, writer ); > writer.Close(); > > XmlDocument will be faster than reparsing the XML from a StringBuilder . > > > > "Slava Sedov" <SlavaSedov@d...> wrote in message > news:26AEE002-80C1-4240-84AE-78C98BD3EF4C@m...... > > > > > > "Oleg Tkachenko [MVP]" wrote: > > > >> Slava Sedov wrote: > >> > need to effectively perform 2 sequential xslt transforms on some data > >> > ((xm1+xsl1)+xsl2) and can`t find a way to do it without intermediate > >> > transform intermediate xml to text - i use XslCompiledTransform with > >> > XPathDocument, is anyone know good way to pass result data after first > >> > xslt-transformation as source data for second xslt-transformation? > >> > >> As XslCompiledTransform doesn't support XmlReader output, there is no > >> such easy way. The only way that doesn't incur reparsing is transforming > >> to XmlNodeWriter, which writes to XmlDocument. But then your next > >> transformation will deal with XmlDocument, which is slower than > >> XPathDocument. > >> We (XML MVPs) are working on this problem. > > > > it is very actual problem, temporary i will use StringBuilder and cached > > XPathDocument but must mark this part of code as "weak" and set "review > > date" > > for this problem, when MS going to solve it? .NET 2.0 or later? > > > >> > >> Another solution is to avoid double stylesheets and instead combine them > >> into one (set mode for each template to distinguish them), then store > >> first transformation in a variable, convert it to a nodeset and run > >> second one. > > > > i used it very long in SQLXML (without ASP.NET) - but it is not acceptable > > for current work (i must divide content, presentation and interaction into > > totally independent parts of code) maybe i need not only 2 sequential of > > transformations, what if i include PI stylesheet into resulting document? > > can > > Microsoft in this case provide support for "precompilied instant chained > > transformations"? :) > > > >> > >> > p.s. also i am interesting about best practice to this scenario - i get > >> > xml1, then apply xslt1 to it and in result i get another xslt2 and then > >> > perform tranformation of xml2 using xslt2. I don`t understand why i > >> > need > >> > store intermediate results as strings instead of storing it as > >> > XPathDocument > >> > or at least XMLDocument. > >> You don't have to. Transform to XmlWriter instead. > > > > can you present any code example? > > > >> > >> -- > >> Oleg Tkachenko [XML MVP, MCAD] > >> http://www.xmllab.net > >> http://blog.tkachenko.com > >> > > > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
