string [] value__,
string [] xmlLang__,
int [] namespaceNode__,
- object [] schemaType__,
+ int [] nodeLineNumber__,
+ int [] nodeLinePosition__,
int [] ownerElement__,
int [] nextAttribute__,
string [] attrLocalName__,
string [] attrNsUri__,
string [] attrValue__,
object [] attrSchemaType__,
+ int [] attrLineNumber__,
+ int [] attrLinePosition__,
int [] nsDeclaredElement__,
int [] nextNsNode__,
string [] nsNodeName__,
value_ = value__;
xmlLang_ = xmlLang__;
namespaceNode_ = namespaceNode__;
- schemaType_ = schemaType__;
+ nodeLineNumber_ = nodeLineNumber__;
+ nodeLinePosition_ = nodeLinePosition__;
// Attribute
ownerElement_ = ownerElement__;
attrNsUri_ = attrNsUri__;
attrValue_ = attrValue__;
attrSchemaType_ = attrSchemaType__;
+ attrLineNumber_ = attrLineNumber__;
+ attrLinePosition_ = attrLinePosition__;
// NamespaceNode
nsDeclaredElement_ = nsDeclaredElement__;
public XPathNavigator CreateNavigator ()
{
if (root == null) {
- root = new DTMXPathNavigator (this, nameTable, firstChild_, parent_, firstAttribute_, previousSibling_, nextSibling_, depth_, position_, nodeType_, baseUri_, isEmptyElement_, localName_, namespaceUri_, prefix_, value_, xmlLang_, namespaceNode_, schemaType_, ownerElement_, nextAttribute_, attrLocalName_, attrPrefix_, attrNsUri_, attrValue_, attrSchemaType_, nsDeclaredElement_, nextNsNode_, nsNodeName_, nsNodeUri_, idTable_);
+ root = new DTMXPathNavigator (this,
+ nameTable,
+ firstChild_,
+ parent_,
+ firstAttribute_,
+ previousSibling_,
+ nextSibling_,
+ depth_,
+ position_,
+ nodeType_,
+ baseUri_,
+ isEmptyElement_,
+ localName_,
+ namespaceUri_,
+ prefix_,
+ value_,
+ xmlLang_,
+ namespaceNode_,
+ nodeLineNumber_,
+ nodeLinePosition_,
+ ownerElement_,
+ nextAttribute_,
+ attrLocalName_,
+ attrPrefix_,
+ attrNsUri_,
+ attrValue_,
+ attrSchemaType_,
+ attrLineNumber_,
+ attrLinePosition_,
+ nsDeclaredElement_,
+ nextNsNode_,
+ nsNodeName_,
+ nsNodeUri_,
+ idTable_);
return root;
} else
return root.Clone ();
string [] value_;
string [] xmlLang_;
int [] namespaceNode_;
- object [] schemaType_; // for XPath 2.0
+ int [] nodeLineNumber_;
+ int [] nodeLinePosition_;
// Attribute
int [] ownerElement_;
string [] attrPrefix_;
string [] attrNsUri_;
string [] attrValue_;
- object [] attrSchemaType_; // for XPath 2.0
+ object [] attrSchemaType_; // for id()
+ int [] attrLineNumber_;
+ int [] attrLinePosition_;
// NamespaceNode
int [] nsDeclaredElement_; // the Element that declares NS, or Root.
public class DTMXPathDocumentBuilder
{
public DTMXPathDocumentBuilder (string url)
- : this (url, XmlSpace.None, false)
+ : this (url, XmlSpace.None, false, 100)
{
}
public DTMXPathDocumentBuilder (string url, XmlSpace space)
- : this (url, space, false)
+ : this (url, space, false, 100)
{
}
- public DTMXPathDocumentBuilder (string url, XmlSpace space, bool supportID)
- : this (new XmlTextReader (url), space, supportID)
+ public DTMXPathDocumentBuilder (string url, XmlSpace space, bool supportID, int defaultCapacity)
+ : this (new XmlTextReader (url), space, supportID, defaultCapacity)
{
}
public DTMXPathDocumentBuilder (XmlReader reader)
- : this (reader, XmlSpace.None, false)
+ : this (reader, XmlSpace.None, false, 100)
{
}
public DTMXPathDocumentBuilder (XmlReader reader, XmlSpace space)
- : this (reader, space, false)
+ : this (reader, space, false, 100)
{
}
- public DTMXPathDocumentBuilder (XmlReader reader, XmlSpace space, bool supportID)
+ public DTMXPathDocumentBuilder (XmlReader reader, XmlSpace space, bool supportID, int defaultCapacity)
{
this.xmlReader = reader;
if (supportID)
this.validatingReader = reader as XmlValidatingReader;
+ lineInfo = reader as IXmlLineInfo;
this.xmlSpace = xmlSpace;
this.nameTable = reader.NameTable;
+ DefaultCapacity = defaultCapacity;
Compile ();
}
XmlValidatingReader validatingReader;
XmlSpace xmlSpace;
XmlNameTable nameTable;
+ IXmlLineInfo lineInfo;
int defaultCapacity = 100;
public int DefaultCapacity {
get { return defaultCapacity; }
string [] value_ = new string [0];
string [] xmlLang_ = new string [0];
int [] namespaceNode_ = new int [0];
- object [] schemaType_ = new object [0];
+ int [] nodeLineNumber_ = new int [0];
+ int [] nodeLinePosition_ = new int [0];
// Attribute
int [] ownerElement_ = new int [0];
string [] attrNsUri_ = new string [0];
string [] attrValue_ = new string [0];
object [] attrSchemaType_ = new object [0];
+ int [] attrLineNumber_ = new int [0];
+ int [] attrLinePosition_ = new int [0];
// NamespaceNode
int [] nsDeclaredElement_ = new int [100];
value_,
xmlLang_,
namespaceNode_,
- schemaType_,
+ nodeLineNumber_,
+ nodeLinePosition_,
// Attribute
ownerElement_,
attrNsUri_,
attrValue_,
attrSchemaType_,
+ attrLineNumber_,
+ attrLinePosition_,
// NamespaceNode
nsDeclaredElement_,
// index 0 is dummy. No node (including Root) is assigned to this index
// So that we can easily compare index != 0 instead of index < 0.
// (Difference between jnz or jbe in 80x86.)
- AddNode (0, 0, 0, 0, 0, 0, XPathNodeType.All, "", false, "", "", "", "", "", 0, null);
+ AddNode (0, 0, 0, 0, 0, 0, XPathNodeType.All, "", false, "", "", "", "", "", 0, 0, 0);
nodeIndex++;
- AddAttribute (0, null, null, null, null, null);
+ AddAttribute (0, null, null, null, null, null, 0, 0);
nextAttribute_ [0] = 0;
AddNsNode (0, null, null);
nsIndex++;
nextNsNode_ [1] = 0;
// add root.
- AddNode (0, 0, 0, 0, -1, 0, XPathNodeType.Root, xmlReader.BaseURI, false, "", "", "", "", "", 1, null);
+ AddNode (0, 0, 0, 0, -1, 0, XPathNodeType.Root, xmlReader.BaseURI, false, "", "", "", "", "", 1, 0, 0);
this.nodeIndex = 1;
this.requireFirstChildFill = true;
value,
xmlReader.XmlLang,
nsIndex,
- null); // schemaType
+ lineInfo != null ? lineInfo.LineNumber : 0,
+ lineInfo != null ? lineInfo.LinePosition : 0);
// this code is tricky, but after ReadString() invokation,
// xmlReader is moved to next node!!
if (value == null)
} else {
// add attribute node.
attributeIndex ++;
- this.AddAttribute (nodeIndex, xmlReader.LocalName, xmlReader.NamespaceURI, xmlReader.Prefix != null ? xmlReader.Prefix : String.Empty, xmlReader.Value, null);
+ this.AddAttribute (nodeIndex,
+ xmlReader.LocalName,
+ xmlReader.NamespaceURI,
+ xmlReader.Prefix != null ? xmlReader.Prefix : String.Empty,
+ xmlReader.Value,
+ null,
+ lineInfo != null ? lineInfo.LineNumber : 0,
+ lineInfo != null ? lineInfo.LinePosition : 0);
if (firstAttributeIndex == 0)
firstAttributeIndex = attributeIndex;
else
"", // Element has no internal value.
xmlReader.XmlLang,
nsIndex,
- null); // schemaType
+ lineInfo != null ? lineInfo.LineNumber : 0,
+ lineInfo != null ? lineInfo.LinePosition : 0);
if (!xmlReader.IsEmptyElement)
requireFirstChildFill = true;
}
SetStringArrayLength (ref value_, size);
SetStringArrayLength (ref xmlLang_, size);
SetIntArrayLength (ref namespaceNode_, size);
- SetObjectArrayLength (ref schemaType_, size);
+ SetIntArrayLength (ref nodeLineNumber_, size);
+ SetIntArrayLength (ref nodeLinePosition_, size);
}
private void SetAttributeArraysLength (int size)
SetStringArrayLength (ref attrNsUri_, size);
SetStringArrayLength (ref attrValue_, size);
SetObjectArrayLength (ref attrSchemaType_, size);
+ SetIntArrayLength (ref attrLineNumber_, size);
+ SetIntArrayLength (ref attrLinePosition_, size);
}
private void SetNsArraysLength (int size)
}
// Here followings are skipped: firstChild, nextSibling,
- public void AddNode (int parent, int firstAttribute, int attributeEnd, int previousSibling, int depth, int position, XPathNodeType nodeType, string baseUri, bool isEmptyElement, string localName, string ns, string prefix, string value, string xmlLang, int namespaceNode, object schemaType)
+ public void AddNode (int parent, int firstAttribute, int attributeEnd, int previousSibling, int depth, int position, XPathNodeType nodeType, string baseUri, bool isEmptyElement, string localName, string ns, string prefix, string value, string xmlLang, int namespaceNode, int lineNumber, int linePosition)
{
if (firstChild_.Length < nodeIndex + 1) {
if (firstChild_.Length >= defaultCapacity)
value_ [nodeIndex] = value;
xmlLang_ [nodeIndex] = xmlLang;
namespaceNode_ [nodeIndex] = namespaceNode;
- schemaType_ [nodeIndex] = schemaType;
+ nodeLineNumber_ [nodeIndex] = lineNumber;
+ nodeLinePosition_ [nodeIndex] = linePosition;
}
// Followings are skipped: nextAttribute,
- public void AddAttribute (int ownerElement, string localName, string ns, string prefix, string value, object schemaType)
+ public void AddAttribute (int ownerElement, string localName, string ns, string prefix, string value, object schemaType, int lineNumber, int linePosition)
{
if (ownerElement_.Length < attributeIndex + 1) {
if (ownerElement_.Length >= defaultCapacity)
attrPrefix_ [attributeIndex] = prefix;
attrValue_ [attributeIndex] = value;
attrSchemaType_ [attributeIndex] = schemaType;
+ attrLineNumber_ [attributeIndex] = lineNumber;
+ attrLinePosition_ [attributeIndex] = linePosition;
}
// Followings are skipped: nextNsNode (may be next attribute in the same element, or ancestors' nsNode)
namespace Mono.Xml.XPath
{
- public class DTMXPathNavigator : XPathNavigator
+ public class DTMXPathNavigator : XPathNavigator, IXmlLineInfo
{
#region Copy of XPathDocument
string [] localName__, string [] namespaceUri__,
string [] prefix__, string [] value__,
string [] xmlLang__, int [] namespaceNode__,
- object [] schemaType__, int [] ownerElement__,
+ int [] nodeLineNumber__, int [] nodeLinePosition__,
+ int [] ownerElement__,
int [] nextAttribute__, string [] attrLocalName__,
string [] attrPrefix__, string [] attrNsUri__,
string [] attrValue__, object [] attrSchemaType__,
+ int [] attrLineNumber__, int [] attrLinePosition__,
int [] nsDeclaredElement__, int [] nextNsNode__,
string [] nsNodeName__, string [] nsNodeUri__,
Hashtable idTable__)
value_ = value__;
xmlLang_ = xmlLang__;
namespaceNode_ = namespaceNode__;
- schemaType_ = schemaType__;
+ nodeLineNumber_ = nodeLineNumber__;
+ nodeLinePosition_ = nodeLinePosition__;
// Attribute
ownerElement_ = ownerElement__;
attrNsUri_ = attrNsUri__;
attrValue_ = attrValue__;
attrSchemaType_ = attrSchemaType__;
+ attrLineNumber_ = attrLineNumber__;
+ attrLinePosition_ = attrLinePosition__;
// NamespaceNode
nsDeclaredElement_ = nsDeclaredElement__;
org.position_, org.nodeType_, org.baseUri_,
org.isEmptyElement_, org.localName_, org.namespaceUri_,
org.prefix_, org.value_, org.xmlLang_,
- org.namespaceNode_, org.schemaType_, org.ownerElement_,
+ org.namespaceNode_, org.nodeLineNumber_, org.nodeLinePosition_,
+ org.ownerElement_,
org.nextAttribute_, org.attrLocalName_, org.attrPrefix_,
org.attrNsUri_, org.attrValue_, org.attrSchemaType_,
+ org.attrLineNumber_, org.attrLinePosition_,
org.nsDeclaredElement_, org.nextNsNode_, org.nsNodeName_,
org.nsNodeUri_, org.idTable_)
{
string [] value_;
string [] xmlLang_;
int [] namespaceNode_;
- object [] schemaType_; // for XPath 2.0
+ int [] nodeLineNumber_;
+ int [] nodeLinePosition_;
// Attribute
int [] ownerElement_;
string [] attrPrefix_;
string [] attrNsUri_;
string [] attrValue_;
- object [] attrSchemaType_; // for XPath 2.0
+ object [] attrSchemaType_; // for id()
+ int [] attrLineNumber_;
+ int [] attrLinePosition_;
// NamespaceNode
int [] nsDeclaredElement_; // the Element that declares NS.
get { return currentIsNode ? isEmptyElement_ [currentNode] : false; }
}
+ int IXmlLineInfo.LineNumber {
+ get {
+ return currentIsAttr ? attrLineNumber_ [currentAttr] :
+ nodeLineNumber_ [currentNode];
+ }
+ }
+
+ int IXmlLineInfo.LinePosition {
+ get {
+ return currentIsAttr ? attrLinePosition_ [currentAttr] :
+ nodeLinePosition_ [currentNode];
+ }
+ }
+
public override string LocalName {
get { return currentIsNode ? localName_ [currentNode] : currentIsAttr ? attrLocalName_ [currentAttr] : nsNodeName_ [currentNs]; }
}
return String.Empty;
}
+ bool IXmlLineInfo.HasLineInfo ()
+ {
+ return true;
+ }
+
public override bool IsDescendant (XPathNavigator nav)
{
DTMXPathNavigator another = nav as DTMXPathNavigator;