diff options
Diffstat (limited to 'mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs')
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs | 116 |
1 files changed, 65 insertions, 51 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs b/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs index 1981ed85a48..6280e3d1bba 100644 --- a/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs +++ b/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs @@ -44,16 +44,33 @@ namespace Mono.Xml.XPath class DTMXPathNavigator2 : XPathNavigator, IXmlLineInfo { - public DTMXPathNavigator2 (DTMXPathDocument2 document) + public DTMXPathNavigator2 (DTMXPathDocument2 document, + XmlNameTable nameTable, + DTMXPathLinkedNode2 [] nodes, + DTMXPathAttributeNode2 [] attributes, + DTMXPathNamespaceNode2 [] namespaces, + string [] atomicStringPool, + string [] nonAtomicStringPool, + Hashtable idTable) { + this.nodes = nodes; + this.attributes = attributes; + this.namespaces = namespaces; + this.atomicStringPool = atomicStringPool; + this.nonAtomicStringPool = nonAtomicStringPool; + this.idTable = idTable; + this.nameTable = nameTable; this.MoveToRoot (); this.document = document; } // Copy constructor including position informations. public DTMXPathNavigator2 (DTMXPathNavigator2 org) + : this (org.document, org.nameTable, + org.nodes, org.attributes, org.namespaces, + org.atomicStringPool, org.nonAtomicStringPool, + org.idTable) { - document = org.document; currentIsNode = org.currentIsNode; currentIsAttr = org.currentIsAttr; @@ -62,33 +79,21 @@ namespace Mono.Xml.XPath currentNs = org.currentNs; } - XmlNameTable nameTable { - get { return document.NameTable; } - } + XmlNameTable nameTable; // Created XPathDocument. This is used to identify the origin of the navigator. DTMXPathDocument2 document; - DTMXPathLinkedNode2 [] nodes { - get { return document.Nodes; } - } - DTMXPathAttributeNode2 [] attributes { - get { return document.Attributes; } - } - DTMXPathNamespaceNode2 [] namespaces { - get { return document.Namespaces; } - } - string [] atomicStringPool { - get { return document.AtomicStringPool; } - } - string [] nonAtomicStringPool { - get { return document.NonAtomicStringPool; } - } + DTMXPathLinkedNode2 [] nodes;// = new DTMXPathLinkedNode [0]; + DTMXPathAttributeNode2 [] attributes;// = new DTMXPathAttributeNode [0]; + DTMXPathNamespaceNode2 [] namespaces;// = new DTMXPathNamespaceNode [0]; + + // String pool + string [] atomicStringPool; + string [] nonAtomicStringPool; // ID table - Hashtable idTable { - get { return document.IdTable; } - } + Hashtable idTable; bool currentIsNode; bool currentIsAttr; @@ -97,6 +102,17 @@ namespace Mono.Xml.XPath int currentAttr; int currentNs; + StringBuilder valueBuilder; + +#region Ctor + + internal DTMXPathNavigator2 (XmlNameTable nt) + { + this.nameTable = nt; + } + +#endregion + #region Properties public override string BaseURI { @@ -217,36 +233,34 @@ namespace Mono.Xml.XPath if (iter == 0) return String.Empty; - StringBuilder builder = null; - BuildValue (iter, ref builder); - return builder == null ? String.Empty : builder.ToString (); - } - } - - void BuildValue (int iter, ref StringBuilder valueBuilder) - { - int end = nodes [currentNode].NextSibling; - if (end == 0) { - int tmp = currentNode; - do { - tmp = nodes [tmp].Parent; - end = nodes [tmp].NextSibling; - } while (end == 0 && tmp != 0); - if (end == 0) - end = nodes.Length; - } + if (valueBuilder == null) + valueBuilder = new StringBuilder (); + else + valueBuilder.Length = 0; + + int end = nodes [currentNode].NextSibling; + if (end == 0) { + int tmp = currentNode; + do { + tmp = nodes [tmp].Parent; + end = nodes [tmp].NextSibling; + } while (end == 0 && tmp != 0); + if (end == 0) + end = nodes.Length; + } - while (iter < end) { - switch (nodes [iter].NodeType) { - case XPathNodeType.Text: - case XPathNodeType.SignificantWhitespace: - case XPathNodeType.Whitespace: - if (valueBuilder == null) - valueBuilder = new StringBuilder (); - valueBuilder.Append (nonAtomicStringPool [nodes [iter].Value]); - break; + while (iter < end) { + switch (nodes [iter].NodeType) { + case XPathNodeType.Text: + case XPathNodeType.SignificantWhitespace: + case XPathNodeType.Whitespace: + valueBuilder.Append (nonAtomicStringPool [nodes [iter].Value]); + break; + } + iter++; } - iter++; + + return valueBuilder.ToString (); } } |