/// /// <summary> * For KElement 'elem' takes information from parent and children about /// * original and corrected CapXPaths, compare them and set CapXPath as a /// * complete path to this element.<br> /// * Checks CapXPath's for every InvalidResource element of the given XMLDoc /// * and all children (of arbitrary depth). Appends right ancestors if /// * CapXPath is not complete.<br> /// * </summary> /// * <param name="elem"> /// * "pool" element like "InvalidElements" or "InvalidAttributes".<br> /// * From this element we have access to its parent and children /// * and can compare their CapXPath's </param> /// * <param name="originalPath"> /// * parent CapXPath before correction. </param> /// private static void capXPathCorrection_Static(KElement elem, string originalPath) { string parentPath = elem.getParentNode_KElement().getAttribute("CapXPath"); VElement vEl = elem.getChildElementVector(null, null, null, true, 0, false); for (int i = 0; i < vEl.Count; i++) { KElement child = (KElement)vEl[i]; string childPath = child.getAttribute("CapXPath"); if (!parentPath.Equals(JDFConstants.EMPTYSTRING) && !childPath.Equals(JDFConstants.EMPTYSTRING)) { string childPathPart = childPath; if (childPath.StartsWith(originalPath)) { childPathPart = childPath.Substring(originalPath.Length + 1); // +1 removes // "/" } child.setAttribute("CapXPath", parentPath + "/" + childPathPart); // recursion to set everywhere the right CapXPath VElement vSubEl = child.getChildElementVector(null, null, null, true, 0, false); for (int j = 0; j < vSubEl.Count; j++) { capXPathCorrection_Static(vSubEl[j], childPath); } } } return; }
public virtual void testNonAsciiFileURL() { for (int i = 0; i < 2; i++) // loop over escape and non-escape { FileInfo f = new FileInfo("4€5%äö.txt"); FileInfo f2 = FileUtil.getFileInDirectory(new DirectoryInfo(sm_dirTestDataTemp), f); f2.Delete(); SupportClass.FileSupport.CreateNewFile(f2); f2.Refresh(); Assert.IsTrue(f2.Exists); string url = UrlUtil.fileToUrl(f2, i == 0); XMLDoc doc = new XMLDoc("URL", null); KElement root = doc.getRoot(); root.setAttribute("url", url); doc.write2File(sm_dirTestDataTemp + "url.xml", 2, false); JDFParser p = new JDFParser(); p.bKElementOnly = true; JDFDoc d = p.parseFile(sm_dirTestDataTemp + "url.xml"); KElement root2 = d.getRoot(); string urlParse = root2.getAttribute("url"); Assert.AreEqual(url, urlParse); FileInfo f3 = UrlUtil.urlToFile(urlParse); Assert.AreEqual(f2.FullName, f3.FullName); Assert.IsTrue(f3.Exists); } }
/// /// <summary> * gets the matching Attribute value String or AbstractSpan object from the /// * parent, depending on the type of the state /// * </summary> /// * <param name="element"> /// * the parent in which to search </param> /// * <returns> Object: either a String or AbstractSpan </returns> /// public virtual object getMatchingObjectInNode(KElement element) { string nam = getName(); if (getListType().Equals(EnumListType.Span)) { return(element.getElement(nam, getDevNS(), 0)); } return(element.getAttribute(nam, getDevNS(), null)); }
/// /// <summary> * Checks XPaths for every InvalidResource element of the given XMLDoc and /// * all chidren (of arbitrary depth). Appends right ancestors if CapXPath is /// * not complete.<br> /// * The point is that that the CapXPath's are created by using getNamePath() /// * method, where the root element is a DevCaps element. But starting with /// * JDF 1.3, DevCap can be located in DevCapPool and can be called from any /// * DevCaps. So the CapXPaths in XMLDoc doc are being fixed by setting the /// * right source of calling. /// * </summary> /// * <param name="root"> /// * root of the XMLDoc document where the CapXPaths must be /// * corrected </param> /// private static void correction_Static(KElement root) { VElement v = root.getChildElementVector("InvalidResource", null, null, true, 0, false); for (int i = 0; i < v.Count; i++) { KElement invRes = v[i]; VElement vv = invRes.getChildElementVector(null, null, null, true, 0, false); for (int j = vv.Count - 1; j >= 0; j--) { capXPathCorrection_Static(vv[j], invRes.getAttribute("CapXPath")); } removePoolElements_Static(invRes); } return; }
/// /// <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); }
public override bool walk(KElement e) { string id = e.getAttribute(AttributeName.RREF, null, null); if (id == null) { return(true); } if (EnclosingInstance.ld.doneSet.Contains(id)) { return(true); } if (EnclosingInstance.ld.resMap.ContainsKey(id)) { EnclosingInstance.ld.doneSet.Add(id); EnclosingInstance.ld.resMap.Remove(id); return(true); } EnclosingInstance.ld.refSet.Add(id); return(true); }
/// /// <summary> * Composes a BugReport in XML form for the given JDFNode 'jdfRoot'. Gives a list of error messages for 'jdfRoot' /// * and every child rejected Node.<br> /// * Returns <code>null</code> if there are no errors. /// * </summary> /// * <param name="jdfRoot"> the node to test </param> /// * <param name="testlists"> testlists that are specified for the State elements (FitsValue_Allowed or FitsValue_Present)<br> /// * Will be used in fitsValue method of the State class. </param> /// * <param name="level"> validation level </param> /// * <returns> XMLDoc - XMLDoc output of the error messages. If XMLDoc is null there are no errors. </returns> /// public XMLDoc getBadJDFInfo(JDFNode jdfRoot, EnumFitsValue testlists, EnumValidationLevel level) { VElement vDC = getChildElementVector(ElementName.DEVICECAP, null, null, true, -1, false); if (vDC == null || vDC.IsEmpty()) { return(null); } VElement vn = new VElement(); for (int i = 0; i < vDC.Count; i++) { JDFDeviceCap dc = (JDFDeviceCap)vDC[i]; XMLDoc bugReport = dc.getBadJDFInfo(jdfRoot, testlists, level); if (bugReport == null) { return(null); } vn.addAll(bugReport.getRoot().getChildElementVector(null, null, null, true, -1, false)); } int vnSize = vn.Count; if (vnSize == 0) { return(null); } XMLDoc bugReport2 = new XMLDoc("BugReport", null); KElement root = bugReport2.getRoot(); bool bFit = false; for (int i = 0; i < vnSize; i++) { KElement e = vn[i]; if (JDFConstants.TRUE.Equals(e.getAttribute(JDFDeviceCap.FITS_TYPE))) { bFit = true; } } if (bFit) { for (int i = 0; i < vnSize; i++) { KElement e = vn[i]; if (JDFConstants.FALSE.Equals(e.getAttribute(JDFDeviceCap.FITS_TYPE))) { vn[i] = null; } } } for (int i = 0; i < vnSize; i++) { if (vn[i] != null) { root.moveElement(vn.item(i), null); } } return(bugReport2); }