> Let me suffix this by stating that I, unfortunately, have had to fork the
> gump codebase :(,

Care to share?  With the Apache license, you are under no obligation to do
so, but the advantages could be significant.

Looking at your patch again, it seems to me that the right answer is to
always move profile children to the front of the parent, not merely expand
it in place.  This would allow overrides to be processed whether they are
referenced before or after the profile element in the workspace.  See below
for an alternate patch which does this...

> but solving the problem in the manner I proposed has not
> only allowed for dependency inheritance and true project overrides, it
has
> allowed me to develop "anti-elements" (as you have mentioned in your
> documentation). Here is an anti element I have developed:
>  <not-jar name="lib/foo.jar" id="jar.foo"/>
> which removes the <jar name="lib/foo.jar" id="jar.foo"/> element
altogether
> (but the order the elements are entered into the workspace most
definitely
> matters).

Drool...

- Sam Ruby

Index: Jenny.java
===================================================================
RCS file: /home/cvs/jakarta-alexandria/proposal/gump/java/Jenny.java,v
retrieving revision 1.7
diff -u -r1.7 Jenny.java
--- Jenny.java 2 Jan 2002 19:12:58 -0000      1.7
+++ Jenny.java 2 Jan 2002 22:07:27 -0000
@@ -84,7 +84,7 @@
      * Expand hrefs in place, recursively.
      * @param node source element
      */
-    private void expand(Element node) throws Exception {
+    private Element expand(Element node) throws Exception {
        // expand hrefs
        Attr href = node.getAttributeNode("href");
        if (href != null && !node.getNodeName().equals("url")) {
@@ -106,24 +106,30 @@
            Element copy=(Element)doc.importNode(sub.getFirstChild(), true);
            moveChildren(node, copy);

-           Element parent = (Element)node.getParentNode();
-           if (node.getNodeName().equals("profile")) {
-               copy.removeAttribute("defined-in");
-               moveChildren(copy, parent);
-           } else {
-               parent.replaceChild(copy,node);
+           node.getParentNode().replaceChild(copy,node);
+           node = copy;
+       }
+
+       // move all profile information to the front
+       Node first = node.getFirstChild();
+       for (Node child=first; child!=null; child=child.getNextSibling()) {
+           if (child.getNodeName().equals("profile")) {
+              child = expand((Element)child);
+              while (child.getFirstChild() != null) {
+                 node.insertBefore(child.getFirstChild(), first);
+              }
            }
        }

        // recurse through the children
-       Node child=node.getFirstChild();
-       while (child != null) {
-           Node next=child.getNextSibling();
+       first = node.getFirstChild();
+       for (Node child=first; child != null; child=child.getNextSibling()) {
            if (child.getNodeType()==Node.ELEMENT_NODE) {
-               expand((Element)child);
+               child=expand((Element)child);
            }
-           child=next;
        }
+
+       return node;
     }

     /**


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to