public virtual void testCopyNodeData() { JDFDoc d = new JDFDoc("JDF"); JDFNode n = d.getJDFRoot(); n.setType(EnumType.Product); JDFNode n1 = n = n.addJDFNode(EnumType.BlockPreparation); n1.setAttribute("foo:bar", "fnarf", "www.foobar.com"); JDFDoc dA = new JDFDoc("JDF"); JDFAncestorPool ap = dA.getJDFRoot().appendAncestorPool(); ap.appendAncestor().setNodeID(n1.getID()); ap.copyNodeData(n, true, true, false); JDFAncestor a0 = ap.getAncestor(0); Assert.AreEqual("fnarf", a0.getAttribute("foo:bar")); Assert.AreEqual(n1.getID(), a0.getNodeID()); string s = dA.write2String(2); JDFParser p = new JDFParser(); JDFDoc test = p.parseString(s); Assert.IsNotNull(test); }
/// /// <summary> * searches for the first attribute occurence in the ancestor elements /// * </summary> /// * <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 180502 </param> /// * <returns> value of attribute found, value of def if not available </returns> /// public virtual string getAncestorAttribute(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]; if (ancestor.hasAttribute(attrib, nameSpaceURI, false)) { return(ancestor.getAttribute(attrib, nameSpaceURI, JDFConstants.EMPTYSTRING)); } } // not found, return the default return(def); }