PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/src/NUnit/util/XmlResultTransform.cs

#
C# | 69 lines | 45 code | 12 blank | 12 comment | 0 complexity | 4a1e07aadece921ce195a3ce15f85839 MD5 | raw file
Possible License(s): GPL-2.0
  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. using System;
  7. using System.IO;
  8. using System.Xml;
  9. using System.Xml.Xsl;
  10. using System.Xml.XPath;
  11. namespace NUnit.Util
  12. {
  13. /// <summary>
  14. /// Summary description for XmlResultTransform.
  15. /// </summary>
  16. public class XmlResultTransform
  17. {
  18. #if NET_2_0
  19. private XslCompiledTransform xslTransform = new XslCompiledTransform();
  20. #else
  21. private XslTransform xslTransform = new XslTransform();
  22. #endif
  23. public XmlResultTransform() { }
  24. public XmlResultTransform( string stylesheet )
  25. {
  26. Load( stylesheet );
  27. }
  28. public XmlResultTransform( XmlReader reader )
  29. {
  30. Load( reader );
  31. }
  32. public void Load( string stylesheet )
  33. {
  34. xslTransform.Load( stylesheet );
  35. }
  36. public void Load( XmlReader reader )
  37. {
  38. // NOTE: Not compatable with .NET 1.0.
  39. // xslTransform.Load(reader, null, null);
  40. xslTransform.Load(reader);
  41. }
  42. public void Transform( string inputFile, string outputFile )
  43. {
  44. Transform( new StreamReader( inputFile ), new StreamWriter( outputFile ) );
  45. }
  46. public void Transform( TextReader reader, TextWriter writer )
  47. {
  48. Transform( new XPathDocument( reader ), writer );
  49. }
  50. public void Transform( IXPathNavigable xpnav, TextWriter writer )
  51. {
  52. // NOTE: Not compatable with .NET 1.0.
  53. // xslTransform.Transform(xpnav, null, writer, null);
  54. xslTransform.Transform(xpnav, null, writer);
  55. }
  56. }
  57. }