public TreeNode GetLastDescendantWithXmlAttribute(string attrName) { if (mChildren.Count == 0) { return(null); } for (int i = Children.Count - 1; i >= 0; i--) { TreeNode child = Children.Get(i); if (child.HasXmlProperty && child.GetXmlProperty().GetAttribute(attrName) != null) { return(child); } TreeNode childIn = child.GetLastDescendantWithXmlAttribute(attrName); if (childIn != null) { return(childIn); } } return(null); }
public bool NeedsXmlNamespacePrefix() { if (!HasXmlProperty) { return(false); } string nsUri_NearestXmlns = null; TreeNode node = this; while (node != null) { XmlProperty xmlProp = node.GetXmlProperty(); foreach (XmlAttribute xmlAttr in xmlProp.Attributes.ContentsAs_Enumerable) { string attrNSPrefix = xmlAttr.Prefix; string attrLocalName = xmlAttr.PrefixedLocalName != null ? xmlAttr.PrefixedLocalName : xmlAttr.LocalName; if (String.IsNullOrEmpty(attrNSPrefix) && attrLocalName.Equals(XmlReaderWriterHelper.NS_PREFIX_XMLNS)) { // xmlns="URI" nsUri_NearestXmlns = xmlAttr.Value; break; } } if (!String.IsNullOrEmpty(nsUri_NearestXmlns)) { break; } node = node.Parent; } if (String.IsNullOrEmpty(nsUri_NearestXmlns)) { nsUri_NearestXmlns = Presentation.PropertyFactory.DefaultXmlNamespaceUri; } string nsUri = GetXmlNamespaceUri(); if (nsUri_NearestXmlns == nsUri) { return(false); } return(true); }
public TreeNode GetNextSiblingWithXmlAttribute(string attrName) { if (Parent == null) { return(null); } TreeNode next = this; while ((next = next.NextSibling) != null) { if (next.HasXmlProperty && next.GetXmlProperty().GetAttribute(attrName) != null) { return(next); } TreeNode nextIn = next.GetFirstDescendantWithXmlAttribute(attrName); if (nextIn != null) { return(nextIn); } } return(Parent.GetNextSiblingWithXmlAttribute(attrName)); }
public TreeNode GetPreviousSiblingWithXmlAttribute(string attrName) { if (Parent == null) { return(null); } TreeNode previous = this; while ((previous = previous.PreviousSibling) != null) { if (previous.HasXmlProperty && previous.GetXmlProperty().GetAttribute(attrName) != null) { return(previous); } TreeNode previousIn = previous.GetLastDescendantWithXmlAttribute(attrName); if (previousIn != null) { return(previousIn); } } return(Parent.GetPreviousSiblingWithXmlAttribute(attrName)); }