* Form.cs: Provide meaningful message when MdiParent is assigned a
[mono.git] / mcs / class / System.XML / Mono.Xml.Xsl.Operations / XslLiteralElement.cs
index beb94657d500d895eaa3f351c2b3a5811c25fd4f..967489f04672a817b6db6e589620ec5e8296ed38 100644 (file)
@@ -44,12 +44,6 @@ namespace Mono.Xml.Xsl.Operations {
                ArrayList attrs;
                XmlQualifiedName [] useAttributeSets;
                Hashtable nsDecls;
-               string excludeResultPrefixes;
-               string extensionElementPrefixes;
-               ArrayList excludedPrefixes;
-               bool requireNameFix;
-               XPathNavigator stylesheetNode;
-               XslStylesheet stylesheet;
 
                public XslLiteralElement (Compiler c) : base (c) {}
                        
@@ -60,32 +54,47 @@ namespace Mono.Xml.Xsl.Operations {
                        public XslLiteralAttribute (Compiler c)
                        {
                                this.prefix = c.Input.Prefix;
-                               this.nsUri = c.Input.NamespaceURI;
+                               if (prefix.Length > 0) {
+                                       string alias = 
+                                               c.CurrentStylesheet.GetActualPrefix (prefix);
+                                       if (alias != prefix) {
+                                               prefix = alias;
+                                               XPathNavigator clone = c.Input.Clone ();
+                                               clone.MoveToParent ();
+                                               nsUri = clone.GetNamespace (alias);
+                                       }
+                                       else
+                                               nsUri = c.Input.NamespaceURI;
+                               }
+                               else
+                                       nsUri = String.Empty;
                                this.localname = c.Input.LocalName;
                                this.val = new XslAvt (c.Input.Value, c);
                        }
                        
                        public void Evaluate (XslTransformProcessor p)
                        {
+                               //FIXME: fix attribute prefixes according to aliases
                                p.Out.WriteAttributeString (prefix, localname, nsUri, val.Evaluate (p));
                        }
                }
                
                protected override void Compile (Compiler c)
                {
-                       requireNameFix = true;
-                       stylesheetNode = c.Input.Clone ();
-                       stylesheet = c.CurrentStylesheet;
+                       prefix = c.Input.Prefix;
+                       string alias = c.CurrentStylesheet.GetActualPrefix (prefix);
+                       if (alias != prefix) {
+                               prefix = alias;
+                               nsUri = c.Input.GetNamespace (alias);
+                       }
+                       else
+                               nsUri = c.Input.NamespaceURI;
 
                        this.localname = c.Input.LocalName;
                        this.useAttributeSets = c.ParseQNameListAttribute ("use-attribute-sets", XsltNamespace);
                        this.nsDecls = c.GetNamespacesToCopy ();
                        if (nsDecls.Count == 0) nsDecls = null;
                        this.isEmptyElement = c.Input.IsEmptyElement;
-                       this.excludeResultPrefixes = c.Input.GetAttribute ("exclude-result-prefixes", XsltNamespace);
-                       this.extensionElementPrefixes = c.Input.GetAttribute ("extension-element-prefixes", XsltNamespace);
-                       excludedPrefixes = new ArrayList (excludeResultPrefixes.Split (XmlChar.WhitespaceChars));
-                       excludedPrefixes.AddRange (extensionElementPrefixes.Split (XmlChar.WhitespaceChars));
 
                        if (c.Input.MoveToFirstAttribute ())
                        {
@@ -103,30 +112,12 @@ namespace Mono.Xml.Xsl.Operations {
                        c.Input.MoveToParent ();
                }
 
-               private void GetCorrectNames ()
-               {
-                       requireNameFix = false;
-                       prefix = stylesheetNode.Prefix;
-                       string alias = stylesheet.PrefixInEffect (prefix, null);
-                       if (alias != null && alias != stylesheetNode.Prefix) {
-                               nsUri = stylesheetNode.GetNamespace (alias);
-                               if (alias != null)
-                                       prefix = alias;
-                       }
-                       else
-                               nsUri = stylesheetNode.NamespaceURI;
-
-               }
-               
                public override void Evaluate (XslTransformProcessor p)
                {
                        // Since namespace-alias might be determined after compilation
                        // of import-ing stylesheets, this must be determined later.
-                       if (requireNameFix)
-                               GetCorrectNames ();
-
                        bool isCData = p.InsideCDataElement;
-                       p.PushElementState (localname, nsUri, true);
+                       p.PushElementState (prefix, localname, nsUri, true);
                        p.Out.WriteStartElement (prefix, localname, nsUri);
 
                        if (useAttributeSets != null)
@@ -139,15 +130,8 @@ namespace Mono.Xml.Xsl.Operations {
                                        ((XslLiteralAttribute)attrs [i]).Evaluate (p);
                        }
 
-                       p.TryStylesheetNamespaceOutput (excludedPrefixes);
-                       if (nsDecls != null) {
-                               foreach (DictionaryEntry de in nsDecls) {
-                                       string actualPrefix = p.CompiledStyle.Style.PrefixInEffect (de.Key as String, excludedPrefixes);
-                                       if (actualPrefix != null)
-                                               p.Out.WriteNamespaceDecl (actualPrefix, (string)de.Value);
-                               }
-                       }
-                       
+                       p.OutputLiteralNamespaceUriNodes (nsDecls, null, null);
+
                        if (children != null) children.Evaluate (p);
 
                        if (isEmptyElement)