Author: atsushi
Date: 2005-03-09 00:17:39 -0500 (Wed, 09 Mar 2005)
New Revision: 41583
Modified:
trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
trunk/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs
trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslFunctions.cs
trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
trunk/mcs/class/System.XML/System.Xml.Xsl/BUGS-MS.txt
trunk/mcs/class/System.XML/System.Xml.Xsl/ChangeLog
trunk/mcs/class/System.XML/System.Xml.Xsl/XsltContext.cs
Log:
2005-03-09 Atsushi Enomoto <[EMAIL PROTECTED]>
* 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.
Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog 2005-03-09 03:45:04 UTC
(rev 41582)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog 2005-03-09 05:17:39 UTC
(rev 41583)
@@ -1,3 +1,12 @@
+2005-03-09 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
* GenericOutputter.cs : When WriteStartElement() requires to add
Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs 2005-03-09 03:45:04 UTC
(rev 41582)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs 2005-03-09 05:17:39 UTC
(rev 41583)
@@ -106,8 +106,8 @@
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 @@
#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 @@
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 @@
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,17 +567,20 @@
{
return XslNameUtil.FromString (s, Input);
}
- /*
- XmlNamespaceManager IStaticXsltContext.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);
}
- */
-
- public XmlNamespaceManager GetNsm ()
- {
- return currentNsm;
- }
#endregion
public void CompileOutput ()
{
@@ -828,6 +830,18 @@
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 @@
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);
- }
- }
}
Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslFunctions.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslFunctions.cs 2005-03-09
03:45:04 UTC (rev 41582)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslFunctions.cs 2005-03-09
05:17:39 UTC (rev 41583)
@@ -284,7 +284,7 @@
class XsltElementAvailable : XPathFunction
{
Expression arg0;
- XmlNamespaceManager nsm;
+ IStaticXsltContext ctx;
public XsltElementAvailable (FunctionArguments args,
IStaticXsltContext ctx) : base (args)
{
@@ -292,14 +292,14 @@
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 @@
class XsltFormatNumber : XPathFunction
{
Expression arg0, arg1, arg2;
- XmlNamespaceManager nsm;
+ IStaticXsltContext ctx;
public XsltFormatNumber (FunctionArguments args,
IStaticXsltContext ctx) : base (args)
{
@@ -342,7 +342,7 @@
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 @@
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 @@
class XsltFunctionAvailable : XPathFunction
{
Expression arg0;
- XmlNamespaceManager nsm;
+ IStaticXsltContext ctx;
public XsltFunctionAvailable (FunctionArguments args,
IStaticXsltContext ctx) : base (args)
{
@@ -376,7 +376,7 @@
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 @@
// 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 @@
class XsltKey : XPathFunction
{
Expression arg0, arg1;
- XmlNamespaceManager nsm;
+ IStaticXsltContext ctx;
XslKey key;
public XsltKey (FunctionArguments args, IStaticXsltContext ctx)
: base (args)
@@ -499,16 +499,15 @@
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 @@
class XsltSystemProperty : XPathFunction
{
Expression arg0;
- XmlNamespaceManager nsm;
+ IStaticXsltContext ctx;
public XsltSystemProperty (FunctionArguments args,
IStaticXsltContext ctx) : base (args)
{
@@ -577,13 +576,13 @@
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) {
Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs 2005-03-09
03:45:04 UTC (rev 41582)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs 2005-03-09
05:17:39 UTC (rev 41583)
@@ -48,10 +48,7 @@
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 @@
XmlQualifiedName [] excludeResultPrefixes;
ArrayList stylesheetNamespaces = new ArrayList ();
- public string BaseUri {
- get { return c.Input.BaseURI; }
- }
-
public XmlQualifiedName [] ExtensionElementPrefixes {
get { return extensionElementPrefixes; }
}
@@ -103,10 +96,6 @@
get { return parameters; }
}
- public XPathNavigator StyleDocument {
- get { return c.Input; }
- }
-
public XslTemplateTable Templates {
get { return templates; }
}
@@ -121,7 +110,6 @@
public XslStylesheet (Compiler c)
{
- this.c = c;
c.PushStylesheet (this);
templates = new XslTemplateTable (this);
@@ -155,7 +143,7 @@
} while (c.Input.MoveToNextNamespace
(XPathNamespaceScope.Local));
c.Input.MoveToParent ();
}
- ProcessTopLevelElements ();
+ ProcessTopLevelElements (c);
}
c.PopStylesheet ();
@@ -308,7 +296,7 @@
// this.importer = importer;
}
- private void HandleInclude (string href)
+ private void HandleInclude (Compiler c, string href)
{
c.PushInputDocument (href);
@@ -324,19 +312,19 @@
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 @@
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 @@
}
}
- private void ProcessTopLevelElements ()
+ private void ProcessTopLevelElements (Compiler c)
{
if (!c.Input.MoveToFirstChild ())
return;
@@ -428,7 +416,7 @@
if (c.Input.NodeType != XPathNodeType.Element)
continue;
Debug.EnterNavigator (c);
- this.HandleTopLevelElement ();
+ this.HandleTopLevelElement (c);
Debug.ExitNavigator (c);
} while (c.Input.MoveToNext ());
Modified: trunk/mcs/class/System.XML/System.Xml.Xsl/BUGS-MS.txt
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.Xsl/BUGS-MS.txt 2005-03-09
03:45:04 UTC (rev 41582)
+++ trunk/mcs/class/System.XML/System.Xml.Xsl/BUGS-MS.txt 2005-03-09
05:17:39 UTC (rev 41583)
@@ -75,7 +75,11 @@
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,7 +95,11 @@
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
impincl_impincl08
Modified: trunk/mcs/class/System.XML/System.Xml.Xsl/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.Xsl/ChangeLog 2005-03-09 03:45:04 UTC
(rev 41582)
+++ trunk/mcs/class/System.XML/System.Xml.Xsl/ChangeLog 2005-03-09 05:17:39 UTC
(rev 41583)
@@ -1,3 +1,9 @@
+2005-03-09 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * XsltContext.cs : removed GetNsm() from IStaticXsltContext and added
+ LookupNamespace() instead.
+ * BUGS-MS.txt : more bug info.
+
2005-03-04 Atsushi Enomoto <[EMAIL PROTECTED]>
* BUGS-MS.txt : more bug info.
Modified: trunk/mcs/class/System.XML/System.Xml.Xsl/XsltContext.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.Xsl/XsltContext.cs 2005-03-09
03:45:04 UTC (rev 41582)
+++ trunk/mcs/class/System.XML/System.Xml.Xsl/XsltContext.cs 2005-03-09
05:17:39 UTC (rev 41583)
@@ -80,6 +80,6 @@
Expression TryGetVariable (string nm);
Expression TryGetFunction (XmlQualifiedName nm,
FunctionArguments args);
XmlQualifiedName LookupQName (string s);
- XmlNamespaceManager GetNsm ();
+ string LookupNamespace (string prefix);
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches