本文整理汇总了C#中XPathNamespaceScope类的典型用法代码示例。如果您正苦于以下问题:C# XPathNamespaceScope类的具体用法?C# XPathNamespaceScope怎么用?C# XPathNamespaceScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XPathNamespaceScope类属于命名空间,在下文中一共展示了XPathNamespaceScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveToFirstNamespace
//Caller( DataDocumentXPathNavigator will make sure that the node is at the right position for this call )
internal bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) {
//Debug.WriteLineIf( XmlTrace.traceXPathNodePointerFunctions.Enabled, "XPathNodePointer:MoveToFirstNamespace(namespaceScope)");
RealFoliate();
_parentOfNS = this._node as XmlBoundElement;
//only need to check with _node, even if _column is not null and its mapping type is element, it can't have attributes
if ( _parentOfNS == null )
return false;
XmlNode node = this._node;
XmlBoundElement be = null;
while ( node != null ) {
be = node as XmlBoundElement;
if ( MoveToNextNamespace( be, null, null ) )
return true;
//didn't find it
if ( namespaceScope == XPathNamespaceScope.Local )
goto labelNoNS;
//try the next element anccestor.
do {
node = node.ParentNode;
} while ( node != null && node.NodeType != XmlNodeType.Element );
}
if ( namespaceScope == XPathNamespaceScope.All ) {
MoveTo( this._doc.attrXml, null, false );
return true;
}
labelNoNS:
//didn't find one namespace node
_parentOfNS = null;
return false;
}
示例2: MoveToNextNamespace
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope)
{
this.currentPosition = -1L;
return this.navigator.MoveToNextNamespace(namespaceScope);
}
示例3: MoveToFirstNamespace
public override bool MoveToFirstNamespace(XPathNamespaceScope scope)
{
XmlElement element = _source as XmlElement;
if (element == null)
{
return false;
}
XmlAttributeCollection attributes;
int index = Int32.MaxValue;
switch (scope)
{
case XPathNamespaceScope.Local:
if (!element.HasAttributes)
{
return false;
}
attributes = element.Attributes;
if (!MoveToFirstNamespaceLocal(attributes, ref index))
{
return false;
}
_source = attributes[index];
_attributeIndex = index;
_namespaceParent = element;
break;
case XPathNamespaceScope.ExcludeXml:
attributes = element.Attributes;
if (!MoveToFirstNamespaceGlobal(ref attributes, ref index, element))
{
return false;
}
XmlAttribute attribute = attributes[index];
while (Ref.Equal(attribute.LocalName, XmlConst.NsXml))
{
if (!MoveToNextNamespaceGlobal(ref attributes, ref index, element))
{
return false;
}
attribute = attributes[index];
}
_source = attribute;
_attributeIndex = index;
_namespaceParent = element;
break;
case XPathNamespaceScope.All:
attributes = element.Attributes;
if (!MoveToFirstNamespaceGlobal(ref attributes, ref index, element))
{
_source = _document.GetNamespaceXml();
// attributeIndex = 0;
}
else
{
_source = attributes[index];
_attributeIndex = index;
}
_namespaceParent = element;
break;
default:
Debug.Assert(false);
return false;
}
return true;
}
示例4: MoveToFirstNamespace
public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
{
this.IncrementNodeCount();
return this.navigator.MoveToFirstNamespace(namespaceScope);
}
示例5: MoveToNextNamespace
public override bool MoveToNextNamespace(XPathNamespaceScope scope)
{
return false;
}
示例6: MoveToFirstNamespace
public override bool MoveToFirstNamespace (
XPathNamespaceScope namespaceScope)
{
if (!currentIsNode)
return false;
int cur = nodes [currentNode].FirstNamespace;
return moveToSpecifiedNamespace (cur, namespaceScope);
}
示例7: MoveToFirstNamespace
public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
{
//StreamUtil.WriteText("I:\\debug.txt","进到 MoveToFirstNamespace()\r\n");
if (!(this.m_navigatorState.CurItem is ElementItem))
return false;
ElementItem element = (ElementItem)this.m_navigatorState.CurItem;
ItemList namespaceList = element.NamespaceList;
if (namespaceList.Count > 0)
{
this.m_navigatorState.CurItem = namespaceList[0];
return true;
}
return false;
}
示例8: MoveToNextNamespace
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope)
{
//StreamUtil.WriteText("I:\\debug.txt","进到 MoveToNextNamespace()\r\n");
Debug.Assert(this.m_navigatorState.CurItem != null, "");
if (this.m_navigatorState.CurItem == this.m_navigatorState.VirtualRoot)
return false;
if (!(this.m_navigatorState.CurItem is AttrItem))
return false;
AttrItem attr = (AttrItem)this.m_navigatorState.CurItem;
if (attr.IsNamespace == false)
return false;
ElementItem element = (ElementItem)attr.parent;
ItemList namespaceList = element.NamespaceList;
if (namespaceList.Count > 0)
{
int nIndex = namespaceList.IndexOf(this.m_navigatorState.CurItem);
if (nIndex == -1)
return false;
if (nIndex + 1 >= namespaceList.Count)
return false;
this.m_navigatorState.CurItem = namespaceList[nIndex + 1];
return true;
}
return false;
}
示例9: CopyNamespaces
/// <summary>
/// Copy all or some (which depends on nsScope) of the namespaces on the navigator's current node to the
/// raw writer.
/// </summary>
private void CopyNamespaces(XPathNavigator nav, XPathNamespaceScope nsScope) {
string prefix = nav.LocalName;
string ns = nav.Value;
if (nav.MoveToNextNamespace(nsScope)) {
CopyNamespaces(nav, nsScope);
}
this.xwrt.WriteNamespaceDeclaration(prefix, ns);
}
示例10: MoveToFirstNamespace
public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
{
return false;
}
示例11: CopyNamespacesHelper
/// <summary>
/// Recursive helper function that reverses order of the namespaces retrieved by MoveToFirstNamespace and
/// MoveToNextNamespace.
/// </summary>
private void CopyNamespacesHelper(XPathNavigator navigator, XPathNamespaceScope nsScope) {
string prefix = navigator.LocalName;
string ns = navigator.Value;
if (navigator.MoveToNextNamespace(nsScope))
CopyNamespacesHelper(navigator, nsScope);
// No possibility for conflict, since we're copying namespaces from well-formed element
WriteNamespaceDeclarationUnchecked(prefix, ns);
}
示例12: CopyNamespaces
/// <summary>
/// Copy all namespaces of the specified type (in-scope, exclude-xml, local) in document order to output.
/// </summary>
private void CopyNamespaces(XPathNavigator navigator, XPathNamespaceScope nsScope) {
Debug.Assert(navigator.NodeType == XPathNodeType.Element, "Only elements have namespaces to copy");
// Default namespace undeclaration isn't included in navigator's namespace list, so add it now
if (navigator.NamespaceURI.Length == 0) {
Debug.Assert(navigator.LocalName.Length != 0, "xmlns:foo='' isn't allowed");
WriteNamespaceDeclarationUnchecked(string.Empty, string.Empty);
}
// Since the namespace list is arranged in reverse-document order, recursively reverse it.
if (navigator.MoveToFirstNamespace(nsScope)) {
CopyNamespacesHelper(navigator, nsScope);
navigator.MoveToParent();
}
}
示例13: MoveToNextNamespace
//Caller( DataDocumentXPathNavigator will make sure that the node is at the right position for this call )
internal bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) {
//Debug.WriteLineIf( XmlTrace.traceXPathNodePointerFunctions.Enabled, "XPathNodePointer:MoveToNextNamespace(namespaceScope)");
RealFoliate();
Debug.Assert( _parentOfNS != null );
XmlNode node = this._node;
//first check within the same boundelement
if ( this._column != null ) {
Debug.Assert( this._column.Namespace == s_strReservedXmlns );
if ( namespaceScope == XPathNamespaceScope.Local && _parentOfNS != this._node ) //already outside scope
return false;
XmlBoundElement be = this._node as XmlBoundElement;
Debug.Assert( be != null );
DataRow curRow = be.Row;
Debug.Assert( curRow != null );
DataColumn curCol = PreviousColumn( curRow, this._column, true );
while ( curCol != null ) {
if ( curCol.Namespace == s_strReservedXmlns ) {
MoveTo( be, curCol, false );
return true;
}
curCol = PreviousColumn( curRow, curCol, true );
}
//didn't find it in this loop
if ( namespaceScope == XPathNamespaceScope.Local )
return false;
//try its ancesstor
do {
node = node.ParentNode;
} while ( node != null && node.NodeType != XmlNodeType.Element );
}
else if ( this._node.NodeType == XmlNodeType.Attribute ) {
XmlAttribute attr = (XmlAttribute)(this._node);
Debug.Assert( attr != null );
node = attr.OwnerElement;
if ( node == null )
return false;
if ( namespaceScope == XPathNamespaceScope.Local && _parentOfNS != node ) //already outside scope
return false;
if ( MoveToNextNamespace( (XmlBoundElement)node, null, (XmlAttribute)attr ) )
return true;
//didn't find it
if ( namespaceScope == XPathNamespaceScope.Local )
return false;
do {
node = node.ParentNode;
} while ( node != null && node.NodeType != XmlNodeType.Element );
}
// till now, node should be the next accesstor (bound) element of the element parent of current namespace node (attribute or data column)
while ( node != null ) {
//try the namespace attributes from the same element
XmlBoundElement be = node as XmlBoundElement;
if ( MoveToNextNamespace( be, null, null ) )
return true;
//no more namespace attribute under the same element
do {
node = node.ParentNode;
} while ( node != null && node.NodeType == XmlNodeType.Element );
}
//didn't find the next namespace, thus return
if ( namespaceScope == XPathNamespaceScope.All ) {
MoveTo( this._doc.attrXml, null, false );
return true;
}
return false;
}
示例14: MoveToNextNamespace
public override bool MoveToNextNamespace (XPathNamespaceScope scope)
{
if (attr == null)
return false;
for (XAttribute a = attr.NextAttribute; a != null; a = a.NextAttribute)
if (a.IsNamespaceDeclaration) {
attr = a;
return true;
}
if (scope == XPathNamespaceScope.Local)
return false;
for (XElement el = ((XElement) attr.Parent).Parent; el != null; el = el.Parent) {
foreach (XAttribute a in el.Attributes ())
if (a.IsNamespaceDeclaration) {
attr = a;
return true;
}
}
if (scope != XPathNamespaceScope.All)
return false;
attr = attr_ns_xml;
return true;
}
示例15: MoveToFirstNamespace
//Moves to the first namespace node depending upon the namespace scope.
public override bool MoveToFirstNamespace( XPathNamespaceScope nsScope ) {
if( nsScope == XPathNamespaceScope.Local ) {
XmlElement _parentOfNS = _curNode as XmlElement;
if( _parentOfNS == null )
return false;
if( MoveToFirstLocalNamespace( _curNode ) )
return true;
else {
_parentOfNS = null;
return false;
}
}
else if( nsScope == XPathNamespaceScope.ExcludeXml )
return MoveToFirstNonXmlNamespace();
else if( nsScope == XPathNamespaceScope.All ) {
_parentOfNS = _curNode as XmlElement;
XmlElement cache = _parentOfNS;
if( _parentOfNS == null )
return false;
if( MoveToFirstNonXmlNamespace() )
return true;
_parentOfNS = cache;
_curNode = attrXmlNS;
return true;
}
else return false;
}