Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: "Chains" of xslt transformations

From: "Chris Lovett" <someone@------.------>
To: NULL
Date: 7/7/2005 12:02:00 AM
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
>> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent