Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgor Bogatov <egorbo@gmail.com>2018-06-25 12:15:20 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2018-06-25 12:15:20 +0300
commit51935465ae5935355206ceb49582e0352cc6229a (patch)
treecea8b67d252b4f29c5b501d58ada835f590f1d0b /mcs/class/Mono.Xml.Ext
parent540f077c58cdd7883c6b0738a6b350f4ff62ca75 (diff)
Delete unused files in BCL (#9288)
The following files in `mcs/class/*.cs` are not used anywhere (*.csproj/*.source).
Diffstat (limited to 'mcs/class/Mono.Xml.Ext')
-rw-r--r--mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/XPathEditableDocument.cs782
-rw-r--r--mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/TokenizerBase.cs1286
-rw-r--r--mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/XQueryConvert.cs1019
-rw-r--r--mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/XQueryDefaultFunctionCall.cs385
4 files changed, 0 insertions, 3472 deletions
diff --git a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/XPathEditableDocument.cs b/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/XPathEditableDocument.cs
deleted file mode 100644
index 76cca96878f..00000000000
--- a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/XPathEditableDocument.cs
+++ /dev/null
@@ -1,782 +0,0 @@
-//
-// Mono.Xml.XPath.XPathEditableDocument
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.com>
-//
-// (C)2004 Novell Inc.
-//
-// Yet another implementation of XPathEditableNavigator.
-// (Even runnable under MS.NET 2.0)
-//
-// By rewriting XPathEditableDocument.CreateNavigator() as just to
-// create XmlDocumentNavigator, XmlDocumentEditableNavigator could be used
-// as to implement XmlDocument.CreateNavigator().
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.ComponentModel;
-using System.IO;
-using System.Xml;
-using System.Xml.Schema;
-using System.Xml.XPath;
-using System.Xml.Serialization;
-
-namespace Mono.Xml.XPath
-{
- public class XPathEditableDocument : IXPathNavigable
- {
- /*
- public static void Main ()
- {
- try {
-#if true
- XmlDocument doc = new XmlDocument ();
- XPathEditableDocument pd = new XPathEditableDocument (doc);
- XPathNavigator nav = pd.CreateNavigator ();
- IChangeTracking xp = pd;
-#else
- XPathDocument doc = new XPathDocument ();
- XPathNavigator nav = doc.CreateNavigator ();
- IChangeTracking xp = doc;
-#endif
- doc.LoadXml ("<root/>");
- nav.MoveToFirstChild (); // root
- XmlWriter w = nav.AppendChild ();
- Console.WriteLine (((IChangeTracking) xp).IsChanged);
- w.WriteElementString ("foo", "foo_text");
- w.WriteElementString ("bar", "bar_text");
- w.WriteStartElement ("hoge");
- w.WriteAttributeString ("fuga", "fugafuga");
- w.WriteAttributeString ("unya", "unyaunya");
- w.WriteFullEndElement ();
- w.Close ();
-
- w = nav.CreateAttributes ();
- w.WriteStartAttribute ("namara");
- w.WriteString ("mokera");
- w.WriteEndAttribute ();
- w.WriteAttributeString ("beccho", "giccho");
- w.Close ();
-
- nav.MoveToRoot ();
- nav.MoveToFirstChild ();
- nav.MoveToFirstChild ();
- nav.DeleteSelf (); // delete foo
- Console.WriteLine (nav.Name);
- nav.MoveToNext ();
- Console.WriteLine (nav.Name);
- Console.WriteLine (nav.MoveToFirstAttribute ());
- nav.DeleteSelf (); // delete fuga
-
- doc.Save (Console.Out);
- } catch (Exception ex) {
- Console.WriteLine (ex);
- }
- }
- */
-
- XmlNode node;
-
- ArrayList changes = new ArrayList ();
-
- public XPathEditableDocument (XmlNode node)
- {
- this.node = node;
- }
-
- public virtual bool CanEdit {
- get { return true; }
- }
-
- public XmlNode Node {
- get { return node; }
- }
-
- public XPathNavigator CreateNavigator ()
- {
- return new XmlDocumentEditableNavigator (this);
- }
-
- public XmlWriter CreateWriter ()
- {
- return CreateNavigator ().AppendChild ();
- }
-
- public bool HasChanges ()
- {
- return IsChanged;
- }
-
- #region IRevertibleChangeTracking/IChangeTracking
- public bool IsChanged {
- get { return changes.Count != 0; }
- }
-
- public void AcceptChanges ()
- {
- changes.Clear ();
- }
-
- public void RejectChanges ()
- {
- for (int i = changes.Count - 1; i >= 0; i--) {
- Insertion ins = changes [i] as Insertion;
- if (ins != null) {
- ins.ParentNode.RemoveChild (ins.InsertedNode);
- continue;
- }
-
- Removal rem = changes [i] as Removal;
- if (rem != null) {
- if (rem.RemovedNode.NodeType == XmlNodeType.Attribute) {
- XmlElement el = (XmlElement) rem.OwnerNode;
- el.SetAttributeNode ((XmlAttribute) rem.RemovedNode);
- }
- else
- rem.OwnerNode.InsertBefore (rem.RemovedNode, rem.NextSibling);
- continue;
- }
- AttributeUpdate au = changes [i] as AttributeUpdate;
- if (au != null) {
- if (au.OldAttribute != null)
- au.Element.SetAttributeNode (au.OldAttribute);
- else
- au.Element.RemoveAttributeNode (au.NewAttribute);
- continue;
- }
- }
- changes.Clear ();
- }
- #endregion
-
- #region IXmlSerializable
- public void WriteXml (XmlWriter writer)
- {
- throw new NotImplementedException ();
- }
-
- public void ReadXml (XmlReader reader)
- {
- throw new NotImplementedException ();
- }
-
- public XmlSchema GetSchema ()
- {
- throw new NotImplementedException ();
- }
- #endregion
-
- internal bool DeleteNode (XmlNode node)
- {
- Removal rem = new Removal ();
- if (node.NodeType == XmlNodeType.Attribute) {
- XmlAttribute attr = node as XmlAttribute;
- rem.OwnerNode = attr.OwnerElement;
- rem.RemovedNode = node;
- attr.OwnerElement.RemoveAttributeNode (attr);
- return false;
- } else {
- rem.OwnerNode = node.ParentNode;
- rem.NextSibling = node.NextSibling;
- rem.RemovedNode = node;
- node.ParentNode.RemoveChild (node);
- return rem.NextSibling != null;
- }
- }
-
- internal XmlWriter CreateInsertionWriter (XmlNode owner, XmlNode previousSibling)
- {
- return new XmlDocumentInsertionWriter (owner, previousSibling, this);
- }
-
- internal XmlWriter CreateAttributesWriter (XmlNode owner)
- {
- return new XmlDocumentAttributeWriter (owner, this);
- }
-
- internal void AttributeUpdate (XmlElement element, XmlAttribute oldAttr, XmlAttribute newAttr)
- {
- AttributeUpdate au = new AttributeUpdate ();
- au.Element = element;
- au.OldAttribute = oldAttr;
- au.NewAttribute = newAttr;
- changes.Add (au);
- }
-
- internal void AppendChild (XmlNode parent, XmlNode child)
- {
- Insertion ins = new Insertion ();
- ins.ParentNode = parent;
- ins.InsertedNode = child;
- changes.Add (ins);
- }
- }
-
- public class XmlDocumentInsertionWriter : XmlWriter
- {
- XmlNode current;
- XmlNode previousSibling;
- XPathEditableDocument document;
- Stack nodeStack = new Stack ();
-
- public XmlDocumentInsertionWriter (XmlNode owner, XmlNode previousSibling, XPathEditableDocument doc)
- {
- this.current = (XmlNode) owner;
- if (current == null)
- throw new InvalidOperationException ();
- this.previousSibling = previousSibling;
- this.document = doc;
- state = WriteState.Content;
- }
-
- WriteState state;
- XmlAttribute attribute;
-
- public override WriteState WriteState {
- get { return state; }
- }
-
- public override void Close ()
- {
- }
-
- public override void Flush ()
- {
- }
-
- public override string LookupPrefix (string ns)
- {
- return current.GetPrefixOfNamespace (ns);
- }
-
- public override void WriteStartAttribute (string prefix, string name, string ns)
- {
- if (state != WriteState.Content)
- throw new InvalidOperationException ("Current state is not inside element. Cannot start attribute.");
- attribute = current.OwnerDocument.CreateAttribute (prefix, name, ns);
- state = WriteState.Attribute;
- }
-
- public override void WriteProcessingInstruction (string name, string value)
- {
- XmlProcessingInstruction pi = current.OwnerDocument.CreateProcessingInstruction (name, value);
- current.AppendChild (pi);
- document.AppendChild (current, pi);
- }
-
- public override void WriteComment (string text)
- {
- XmlComment comment = current.OwnerDocument.CreateComment (text);
- current.AppendChild (comment);
- document.AppendChild (current, comment);
- }
-
- public override void WriteCData (string text)
- {
- XmlCDataSection cdata = current.OwnerDocument.CreateCDataSection (text);
- current.AppendChild (cdata);
- document.AppendChild (current, cdata);
- }
-
- public override void WriteStartElement (string prefix, string name, string ns)
- {
- if (current.OwnerDocument == null)
- throw new Exception ("Should not happen.");
- XmlElement el = current.OwnerDocument.CreateElement (prefix, name, ns);
- current.AppendChild (el);
- document.AppendChild (current, el);
- nodeStack.Push (current);
- current = el;
- }
-
- public override void WriteEndElement ()
- {
- if (nodeStack.Count == 0)
- throw new InvalidOperationException ("No element is opened.");
- current = nodeStack.Pop () as XmlNode;
- }
-
- public override void WriteFullEndElement ()
- {
- WriteEndElement ();
- XmlElement el = current as XmlElement;
- if (el != null)
- el.IsEmpty = false;
- }
-
- public override void WriteDocType (string name, string pubid, string systemId, string intsubset)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteStartDocument ()
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteStartDocument (bool standalone)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteEndDocument ()
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteBase64 (byte [] data, int start, int length)
- {
- WriteString (Convert.ToBase64String (data, start, length));
- }
-
- public override void WriteRaw (char [] raw, int start, int length)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteRaw (string raw)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteSurrogateCharEntity (char msb, char lsb)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteCharEntity (char c)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteEntityRef (string entname)
- {
- if (state != WriteState.Attribute)
- throw new InvalidOperationException ("Current state is not inside attribute. Cannot write attribute value.");
- attribute.AppendChild (attribute.OwnerDocument.CreateEntityReference (entname));
- }
-
- public override void WriteChars (char [] data, int start, int length)
- {
- WriteString (new string (data, start, length));
- }
-
- public override void WriteString (string text)
- {
- if (attribute != null)
- attribute.Value += text;
- else {
- XmlText t = current.OwnerDocument.CreateTextNode (text);
- current.AppendChild (t);
- document.AppendChild (current, t);
- }
- }
-
- public override void WriteWhitespace (string text)
- {
- if (state != WriteState.Attribute)
- current.AppendChild (current.OwnerDocument.CreateTextNode (text));
- else if (attribute.ChildNodes.Count == 0)
- attribute.AppendChild (attribute.OwnerDocument.CreateWhitespace (text));
- else
- attribute.Value += text;
- }
-
- public override void WriteEndAttribute ()
- {
- XmlElement element = current as XmlElement;
- if (state != WriteState.Attribute || element == null)
- throw new InvalidOperationException ("Current state is not inside attribute. Cannot close attribute.");
- document.AttributeUpdate (element, element.SetAttributeNode (attribute), attribute);
- attribute = null;
- state = WriteState.Content;
- }
- }
-
- public class XmlDocumentAttributeWriter : XmlWriter
- {
- XmlElement element;
- XPathEditableDocument document;
-
- public XmlDocumentAttributeWriter (XmlNode owner, XPathEditableDocument doc)
- {
- element = owner as XmlElement;
- if (element == null)
- throw new ArgumentException ("To write attributes, current node must be an element.");
- state = WriteState.Content;
- document = doc;
- }
-
- WriteState state;
- XmlAttribute attribute;
-
- public override WriteState WriteState {
- get { return state; }
- }
-
- public override void Close ()
- {
- }
-
- public override void Flush ()
- {
- }
-
- public override string LookupPrefix (string ns)
- {
- return element.GetPrefixOfNamespace (ns);
- }
-
- public override void WriteStartAttribute (string prefix, string name, string ns)
- {
- if (state != WriteState.Content)
- throw new InvalidOperationException ("Current state is not inside element. Cannot start attribute.");
- attribute = element.OwnerDocument.CreateAttribute (prefix, name, ns);
- state = WriteState.Attribute;
- }
-
- public override void WriteProcessingInstruction (string name, string value)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteComment (string text)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteCData (string text)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteStartElement (string prefix, string name, string ns)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteEndElement ()
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteFullEndElement ()
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteDocType (string name, string pubid, string systemId, string intsubset)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteStartDocument ()
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteStartDocument (bool standalone)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteEndDocument ()
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteBase64 (byte [] data, int start, int length)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteRaw (char [] raw, int start, int length)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteRaw (string raw)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteSurrogateCharEntity (char msb, char lsb)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteCharEntity (char c)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteEntityRef (string entname)
- {
- if (state != WriteState.Attribute)
- throw new InvalidOperationException ("Current state is not inside attribute. Cannot write attribute value.");
- attribute.AppendChild (attribute.OwnerDocument.CreateEntityReference (entname));
- }
-
- public override void WriteChars (char [] data, int start, int length)
- {
- WriteString (new string (data, start, length));
- }
-
- public override void WriteString (string text)
- {
- if (state != WriteState.Attribute)
- throw new InvalidOperationException ("Current state is not inside attribute. Cannot write attribute value.");
- attribute.Value += text;
- }
-
- public override void WriteWhitespace (string text)
- {
- if (state != WriteState.Attribute)
- throw new InvalidOperationException ("Current state is not inside attribute. Cannot write attribute value.");
- if (attribute.ChildNodes.Count == 0)
- attribute.AppendChild (attribute.OwnerDocument.CreateWhitespace (text));
- else
- attribute.Value += text;
- }
-
- public override void WriteEndAttribute ()
- {
- if (state != WriteState.Attribute)
- throw new InvalidOperationException ("Current state is not inside attribute. Cannot close attribute.");
- document.AttributeUpdate (element, element.SetAttributeNode (attribute), attribute);
- attribute = null;
- state = WriteState.Content;
- }
- }
-
- public class Insertion
- {
- // AppendChild : last child / true
- // InsertBefore : current node / false
- // InsertAfter : current node / true
- // PrependChild : first child / false
- public XmlNode ParentNode;
- public XmlNode InsertedNode;
- public bool Afterward;
- }
-
- public class Removal
- {
- public XmlNode OwnerNode;
- public XmlNode NextSibling;
- public XmlNode RemovedNode;
- }
-
- public class AttributeUpdate
- {
- public XmlElement Element;
- public XmlAttribute NewAttribute;
- public XmlAttribute OldAttribute;
- }
-
- public class XmlDocumentEditableNavigator : XPathNavigator, IHasXmlNode
- {
- static readonly bool isXmlDocumentNavigatorImpl;
-
- static XmlDocumentEditableNavigator ()
- {
- isXmlDocumentNavigatorImpl =
- (typeof (XmlDocumentEditableNavigator).Assembly
- == typeof (XmlDocument).Assembly);
- }
-
- XPathEditableDocument document;
- XPathNavigator navigator;
-
- public XmlDocumentEditableNavigator (XPathEditableDocument doc)
- {
- document = doc;
- if (isXmlDocumentNavigatorImpl)
- navigator = new XmlDocumentNavigator (doc.Node);
- else
- navigator = doc.CreateNavigator ();
- }
-
- public XmlDocumentEditableNavigator (XmlDocumentEditableNavigator nav)
- {
- document = nav.document;
- navigator = nav.navigator.Clone ();
- }
-
- public override string BaseURI {
- get { return navigator.BaseURI; }
- }
-
- public override bool IsEmptyElement {
- get { return navigator.IsEmptyElement; }
- }
-
- public override string LocalName {
- get { return navigator.LocalName; }
- }
-
- public override XmlNameTable NameTable {
- get { return navigator.NameTable; }
- }
-
- public override string Name {
- get { return navigator.Name; }
- }
-
- public override string NamespaceURI {
- get { return navigator.NamespaceURI; }
- }
-
- public override XPathNodeType NodeType {
- get { return navigator.NodeType; }
- }
-
- public override string Prefix {
- get { return navigator.Prefix; }
- }
-
- public override string Value {
- get { return navigator.Value; }
- }
-
- public override XPathNavigator Clone ()
- {
- return new XmlDocumentEditableNavigator (this);
- }
-
- public override XPathNavigator CreateNavigator ()
- {
- return navigator.Clone ();
- }
-
- public XmlNode GetNode ()
- {
- return ((IHasXmlNode) navigator).GetNode ();
- }
-
- public override bool IsSamePosition (XPathNavigator other)
- {
- XmlDocumentEditableNavigator nav = other as XmlDocumentEditableNavigator;
- if (nav != null)
- return navigator.IsSamePosition (nav.navigator);
- else
- return navigator.IsSamePosition (nav);
- }
-
- public override bool MoveTo (XPathNavigator other)
- {
- XmlDocumentEditableNavigator nav = other as XmlDocumentEditableNavigator;
- if (nav != null)
- return navigator.MoveTo (nav.navigator);
- else
- return navigator.MoveTo (nav);
- }
-
- public override bool MoveToFirstAttribute ()
- {
- return navigator.MoveToFirstAttribute ();
- }
-
- public override bool MoveToFirstChild ()
- {
- return navigator.MoveToFirstChild ();
- }
-
- public override bool MoveToFirstNamespace (XPathNamespaceScope scope)
- {
- return navigator.MoveToFirstNamespace (scope);
- }
-
- public override bool MoveToId (string id)
- {
- return navigator.MoveToId (id);
- }
-
- public override bool MoveToNext ()
- {
- return navigator.MoveToNext ();
- }
-
- public override bool MoveToNextAttribute ()
- {
- return navigator.MoveToNextAttribute ();
- }
-
- public override bool MoveToNextNamespace (XPathNamespaceScope scope)
- {
- return navigator.MoveToNextNamespace (scope);
- }
-
- public override bool MoveToParent ()
- {
- return navigator.MoveToParent ();
- }
-
- public override bool MoveToPrevious ()
- {
- return navigator.MoveToPrevious ();
- }
-
- public override XmlWriter AppendChild ()
- {
- XmlNode n = ((IHasXmlNode) navigator).GetNode ();
- if (n == null)
- throw new InvalidOperationException ("Should not happen.");
- return document.CreateInsertionWriter (n, null);
- }
-
- public override XmlWriter InsertBefore ()
- {
- XmlNode n = ((IHasXmlNode) navigator).GetNode ();
- return document.CreateInsertionWriter (n.ParentNode, n.PreviousSibling);
- }
-
- public override XmlWriter CreateAttributes ()
- {
- XmlNode n = ((IHasXmlNode) navigator).GetNode ();
- return document.CreateInsertionWriter (n, null);
- }
-
- public override bool DeleteSelf ()
- {
- XmlNode n = ((IHasXmlNode) navigator).GetNode ();
- if (!navigator.MoveToNext ())
- navigator.MoveToParent ();
- return document.DeleteNode (n);
- }
-
- public override void SetValue (string value)
- {
- XmlNode n = ((IHasXmlNode) navigator).GetNode ();
- foreach (XmlNode c in n.ChildNodes)
- document.DeleteNode (c);
- XmlWriter w = document.CreateInsertionWriter (n, null);
- w.WriteValue (value);
- w.Close ();
- }
- }
-}
-
diff --git a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/TokenizerBase.cs b/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/TokenizerBase.cs
deleted file mode 100644
index f13261890d9..00000000000
--- a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/TokenizerBase.cs
+++ /dev/null
@@ -1,1286 +0,0 @@
-//
-// XQueryTokenizer.cs
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.com>
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Security.Policy;
-using System.Xml;
-using System.Xml.Query;
-using System.Xml.Schema;
-using System.Xml.XPath;
-using Mono.Xml.XQuery;
-using Mono.Xml.XPath2;
-using Mono.Xml;
-
-#if XPATH2_PARSER
-namespace Mono.Xml.XPath2.Parser
-#elif XQUERY_PARSER
-namespace Mono.Xml.XQuery.Parser
-#endif
-{
- // FIXME: make internal in the future
- public class XQueryTokenizer : yyParser.yyInput, IXmlLineInfo
- {
- int line = 1;
- int column = 0;
- bool nextIncrementLine;
-
- // namespace resolver
- XmlNamespaceManager nsResolver;
- string defaultFunctionNamespace = XQueryFunction.Namespace;
-
- // input source
- TextReader source;
- int peekChar = -1;
-
- // token info
- int currentToken;
- string prefixName;
- object tokenValue;
-
- int lookAheadToken = -1;
- object lookAheadTokenValue;
-
- // state info
- WhitespaceHandling ws = WhitespaceHandling.Arbitrary;
- ParseState state = ParseState.Default;
- Stack stateStack;
-
- char [] buffer = new char [30];
- int bufferIndex;
-
- public XQueryTokenizer (TextReader reader)
- {
- this.source = reader;
-
- stateStack = new Stack ();
-
- nsResolver = new XmlNamespaceManager (new NameTable ());
- nsResolver.AddNamespace ("xs", XmlSchema.Namespace);
- nsResolver.AddNamespace ("xdt", InternalPool.XdtNamespace);
- // FIXME: Are they really predefined?
- nsResolver.AddNamespace ("xsi", XmlSchema.InstanceNamespace);
- nsResolver.AddNamespace ("fn", "http://www.w3.org/2003/11/xpath-functions");
- nsResolver.AddNamespace ("local", "http://www.w3.org/2003/11/xquery-local-functions");
- }
-
- internal IXmlNamespaceResolver NSResolver {
- get { return nsResolver; }
- }
-
- internal string DefaultFunctionNamespace {
- get { return defaultFunctionNamespace; }
- set { defaultFunctionNamespace = value; }
- }
-
- public void AddNamespace (string prefix, string ns)
- {
- nsResolver.AddNamespace (prefix, ns);
- }
-
- public bool advance ()
- {
- if (currentToken < 0)
- return false;
- if (lookAheadToken >= 0) {
- tokenValue = lookAheadTokenValue;
- currentToken = lookAheadToken;
- lookAheadToken = -1;
- }
- else
- currentToken = ParseToken ();
- return currentToken >= 0;
- }
-
- public int token ()
- {
- return currentToken;
- }
-
- public object value ()
- {
- return tokenValue;
- }
-
- public bool HasLineInfo ()
- {
- return true;
- }
-
- public int LineNumber {
- get { return line; }
- }
-
- public int LinePosition {
- get { return column; }
- }
-
- internal WhitespaceHandling Space {
- get { return ws; }
- set { ws = value; }
- }
-
- internal ParseState State {
- get { return state; }
- set {
-// Console.Error.WriteLine ("**** eno **** state transition from {0} to {1}, stack count = {2}", state, value, stateStack.Count);
-//foreach (ParseState ps in stateStack.ToArray ()) Console.Error.WriteLine ("***** eno ***** " + ps);
- state = value;
- }
- }
-
- internal void PushState (ParseState newState)
- {
- stateStack.Push (newState);
-// Console.Error.WriteLine ("**** eno **** state pushed {0}, added stack count = {1}", newState, stateStack.Count);
-//foreach (ParseState ps in stateStack.ToArray ()) Console.Error.WriteLine ("***** eno ***** " + ps);
- }
-
- internal void PopState ()
- {
- if (stateStack.Count == 0)
- throw Error ("Internal state transition error. State stack is empty.");
- state = (ParseState) stateStack.Pop ();
-// Console.Error.WriteLine ("**** eno **** state pop, now as {0}, stack count = {1}", state, stateStack.Count);
-//foreach (ParseState ps in stateStack.ToArray ()) Console.Error.WriteLine ("***** eno ***** " + ps);
- }
-
- private XmlQueryCompileException Error (string message)
- {
- return new XmlQueryCompileException (message, this, null, null);
- }
-
- private int ParseToken ()
- {
- bufferIndex = 0;
-
- switch (state) {
- case ParseState.StartTag:
- break;
- default:
- SkipWhitespaces ();
- break;
- }
- /*
- switch (ws) {
- case WhitespaceHandling.Arbitrary:
- SkipWhitespaces ();
- break;
- case WhitespaceHandling.Explicit:
- if (!XmlChar.IsWhitespace (PeekChar ()))
- throw Error ("Whitespace is required.");
- goto case WhitespaceHandling.Arbitrary;
- }
- */
-
- int c = PeekChar ();
- if (c < 0)
- return -1;
-
- // FIXME: consider DOUBLE_LITERAL
- if (Char.IsNumber ((char) c)) {
- tokenValue = ReadDecimal (false);
- return Token.DECIMAL_LITERAL;
- }
-
- switch (state) {
- case ParseState.OccurenceIndicator:
- return ParseOccurenceIndicator ();
- case ParseState.XmlPIContent:
- return ParseXmlPIContent ();
- case ParseState.XmlComment:
- return ParseXmlCommentContent ();
- case ParseState.ElementContent:
- return ParseElementContent ();
- case ParseState.StartTag:
- return ParseStartTag ();
- case ParseState.QuotAttributeContent:
- return ParseAttributeContent ('"');
- case ParseState.AposAttributeContent:
- return ParseAttributeContent ('\'');
- default:
- return ParseDefault ();
- }
- }
-
- private int ParseXQueryComment ()
- {
- while (true) {
- int c = ReadChar ();
- if (c < 0)
- throw Error ("Unexpected end of query text inside XML processing instruction content");
- if (c == ':') {
- if (PeekChar () == ')') {
- ReadChar ();
- tokenValue = CreateValueString ();
- return Token.XML_PI_TO_END;
- }
- else
- AddValueChar (':');
- }
- else
- AddValueChar ((char) c);
- }
- }
-
- private int ParseXmlPIContent ()
- {
- while (true) {
- int c = ReadChar ();
- if (c < 0)
- throw Error ("Unexpected end of query text inside XML processing instruction content");
- if (c == '?') {
- if (PeekChar () == '>') {
- ReadChar ();
- tokenValue = CreateValueString ();
- return Token.XML_PI_TO_END;
- }
- else
- AddValueChar ('?');
- }
- else
- AddValueChar ((char) c);
- }
- }
-
- private int ParseXmlCommentContent ()
- {
- // FIXME: handle ---> correctly
- while (true) {
- int c = ReadChar ();
- if (c < 0)
- throw Error ("Unexpected end of query text inside XML comment content");
- if (c == '-') {
- if (PeekChar () == '-') {
- ReadChar ();
- if (PeekChar () == '>') {
- tokenValue = CreateValueString ();
- return Token.XML_COMMENT_TO_END;
- } else {
- AddValueChar ('-');
- AddValueChar ('-');
- }
- }
- else
- AddValueChar ('-');
- }
- else
- AddValueChar ((char) c);
- }
- }
-
- private int ParseXmlCDataContent ()
- {
- // FIXME: handle ]]]> correctly
- while (true) {
- int c = ReadChar ();
- if (c < 0)
- throw Error ("Unexpected end of query text inside XML CDATA section content");
- if (c == ']') {
- ReadChar ();
- if (PeekChar () == ']') {
- ReadChar ();
- if (PeekChar () == '>') {
- tokenValue = CreateValueString ();
- return Token.XML_CDATA_TO_END;
- } else {
- AddValueChar (']');
- AddValueChar (']');
- }
- }
- else
- AddValueChar (']');
- }
- else
- AddValueChar ((char) c);
- }
- }
-
- private int ParseElementContent ()
- {
- tokenValue = null;
- int c = PeekChar ();
- if (c < 0)
- throw Error ("Unexpected end of query text inside XML processing instruction content");
- switch ((char) c) {
- case '<':
- case '{':
- return ParseDefault ();
- }
-
- while (true) {
- c = PeekChar ();
- if (c < 0)
- throw Error ("Unexpected end of query text inside XML processing instruction content");
- switch ((char) c) {
- case '&':
- ReadChar ();
- ReadPredefinedEntity ();
- continue;
- case '<':
- tokenValue += CreateValueString ();
- return Token.ELEM_CONTENT_LITERAL;
- default:
- AddValueChar ((char) c);
- ReadChar ();
- continue;
- }
- }
- }
-
- private void ReadPredefinedEntity ()
- {
- string token = ReadOneToken ();
- Expect (";");
- switch (token) {
- case "lt":
- AddValueChar ('<');
- return;
- case "gt":
- AddValueChar ('>');
- return;
- case "amp":
- AddValueChar ('&');
- return;
- case "quot":
- AddValueChar ('"');
- return;
- case "apos":
- AddValueChar ('\'');
- return;
- default:
- throw Error (String.Format ("Unexpected general entity name: {0} .", token));
- }
- }
-
- // FIXME: not used as yet
- private int ParseExtContent ()
- {
- // FIXME: handle :::) correctly
- while (true) {
- int c = PeekChar ();
- if (c < 0)
- throw Error ("Unexpected end of query text inside external content");
- if (c == ':') {
- ReadChar ();
- if (PeekChar () == ':') {
- ReadChar ();
- if (PeekChar () == ')') {
- tokenValue = CreateValueString ();
- return Token.EXT_CONTENT;
- } else {
- AddValueChar (':');
- AddValueChar (':');
- }
- }
- else
- AddValueChar (':');
- }
- else
- AddValueChar ((char) c);
- }
- }
-
- private int ParseOccurenceIndicator ()
- {
- state = ParseState.Operator;
- switch (PeekChar ()) {
- case '?':
- ReadChar ();
- return Token.QUESTION;
- case '*':
- ReadChar ();
- return Token.ASTERISK;
- case '+':
- ReadChar ();
- return Token.PLUS;
- default:
- return ParseOperator ();
- }
- }
-
- private int ParseStartTag ()
- {
- int c = PeekChar ();
- switch (c) {
- case '\'':
- ReadChar ();
- return Token.APOS;
- case '"':
- ReadChar ();
- return Token.QUOT;
- case '>':
- ReadChar ();
- return Token.GREATER;
- case '/':
- ReadChar ();
- Expect (">");
- return Token.EMPTY_TAG_CLOSE;
- }
- // FIXME: there seems a bug in the spec that StartTag
- // state must accept QName without heading space for
- // start tag name.
-// if (!XmlChar.IsWhitespace (PeekChar ()))
-// throw Error ("Whitespace is required.");
- SkipWhitespaces ();
- return ParseDefault (); // only QName is allowed here.
- }
-
- private int ParseAttributeContent (char closeChar)
- {
- int t = Token.ATT_VALUE_LITERAL;
- while (true) {
- int c = PeekChar ();
- if (c < 0)
- throw Error ("Unexpected end of attribute value content.");
- if (c == closeChar) {
- ReadChar ();
- c = PeekChar ();
- if (c == closeChar) {
- ReadChar ();
- AddValueChar (closeChar);
- }
- else
- t = closeChar == '"' ? Token.QUOT : Token.APOS;
- }
- else if (c == '{') {
- ReadChar ();
- c = PeekChar ();
- if (c == '{') {
- ReadChar ();
- AddValueChar ('{');
- }
- else
- t = Token.OPEN_CURLY;
- }
- else
- AddValueChar ((char) ReadChar ());
-
- if (t != Token.ATT_VALUE_LITERAL) {
- if (bufferIndex > 0) {
- lookAheadToken = t;
- tokenValue = CreateValueString ();
- return Token.ATT_VALUE_LITERAL;
- }
- else
- return t;
- }
- }
- }
-
- private int ParseOperator ()
- {
- // TODO: implement
- return ParseDefault ();
- }
-
- private int ParseDefault ()
- {
- int c = ReadChar ();
- switch (c) {
- case '.':
- if (PeekChar () == '.') {
- ReadChar ();
- return Token.DOT2;
- }
- else if (Char.IsNumber ((char) PeekChar ())) {
- tokenValue = ReadDecimal (true);
- }
- return Token.DOT;
- case ',':
- return Token.COMMA;
- case ';':
- return Token.SEMICOLON;
- case '(':
- if (PeekChar () == ':') {
- ReadChar ();
- if (PeekChar () == ':') {
- ReadChar ();
- return Token.PRAGMA_OPEN;
- }
- ParseXQueryComment ();
- return ParseToken (); // start again
- }
- return Token.OPEN_PAREN;
- case ')':
- return Token.CLOSE_PAREN;
- case ':':
- switch (PeekChar ()) {
- case ':':
- ReadChar ();
- if (PeekChar () == ')') {
- ReadChar ();
- return Token.PRAGMA_CLOSE;
- }
- return Token.COLON2;
- case ')':
- ReadChar ();
- return Token.CLOSE_PAREN_COLON;
- case '=':
- ReadChar ();
- return Token.COLON_EQUAL;
- }
- return Token.COLON;
- case '[':
- return Token.OPEN_BRACKET;
- case ']':
- return Token.CLOSE_BRACKET;
- case '{':
- return Token.OPEN_CURLY;
- case '}':
- return Token.CLOSE_CURLY;
- case '$':
- return Token.DOLLAR;
- case '\'':
- tokenValue = ReadQuoted ('\'');
- return Token.STRING_LITERAL;
- case '"':
- tokenValue = ReadQuoted ('"');
- return Token.STRING_LITERAL;
- case '=':
- return Token.EQUAL;
- case '<':
- // only happens when state is ElementContent
- // (otherwise it might be "/foo</bar")
- if (state == ParseState.ElementContent) {
- switch ((char) PeekChar ()) {
- case '/':
- ReadChar ();
- return Token.END_TAG_START;
- case '!':
- ReadChar ();
- switch (PeekChar ()) {
- case '-':
- ReadChar ();
- if (ReadChar () != '-')
- throw Error ("Invalid sequence of characters '<!-'.");
-
- return Token.XML_COMMENT_START;
- case '[':
- ReadChar ();
- Expect ("CDATA[");
- return Token.XML_CDATA_START;
- }
- throw Error ("Invalid sequence of characters '<!'.");
- case '?':
- ReadChar ();
- return Token.XML_PI_START;
- default:
- return Token.LESSER;
- }
- }
-
- switch (PeekChar ()) {
- case '<':
- ReadChar ();
- return Token.LESSER2;
- case '=':
- ReadChar ();
- return Token.LESSER_EQUAL;
- }
- return Token.LESSER;
- case '>':
- switch (PeekChar ()) {
- case '>':
- ReadChar ();
- return Token.GREATER2;
- case '=':
- ReadChar ();
- return Token.GREATER_EQUAL;
- }
- return Token.GREATER;
- case '|':
- return Token.BAR;
- case '*':
- if (PeekChar () == ':') {
- ReadChar ();
- // FIXME: more check
- tokenValue = new XmlQualifiedName (ReadOneToken (), "*");
- return Token.WILD_PREFIX;
- }
- return Token.ASTERISK;
- case '+':
- return Token.PLUS;
- case '-':
- return Token.MINUS;
- case '/':
- // only happens when state is StartTag
- // (otherwise it might be "/>$extvar")
- if (state == ParseState.StartTag && PeekChar () == '>') {
- ReadChar ();
- return Token.EMPTY_TAG_CLOSE;
- }
- if (PeekChar () == '/') {
- ReadChar ();
- return Token.SLASH2;
- }
- return Token.SLASH;
- case '?':
- return Token.QUESTION;
- case '@':
- return Token.AT;
- }
-
- peekChar = c;
- prefixName = null;
- string name = ReadOneToken ();
-
- tokenValue = name;
- bool validKeyword = false;
-
- switch (state) {
- case ParseState.XmlSpaceDecl:
- switch (name) {
- case "preserve":
- return Token.PRESERVE;
- case "strip":
- return Token.STRIP;
- }
- break;
- case ParseState.CloseKindTest:
- if (name == "nillable")
- return Token.NILLABLE;
- break;
- case ParseState.ExtKey:
- switch (name) {
- case "pragma":
- return Token.PRAGMA;
- case "extension":
- return Token.EXTENSION;
- }
- break;
- case ParseState.KindTest:
- switch (name) {
- case "context":
- return Token.CONTEXT;
- case "element":
- return Token.ELEMENT;
- case "global":
- return Token.GLOBAL;
- case "type":
- return Token.TYPE;
- }
- break;
- case ParseState.ItemType:
- switch (name) {
- case "attribute":
- return Token.ATTRIBUTE;
- case "comment":
- return Token.COMMENT;
- case "document-node":
- return Token.DOCUMENT_NODE;
- case "element":
- return Token.ELEMENT;
- case "empty":
- return Token.EMPTY;
- case "item":
- return Token.ITEM;
- case "node":
- return Token.NODE;
- case "processing-instruction":
- return Token.PROCESSING_INSTRUCTION;
- case "text":
- return Token.TEXT;
- }
- break;
- case ParseState.NamespaceKeyword:
- switch (name) {
- case "declare":
- return Token.DECLARE;
- case "default":
- return Token.DEFAULT;
- case "element":
- return Token.ELEMENT;
- case "function":
- return Token.FUNCTION;
- case "namespace":
- return Token.NAMESPACE;
- }
- break;
- case ParseState.OccurenceIndicator:
- case ParseState.Operator:
- switch (name) {
- case "and":
- case "as":
- case "ascending":
- case "at":
- case "base-uri":
- case "by":
- case "case":
- case "cast":
- case "castable":
- case "collation":
- case "declare":
- case "default":
- case "descending":
- case "div":
- case "element":
- case "else":
- case "empty":
- case "eq":
- case "every":
- case "except":
- case "external":
- case "for":
- case "function":
- case "ge":
- case "global":
- case "greatest":
- case "gt":
- case "idiv":
- case "import":
- case "in":
- case "instance":
- case "intersect":
- case "is":
- case "lax":
- case "le":
- case "least":
- case "let":
- case "lt":
- case "mod":
- case "module":
- case "namespace":
- case "ne":
- case "of":
- case "or":
- case "order":
- case "ordered":
- case "ordering":
- case "return":
- case "satisfies":
- case "schema":
- case "skip":
- case "some":
- case "stable":
- case "strict":
- case "then":
- case "to":
- case "treat":
- case "typwswitch":
- case "union":
- case "unordered":
- case "variable":
- case "where":
- case "xmlspace":
- validKeyword = true;
- break;
- }
- break;
- case ParseState.Default:
- switch (name) {
- case "ancestor":
- case "ancestor-or-self":
- case "as":
- case "attribute":
- case "base-uri":
- case "child":
- case "collation":
- case "comment":
- case "construction":
- case "declare":
- case "default":
- case "descendant":
- case "descendant-or-self":
- case "document":
- case "document-node":
- case "element":
- case "every":
- case "following":
- case "following-sibling":
- case "for":
- case "function":
- case "global":
- case "if":
- case "import":
- case "lax":
- case "let":
- case "module":
- case "namespace":
- case "node":
- case "ordered":
- case "parent":
- case "preceding":
- case "preceding-sibling":
- case "processing-instruction":
- case "schema":
- case "self":
- case "some":
- case "strict":
- case "strip":
- case "text":
- case "typeswitch":
- case "unordered":
- case "validate":
- case "validation":
- case "version":
- case "xmlspace":
- case "xquery":
- validKeyword = true;
- break;
- }
- break;
- }
-
- if (validKeyword) {
- switch (name) {
- case "xquery":
- return Token.XQUERY;
- case "version":
- return Token.VERSION;
- case "pragma":
- return Token.PRAGMA;
- case "extension":
- return Token.EXTENSION;
- case "module":
- return Token.MODULE;
- case "namespace":
- return Token.NAMESPACE;
- case "declare":
- return Token.DECLARE;
- case "xmlspace":
- return Token.XMLSPACE;
- case "preserve":
- return Token.PRESERVE;
- case "strip":
- return Token.STRIP;
- case "default":
- return Token.DEFAULT;
- case "construction":
- return Token.CONSTRUCTION;
- case "ordering":
- return Token.ORDERING;
- case "ordered":
- return Token.ORDERED;
- case "unordered":
- return Token.UNORDERED;
- case "document-node":
- return Token.DOCUMENT_NODE;
- case "document":
- return Token.DOCUMENT;
- case "element":
- return Token.ELEMENT;
- case "attribute":
- return Token.ATTRIBUTE;
- case "processing-instruction":
- return Token.PROCESSING_INSTRUCTION;
- case "comment":
- return Token.COMMENT;
- case "text":
- return Token.TEXT;
- case "node":
- return Token.NODE;
- case "function":
- return Token.FUNCTION;
- case "collation":
- return Token.COLLATION;
- case "base-uri":
- return Token.BASEURI;
- case "import":
- return Token.IMPORT;
- case "schema":
- return Token.SCHEMA;
- case "at":
- return Token.AT;
- case "variable":
- return Token.VARIABLE;
- case "as":
- return Token.AS;
- case "external":
- return Token.EXTERNAL;
- case "validation":
- return Token.VALIDATION;
- case "lax":
- return Token.LAX;
- case "strict":
- return Token.STRICT;
- case "skip":
- return Token.SKIP;
- case "return":
- return Token.RETURN;
- case "for":
- return Token.FOR;
- case "let":
- return Token.LET;
- case "in":
- return Token.IN;
- case "where":
- return Token.WHERE;
- case "order":
- return Token.ORDER;
- case "by":
- return Token.BY;
- case "stable":
- return Token.STABLE;
- case "ascending":
- return Token.ASCENDING;
- case "descending":
- return Token.DESCENDING;
- case "empty":
- return Token.EMPTY;
- case "greatest":
- return Token.GREATEST;
- case "least":
- return Token.LEAST;
- case "some":
- return Token.SOME;
- case "every":
- return Token.EVERY;
- case "satisfies":
- return Token.SATISFIES;
- case "is":
- return Token.IS;
- case "to":
- return Token.TO;
- case "eq":
- return Token.EQ;
- case "ne":
- return Token.NE;
- case "lt":
- return Token.LT;
- case "le":
- return Token.LE;
- case "gt":
- return Token.GT;
- case "ge":
- return Token.GE;
- case "and":
- return Token.AND;
- case "or":
- return Token.OR;
- case "instance":
- return Token.INSTANCE;
- case "of":
- return Token.OF;
- case "if":
- return Token.IF;
- case "then":
- return Token.THEN;
- case "else":
- return Token.ELSE;
- case "typeswitch":
- return Token.TYPESWITCH;
- case "case":
- return Token.CASE;
- case "treat":
- return Token.TREAT;
- case "castable":
- return Token.CASTABLE;
- case "cast":
- return Token.CAST;
- case "div":
- return Token.DIV;
- case "idiv":
- return Token.IDIV;
- case "mod":
- return Token.MOD;
- case "union":
- return Token.UNION;
- case "intersect":
- return Token.INTERSECT;
- case "except":
- return Token.EXCEPT;
- case "validate":
- return Token.VALIDATE;
- case "context":
- return Token.CONTEXT;
- case "nillable":
- return Token.NILLABLE;
- case "item":
- return Token.ITEM;
- case "global":
- return Token.GLOBAL;
- case "type":
- return Token.TYPE;
- case "child":
- return Token.CHILD;
- case "descendant":
- return Token.DESCENDANT;
- case "self":
- return Token.SELF;
- case "descendant-or-self":
- return Token.DESCENDANT_OR_SELF;
- case "following-sibling":
- return Token.FOLLOWING_SIBLING;
- case "following":
- return Token.FOLLOWING;
- case "parent":
- return Token.PARENT;
- case "ancestor":
- return Token.ANCESTOR;
- case "preceding":
- return Token.PRECEDING;
- case "preceding-sibling":
- return Token.PRECEDING_SIBLING;
- case "ancestor-or-self":
- return Token.ANCESTOR_OR_SELF;
- }
- }
-
- switch (state) {
- case ParseState.NamespaceDecl:
- case ParseState.NamespaceKeyword:
- case ParseState.XmlSpaceDecl:
- case ParseState.KindTestForPI:
- case ParseState.XmlPI:
- return Token.NCNAME;
- }
-
- if (PeekChar () == ':') {
- ReadChar ();
- prefixName = name;
- switch (PeekChar ()) {
- case '*':
- ReadChar ();
- name = "*";
- break;
- case '=': // ex. let foo:= ...
- ReadChar ();
- tokenValue = new XmlQualifiedName (name, nsResolver.DefaultNamespace);
- lookAheadToken = Token.COLON_EQUAL;
- return Token.QNAME;
- default:
- name = ReadOneToken ();
- break;
- }
-
- string ns = nsResolver.LookupNamespace (prefixName);
- if (ns == null)
- throw Error (String.Format ("Prefix '{0}' is not mapped to any namespace URI.", prefixName));
- tokenValue = new XmlQualifiedName (name, ns);
- prefixName = null;
- return name == "*" ? Token.WILD_LOCALNAME : Token.QNAME;
- }
- tokenValue = new XmlQualifiedName (name);
- return Token.QNAME;
- }
-
- private int PeekChar ()
- {
- if (peekChar == -1)
- peekChar = source.Read ();
- return peekChar;
- }
-
- private int ReadChar ()
- {
- int ret;
- if (peekChar != -1) {
- ret = peekChar;
- peekChar = -1;
- }
- else
- ret = source.Read ();
-
- if (nextIncrementLine) {
- line++;
- column = 0;
- nextIncrementLine = false;
- }
- column++;
- switch (ret) {
- case '\r':
- break;
- case '\n':
- nextIncrementLine = true;
- goto default;
- default:
- break;
- }
-
- return ret;
- }
-
- private void SkipWhitespaces ()
- {
- while (true) {
- switch (PeekChar ()) {
- case ' ':
- case '\t':
- case '\r':
- case '\n':
- ReadChar ();
- continue;
- default:
- return;
- }
- }
- }
-
- private void AddValueChar (char c)
- {
- if (bufferIndex == buffer.Length) {
- char [] newBuf = new char [bufferIndex * 2];
- Array.Copy (buffer, newBuf, bufferIndex);
- buffer = newBuf;
- }
- buffer [bufferIndex++] = c;
- }
-
- private string CreateValueString ()
- {
- return new string (buffer, 0, bufferIndex);
- }
-
- private void Expect (string expected)
- {
- for (int i = 0; i < expected.Length; i++)
- if (ReadChar () != expected [i])
- throw Error (String.Format ("Expected token '{0}' did not appear.", expected));
- }
-
- // TODO: parse three quoted
- private string ReadQuoted (char quoteChar)
- {
- bufferIndex = 0;
- bool loop = true;
- do {
- int c = ReadChar ();
- switch (c) {
- case -1:
- case '"':
- if (quoteChar == '"')
- loop = false;
- break;
- case '\'':
- if (quoteChar == '\'')
- loop = false;
- break;
- default:
- AddValueChar ((char) c);
- break;
- }
- } while (loop);
-
- return CreateValueString ();
- }
-
- private decimal ReadDecimal (bool floatingPoint)
- {
- bufferIndex = 0;
- bool cond = true;
- do {
- int c = PeekChar ();
- if (c < 0) {
- cond = false;
- }
- // FIXME: more complex
- else if (Char.IsNumber ((char) c) || c == '.') {
- ReadChar ();
- AddValueChar ((char) c);
- continue;
- }
- else
- cond = false;
- } while (cond);
- string s = (floatingPoint ? "." : "") + CreateValueString ();
- return decimal.Parse (s);
- }
-
- private string ReadOneToken ()
- {
- bufferIndex = 0;
- bool loop = true;
- do {
- int c = PeekChar ();
- switch (c) {
- case -1:
- case ' ':
- case '\t':
- case '\r':
- case '\n':
- loop = false;
- break;
- default:
- if (!IsTokenContinuable (c)) {
- if (c == ':') {
- if (prefixName != null)
- throw new XmlQueryCompileException ("Invalid colon was found.");
- prefixName = CreateValueString ();
- }
- loop = false;
- break;
- }
-
- ReadChar ();
- AddValueChar ((char) c);
- break;
- }
- } while (loop);
-
- return CreateValueString ();
- }
-
- private bool IsTokenContinuable (int c)
- {
- switch (c) {
- case '-':
- case '_':
- case '.':
- return true;
- }
- return XmlChar.IsNCNameChar (c);
- }
-
- }
-
- public enum WhitespaceHandling {
- Arbitrary,
- Explicit,
- Significant
- }
-
- public enum ParseState {
- Default,
- Operator,
- NamespaceDecl,
- NamespaceKeyword,
- XmlSpaceDecl,
- ItemType,
- KindTest,
- KindTestForPI,
- CloseKindTest,
- OccurenceIndicator,
- SchemaContextStep,
- VarName,
- StartTag,
- ElementContent,
- EndTag,
- XmlComment,
- ExprComment,
- ExtKey,
- XmlPI,
- XmlPIContent,
- CDataSection,
- QuotAttributeContent,
- AposAttributeContent,
- }
-
-}
diff --git a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/XQueryConvert.cs b/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/XQueryConvert.cs
deleted file mode 100644
index e1de237599a..00000000000
--- a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/XQueryConvert.cs
+++ /dev/null
@@ -1,1019 +0,0 @@
-//
-// System.Xml.Query.XQueryConvert
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.com>
-//
-// Copyright (C) 2004 Novell Inc.
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Globalization;
-using System.IO;
-using System.Text;
-using System.Xml;
-using System.Xml.Schema;
-using System.Xml.XPath;
-
-namespace System.Xml
-{
- internal class XQueryConvert // Won't be public in the final stage
- {
- [MonoTODO]
- public static bool ShouldCheckValueFacets (XmlSchemaType schemaTypeDest)
- {
- throw new NotImplementedException ();
- }
-
- public static XmlTypeCode GetFallbackType (XmlTypeCode type)
- {
- switch (type) {
- case XmlTypeCode.AnyAtomicType:
- return XmlTypeCode.Item;
- case XmlTypeCode.UntypedAtomic:
- return XmlTypeCode.String;
- case XmlTypeCode.Notation:
- return XmlTypeCode.QName;
- case XmlTypeCode.NormalizedString:
- case XmlTypeCode.Token:
- case XmlTypeCode.Language:
- case XmlTypeCode.NmToken:
- case XmlTypeCode.Name:
- case XmlTypeCode.NCName:
- case XmlTypeCode.Id:
- case XmlTypeCode.Idref:
- case XmlTypeCode.Entity:
- return XmlTypeCode.String;
- case XmlTypeCode.NonPositiveInteger:
- return XmlTypeCode.Decimal;
- case XmlTypeCode.NegativeInteger:
- return XmlTypeCode.NonPositiveInteger;
- case XmlTypeCode.Long:
- return XmlTypeCode.Integer;
- case XmlTypeCode.Short:
- return XmlTypeCode.Int;
- case XmlTypeCode.Byte:
- return XmlTypeCode.Int;
- case XmlTypeCode.NonNegativeInteger:
- return XmlTypeCode.Decimal;
- case XmlTypeCode.UnsignedLong:
- return XmlTypeCode.NonNegativeInteger;
- case XmlTypeCode.UnsignedInt:
- return XmlTypeCode.Integer;
- case XmlTypeCode.UnsignedShort:
- return XmlTypeCode.Int;
- case XmlTypeCode.UnsignedByte:
- return XmlTypeCode.UnsignedShort;
- case XmlTypeCode.PositiveInteger:
- return XmlTypeCode.NonNegativeInteger;
- default:
- return XmlTypeCode.None;
- }
- }
-
- [MonoTODO]
- // See XQuery & XPath 2.0 functions & operators section 17.
- public static bool CanConvert (XPathItem item, XmlSchemaType schemaTypeDest)
- {
- if (item == null)
- throw new ArgumentNullException ("item");
- if (schemaTypeDest == null)
- throw new ArgumentNullException ("schemaTypeDest");
- XmlTypeCode src = item.XmlType.TypeCode;
- XmlTypeCode dst = schemaTypeDest.TypeCode;
-
- // Notation cannot be converted from other than Notation
- if (src == XmlTypeCode.Notation && dst != XmlTypeCode.Notation)
- return false;
-
- // untypedAtomic and string are convertable unless source type is QName.
- switch (dst) {
- case XmlTypeCode.UntypedAtomic:
- case XmlTypeCode.String:
- return src != XmlTypeCode.QName;
- }
-
- switch (src) {
- case XmlTypeCode.None:
- case XmlTypeCode.Item:
- case XmlTypeCode.Node:
- case XmlTypeCode.Document:
- case XmlTypeCode.Element:
- case XmlTypeCode.Attribute:
- case XmlTypeCode.Namespace:
- case XmlTypeCode.ProcessingInstruction:
- case XmlTypeCode.Comment:
- case XmlTypeCode.Text:
- throw new NotImplementedException (); // FIXME: check what happens
-
- case XmlTypeCode.AnyAtomicType:
- throw new NotImplementedException (); // FIXME: check what happens
- case XmlTypeCode.UntypedAtomic:
- case XmlTypeCode.String:
- // 'M'
- throw new NotImplementedException (); // FIXME: check what happens
-
- case XmlTypeCode.Boolean:
- case XmlTypeCode.Decimal:
- switch (dst) {
- case XmlTypeCode.Float:
- case XmlTypeCode.Double:
- case XmlTypeCode.Decimal:
- case XmlTypeCode.Boolean:
- return true;
- }
- return false;
-
- case XmlTypeCode.Float:
- case XmlTypeCode.Double:
- if (dst == XmlTypeCode.Decimal)
- // 'M'
- throw new NotImplementedException (); // FIXME: check what happens
- goto case XmlTypeCode.Decimal;
-
- case XmlTypeCode.Duration:
- switch (dst) {
- case XmlTypeCode.Duration:
- case XmlTypeCode.YearMonthDuration:
- case XmlTypeCode.DayTimeDuration:
- return true;
- }
- return false;
-
- case XmlTypeCode.DateTime:
- switch (dst) {
- case XmlTypeCode.DateTime:
- case XmlTypeCode.Time:
- case XmlTypeCode.Date:
- case XmlTypeCode.GYearMonth:
- case XmlTypeCode.GYear:
- case XmlTypeCode.GMonthDay:
- case XmlTypeCode.GDay:
- case XmlTypeCode.GMonth:
- return true;
- }
- return false;
-
- case XmlTypeCode.Time:
- switch (dst) {
- case XmlTypeCode.Time:
- case XmlTypeCode.Date:
- return true;
- }
- return false;
-
- case XmlTypeCode.Date:
- if (dst == XmlTypeCode.Time)
- return false;
- goto case XmlTypeCode.DateTime;
-
- case XmlTypeCode.GYearMonth:
- case XmlTypeCode.GYear:
- case XmlTypeCode.GMonthDay:
- case XmlTypeCode.GDay:
- case XmlTypeCode.GMonth:
- return src == dst;
-
- case XmlTypeCode.HexBinary:
- case XmlTypeCode.Base64Binary:
- if (src == dst)
- return true;
- switch (dst) {
- case XmlTypeCode.HexBinary:
- case XmlTypeCode.Base64Binary:
- return true;
- }
- return false;
-
- case XmlTypeCode.AnyUri:
- case XmlTypeCode.QName:
- case XmlTypeCode.Notation:
- return src == dst;
-
- case XmlTypeCode.NormalizedString:
- case XmlTypeCode.Token:
- case XmlTypeCode.Language:
- case XmlTypeCode.NmToken:
- case XmlTypeCode.Name:
- case XmlTypeCode.NCName:
- case XmlTypeCode.Id:
- case XmlTypeCode.Idref:
- case XmlTypeCode.Entity:
- case XmlTypeCode.Integer:
- case XmlTypeCode.NonPositiveInteger:
- case XmlTypeCode.NegativeInteger:
- case XmlTypeCode.Long:
- case XmlTypeCode.Int:
- case XmlTypeCode.Short:
- case XmlTypeCode.Byte:
- case XmlTypeCode.NonNegativeInteger:
- case XmlTypeCode.UnsignedLong:
- case XmlTypeCode.UnsignedInt:
- case XmlTypeCode.UnsignedShort:
- case XmlTypeCode.UnsignedByte:
- case XmlTypeCode.PositiveInteger:
- throw new NotImplementedException ();
-
- // xdt:*
- case XmlTypeCode.YearMonthDuration:
- if (dst == XmlTypeCode.DayTimeDuration)
- return false;
- goto case XmlTypeCode.Duration;
- case XmlTypeCode.DayTimeDuration:
- if (dst == XmlTypeCode.YearMonthDuration)
- return false;
- goto case XmlTypeCode.Duration;
- }
-
- throw new NotImplementedException ();
- }
-
- // Individual conversion
-
- public static string AnyUriToString (string value)
- {
- return value;
- }
-
- public static byte [] Base64BinaryToHexBinary (byte [] value)
- {
- return XmlConvert.FromBinHexString (Convert.ToBase64String (value));
- }
-
- public static string Base64BinaryToString (byte [] value)
- {
- return Convert.ToBase64String (value);
- }
-
- public static decimal BooleanToDecimal (bool value)
- {
- return Convert.ToDecimal (value);
- }
-
- public static double BooleanToDouble (bool value)
- {
- return Convert.ToDouble (value);
- }
-
- public static float BooleanToFloat (bool value)
- {
- return Convert.ToSingle (value);
- }
-
- public static int BooleanToInt (bool value)
- {
- return Convert.ToInt32 (value);
- }
-
- public static long BooleanToInteger (bool value)
- {
- return Convert.ToInt64 (value);
- }
-
- public static string BooleanToString (bool value)
- {
- // It looks not returning "True"
- return value ? "true" : "false";
- }
-
- [MonoTODO]
- public static DateTime DateTimeToDate (DateTime value)
- {
- return value.Date;
- }
-
- [MonoTODO]
- public static DateTime DateTimeToGDay (DateTime value)
- {
- return new DateTime (0, 0, value.Day);
- }
-
- [MonoTODO]
- public static DateTime DateTimeToGMonth (DateTime value)
- {
- return new DateTime (0, value.Month, 0);
- }
-
- [MonoTODO]
- public static DateTime DateTimeToGYear (DateTime value)
- {
- return new DateTime (value.Year, 0, 0);
- }
-
- [MonoTODO]
- public static DateTime DateTimeToGYearMonth (DateTime value)
- {
- return new DateTime (value.Year, value.Month, 0);
- }
-
- [MonoTODO]
- public static DateTime DateToDateTime (DateTime value)
- {
- return value.Date;
- }
-
- [MonoTODO]
- public static DateTime DateToGDay (DateTime value)
- {
- return new DateTime (0, 0, value.Day);
- }
-
- [MonoTODO]
- public static DateTime DateToGMonth (DateTime value)
- {
- return new DateTime (0, value.Month, 0);
- }
-
- [MonoTODO]
- public static DateTime DateToGYear (DateTime value)
- {
- return new DateTime (value.Year, 0, 0);
- }
-
- [MonoTODO]
- public static DateTime DateToGYearMonth (DateTime value)
- {
- return new DateTime (value.Year, value.Month, 0);
- }
-
- [MonoTODO]
- public static string DateToString (DateTime value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static string DateTimeToString (DateTime value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static string DayTimeDurationToDuration (TimeSpan value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static string DayTimeDurationToString (TimeSpan value)
- {
- return DayTimeDurationToDuration (value);
- }
-
- [MonoTODO]
- public static bool DecimalToBoolean (decimal value)
- {
- return value != 0;
- }
-
- [MonoTODO]
- public static double DecimalToDouble (decimal value)
- {
- return (double) value;
- }
-
- [MonoTODO]
- public static float DecimalToFloat (decimal value)
- {
- return (float) value;
- }
-
- [MonoTODO]
- public static int DecimalToInt (decimal value)
- {
- return (int) value;
- }
-
- [MonoTODO]
- public static long DecimalToInteger (decimal value)
- {
- return (long) value;
- }
-
- [MonoTODO] // what if value was negative?
- public static decimal DecimalToNonNegativeInteger (decimal value)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO] // what if value was positive?
- public static decimal DecimalToNonPositiveInteger (decimal value)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public static string DecimalToString (decimal value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static bool DoubleToBoolean (double value)
- {
- return value != 0;
- }
-
- [MonoTODO]
- public static decimal DoubleToDecimal (double value)
- {
- return (decimal) value;
- }
-
- [MonoTODO]
- public static float DoubleToFloat (double value)
- {
- return (float) value;
- }
-
- [MonoTODO]
- public static int DoubleToInt (double value)
- {
- return (int) value;
- }
-
- [MonoTODO]
- public static long DoubleToInteger (double value)
- {
- return (long) value;
- }
-
- [MonoTODO] // what if value was negative?
- public static decimal DoubleToNonNegativeInteger (double value)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO] // what if value was positive?
- public static decimal DoubleToNonPositiveInteger (double value)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public static string DoubleToString (double value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static TimeSpan DurationToDayTimeDuration (string value)
- {
- return XmlConvert.ToTimeSpan (value);
- }
-
- [MonoTODO]
- public static string DurationToString (string value)
- {
- return XmlConvert.ToString (XmlConvert.ToTimeSpan (value));
- }
-
- [MonoTODO]
- public static TimeSpan DurationToYearMonthDuration (string value)
- {
- return XmlConvert.ToTimeSpan (value);
- }
-
-
- [MonoTODO]
- public static bool FloatToBoolean (float value)
- {
- return value != 0;
- }
-
- [MonoTODO]
- public static decimal FloatToDecimal (float value)
- {
- return (decimal) value;
- }
-
- [MonoTODO]
- public static double FloatToDouble (float value)
- {
- return (double) value;
- }
-
- [MonoTODO]
- public static int FloatToInt (float value)
- {
- return (int) value;
- }
-
- [MonoTODO]
- public static long FloatToInteger (float value)
- {
- return (long) value;
- }
-
- [MonoTODO] // what if value was negative?
- public static decimal FloatToNonNegativeInteger (float value)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO] // what if value was positive?
- public static decimal FloatToNonPositiveInteger (float value)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public static string FloatToString (float value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static string GDayToString (DateTime value)
- {
- return XmlConvert.ToString (TimeSpan.FromDays (value.Day));
- }
-
- [MonoTODO]
- public static string GMonthDayToString (DateTime value)
- {
- return XmlConvert.ToString (new TimeSpan (value.Day, value.Hour, value.Minute, value.Second));
- }
-
- [MonoTODO]
- public static string GMonthToString (DateTime value)
- {
- return XmlConvert.ToString (new TimeSpan (0, value.Month, 0));
- }
-
- [MonoTODO]
- public static string GYearMonthToString (DateTime value)
- {
- return XmlConvert.ToString (new TimeSpan (value.Year, value.Month, 0));
- }
-
- [MonoTODO]
- public static string GYearToString (DateTime value)
- {
- return XmlConvert.ToString (new TimeSpan (new DateTime (value.Year, 0, 0).Ticks));
- }
-
- public static string HexBinaryToString (byte [] data)
- {
- return XmlConvert.ToBinHexString (data);
- }
-
- public static string HexBinaryToBase64String (byte [] data)
- {
- return XmlConvert.ToBinHexString (data);
- }
-
-
- [MonoTODO]
- public static bool IntegerToBoolean (long value)
- {
- return value != 0;
- }
-
- [MonoTODO]
- public static decimal IntegerToDecimal (long value)
- {
- return (decimal) value;
- }
-
- [MonoTODO]
- public static double IntegerToDouble (long value)
- {
- return (double) value;
- }
-
- [MonoTODO]
- public static float IntegerToFloat (long value)
- {
- return (float) value;
- }
-
- [MonoTODO]
- public static int IntegerToInt (long value)
- {
- return (int) value;
- }
-
- [MonoTODO]
- public static string IntegerToString (long value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static bool IntToBoolean (int value)
- {
- return value != 0;
- }
-
- [MonoTODO]
- public static decimal IntToDecimal (int value)
- {
- return (decimal) value;
- }
-
- [MonoTODO]
- public static double IntToDouble (int value)
- {
- return (double) value;
- }
-
- [MonoTODO]
- public static float IntToFloat (int value)
- {
- return (float) value;
- }
-
- [MonoTODO]
- public static long IntToInteger (int value)
- {
- return (long) value;
- }
-
- [MonoTODO]
- public static string IntToString (int value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static string NonNegativeIntegerToString (decimal value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static string NonPositiveIntegerToString (decimal value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static DateTime TimeToDateTime (DateTime value)
- {
- return value;
- }
-
- [MonoTODO]
- public static string TimeToString (DateTime value)
- {
- return XmlConvert.ToString (value, "HH:mm:ssZ");
- }
-
- [MonoTODO]
- public static string YearMonthDurationToDuration (TimeSpan value)
- {
- return XmlConvert.ToString (value);
- }
-
- [MonoTODO]
- public static string YearMonthDurationToString (TimeSpan value)
- {
- return YearMonthDurationToDuration (value);
- }
-
- [MonoTODO]
- public static string StringToAnyUri (string value)
- {
- return value;
- }
-
- [MonoTODO]
- public static byte [] StringToBase64Binary (string value)
- {
- return Convert.FromBase64String (value);
- }
-
- [MonoTODO]
- public static bool StringToBoolean (string value)
- {
- return XmlConvert.ToBoolean (value);
- }
-
- [MonoTODO]
- public static DateTime StringToDate (string value)
- {
- return XmlConvert.ToDateTime (value);
- }
-
- [MonoTODO]
- public static DateTime StringToDateTime (string value)
- {
- return XmlConvert.ToDateTime (value);
- }
-
- [MonoTODO]
- public static TimeSpan StringToDayTimeDuration (string value)
- {
- return XmlConvert.ToTimeSpan (value);
- }
-
- [MonoTODO]
- public static decimal StringToDecimal (string value)
- {
- return XmlConvert.ToDecimal (value);
- }
-
- [MonoTODO]
- public static double StringToDouble (string value)
- {
- return XmlConvert.ToDouble (value);
- }
-
- [MonoTODO]
- public static string StringToDuration (string value)
- {
- return XmlConvert.ToString (XmlConvert.ToTimeSpan (value));
- }
-
- [MonoTODO]
- public static float StringToFloat (string value)
- {
- return XmlConvert.ToSingle (value);
- }
-
- [MonoTODO]
- public static DateTime StringToGDay (string value)
- {
- return XmlConvert.ToDateTime (value);
- }
-
- [MonoTODO]
- public static DateTime StringToGMonth (string value)
- {
- return XmlConvert.ToDateTime (value);
- }
-
- [MonoTODO]
- public static DateTime StringToGMonthDay (string value)
- {
- return XmlConvert.ToDateTime (value);
- }
-
- [MonoTODO]
- public static DateTime StringToGYear (string value)
- {
- return XmlConvert.ToDateTime (value);
- }
-
- [MonoTODO]
- public static DateTime StringToGYearMonth (string value)
- {
- return XmlConvert.ToDateTime (value);
- }
-
- [MonoTODO]
- public static byte [] StringToHexBinary (string value)
- {
- return XmlConvert.FromBinHexString (value);
- }
-
- [MonoTODO]
- public static int StringToInt (string value)
- {
- return XmlConvert.ToInt32 (value);
- }
-
- [MonoTODO]
- public static long StringToInteger (string value)
- {
- return XmlConvert.ToInt64 (value);
- }
-
- [MonoTODO]
- public static decimal StringToNonNegativeInteger (string value)
- {
- return XmlConvert.ToDecimal (value);
- }
-
- [MonoTODO]
- public static decimal StringToNonPositiveInteger (string value)
- {
- return XmlConvert.ToDecimal (value);
- }
-
- [MonoTODO]
- public static DateTime StringToTime (string value)
- {
- return XmlConvert.ToDateTime (value);
- }
-
- [MonoTODO]
- public static long StringToUnsignedInt (string value)
- {
- return XmlConvert.ToInt32 (value);
- }
-
- [MonoTODO]
- public static decimal StringToUnsignedLong (string value)
- {
- return XmlConvert.ToInt32 (value);
- }
-
- [MonoTODO]
- public static int StringToUnsignedShort (string value)
- {
- return XmlConvert.ToInt32 (value);
- }
-
- [MonoTODO]
- public static TimeSpan StringToYearMonthDuration (string value)
- {
- return XmlConvert.ToTimeSpan (value);
- }
-
- [MonoTODO]
- public static string ItemToAnyUri (XPathItem value)
- {
- return value.Value;
- }
-
- [MonoTODO]
- public static byte [] ItemToBase64Binary (XPathItem value)
- {
- return Convert.FromBase64String (value.Value);
- }
-
- [MonoTODO]
- public static bool ItemToBoolean (XPathItem value)
- {
- return XmlConvert.ToBoolean (value.Value);
- }
-
- [MonoTODO]
- public static DateTime ItemToDate (XPathItem value)
- {
- return XmlConvert.ToDateTime (value.Value);
- }
-
- [MonoTODO]
- public static DateTime ItemToDateTime (XPathItem value)
- {
- return XmlConvert.ToDateTime (value.Value);
- }
-
- [MonoTODO]
- public static TimeSpan ItemToDayTimeDuration (XPathItem value)
- {
- return XmlConvert.ToTimeSpan (value.Value);
- }
-
- [MonoTODO]
- public static decimal ItemToDecimal (XPathItem value)
- {
- return XmlConvert.ToDecimal (value.Value);
- }
-
- [MonoTODO]
- public static double ItemToDouble (XPathItem value)
- {
- return XmlConvert.ToDouble (value.Value);
- }
-
- [MonoTODO]
- public static string ItemToDuration (XPathItem value)
- {
- return XmlConvert.ToString (XmlConvert.ToTimeSpan (value.Value));
- }
-
- [MonoTODO]
- public static float ItemToFloat (XPathItem value)
- {
- return XmlConvert.ToSingle (value.Value);
- }
-
- [MonoTODO]
- public static DateTime ItemToGDay (XPathItem value)
- {
- return XmlConvert.ToDateTime (value.Value);
- }
-
- [MonoTODO]
- public static DateTime ItemToGMonth (XPathItem value)
- {
- return XmlConvert.ToDateTime (value.Value);
- }
-
- [MonoTODO]
- public static DateTime ItemToGMonthDay (XPathItem value)
- {
- return XmlConvert.ToDateTime (value.Value);
- }
-
- [MonoTODO]
- public static DateTime ItemToGYear (XPathItem value)
- {
- return XmlConvert.ToDateTime (value.Value);
- }
-
- [MonoTODO]
- public static DateTime ItemToGYearMonth (XPathItem value)
- {
- return XmlConvert.ToDateTime (value.Value);
- }
-
- [MonoTODO]
- public static byte [] ItemToHexBinary (XPathItem value)
- {
- return XmlConvert.FromBinHexString (value.Value);
- }
-
- [MonoTODO]
- public static int ItemToInt (XPathItem value)
- {
- return XmlConvert.ToInt32 (value.Value);
- }
-
- [MonoTODO]
- public static long ItemToInteger (XPathItem value)
- {
- return XmlConvert.ToInt64 (value.Value);
- }
-
- [MonoTODO]
- public static XPathItem ItemToItem (XPathItem value, XmlSchemaType schemaTypeDest)
- {
- return new XPathAtomicValue (value.Value, schemaTypeDest);
- }
-
- [MonoTODO]
- public static decimal ItemToNonNegativeInteger (XPathItem value)
- {
- return XmlConvert.ToDecimal (value.Value);
- }
-
- [MonoTODO]
- public static decimal ItemToNonPositiveInteger (XPathItem value)
- {
- return XmlConvert.ToDecimal (value.Value);
- }
-
- [MonoTODO]
- public static XmlQualifiedName ItemToQName (XPathItem value)
- {
- return (XmlQualifiedName) value.TypedValue;
- }
-
- [MonoTODO]
- public static string ItemToString (XPathItem value)
- {
- if (value.ValueType == typeof (DateTime))
- return XmlConvert.ToString ((DateTime) value.TypedValue);
- if (value.TypedValue is XmlQualifiedName)
- throw new ArgumentException ("Invalid cast from schema QName type to string type.");
- return value.Value;
- }
-
- [MonoTODO]
- public static DateTime ItemToTime (XPathItem value)
- {
- return XmlConvert.ToDateTime (value.Value);
- }
-
- [MonoTODO]
- public static long ItemToUnsignedInt (XPathItem value)
- {
- return XmlConvert.ToInt32 (value.Value);
- }
-
- [MonoTODO]
- public static decimal ItemToUnsignedLong (XPathItem value)
- {
- return XmlConvert.ToInt32 (value.Value);
- }
-
- [MonoTODO]
- public static int ItemToUnsignedShort (XPathItem value)
- {
- return XmlConvert.ToInt32 (value.Value);
- }
-
- [MonoTODO]
- public static TimeSpan ItemToYearMonthDuration (XPathItem value)
- {
- return XmlConvert.ToTimeSpan (value.Value);
- }
- }
-}
-
diff --git a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/XQueryDefaultFunctionCall.cs b/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/XQueryDefaultFunctionCall.cs
deleted file mode 100644
index f2ea8664e01..00000000000
--- a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath2/XQueryDefaultFunctionCall.cs
+++ /dev/null
@@ -1,385 +0,0 @@
-//
-// XQueryDefaultFunctionCall.cs
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.com>
-//
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-//
-// XQuery 1.0 and XPath 2.0 Functions implementation as XPathItemExpression.
-// See XQuery 1.0 and XPath 2.0 Functions and Operators.
-//
-using System;
-using System.Collections;
-using System.Reflection;
-using System.Xml;
-using System.Xml.Schema;
-using System.Xml.Query;
-using System.Xml.XPath;
-using System.Xml.Xsl;
-
-namespace Mono.Xml.XPath2
-{
- internal abstract class DefaultFunctionCall : FunctionCallExprBase
- {
- static Hashtable qnameTable = new Hashtable ();
- static XmlQualifiedName GetName (string name)
- {
- XmlQualifiedName qname = qnameTable [name] as XmlQualifiedName;
- if (qname == null) {
- qname = new XmlQualifiedName (name, XQueryFunction.Namespace);
- qnameTable.Add (name, qname);
- }
- return qname;
- }
-
- public DefaultFunctionCall (XQueryStaticContext ctx, string name, int minArgs, int maxArgs, SequenceType type, ExprSequence args)
- : base (GetName (name), args)
- {
- this.type = type;
- this.minArgs = minArgs;
- this.maxArgs = maxArgs;
- }
-
- SequenceType type;
- int minArgs;
- int maxArgs;
-
- public override int MinArgs { get { return minArgs; } }
- public override int MaxArgs { get { return maxArgs; } }
-
- public override SequenceType StaticType {
- get { return type; }
- }
- }
-
- // Accessors
-
- // 2.1 fn:node-name ($arg as node ()?) as xs:QName?
- internal class FnNodeNameCall : DefaultFunctionCall
- {
- public FnNodeNameCall (XQueryStaticContext ctx, ExprSequence args)
- : base (ctx, "node-name", 1, 1, SequenceType.Create (XmlSchemaSimpleType.XsQName, Occurence.Optional), args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- XPathSequence res = Args [0].Evaluate (iter);
- if (!res.MoveNext ())
- return new XPathEmptySequence (iter.Context);
- // FIXME: what happens if context item is not a node.
- XPathNavigator nav = res.Current as XPathNavigator;
- if (nav == null || nav.LocalName == String.Empty)
- return new XPathEmptySequence (iter.Context);
- return new SingleItemIterator (new XPathAtomicValue (new XmlQualifiedName (nav.LocalName, nav.NamespaceURI), XmlSchemaSimpleType.XsQName), iter);
- }
- }
-
- // 2.2 fn:nilled ($arg as node()) as xs:boolean?
- internal class FnNilledCall : DefaultFunctionCall
- {
- public FnNilledCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "nilled", 1, 1, SequenceType.Create (XmlSchemaSimpleType.XsBoolean, Occurence.One), args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- XPathSequence res = Args [0].Evaluate (iter);
- if (!res.MoveNext ())
- return new XPathEmptySequence (iter.Context);
- XPathNavigator nav = res.Current as XPathNavigator;
- IXmlSchemaInfo info = nav.NodeType == XPathNodeType.Element ? nav.SchemaInfo : null;
- if (info != null)
- return new SingleItemIterator (new XPathAtomicValue (info.IsNil, null), iter);
- else
- return new XPathEmptySequence (iter.Context);
- }
- }
-
- // 2.3 fn:string ($arg as item()?) as xs:string
- internal class FnStringCall : DefaultFunctionCall
- {
- public FnStringCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "string", 0, 1, SequenceType.Create (XmlSchemaSimpleType.XsString, Occurence.Optional), args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- XPathItem item = null;
- if (Args.Length == 0)
- item = iter.Context.CurrentItem;
- else {
- XPathSequence res = Args [0].Evaluate (iter);
- if (!res.MoveNext ())
- return new XPathEmptySequence (iter.Context);
- item = res.Current;
- }
- return new SingleItemIterator (new XPathAtomicValue (Core (item), null), iter);
- }
-
- private string Core (XPathItem item)
- {
- XPathNavigator nav = item as XPathNavigator;
-
- return nav != null ? nav.Value : XQueryConvert.ItemToString (item);
- }
- }
-
- // 2.4 fn:data ($arg as item()*) as xdt:anyAtomicType*
- internal class FnDataCall : DefaultFunctionCall
- {
- public FnDataCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "data", 1, 1, SequenceType.Create (XmlSchemaComplexType.AnyType, Occurence.ZeroOrMore), args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- return new AtomizingIterator (Args [0].Evaluate (iter));
- }
- }
-
- // 2.5 fn:base-uri ($arg as node()?) as xs:anyURI?
- internal class FnBaseUriCall : DefaultFunctionCall
- {
- public FnBaseUriCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "base-uri", 1, 1, SequenceType.Create (XmlSchemaSimpleType.XsAnyUri, Occurence.Optional), args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- XPathSequence res = Args [0].Evaluate (iter);
- if (res.MoveNext ())
- return new XPathEmptySequence (iter.Context);
- XPathNavigator nav = res.Current as XPathNavigator;
- if (nav == null)
- return new XPathEmptySequence (iter.Context);
- else
- return new SingleItemIterator (new XPathAtomicValue (nav.BaseURI, XmlSchemaSimpleType.XsString), iter);
- }
- }
-
- // 2.6 fn:document-uri ($arg as node()?) as xs:anyURI?
- internal class FnDocumentUriCall : DefaultFunctionCall
- {
- public FnDocumentUriCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "document-uri", 1, 1, SequenceType.Create (XmlSchemaSimpleType.XsAnyUri, Occurence.Optional), args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- XPathSequence res = Args [0].Evaluate (iter);
- if (res.MoveNext ())
- return new XPathEmptySequence (iter.Context);
- XPathNavigator nav = res.Current as XPathNavigator;
- if (nav == null)
- return new XPathEmptySequence (iter.Context);
- nav = nav.Clone ();
- nav.MoveToRoot ();
- return new SingleItemIterator (new XPathAtomicValue (nav.BaseURI, null), iter);
- }
- }
-
- // 3 fn:error ()
- // fn:error ($error as xs:QName)
- // fn:error ($error as xs:QName, $description as xs:string)
- // fn:error ($error as xs:QName, $description as xs:string, $error-object as item()*)
- internal class FnErrorCall : DefaultFunctionCall
- {
- public FnErrorCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- // FIXME: return type is actually none
- : base (ctx, "error", 0, 3, SequenceType.AnyType, args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- // error name
- XPathSequence errorNameIter = Args.Length > 0 ? Args [0].Evaluate (iter) : null;
- XmlQualifiedName errorType = XmlQualifiedName.Empty;
- if (errorNameIter != null && errorNameIter.MoveNext ())
- errorType = XQueryConvert.ItemToQName (errorNameIter.Current);
-
- // description
- string description = Args.Length > 1 ? Args [1].EvaluateAsString (iter) : String.Empty;
-
- // error-object
- XPathSequence errorObjIter = Args.Length > 2 ? Args [2].Evaluate (iter) : null;
-
- // FIXME: add error-object information
- throw new XmlQueryException (errorType + description);
- }
- }
-
- // 4 trace ($value as item()*, $label as xs:string) as item()*
- internal class FnTraceCall : DefaultFunctionCall
- {
- public FnTraceCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "trace", 2, 2, SequenceType.Create (XmlSchemaComplexType.AnyType, Occurence.ZeroOrMore), args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- return new TracingIterator (Args [0].Evaluate (iter), Args [1].EvaluateAsString (iter));
- }
- }
-
- // 5 constructor functions
- internal class AtomicConstructorCall : DefaultFunctionCall
- {
- // FIXME: use IXmlNamespaceResolver.LookupPrefix() in ctx
- public AtomicConstructorCall (XQueryStaticContext ctx, SequenceType type, XPathItemExpression [] args)
- : base (ctx, type.SchemaType.QualifiedName.Name, 1, 1, type, args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- return new SingleItemIterator (XQueryConvert.ItemToItem (Atomize (Args [0].Evaluate (iter)), null), iter);
- }
- }
-
- // 6 functions on numerics (operators are not defined here)
-
- // 6.4.1 fn:abs ($arg as numeric?) as numeric?
- internal class FnAbsCall : DefaultFunctionCall
- {
- public FnAbsCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "abs", 1, 1, args [0].StaticType, args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- XPathSequence arg = Args [0].Evaluate (iter);
- if (!arg.MoveNext ())
- return new XPathEmptySequence (iter.Context);
- XPathAtomicValue a = null;
- // FIXME: use schema type IsDerivedFrom()
- switch (Type.GetTypeCode (arg.Current.ValueType)) {
- case TypeCode.Int64:
- return new SingleItemIterator (new XPathAtomicValue (System.Math.Abs (arg.Current.ValueAsInt64), arg.Current.XmlType), iter);
- case TypeCode.Int32:
- return new SingleItemIterator (new XPathAtomicValue (System.Math.Abs (arg.Current.ValueAsInt32), arg.Current.XmlType), iter);
- case TypeCode.Double:
- return new SingleItemIterator (new XPathAtomicValue (System.Math.Abs (arg.Current.ValueAsDouble), arg.Current.XmlType), iter);
- case TypeCode.Decimal:
- return new SingleItemIterator (new XPathAtomicValue (System.Math.Abs (arg.Current.ValueAsDecimal), arg.Current.XmlType), iter);
- case TypeCode.Single:
- return new SingleItemIterator (new XPathAtomicValue (System.Math.Abs (arg.Current.ValueAsSingle), arg.Current.XmlType), iter);
- }
- return new XPathEmptySequence (iter.Context);
- }
- }
-
- // 6.4.2 fn:ceiling ($arg as numeric?) as numeric?
- internal class FnCeilingCall : DefaultFunctionCall
- {
- public FnCeilingCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "ceiling", 1, 1, args [0].StaticType, args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- throw new NotImplementedException ();
- }
- }
-
- // 6.4.3 fn:floor ($arg as numeric?) as numeric?
- internal class FnFloorCall : DefaultFunctionCall
- {
- public FnFloorCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "floor", 1, 1, args [0].StaticType, args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- throw new NotImplementedException ();
- }
- }
-
- // 6.4.4 fn:round ($arg as numeric?) as numeric?
- internal class FnRoundCall : DefaultFunctionCall
- {
- public FnRoundCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "round", 1, 1, args [0].StaticType, args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- throw new NotImplementedException ();
- }
- }
-
- // 6.4.5 fn:round-half-to-even ($arg as numeric?) as numeric?
- internal class FnRoundHalfToEvenCall : DefaultFunctionCall
- {
- public FnRoundHalfToEvenCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "round-half-to-even", 1, 2, args [0].StaticType, args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- throw new NotImplementedException ();
- }
- }
-
- // 7.2.1 fn:codepoints-to-string ($arg as xs:integer*) as xs:string
- internal class FnCodepointsToStringCall : DefaultFunctionCall
- {
- public FnCodepointsToStringCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "codepoints-to-string", 1, 1, SequenceType.IntegerList, args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- throw new NotImplementedException ();
- }
- }
-
- internal class FnStringCallToCodepointsCall : DefaultFunctionCall
- {
- public FnStringCallToCodepointsCall (XQueryStaticContext ctx, XPathItemExpression [] args)
- : base (ctx, "string-to-codepoints", 1, 1, SequenceType.Create (XmlSchemaSimpleType.XsString, Occurence.Optional), args)
- {
- }
-
- public override XPathSequence Evaluate (XPathSequence iter)
- {
- throw new NotImplementedException ();
- }
- }
-}