Author: atsushi
Date: 2005-03-07 15:29:21 -0500 (Mon, 07 Mar 2005)
New Revision: 41537

Modified:
   trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog
   trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs
   trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
Log:
2005-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * XslStylesheet.cs : Now namespace aliases are collected in prior to
          all other toplevel elements. Removed unused code.

        * XslAttribute.cs,
          XslLiteralElement.cs :
          Now namespace aliases are collected in prior to template
          evaluation, so compute expected prefix at compile time.



Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog   2005-03-07 20:24:49 UTC 
(rev 41536)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog   2005-03-07 20:29:21 UTC 
(rev 41537)
@@ -1,5 +1,10 @@
 2005-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * XslStylesheet.cs : Now namespace aliases are collected in prior to
+         all other toplevel elements. Removed unused code.
+
+2005-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * GenericOutputter.cs : compute attribute prefix only when actual
          emission. Fixed some cases that namespace output was missing.
 

Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs    2005-03-07 
20:24:49 UTC (rev 41536)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs    2005-03-07 
20:29:21 UTC (rev 41537)
@@ -358,15 +358,8 @@
                                case "strip-space":
                                        AddSpaceControls 
(c.ParseQNameListAttribute ("elements"), XmlSpace.Default, n);
                                        break;
-                               
                                case "namespace-alias":
-                                       string sprefix = (string) 
c.GetAttribute ("stylesheet-prefix", "");
-                                       if (sprefix == "#default")
-                                               sprefix = String.Empty;
-                                       string rprefix= (string) c.GetAttribute 
("result-prefix", "");
-                                       if (rprefix == "#default")
-                                               rprefix = String.Empty;
-                                       namespaceAliases.Set (sprefix, rprefix);
+                                       // do nothing. It is handled in prior.
                                        break;
                                
                                case "attribute-set":
@@ -413,17 +406,33 @@
                
                private void ProcessTopLevelElements ()
                {
-                       if (c.Input.MoveToFirstChild ()) {
-                               do {
-                                       if (c.Input.NodeType == 
XPathNodeType.Element) {                                        
-                                               Debug.EnterNavigator (c);
-                                               this.HandleTopLevelElement();
-                                               Debug.ExitNavigator (c);
-                                       }
-                               } while (c.Input.MoveToNext ());
-                               
-                               c.Input.MoveToParent ();
-                       }
+                       if (!c.Input.MoveToFirstChild ())
+                               return;
+                       do {
+                               // Collect namespace aliases first.
+                               if (c.Input.NodeType != XPathNodeType.Element ||
+                                       c.Input.LocalName != "namespace-alias" 
||
+                                       c.Input.NamespaceURI != XsltNamespace)
+                                       continue;
+                               string sprefix = (string) c.GetAttribute 
("stylesheet-prefix", "");
+                               if (sprefix == "#default")
+                                       sprefix = String.Empty;
+                               string rprefix= (string) c.GetAttribute 
("result-prefix", "");
+                               if (rprefix == "#default")
+                                       rprefix = String.Empty;
+                               namespaceAliases.Set (sprefix, rprefix);
+                       } while (c.Input.MoveToNext ());
+
+                       c.Input.MoveToFirst ();
+                       do {
+                               if (c.Input.NodeType != XPathNodeType.Element)
+                                       continue;
+                               Debug.EnterNavigator (c);
+                               this.HandleTopLevelElement ();
+                               Debug.ExitNavigator (c);
+                       } while (c.Input.MoveToNext ());
+                       
+                       c.Input.MoveToParent ();
                }
 
                private void AddSpaceControls (QName [] names, XmlSpace result, 
XPathNavigator styleElem)
@@ -432,46 +441,5 @@
                        foreach (QName name in names)
                                spaceControls [name] = result;
                }
