95ca244b9a975cc0465f5cc97ad05af40354d3db
[mono.git] / mcs / class / referencesource / System.Data.SqlXml / System / Xml / Xsl / XsltOld / BeginEvent.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="BeginEvent.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>                                                                
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
7
8 namespace System.Xml.Xsl.XsltOld {
9     using Res = System.Xml.Utils.Res;
10     using System;
11     using System.Diagnostics;
12     using System.Xml;
13     using System.Xml.XPath;
14
15     internal class BeginEvent : Event {
16         private XPathNodeType nodeType;
17         private string        namespaceUri;
18         private string        name;
19         private string        prefix;
20         private bool          empty;
21         private object        htmlProps;
22 #if DEBUG
23         private bool          replaceNSAliasesDone;
24 #endif
25         
26         public BeginEvent(Compiler compiler) {
27             NavigatorInput input = compiler.Input;
28             Debug.Assert(input != null);
29             Debug.Assert(input.NodeType != XPathNodeType.Namespace);
30             this.nodeType     = input.NodeType;
31             this.namespaceUri = input.NamespaceURI;
32             this.name         = input.LocalName;
33             this.prefix       = input.Prefix;
34             this.empty        = input.IsEmptyTag;
35             if (nodeType ==  XPathNodeType.Element) {
36                 this.htmlProps = HtmlElementProps.GetProps(this.name);
37             }
38             else if (nodeType ==  XPathNodeType.Attribute) {
39                 this.htmlProps = HtmlAttributeProps.GetProps(this.name);
40             }
41         }
42
43         public override void ReplaceNamespaceAlias(Compiler compiler){
44 #if DEBUG
45             Debug.Assert(! replaceNSAliasesDone, "Second attempt to replace NS aliases!. This bad.");
46             replaceNSAliasesDone = true;
47 #endif
48             if (this.nodeType == XPathNodeType.Attribute && this.namespaceUri.Length == 0) {
49                 return ; // '#default' aren't apply to attributes.
50             }
51             NamespaceInfo ResultURIInfo = compiler.FindNamespaceAlias(this.namespaceUri);
52             if (ResultURIInfo != null) {
53                 this.namespaceUri = ResultURIInfo.nameSpace;
54                 if (ResultURIInfo.prefix != null) {
55                     this.prefix = ResultURIInfo.prefix; 
56                 }
57             }
58         }
59         
60         public override bool Output(Processor processor, ActionFrame frame) {
61             return processor.BeginEvent(this.nodeType, this.prefix, this.name, this.namespaceUri, this.empty, this.htmlProps, false);
62         }
63     }
64 }