Example #1
0
        private static void removePoolElements_Static(KElement root)
        {
            VElement v = root.getChildElementVector(null, null, null, true, 0, false);

            for (int j = v.Count - 1; j >= 0; j--)
            {
                KElement el  = v[j];
                string   nam = el.Name;
                if (nam.Equals("InvalidAttributes") || nam.Equals("InvalidElements") || nam.Equals("UnknownAttributes") || nam.Equals("UnknownElements") || nam.Equals("MissingAttributes"))
                {
                    moveChildElementVector_Static(root, el);
                    if (!el.hasChildElements() && !el.hasAttributes())
                    {
                        root.removeChild(el);
                    }
                }
            }
            VElement vv = root.getChildElementVector(null, null, null, true, 0, false);

            for (int i = vv.Count - 1; i >= 0; i--)
            {
                removePoolElements_Static(vv[i]);
            }
            return;
        }
Example #2
0
        ///
        ///	 <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;
        }
Example #3
0
 ///
 ///	 <summary> * Moves the ChildElementVector of the second element into the first
 ///	 *  </summary>
 ///	 * <param name="moveToElement">
 ///	 *            the first element - new parent for the children of the second
 ///	 *            element </param>
 ///	 * <param name="moveFromElement">
 ///	 *            the second element - element whose children will be removed </param>
 ///
 private static void moveChildElementVector_Static(KElement moveToElement, KElement moveFromElement)
 {
     if (moveToElement != null && moveFromElement != null)
     {
         VElement v = moveFromElement.getChildElementVector(null, null, null, true, 0, false);
         for (int i = 0; i < v.Count; i++)
         {
             moveToElement.moveElement(v[i], null);
         }
     }
     return;
 }
Example #4
0
        ///
        ///	 <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;
        }