/src/NUnit/util/XmlResultTransform.cs
C# | 69 lines | 45 code | 12 blank | 12 comment | 0 complexity | 4a1e07aadece921ce195a3ce15f85839 MD5 | raw file
1// **************************************************************** 2// Copyright 2007, Charlie Poole 3// This is free software licensed under the NUnit license. You may 4// obtain a copy of the license at http://nunit.org 5// **************************************************************** 6 7using System; 8using System.IO; 9using System.Xml; 10using System.Xml.Xsl; 11using System.Xml.XPath; 12 13namespace NUnit.Util 14{ 15 /// <summary> 16 /// Summary description for XmlResultTransform. 17 /// </summary> 18 public class XmlResultTransform 19 { 20#if NET_2_0 21 private XslCompiledTransform xslTransform = new XslCompiledTransform(); 22#else 23 private XslTransform xslTransform = new XslTransform(); 24#endif 25 26 public XmlResultTransform() { } 27 28 public XmlResultTransform( string stylesheet ) 29 { 30 Load( stylesheet ); 31 } 32 33 public XmlResultTransform( XmlReader reader ) 34 { 35 Load( reader ); 36 } 37 38 public void Load( string stylesheet ) 39 { 40 xslTransform.Load( stylesheet ); 41 } 42 43 public void Load( XmlReader reader ) 44 { 45 // NOTE: Not compatable with .NET 1.0. 46 // xslTransform.Load(reader, null, null); 47 48 xslTransform.Load(reader); 49 } 50 51 public void Transform( string inputFile, string outputFile ) 52 { 53 Transform( new StreamReader( inputFile ), new StreamWriter( outputFile ) ); 54 } 55 56 public void Transform( TextReader reader, TextWriter writer ) 57 { 58 Transform( new XPathDocument( reader ), writer ); 59 } 60 61 public void Transform( IXPathNavigable xpnav, TextWriter writer ) 62 { 63 // NOTE: Not compatable with .NET 1.0. 64 // xslTransform.Transform(xpnav, null, writer, null); 65 66 xslTransform.Transform(xpnav, null, writer); 67 } 68 } 69}