The Labs \ Source Viewer \ SSCLI \ System.Xml.Xsl.XsltOld \ NamespaceEvent

  1. //------------------------------------------------------------------------------
  2. // <copyright file="NameSpaceEvent.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.Xsl.XsltOld
  16. {
  17.     using Res = System.Xml.Utils.Res;
  18.     using System;
  19.     using System.Diagnostics;
  20.     using System.Xml;
  21.     using System.Xml.XPath;
  22.    
  23.     internal class NamespaceEvent : Event
  24.     {
  25.         private string namespaceUri;
  26.         private string name;
  27.        
  28.         public NamespaceEvent(NavigatorInput input)
  29.         {
  30.             Debug.Assert(input != null);
  31.             Debug.Assert(input.NodeType == XPathNodeType.Namespace);
  32.             this.namespaceUri = input.Value;
  33.             this.name = input.LocalName;
  34.         }
  35.        
  36.         public override void ReplaceNamespaceAlias(Compiler compiler)
  37.         {
  38.             if (this.namespaceUri.Length != 0) {
  39.                 // Do we need to check this for namespace?
  40.                 NamespaceInfo ResultURIInfo = compiler.FindNamespaceAlias(this.namespaceUri);
  41.                 if (ResultURIInfo != null) {
  42.                     this.namespaceUri = ResultURIInfo.nameSpace;
  43.                     if (ResultURIInfo.prefix != null) {
  44.                         this.name = ResultURIInfo.prefix;
  45.                     }
  46.                 }
  47.             }
  48.         }
  49.        
  50.         public override bool Output(Processor processor, ActionFrame frame)
  51.         {
  52.             bool res;
  53.                 /*prefix:*/                /*empty:*/            res = processor.BeginEvent(XPathNodeType.Namespace, null, this.name, this.namespaceUri, false);
  54.             Debug.Assert(res);
  55.             // Namespace node as any other attribute can't fail because it doesn't signal record change
  56.             res = processor.EndEvent(XPathNodeType.Namespace);
  57.             Debug.Assert(res);
  58.             return true;
  59.         }
  60.     }
  61. }

Developer Fusion