Example #1
0
        ///
        ///	 <summary> * searches for the first attribute occurence in the ancestor elements subelements<br>
        ///	 * e.g. the JobPriority in NodeInfo
        ///	 *  </summary>
        ///	 * <param name="element"> node name to look in </param>
        ///	 * <param name="attrib"> the attribute name </param>
        ///	 * <param name="nameSpaceURI"> the XML-namespace </param>
        ///	 * <param name="def"> the default if it does not exist
        ///	 * @since 200503 </param>
        ///	 * <returns> value of attribute found, empty string if not available </returns>
        ///
        public virtual string getAncestorElementAttribute(string element, string attrib, string nameSpaceURI, string def)
        {
            VElement v = getPoolChildren(null);

            // the last in list is the direct parent, the first is the original root

            for (int i = v.Count - 1; i >= 0; i--)
            {
                JDFAncestor ancestor = (JDFAncestor)v[i];
                KElement    e        = ancestor.getElement(element, nameSpaceURI, 0);
                if ((e != null) && (e.hasAttribute(attrib, nameSpaceURI, false)))
                {
                    return(e.getAttribute(attrib, nameSpaceURI, JDFConstants.EMPTYSTRING));
                }
            }
            return(def);
        }
Example #2
0
        ///
        ///	 <summary> * searches for the first element occurence in the ancestor elements
        ///	 *  </summary>
        ///	 * <param name="element"> the element name </param>
        ///	 * <param name="nameSpaceURI"> the XML-namespace of the element </param>
        ///	 * <param name="xPath"> the xpath of a required attribute
        ///	 * @since 290502 </param>
        ///	 * <returns> value of attribute found, empty string if not available </returns>
        ///
        public virtual KElement getAncestorElement(string element, string nameSpaceURI, string xPath)
        {
            VElement v         = getPoolChildren(null);
            bool     bWildCard = isWildCard(xPath);

            // the last in list is the direct parent, the first is the original root
            for (int i = v.Count - 1; i >= 0; i--)
            {
                JDFAncestor ancestor = (JDFAncestor)v[i];
                KElement    e        = ancestor.getElement(element, nameSpaceURI, 0);
                if ((e != null) && (bWildCard || e.hasXPathNode(xPath)))
                {
                    return(e);
                }
            }
            // not found, return an empty element
            return(null);
        }