BizTalk Utilities CV ,   Jobs ,   Code library
 
Go to the front page to continue learning about XML or select below:

Contents

ReBlogger Contents

Previous posts in .NET XML, System.XML

 
 
Page 11319 of 19640

How to validate XSLT output in .NET 2.0

Blogger : Oleg Tkachenko
All posts : All posts by Oleg Tkachenko
Category : .NET XML, System.XML
Blogged date : 2006 Jul 11

How would you validate XSLT output on the fly without caching transformation result as a whole? That's easy - just use MvpXslTransform class that adds to the XslCompiledTransform class ability to transform into XmlReader and wrap that reader witth a validating reader. As a result - streaming validation, no memory hogging and ability to abort transformation at first validation error. Simple sample below.

XPathDocument doc = 
    new XPathDocument("source.xml");
MvpXslTransform xslt = new MvpXslTransform();
xslt.Load("XSLTFile1.xslt");
XmlReader resultReader = 
    xslt.Transform(new XmlInput(doc), null);
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add(" ", "orders.xsd");
XmlReader validatingReader = 
    XmlReader.Create(resultReader, settings);
XmlWriter w = XmlWriter.Create(Console.Out);
w.WriteNode(validatingReader, false);
w.Close();

You can get MvpXslTransform class with Mvp.Xml library v2.0 at the Mvp.Xml project site.


Read comments or post a reply to : How to validate XSLT output in .NET 2.0
Page 11319 of 19640

Newest posts
 

    Email TopXML