2005-03-09 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 9 Mar 2005 05:17:39 +0000 (05:17 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 9 Mar 2005 05:17:39 +0000 (05:17 -0000)
* XsltContext.cs : removed GetNsm() from IStaticXsltContext and added
  LookupNamespace() instead.
* BUGS-MS.txt : more bug info.

* XslFunctions.cs, Compiler.cs : Eliminated XPathNavigatorNsm class
  to reduce references to stylesheet XPathNavigator. To accomplish it,
  IStaticXsltContext does not declare GetNsm() anymore. All xslt
  function types now directly hold IStaticXsltContext.
* XslStylesheet.cs : removed "Compiler c" field.
  Removed unused properties.

svn path=/trunk/mcs/; revision=41583

mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs
mcs/class/System.XML/Mono.Xml.Xsl/XslFunctions.cs
mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
mcs/class/System.XML/System.Xml.Xsl/BUGS-MS.txt
mcs/class/System.XML/System.Xml.Xsl/ChangeLog
mcs/class/System.XML/System.Xml.Xsl/XsltContext.cs

index 5f63612b8389963e79fbf53e8240f3257629ed0b..62351665b717e48ac347184628f232349b296645 100644 (file)
@@ -1,3 +1,12 @@
+2005-03-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XslFunctions.cs, Compiler.cs : Eliminated XPathNavigatorNsm class
+         to reduce references to stylesheet XPathNavigator. To accomplish it,
+         IStaticXsltContext does not declare GetNsm() anymore. All xslt
+         function types now directly hold IStaticXsltContext.
+       * XslStylesheet.cs : removed "Compiler c" field.
+         Removed unused properties.
+
 2005-03-08  Atsushi Enomoto  <atsushi@ximian.com>
 
        * GenericOutputter.cs : When WriteStartElement() requires to add
index 04bb627e1ac29db6f66ba73d32176a9bd8759f38..ccb82f2627d60a39eecb7378d02ced721280e7c3 100644 (file)
@@ -106,8 +106,8 @@ namespace Mono.Xml.Xsl
        internal class Compiler : IStaticXsltContext {
                public const string XsltNamespace = "http://www.w3.org/1999/XSL/Transform";
                        
-               ArrayList inputNSResolverStack = new ArrayList ();
-               XPathNavigatorNsm currentNsm;
+               ArrayList inputStack = new ArrayList ();
+               XPathNavigator currentInput;
                
                Stack styleStack = new Stack ();
                XslStylesheet currentStyle;
@@ -175,13 +175,13 @@ namespace Mono.Xml.Xsl
                
 #region Input
                public XPathNavigator Input {
-                       get { return currentNsm.Navigator; }
+                       get { return currentInput; }
                }
                
                public XslStylesheet CurrentStylesheet {
                        get { return currentStyle; }
                }
-               
+
                public void PushStylesheet (XslStylesheet style)
                {
                        if (currentStyle != null) styleStack.Push (currentStyle);
@@ -222,28 +222,27 @@ namespace Mono.Xml.Xsl
                private void PushInputDocument (XPathNavigator nav)
                {
                        // Inclusion nest check
-                       IXmlLineInfo li = currentNsm != null ?
-                               currentNsm.Navigator as IXmlLineInfo : null;
+                       IXmlLineInfo li = currentInput as IXmlLineInfo;
                        bool hasLineInfo = (li != null && !li.HasLineInfo ());
-                       for (int i = 0; i < inputNSResolverStack.Count; i++) {
-                               XPathNavigator cur = ((XPathNavigatorNsm) inputNSResolverStack [i]).Navigator;
+                       for (int i = 0; i < inputStack.Count; i++) {
+                               XPathNavigator cur = (XPathNavigator) inputStack [i];
                                if (cur.BaseURI == nav.BaseURI) {
                                        throw new XsltCompileException (null,
-                                               currentNsm.Navigator.BaseURI, 
+                                               currentInput.BaseURI, 
                                                hasLineInfo ? li.LineNumber : 0,
                                                hasLineInfo ? li.LinePosition : 0);
                                }
                        }
-                       if (currentNsm != null)
-                               inputNSResolverStack.Add (currentNsm);
-                       currentNsm = new XPathNavigatorNsm (nav);
+                       if (currentInput != null)
+                               inputStack.Add (currentInput);
+                       currentInput = nav;
                }
                
                public void PopInputDocument ()
                {
-                       int last = inputNSResolverStack.Count - 1;
-                       currentNsm = (XPathNavigatorNsm) inputNSResolverStack [last];
-                       inputNSResolverStack.RemoveAt (last);
+                       int last = inputStack.Count - 1;
+                       currentInput = (XPathNavigator) inputStack [last];
+                       inputStack.RemoveAt (last);
                }
                
                public QName ParseQNameAttribute (string localName)
@@ -539,7 +538,7 @@ namespace Mono.Xml.Xsl
                
                Expression IStaticXsltContext.TryGetFunction (QName name, FunctionArguments args)
                {
-                       string ns = GetNsm ().LookupNamespace (name.Namespace, false);
+                       string ns = LookupNamespace (name.Namespace);
                        if (ns == XslStylesheet.MSXsltNamespace && name.Name == "node-set")
                                return new MSXslNodeSet (args);
                        
@@ -568,16 +567,19 @@ namespace Mono.Xml.Xsl
                {
                        return XslNameUtil.FromString (s, Input);
                }
-               /*
-               XmlNamespaceManager IStaticXsltContext.GetNsm ()
-               {
-                       return currentNsm;
-               }
-               */
-               
-               public XmlNamespaceManager GetNsm ()
+
+               public string LookupNamespace (string prefix)
                {
-                       return currentNsm;
+                       if (prefix == "" || prefix == null)
+                               return "";
+                       
+                       XPathNavigator n = Input;
+                       if (Input.NodeType == XPathNodeType.Attribute) {
+                               n = Input.Clone ();
+                               n.MoveToParent ();
+                       }
+
+                       return n.GetNamespace (prefix);
                }
 #endregion
                public void CompileOutput ()
@@ -828,6 +830,18 @@ namespace Mono.Xml.Xsl
                                throw new ArgumentException ("Invalid name: " + name);
                }
 
+               public static QName FromString (string name, IStaticXsltContext ctx)
+               {
+                       int colon = name.IndexOf (':');
+                       if (colon > 0)
+                               return new QName (name.Substring (colon + 1), ctx.LookupNamespace (name.Substring (0, colon)));
+                       else if (colon < 0)
+                               // Default namespace is not used for unprefixed names.
+                               return new QName (name, "");
+                       else
+                               throw new ArgumentException ("Invalid name: " + name);
+               }
+
                public static QName FromString (string name, XmlNamespaceManager ctx)
                {
                        int colon = name.IndexOf (':');
@@ -851,36 +865,4 @@ namespace Mono.Xml.Xsl
                                throw new ArgumentException ("Invalid name: " + name);
                }
        }
-       
-       internal class XPathNavigatorNsm : XmlNamespaceManager {
-               XPathNavigator nsScope;
-               
-               public XPathNavigatorNsm (XPathNavigator n) : base (n.NameTable) {
-                       nsScope = n;
-               }
-
-               public XPathNavigator Navigator {
-                       get { return nsScope; }
-               }
-
-               public override string DefaultNamespace { get { return String.Empty; }}
-
-#if NET_2_0
-               public override string LookupNamespace (string prefix, bool atomizedNames)
-#else
-               internal override string LookupNamespace (string prefix, bool atomizedNames)
-#endif
-               {
-                       if (prefix == "" || prefix == null)
-                               return "";
-                       
-                       XPathNavigator n = nsScope;
-                       if (nsScope.NodeType == XPathNodeType.Attribute) {
-                               n = nsScope.Clone ();
-                               n.MoveToParent ();
-                       }
-
-                       return n.GetNamespace (prefix);
-               }
-       }
 }
index b699a1e78527829f701f7f5c6d916fa9151a5618..dca0406f704a8dc3836bb715668c845e5993bb65 100755 (executable)
@@ -284,7 +284,7 @@ namespace Mono.Xml.Xsl
        class XsltElementAvailable : XPathFunction 
        {
                Expression arg0;
-               XmlNamespaceManager nsm;
+               IStaticXsltContext ctx;
                
                public XsltElementAvailable (FunctionArguments args, IStaticXsltContext ctx) : base (args)
                {
@@ -292,14 +292,14 @@ namespace Mono.Xml.Xsl
                                throw new XPathException ("element-available takes 1 arg");
                        
                        arg0 = args.Arg;
-                       nsm = ctx.GetNsm ();
+                       this.ctx = ctx;
                }
                
                public override XPathResultType ReturnType { get { return XPathResultType.Boolean; }}
 
                public override object Evaluate (BaseIterator iter)
                {
-                       QName name = XslNameUtil.FromString (arg0.EvaluateString (iter), nsm);
+                       QName name = XslNameUtil.FromString (arg0.EvaluateString (iter), ctx);
 
                        return (
                                (name.Namespace == Compiler.XsltNamespace) &&
@@ -331,7 +331,7 @@ namespace Mono.Xml.Xsl
        class XsltFormatNumber : XPathFunction 
        {
                Expression arg0, arg1, arg2;
-               XmlNamespaceManager nsm;
+               IStaticXsltContext ctx;
                
                public XsltFormatNumber (FunctionArguments args, IStaticXsltContext ctx) : base (args)
                {
@@ -342,7 +342,7 @@ namespace Mono.Xml.Xsl
                        arg1 = args.Tail.Arg;
                        if (args.Tail.Tail != null) {
                                arg2= args.Tail.Tail.Arg;
-                               nsm = ctx.GetNsm ();
+                               this.ctx = ctx;
                        }
                }
                public override XPathResultType ReturnType { get { return XPathResultType.String; }}
@@ -354,7 +354,7 @@ namespace Mono.Xml.Xsl
                        QName nm = QName.Empty;
                        
                        if (arg2 != null)
-                               nm = XslNameUtil.FromString (arg2.EvaluateString (iter), nsm);
+                               nm = XslNameUtil.FromString (arg2.EvaluateString (iter), ctx);
                        
                        try {
                                return (iter.NamespaceManager as XsltCompiledContext).Processor.CompiledStyle
@@ -368,7 +368,7 @@ namespace Mono.Xml.Xsl
        class XsltFunctionAvailable : XPathFunction 
        {
                Expression arg0;
-               XmlNamespaceManager nsm;
+               IStaticXsltContext ctx;
                
                public XsltFunctionAvailable (FunctionArguments args, IStaticXsltContext ctx) : base (args)
                {
@@ -376,7 +376,7 @@ namespace Mono.Xml.Xsl
                                throw new XPathException ("element-available takes 1 arg");
                        
                        arg0 = args.Arg;
-                       nsm = ctx.GetNsm ();
+                       this.ctx = ctx;
                }
                
                public override XPathResultType ReturnType { get { return XPathResultType.Boolean; }}
@@ -389,7 +389,7 @@ namespace Mono.Xml.Xsl
                        // extension function
                        if (colon > 0)
                                return (iter.NamespaceManager as XsltCompiledContext).ResolveFunction (
-                                       XslNameUtil.FromString (name, nsm),
+                                       XslNameUtil.FromString (name, ctx),
                                        null) != null;
                        
                        return (
@@ -490,7 +490,7 @@ namespace Mono.Xml.Xsl
        class XsltKey : XPathFunction 
        {
                Expression arg0, arg1;
-               XmlNamespaceManager nsm;
+               IStaticXsltContext ctx;
                XslKey key;
                
                public XsltKey (FunctionArguments args, IStaticXsltContext ctx) : base (args)
@@ -499,16 +499,15 @@ namespace Mono.Xml.Xsl
                                throw new XPathException ("key takes 2 args");
                        arg0 = args.Arg;
                        arg1 = args.Tail.Arg;
-                       nsm = ctx.GetNsm ();
+                       this.ctx = ctx;
                }
                public Expression KeyName { get { return arg0; } }
                public Expression Field { get { return arg1; } }
-               public XmlNamespaceManager NamespaceManager { get { return nsm; } }
                public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; }}
                
                public override object Evaluate (BaseIterator iter)
                {
-                       QName name = XslNameUtil.FromString (arg0.EvaluateString (iter), nsm);
+                       QName name = XslNameUtil.FromString (arg0.EvaluateString (iter), this.ctx);
                        XsltCompiledContext ctx = iter.NamespaceManager as XsltCompiledContext;
                        if (key == null)
                                key = ctx.Processor.CompiledStyle.Style.FindKey (name);
@@ -569,7 +568,7 @@ namespace Mono.Xml.Xsl
        class XsltSystemProperty : XPathFunction 
        {
                Expression arg0;
-               XmlNamespaceManager nsm;
+               IStaticXsltContext ctx;
                
                public XsltSystemProperty (FunctionArguments args, IStaticXsltContext ctx) : base (args)
                {
@@ -577,13 +576,13 @@ namespace Mono.Xml.Xsl
                                throw new XPathException ("system-property takes 1 arg");
                        
                        arg0 = args.Arg;
-                       nsm = ctx.GetNsm ();
+                       this.ctx = ctx;
                }
                
                public override XPathResultType ReturnType { get { return XPathResultType.String; }}
                public override object Evaluate (BaseIterator iter)
                {
-                       QName name = XslNameUtil.FromString (arg0.EvaluateString (iter), nsm);
+                       QName name = XslNameUtil.FromString (arg0.EvaluateString (iter), ctx);
                        
                        if (name.Namespace == Compiler.XsltNamespace) {
                                switch (name.Name) {
index 4e2df27caad1509e2b9a84ec50035b1f4d75b3a7..0beef2e5499dde1b2a6c1b1158e94fea00a0b6f8 100644 (file)
@@ -48,10 +48,7 @@ namespace Mono.Xml.Xsl {
        internal class XslStylesheet {
                public const string XsltNamespace = "http://www.w3.org/1999/XSL/Transform";
                public const string MSXsltNamespace = "urn:schemas-microsoft-com:xslt";
-               
-               Compiler c;
 
-//             XslStylesheet importer;
                // Top-level elements
                ArrayList imports = new ArrayList ();
                // [QName]=>XmlSpace
@@ -71,10 +68,6 @@ namespace Mono.Xml.Xsl {
                XmlQualifiedName [] excludeResultPrefixes;
                ArrayList stylesheetNamespaces = new ArrayList ();
 
-               public string BaseUri {
-                       get { return c.Input.BaseURI; }
-               }
-
                public XmlQualifiedName [] ExtensionElementPrefixes {
                        get { return extensionElementPrefixes; }
                }
@@ -103,10 +96,6 @@ namespace Mono.Xml.Xsl {
                        get { return parameters; }
                }
 
-               public XPathNavigator StyleDocument {
-                       get { return c.Input; }
-               }
-
                public XslTemplateTable Templates {
                        get { return templates; }
                }
@@ -121,7 +110,6 @@ namespace Mono.Xml.Xsl {
 
                public XslStylesheet (Compiler c)
                {
-                       this.c = c;
                        c.PushStylesheet (this);
                        
                        templates = new XslTemplateTable (this);
@@ -155,7 +143,7 @@ namespace Mono.Xml.Xsl {
                                        } while (c.Input.MoveToNextNamespace (XPathNamespaceScope.Local));
                                        c.Input.MoveToParent ();
                                }
-                               ProcessTopLevelElements ();
+                               ProcessTopLevelElements (c);
                        }
                        
                        c.PopStylesheet ();
@@ -308,7 +296,7 @@ namespace Mono.Xml.Xsl {
 //                     this.importer = importer;
                }
                
-               private void HandleInclude (string href)
+               private void HandleInclude (Compiler c, string href)
                {
                        c.PushInputDocument (href);
 
@@ -324,19 +312,19 @@ namespace Mono.Xml.Xsl {
                                Templates.Add (new XslTemplate (c));
                        }
                        else
-                               ProcessTopLevelElements ();
+                               ProcessTopLevelElements (c);
 
                        c.PopInputDocument ();
                }
                
-               private void HandleImport (string href)
+               private void HandleImport (Compiler c, string href)
                {
                        c.PushInputDocument (href);
                        imports.Add (new XslStylesheet (c, this));
                        c.PopInputDocument ();
                }
                
-               private void HandleTopLevelElement ()
+               private void HandleTopLevelElement (Compiler c)
                {
                        XPathNavigator n = c.Input;
                        switch (n.NamespaceURI)
@@ -346,10 +334,10 @@ namespace Mono.Xml.Xsl {
                                switch (n.LocalName)
                                {
                                case "include":
-                                       HandleInclude (c.GetAttribute ("href"));
+                                       HandleInclude (c, c.GetAttribute ("href"));
                                        break;
                                case "import":
-                                       HandleImport (c.GetAttribute ("href"));
+                                       HandleImport (c, c.GetAttribute ("href"));
                                        break;
                                case "preserve-space":
                                        AddSpaceControls (c.ParseQNameListAttribute ("elements"), XmlSpace.Preserve, n);
@@ -404,7 +392,7 @@ namespace Mono.Xml.Xsl {
                        }
                }
                
-               private void ProcessTopLevelElements ()
+               private void ProcessTopLevelElements (Compiler c)
                {
                        if (!c.Input.MoveToFirstChild ())
                                return;
@@ -428,7 +416,7 @@ namespace Mono.Xml.Xsl {
                                if (c.Input.NodeType != XPathNodeType.Element)
                                        continue;
                                Debug.EnterNavigator (c);
-                               this.HandleTopLevelElement ();
+                               this.HandleTopLevelElement (c);
                                Debug.ExitNavigator (c);
                        } while (c.Input.MoveToNext ());
                        
index c726d6da5c9329d3dfe6ecd4f44dcbc40cbcbdcf..4b3fd640ecdabaf20260141b119b392a62add8d2 100755 (executable)
@@ -75,7 +75,11 @@ No. 0012
 No. 0013
        When XslTransform output is XmlWriter (not Stream), document()
        function is not working properly.
-       (copy_copy27, namespace_namespace20, reluri_reluri09 - reluri_reluri11)
+       (copy_copy27, namespace_namespace20, reluri_reluri09 -
+       reluri_reluri11, XSLTFunctions_Bug76054, XSLTFunctions_Bug76984,
+       XSLTFunctions_DocumentFuncWithEmptyArg, XSLTFunctions_DocumentInUnion,
+       XSLTFunctions_DocumentInUnionWithDuplicateNodes,
+       XSLTFunctions_DocumentFunctionNoArg)
 
 No. 0014
        Standard XSLT function unparsed-entity-uri() is not found.
@@ -91,6 +95,10 @@ No. 0016
        such one as XSLT instruction.
        (XSLTFunctions_ElementAvailFunctionTrue)
 
+No. 0017
+       format-number() does not accept some patterns.
+       (XSLTFunctions_specialCharInPattern)
+
 
 Not sure the reason why:
        idkey_idkey49
index 4fd70c7f9bfff9a845a1833e853c95f287dc4e9c..1289e187fb86d7a26638f23693d12211f7987fa1 100644 (file)
@@ -1,3 +1,9 @@
+2005-03-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XsltContext.cs : removed GetNsm() from IStaticXsltContext and added
+         LookupNamespace() instead.
+       * BUGS-MS.txt : more bug info.
+
 2005-03-04  Atsushi Enomoto  <atsushi@ximian.com>
 
        * BUGS-MS.txt : more bug info.
index 324588d4e5bbf26fb99db94bae591bc2216831ef..f8c9d8c5a9e88eb5ca4d1192703ef9cc4de0e57a 100644 (file)
@@ -80,6 +80,6 @@ namespace System.Xml.Xsl
                Expression TryGetVariable (string nm);
                Expression TryGetFunction (XmlQualifiedName nm, FunctionArguments args);
                XmlQualifiedName LookupQName (string s);
-               XmlNamespaceManager GetNsm ();
+               string LookupNamespace (string prefix);
        }\r
 }\r