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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="BeginEvent.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 BeginEvent : Event
  24.     {
  25.         private XPathNodeType nodeType;
  26.         private string namespaceUri;
  27.         private string name;
  28.         private string prefix;
  29.         private bool empty;
  30.         private object htmlProps;
  31.         #if DEBUG
  32.         private bool replaceNSAliasesDone;
  33.         #endif
  34.        
  35.         public BeginEvent(Compiler compiler)
  36.         {
  37.             NavigatorInput input = compiler.Input;
  38.             Debug.Assert(input != null);
  39.             Debug.Assert(input.NodeType != XPathNodeType.Namespace);
  40.             this.nodeType = input.NodeType;
  41.             this.namespaceUri = input.NamespaceURI;
  42.             this.name = input.LocalName;
  43.             this.prefix = input.Prefix;
  44.             this.empty = input.IsEmptyTag;
  45.             if (nodeType == XPathNodeType.Element) {
  46.                 this.htmlProps = HtmlElementProps.GetProps(this.name);
  47.             }
  48.             else if (nodeType == XPathNodeType.Attribute) {
  49.                 this.htmlProps = HtmlAttributeProps.GetProps(this.name);
  50.             }
  51.         }
  52.        
  53.         public override void ReplaceNamespaceAlias(Compiler compiler)
  54.         {
  55.             #if DEBUG
  56.             Debug.Assert(!replaceNSAliasesDone, "Second attempt to replace NS aliases!. This bad.");
  57.             replaceNSAliasesDone = true;
  58.             #endif
  59.             if (this.nodeType == XPathNodeType.Attribute && this.namespaceUri.Length == 0) {
  60.                 return;
  61.                 // '#default' aren't apply to attributes.
  62.             }
  63.             NamespaceInfo ResultURIInfo = compiler.FindNamespaceAlias(this.namespaceUri);
  64.             if (ResultURIInfo != null) {
  65.                 this.namespaceUri = ResultURIInfo.nameSpace;
  66.                 if (ResultURIInfo.prefix != null) {
  67.                     this.prefix = ResultURIInfo.prefix;
  68.                 }
  69.             }
  70.         }
  71.        
  72.         public override bool Output(Processor processor, ActionFrame frame)
  73.         {
  74.             return processor.BeginEvent(this.nodeType, this.prefix, this.name, this.namespaceUri, this.empty, this.htmlProps, false);
  75.         }
  76.     }
  77. }

Developer Fusion