本文整理汇总了C#中System.Xml.XPath.XPathNodeIterator.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNodeIterator.Clone方法的具体用法?C# XPathNodeIterator.Clone怎么用?C# XPathNodeIterator.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNodeIterator
的用法示例。
在下文中一共展示了XPathNodeIterator.Clone方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XPathIteratorReader
/// <summary>
/// Initializes the reader.
/// </summary>
/// <param name="iterator">The iterator to expose as a single reader.</param>
/// <param name="rootName">The name to use for the enclosing root element.</param>
/// <param name="ns">The namespace URI of the root element.</param>
public XPathIteratorReader(XPathNodeIterator iterator, string rootName, string ns)
: base(new StringReader(String.Empty))
{
_iterator = iterator.Clone();
_current = new FakedRootReader(rootName, ns, XmlNodeType.Element);
_rootname = new XmlQualifiedName(rootName, ns);
}
示例2: Clone
protected static XPathNodeIterator Clone(XPathNodeIterator input)
{
if (input != null)
{
return input.Clone();
}
return null;
}
示例3: XmlIteratorNodeList
public XmlIteratorNodeList (XmlDocument doc, XPathNodeIterator iter)
{
if (doc == null)
throw new Exception ("huh?");
this.doc = doc;
//doc.NodeRemoving += SaveNodeList;
source = iter;
iterator = iter.Clone ();
list = new ArrayList ();
}
示例4: SelectNodeList
// Create a new node list.
public SelectNodeList(XPathNodeIterator iterator)
{
if(iterator != null)
{
this.iterator = iterator.Clone();
this.current = iterator.Clone();
finished = false;
}
else
{
finished = true;
}
cached = new ArrayList();
}
示例5: ExsltNodeList
/// <summary>
/// Initializes the ExsltNodeList with the specified XPathNodeIterator. All nodes
/// in the iterator are placed in the list.
/// </summary>
/// <param name="iterator">The iterator to load the nodelist from</param>
/// <param name="removeDuplicates">A flag that indicates whether duplicate nodes
/// should be loaded into the nodelist or only node with unique identity should
/// be added</param>
public ExsltNodeList(XPathNodeIterator iterator, bool removeDuplicates){
XPathNodeIterator it = iterator.Clone();
while(it.MoveNext()){
if(removeDuplicates){
if(this.Contains(it.Current)){
continue;
}
}
this.Add(it.Current.Clone());
}
}
示例6: distinct
/// <summary>
/// Selects nodes from the specified <paramref name="nodeset"/> that have unique values selected with <paramref name="xpath"/>.
/// </summary>
/// <param name="nodeset">The <c>nodeset</c> that contains the nodes to filter.</param>
/// <param name="xpath">The xpath to use to select the value that should be unique between nodes.</param>
/// <param name="includeNullEntries">If set to <c>true</c>, nodes that fail to select the specified <paramref name="xpath"/> will be included too.</param>
/// <returns>
/// The nodes from the specified <paramref name="nodeset"/> that have unique values selected with <paramref name="xpath"/>.
/// </returns>
public XPathNodeIterator distinct(XPathNodeIterator nodeset, string xpath, bool includeNullEntries)
{
if (nodeset.Count < 2)
return nodeset;
var result = new List<NodeInfo>();
var selections = new List<string>();
XPathNodeIterator clone = nodeset.Clone();
while (clone.MoveNext())
{
XPathNavigator selected = clone.Current.SelectSingleNode(xpath);
if (selected == null)
{
if (includeNullEntries)
result.Add(new NodeInfo(clone.Current));
continue;
}
if (!selections.Contains(selected.Value))
{
selections.Add(selected.Value);
result.Add(new NodeInfo(clone.Current));
}
}
if (result.Count > 0)
{
List<string> distinct = result.Select(t => t.XPath).ToList();
return result[0].Root.Select(string.Join(" | ", distinct), NodeInfo.GetNamespaceManager(result));
}
return empty.Select("*");
}
示例7: either
/// <summary>
/// Returns <paramref name="nodeset1"/> if it is not empty, otherwise <paramref name="nodeset2"/>.
/// </summary>
/// <param name="nodeset1">The primary selection.</param>
/// <param name="nodeset2">The secondary selection.</param>
/// <returns><paramref name="nodeset1"/> if it is not empty, otherwise <paramref name="nodeset2"/></returns>
public XPathNodeIterator either(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
{
return nodeset1.Count != 0 ? nodeset1.Clone() : nodeset2.Clone();
}
示例8: XmlNodeListIterator
public XmlNodeListIterator(XPathNodeIterator iterator)
{
_iterator = iterator.Clone();
}
示例9: XPathNodeIteratorEnumerator
public XPathNodeIteratorEnumerator (XPathNodeIterator source)
{
this.source = source.Clone ();
current = null;
}
示例10: Init
internal void Init(XPathNodeIterator i, string query = "/")
{
_i = i.Clone();
if (_i.CurrentPosition == 0) // standing before first node
_i.MoveNext();
_nav = _i.Current;
base_xml = _nav.OuterXml;
_query = query;
#if DEBUG
Debug.Print("xml:\n" + base_xml + "\n");
Debug.Print("query:" + _query + "\n\n");
#endif
}
示例11: XmlIteratorNodeList
public XmlIteratorNodeList (XPathNodeIterator iter)
{
source = iter;
iterator = iter.Clone ();
list = new ArrayList ();
}
示例12: rel_join
public XPathNodeIterator rel_join(XPathNodeIterator one, XPathNodeIterator two, string by, string name,
string prefix, string ns, string fp, string sp){
var sw = new StringWriter();
XmlWriter w = new XmlTextWriter(sw);
w.WriteStartElement("root");
w.WriteAttributeString("xmlns", "xes", "http://www.w3.org/2000/xmlns/", "MT-xml-expert-systems");
while (one.MoveNext()){
var t = two.Clone();
while (t.MoveNext()){
w.WriteStartElement(prefix, name, ns);
var attrs = one.Current.Clone();
while (attrs.MoveToFirstAttribute() || attrs.MoveToNextAttribute()){
if (attrs.Prefix == "xes" && attrs.LocalName == "UID") continue;
w.WriteAttributeString(attrs.Prefix, fp + attrs.LocalName, attrs.NamespaceURI, attrs.Value);
}
attrs = t.Current.Clone();
while (attrs.MoveToFirstAttribute() || attrs.MoveToNextAttribute()){
if (attrs.Prefix == "xes" && attrs.LocalName == "UID") continue;
w.WriteAttributeString(attrs.Prefix, sp + attrs.LocalName, attrs.NamespaceURI, attrs.Value);
}
w.WriteEndElement();
}
}
w.WriteEndElement();
w.Flush();
var nav = XmlUtil.GetNavigator(sw.ToString());
var res = nav.Select("/root/*[" + by + "]");
return res;
}
示例13: InsureFontNameAttributes
/// <summary>
/// InsureFontNameAttributes
/// </summary>
/// <param name="xpIterator"></param>
/// <param name="xpe"></param>
/// <param name="strNewFontName"></param>
/// <param name="bCreateIfNotPresent">indicates whether to create the attribute/element if it doesn't already exist</param>
/// <returns>true if the attribute was already present; false if not (whether it was created or not)</returns>
protected bool InsureFontNameAttributes(XPathNodeIterator xpIterator, XPathExpression xpe,
string strNewFontName, bool bCreateIfNotPresent)
{
XPathNodeIterator xpIteratorAttrib = xpIterator.Current.Select(xpe);
if (xpIteratorAttrib.MoveNext())
{
xpIteratorAttrib.Current.SetValue(strNewFontName);
return true;
}
else if (bCreateIfNotPresent)
{
xpIteratorAttrib = xpIterator.Clone();
string strExpr = xpe.Expression;
// this code only handles expressions of the form "w:x/y:z" so there should be 4 "parts")
string[] astrSplit = strExpr.Split(new char[] { '/', ':', '@' }, StringSplitOptions.RemoveEmptyEntries);
System.Diagnostics.Debug.Assert(astrSplit.Length == 6);
string strChildElementPrefix = astrSplit[0];
string strNameSpace = m_mapPrefix2NamespaceURI[strChildElementPrefix];
string strChildElementName = astrSplit[1];
int nOffset = 0;
if (astrSplit.Length == 6)
{
if (!xpIteratorAttrib.Current.MoveToChild(strChildElementName, strNameSpace))
{
xpIteratorAttrib.Current.PrependChildElement(strChildElementPrefix, strChildElementName, strNameSpace, null);
bool bMoveRes = xpIteratorAttrib.Current.MoveToChild(strChildElementName, strNameSpace);
System.Diagnostics.Debug.Assert(bMoveRes);
}
nOffset = 2;
}
strChildElementPrefix = astrSplit[0 + nOffset];
strNameSpace = m_mapPrefix2NamespaceURI[strChildElementPrefix];
strChildElementName = astrSplit[1 + nOffset];
string strAttribPrefix = astrSplit[2 + nOffset];
string strAttribName = astrSplit[3 + nOffset];
if (!xpIteratorAttrib.Current.MoveToChild(strChildElementName, strNameSpace))
{
xpIteratorAttrib.Current.PrependChildElement(strChildElementPrefix, strChildElementName, strNameSpace, null);
bool bMoveRes = xpIteratorAttrib.Current.MoveToChild(strChildElementName, strNameSpace);
System.Diagnostics.Debug.Assert(bMoveRes);
}
xpIteratorAttrib.Current.CreateAttribute(strAttribPrefix, strAttribName, strNameSpace, strNewFontName);
}
return false;
}
示例14: selectProduct
/// <summary>
/// A helper method to retrieve the right Item. If the current item is a variant and
/// a specific field doesn't exist on the variant, then the parent item is returned.
/// </summary>
/// <param name="fieldName">
/// </param>
/// <param name="ni">
/// </param>
public XPathNodeIterator selectProduct(string fieldName, XPathNodeIterator ni)
{
XPathNodeIterator clone = ni.Clone();
var helper = new Xml.Xsl.XslHelper();
string fldValue = helper.fld(fieldName, clone);
if (fldValue.Length > 0)
{
return ni;
}
string currentId = clone.Current.GetAttribute("id", string.Empty);
Item currentItem = Sitecore.Context.Database.GetItem(currentId);
if (currentItem != null)
{
Item parentItem = currentItem.Parent;
if (parentItem != null &&
parentItem.Fields[fieldName] != null)
{
return helper.item(parentItem.Paths.FullPath, ni);
}
}
return ni;
}