+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
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;
#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);
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)
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);
{
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 ()
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 (':');
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);
- }
- }
}
class XsltElementAvailable : XPathFunction
{
Expression arg0;
- XmlNamespaceManager nsm;
+ IStaticXsltContext ctx;
public XsltElementAvailable (FunctionArguments args, IStaticXsltContext ctx) : base (args)
{
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) &&
class XsltFormatNumber : XPathFunction
{
Expression arg0, arg1, arg2;
- XmlNamespaceManager nsm;
+ IStaticXsltContext ctx;
public XsltFormatNumber (FunctionArguments args, IStaticXsltContext ctx) : base (args)
{
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; }}
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
class XsltFunctionAvailable : XPathFunction
{
Expression arg0;
- XmlNamespaceManager nsm;
+ IStaticXsltContext ctx;
public XsltFunctionAvailable (FunctionArguments args, IStaticXsltContext ctx) : base (args)
{
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; }}
// extension function
if (colon > 0)
return (iter.NamespaceManager as XsltCompiledContext).ResolveFunction (
- XslNameUtil.FromString (name, nsm),
+ XslNameUtil.FromString (name, ctx),
null) != null;
return (
class XsltKey : XPathFunction
{
Expression arg0, arg1;
- XmlNamespaceManager nsm;
+ IStaticXsltContext ctx;
XslKey key;
public XsltKey (FunctionArguments args, IStaticXsltContext ctx) : base (args)
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);
class XsltSystemProperty : XPathFunction
{
Expression arg0;
- XmlNamespaceManager nsm;
+ IStaticXsltContext ctx;
public XsltSystemProperty (FunctionArguments args, IStaticXsltContext ctx) : base (args)
{
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) {
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
XmlQualifiedName [] excludeResultPrefixes;
ArrayList stylesheetNamespaces = new ArrayList ();
- public string BaseUri {
- get { return c.Input.BaseURI; }
- }
-
public XmlQualifiedName [] ExtensionElementPrefixes {
get { return extensionElementPrefixes; }
}
get { return parameters; }
}
- public XPathNavigator StyleDocument {
- get { return c.Input; }
- }
-
public XslTemplateTable Templates {
get { return templates; }
}
public XslStylesheet (Compiler c)
{
- this.c = c;
c.PushStylesheet (this);
templates = new XslTemplateTable (this);
} while (c.Input.MoveToNextNamespace (XPathNamespaceScope.Local));
c.Input.MoveToParent ();
}
- ProcessTopLevelElements ();
+ ProcessTopLevelElements (c);
}
c.PopStylesheet ();
// this.importer = importer;
}
- private void HandleInclude (string href)
+ private void HandleInclude (Compiler c, string href)
{
c.PushInputDocument (href);
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)
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);
}
}
- private void ProcessTopLevelElements ()
+ private void ProcessTopLevelElements (Compiler c)
{
if (!c.Input.MoveToFirstChild ())
return;
if (c.Input.NodeType != XPathNodeType.Element)
continue;
Debug.EnterNavigator (c);
- this.HandleTopLevelElement ();
+ this.HandleTopLevelElement (c);
Debug.ExitNavigator (c);
} while (c.Input.MoveToNext ());
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.
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
+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.
Expression TryGetVariable (string nm);
Expression TryGetFunction (XmlQualifiedName nm, FunctionArguments args);
XmlQualifiedName LookupQName (string s);
- XmlNamespaceManager GetNsm ();
+ string LookupNamespace (string prefix);
}\r
}\r