-
-               public string PrefixInEffect (string prefix, ArrayList 
additionalExcluded)
-               {
-                       if (additionalExcluded != null && 
additionalExcluded.Contains (prefix == String.Empty ? "#default" : prefix))
-                               return null;
-                       if (prefix == "#default")
-                               prefix = String.Empty;
-
-                       if (ExcludeResultPrefixes != null) {
-                               bool exclude = false;
-                               foreach (XmlQualifiedName exc in 
ExcludeResultPrefixes)
-                                       if (exc.Name == "#default" && prefix == 
String.Empty || exc.Name == prefix) {
-                                               exclude = true;
-                                               break;
-                                       }
-                               if (exclude)
-                                       return null;
-                       }
-
-                       if (ExtensionElementPrefixes != null) {
-                               bool exclude = false;
-                               foreach (XmlQualifiedName exc in 
ExtensionElementPrefixes)
-                                       if (exc.Name == "#default" && prefix == 
String.Empty || exc.Name == prefix) {
-                                               exclude = true;
-                                               break;
-                                       }
-                               if (exclude)
-                                       return null;
-                       }
-
-                       return GetActualPrefix (prefix);
-               }
        }
-
-       
-       internal enum XslDefaultValidation
-       {
-               Strict,
-               Lax,
-               Preserve,
-               Strip
-       }
 }

Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog        
2005-03-07 20:24:49 UTC (rev 41536)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog        
2005-03-07 20:29:21 UTC (rev 41537)
@@ -1,5 +1,12 @@
 2005-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * XslAttribute.cs,
+         XslLiteralElement.cs :
+         Now namespace aliases are collected in prior to template
+         evaluation, so compute expected prefix at compile time.
+
+2005-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * XslLiteralElement.cs : renamed TryElementNamespacesOutput() to
          OutputLiteralNamespaceUriNodes() so that everyone can understand
          what it means and when it should be invoked.

Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs  
2005-03-07 20:24:49 UTC (rev 41536)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs  
2005-03-07 20:29:21 UTC (rev 41537)
@@ -74,25 +74,18 @@
                                        throw new XsltCompileException 
("Invalid attribute name.", ex, c.Input);
                                }
                        }
+
+                       if (calcPrefix != String.Empty) {
+                               calcPrefix = 
c.CurrentStylesheet.GetActualPrefix (calcPrefix);
+                               if (calcPrefix == null)
+                                       calcPrefix = String.Empty;
+                       }
+
                        if (calcPrefix != String.Empty && ns == null)
                                calcNs = nav.GetNamespace (calcPrefix);
                        else if (ns != null)
                                calcNs = XslAvt.AttemptPreCalc (ref ns);
 
-                       if (calcNs ==null && calcPrefix != String.Empty) {
-                               string test = 
c.CurrentStylesheet.PrefixInEffect (calcPrefix, null);
-                               if (test != null) {
-                                       string alias = 
c.CurrentStylesheet.NamespaceAliases [calcPrefix] as string;
-                                       if (alias != null)
-                                               calcNs = c.Input.GetNamespace 
(alias);
-                                       else
-                                               calcNs = c.Input.NamespaceURI;
-                               }
-                       }
-
-//                     if (ns == null && calcNs == null)
-//                             nsm = c.GetNsm ();
-                               
                        if (c.Input.MoveToFirstChild ()) {
                                value = c.CompileTemplateContent 
(XPathNodeType.Attribute);
                                c.Input.MoveToParent ();

Modified: 
trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs     
2005-03-07 20:24:49 UTC (rev 41536)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs     
2005-03-07 20:29:21 UTC (rev 41537)
@@ -44,9 +44,6 @@
                ArrayList attrs;
                XmlQualifiedName [] useAttributeSets;
                Hashtable nsDecls;
-               bool requireNameFix;
-               XPathNavigator stylesheetNode;
-               XslStylesheet stylesheet;
 
                public XslLiteralElement (Compiler c) : base (c) {}
                        
@@ -71,9 +68,14 @@
                
                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);
@@ -97,28 +99,10 @@
                        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 (prefix, localname, nsUri, true);
                        p.Out.WriteStartElement (prefix, localname, nsUri);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to