1 //------------------------------------------------------------------------------
2 // <copyright file="BeginEvent.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
8 namespace System.Xml.Xsl.XsltOld {
9 using Res = System.Xml.Utils.Res;
11 using System.Diagnostics;
13 using System.Xml.XPath;
15 internal class BeginEvent : Event {
16 private XPathNodeType nodeType;
17 private string namespaceUri;
19 private string prefix;
21 private object htmlProps;
23 private bool replaceNSAliasesDone;
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);
38 else if (nodeType == XPathNodeType.Attribute) {
39 this.htmlProps = HtmlAttributeProps.GetProps(this.name);
43 public override void ReplaceNamespaceAlias(Compiler compiler){
45 Debug.Assert(! replaceNSAliasesDone, "Second attempt to replace NS aliases!. This bad.");
46 replaceNSAliasesDone = true;
48 if (this.nodeType == XPathNodeType.Attribute && this.namespaceUri.Length == 0) {
49 return ; // '#default' aren't apply to attributes.
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;
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);