本文整理汇总了C#中System.Xml.XPath.XPathNavigator.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.Clone方法的具体用法?C# XPathNavigator.Clone怎么用?C# XPathNavigator.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.Clone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseXML
public override bool ParseXML(XPathNavigator node)
{
XPathNavigator child = node.Clone();
base.ParseXML(child);
child = node.Clone();
if(child.MoveToChild("name", String.Empty))
name = child.Value;
return true;
}
示例2: XPathNavigatorReader
public XPathNavigatorReader (XPathNavigator nav)
{
// It seems that this class have only to support linked
// node as its parameter
switch (nav.NodeType) {
case XPathNodeType.Attribute:
case XPathNodeType.Namespace:
throw new InvalidOperationException (String.Format ("NodeType {0} is not supported to read as a subtree of an XPathNavigator.", nav.NodeType));
}
root = nav.Clone ();
current = nav.Clone ();
}
示例3: ParseXML
public bool ParseXML(XPathNavigator node)
{
XPathNavigator child = node.Clone();
if(child.MoveToChild("id", String.Empty))
ID = child.ValueAsInt;
child = node.Clone();
if(child.MoveToChild("code", String.Empty))
Code = child.Value;
child = node.Clone();
if(child.MoveToChild("name", String.Empty))
Name = child.Value;
return true;
}
示例4: SchematronValidationEventArgs
/// <summary>
/// Creates a new instance of the <see cref="SchematronValidationEventArgs"/>.
/// </summary>
/// <param name="schematron">The <see cref="SchematronDocument"/> that detected the event.</param>
/// <param name="queryEngine">The <see cref="IQueryLanguage"/> that detected the event.</param>
/// <param name="pattern">The active <see cref="Pattern"/>.</param>
/// <param name="rule">The <see cref="Sepia.Schematron.Rule"/> that caused the event to be raised.</param>
/// <param name="assertion">The <see cref="Sepia.Schematron.Assertion"/> that caused the event to be raised.</param>
/// <param name="context">An <see cref="object"/> that provides the context for the <paramref name="rule"/> and <paramref name="assertion"/>.</param>
/// <param name="instance">An <see cref="XPathNavigator"/> to the document node that cause the event to be raised.</param>
public SchematronValidationEventArgs(SchematronDocument schematron, IQueryLanguage queryEngine, Pattern pattern, Rule rule, Assertion assertion, object context, XPathNavigator instance)
{
this.schematron = schematron;
this.queryEngine = queryEngine;
this.pattern = pattern;
this.rule = rule;
this.assertion = assertion;
this.instance = instance.Clone();
if (assertion == null)
{
message = "A schematron validation event occured.";
}
else
{
message = assertion.Message.ToString(instance, context);
}
List<string> diagnostics = new List<string>();
if (assertion != null && !string.IsNullOrEmpty(assertion.Diagnostics))
{
foreach (string id in assertion.Diagnostics.Split(' '))
{
Diagnostic diagnostic = schematron.Diagnostics[id];
diagnostics.Add(diagnostic.Message.ToString(instance, context));
}
}
this.diagnostics = diagnostics.ToArray();
}
示例5: MatchNode
public override XPathNavigator MatchNode(XPathNavigator context)
{
if (context != null)
{
if (!this.abbrAxis)
{
throw XPathException.Create("Xp_InvalidPattern");
}
XPathNavigator navigator = null;
if (this.matches(context))
{
if (this.matchSelf && ((navigator = base.qyInput.MatchNode(context)) != null))
{
return navigator;
}
XPathNavigator current = context.Clone();
while (current.MoveToParent())
{
navigator = base.qyInput.MatchNode(current);
if (navigator != null)
{
return navigator;
}
}
}
}
return null;
}
示例6: Advance
public override XPathNavigator Advance() {
while (true) {
if (currentNode == null) {
if (nextInput == null) {
nextInput = FetchInput(); // This can happen at the begining and at the end
}
if (elementStk.Count == 0) {
if (nextInput == null) {
return null;
}
currentNode = nextInput;
nextInput = FetchInput();
} else {
currentNode = elementStk.Pop();
}
}
while (currentNode.IsDescendant(nextInput)) {
elementStk.Push(currentNode);
currentNode = nextInput;
nextInput = qyInput.Advance();
if (nextInput != null) {
nextInput = nextInput.Clone();
}
}
while (currentNode.MoveToNext()) {
if (matches(currentNode)) {
position++;
return currentNode;
}
}
currentNode = null;
}
} // Advance
示例7: AddToStack
void AddToStack(XPathNavigator current)
{
XmlNodeOrder compare;
for (int i=0; i< ElementList.Count ; i++)
{
XPathNavigator nav = ElementList[i] as XPathNavigator;
compare = nav.ComparePosition(current) ;
if (compare == XmlNodeOrder.Same ) return;
if (compare == XmlNodeOrder.Before)
{
ElementList.Insert(i,current.Clone());
return;
}
}
ElementList.Add(current.Clone());
}
示例8: Create
static public XPathNavigatorReader Create(XPathNavigator navToRead)
{
XPathNavigator nav = navToRead.Clone();
IXmlLineInfo xli = nav as IXmlLineInfo;
IXmlSchemaInfo xsi = nav as IXmlSchemaInfo;
#if NAVREADER_SUPPORTSLINEINFO
if (null == xsi) {
if (null == xli) {
return new XPathNavigatorReader(nav, xli, xsi);
}
else {
return new XPathNavigatorReaderWithLI(nav, xli, xsi);
}
}
else {
if (null == xli) {
return new XPathNavigatorReaderWithSI(nav, xli, xsi);
}
else {
return new XPathNavigatorReaderWithLIAndSI(nav, xli, xsi);
}
}
#else
if (null == xsi)
{
return new XPathNavigatorReader(nav, xli, xsi);
}
else
{
return new XPathNavigatorReaderWithSI(nav, xli, xsi);
}
#endif
}
示例9: GetInnerXml
// get InnerXml without changing the spacing
public static string GetInnerXml (XPathNavigator node) {
// check for null argument, and clone so we don't change input
if (node == null) throw new ArgumentNullException("node");
XPathNavigator current = node.Clone();
// create appropriate settings for the output writer
XmlWriterSettings settings = new XmlWriterSettings();
settings.ConformanceLevel = ConformanceLevel.Fragment;
settings.OmitXmlDeclaration = true;
// construct a writer for our output
StringBuilder builder = new StringBuilder();
XmlWriter writer = XmlWriter.Create(builder, settings);
// write the output
bool writing = current.MoveToFirstChild();
while (writing) {
current.WriteSubtree(writer);
writing = current.MoveToNext();
}
// finish up and return the result
writer.Close();
return(builder.ToString());
}
示例10: XPathSimpleIterator
public XPathSimpleIterator(XPathBaseIterator parent) : base (parent)
{
this.parent = parent;
navigator = parent.Current.Clone();
current = navigator.Clone();
pos = 0;
}
示例11: MatchNode
public override XPathNavigator MatchNode(XPathNavigator context)
{
if (context != null)
{
if (!abbrAxis)
{
throw XPathException.Create(SR.Xp_InvalidPattern);
}
XPathNavigator result = null;
if (matches(context))
{
if (matchSelf)
{
if ((result = qyInput.MatchNode(context)) != null)
{
return result;
}
}
XPathNavigator anc = context.Clone();
while (anc.MoveToParent())
{
if ((result = qyInput.MatchNode(anc)) != null)
{
return result;
}
}
}
}
return null;
}
示例12: FullName
static void FullName(XPathNavigator navigator, StringBuilder s)
{
if (navigator.NodeType == XPathNodeType.Root)
return;
string name = navigator.Name;
string value = null;
XPathNodeType nodeType = navigator.NodeType;
if (nodeType == XPathNodeType.Attribute)
value = navigator.Value;
int same = 0;
int position = 0;
XPathNavigator sibling = navigator.Clone();
sibling.MoveToFirst();
do
{
if (sibling.NodeType == nodeType && sibling.Name == name)
{
if (sibling.IsSamePosition(navigator))
position = same;
else
++same;
}
} while (sibling.MoveToNext());
if (navigator.MoveToParent())
FullName(navigator, s);
switch (nodeType)
{
case XPathNodeType.Element:
s.Append('/');
s.Append(name);
if (same != 0)
{
s.Append('[');
s.Append((position + 1).ToString(CultureInfo.InvariantCulture));
s.Append(']');
}
break;
case XPathNodeType.Attribute:
s.Append("[@");
s.Append(name);
if (same != 0)
s.AppendFormat(" = '{0}'", value);
s.Append("]");
break;
case XPathNodeType.Comment:
case XPathNodeType.Namespace:
case XPathNodeType.ProcessingInstruction:
case XPathNodeType.Root:
case XPathNodeType.Text:
case XPathNodeType.Whitespace:
default:
throw new NotSupportedException();
}
}
示例13: XPathSelectionIterator
public XPathSelectionIterator(XPathNavigator nav, string xpath) {
this.nav = nav;
query = new QueryBuilder().Build( xpath, /*allowVar:*/true, /*allowKey:*/true );
if (query.ReturnType() != XPathResultType.NodeSet) {
throw new XPathException(Res.Xp_NodeSetExpected);
}
query.setContext(nav.Clone());
}
示例14: Clone
protected static XPathNavigator Clone(XPathNavigator input)
{
if (input != null)
{
return input.Clone();
}
return null;
}
示例15: SubtreeeXPathNavigator
private SubtreeeXPathNavigator(XPathNavigator root, XPathNavigator current,
bool atRoot, bool enableFragment)
{
_root = root.Clone();
_navigator = current.Clone();
_atroot = atRoot;
_fragment = enableFragment;
}