The Labs \ Source Viewer \ SSCLI \ System.Xml \ XmlDOMTextWriter

  1. //------------------------------------------------------------------------------
  2. // <copyright file="XmlDomTextWriter.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Xml
  16. {
  17.    
  18.     using System;
  19.     using System.IO;
  20.     using System.Text;
  21.    
  22.     // Represents a writer that will make it possible to work with prefixes even
  23.     // if the namespace is not specified.
  24.     // This is not possible with XmlTextWriter. But this class inherits XmlTextWriter.
  25.     internal class XmlDOMTextWriter : XmlTextWriter
  26.     {
  27.        
  28.         public XmlDOMTextWriter(Stream w, Encoding encoding) : base(w, encoding)
  29.         {
  30.         }
  31.        
  32.         public XmlDOMTextWriter(string filename, Encoding encoding) : base(filename, encoding)
  33.         {
  34.         }
  35.        
  36.         public XmlDOMTextWriter(TextWriter w) : base(w)
  37.         {
  38.         }
  39.        
  40.         // Overrides the baseclass implementation so that emptystring prefixes do
  41.         // do not fail if namespace is not specified.
  42.         public override void WriteStartElement(string prefix, string localName, string ns)
  43.         {
  44.             if ((ns.Length == 0) && (prefix.Length != 0))
  45.                 prefix = "";
  46.            
  47.             base.WriteStartElement(prefix, localName, ns);
  48.         }
  49.        
  50.         // Overrides the baseclass implementation so that emptystring prefixes do
  51.         // do not fail if namespace is not specified.
  52.         public override void WriteStartAttribute(string prefix, string localName, string ns)
  53.         {
  54.             if ((ns.Length == 0) && (prefix.Length != 0))
  55.                 prefix = "";
  56.            
  57.             base.WriteStartAttribute(prefix, localName, ns);
  58.         }
  59.     }
  60. }

Developer Fusion