diff --git a/xdoc/src/main/org/apache/maven/NavBean.java b/xdoc/src/main/org/apache/maven/NavBean.java
new file mode 100644
index 00000000..7a4cfe75
--- /dev/null
+++ b/xdoc/src/main/org/apache/maven/NavBean.java
@@ -0,0 +1,174 @@
+package org.apache.maven;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Maven" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache Maven", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ * ====================================================================
+ */
+
+import java.util.List;
+
+import org.dom4j.Attribute;
+import org.dom4j.Node;
+import org.dom4j.tree.DefaultElement;
+
+/**
+ * @author Ben Walding
+ * @version $Id: NavBean.java,v 1.1 2003/02/16 23:03:02 bwalding Exp $
+ */
+public class NavBean
+{
+ private String location;
+ private Node document;
+
+ public void setDocument(Object o)
+ {
+ document = (Node) o;
+
+ Node loc = document.selectSingleNode("//location");
+ if (loc != null)
+ location = loc.getStringValue();
+
+ }
+
+ private static String getAttribute(DefaultElement elem, String attribute, String defaultValue)
+ {
+ Attribute attr = elem.attribute(attribute);
+ if (attr == null)
+ return defaultValue;
+
+ return attr.getStringValue();
+ }
+
+ private static boolean getCollapseAttribute(DefaultElement elem)
+ {
+ return Boolean.valueOf(getAttribute(elem, "collapse", "false")).booleanValue();
+ }
+ private static String getHREFAttribute(DefaultElement elem)
+ {
+ return getAttribute(elem, "href", null);
+ }
+
+ /**
+ * Determines if the given node is collapsed. If a parent of this node is
+ * collapsed, this will give spurious results.
+ * @param o
+ * @return boolean
+ */
+ public boolean isCollapsed(Object o)
+ {
+ //If we don't know where we are, collapse it - something outside of our knowledge
+ if (location == null)
+ return true;
+
+ if (!(o instanceof DefaultElement))
+ {
+ System.out.println(o.getClass().getName());
+ return false;
+ }
+ DefaultElement elem = (DefaultElement) o;
+
+ boolean collapsed = getCollapseAttribute(elem);
+ if (!collapsed)
+ return false;
+
+ if (isSelected(o))
+ return false;
+
+ String xpath = ".//item[@href='" + location + "']";
+
+ List l = elem.selectNodes(xpath);
+
+ if (l.size() != 0)
+ return false;
+
+ return true;
+ }
+
+ /**
+ * Determines if a given item node is the selected node
+ * @param o
+ * @return boolean
+ */
+ public boolean isSelected(Object o)
+ {
+ if (location == null)
+ return false;
+
+ DefaultElement elem = (DefaultElement) o;
+ if (location.equals(getHREFAttribute(elem)))
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Sets the location.
+ * @param location The location to set
+ */
+ public void setLocation(String location)
+ {
+ this.location = location;
+ }
+
+ /**
+ * Find the first item with a given href
+ * @param href
+ * @return DefaultElement
+ */
+ public DefaultElement getFirstNodeByHREF(String href)
+ {
+ String xpath = "//item[@href='" + href + "']";
+ return (DefaultElement) document.selectSingleNode(xpath);
+ }
+}
diff --git a/xdoc/src/plugin-resources/site.jsl b/xdoc/src/plugin-resources/site.jsl
index 9e76458c..61dc5255 100644
--- a/xdoc/src/plugin-resources/site.jsl
+++ b/xdoc/src/plugin-resources/site.jsl
@@ -10,8 +10,13 @@
xmlns:doc="doc"
xmlns="dummy" trim="false">
-
-
+
+
+ ${navbean.setDocument(doc)}
+
+
@@ -431,11 +436,22 @@
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xdoc/src/test-resources/navigation.xml b/xdoc/src/test-resources/navigation.xml
new file mode 100644
index 00000000..11b1f623
--- /dev/null
+++ b/xdoc/src/test-resources/navigation.xml
@@ -0,0 +1,21 @@
+
+
+
+ Maven xdoc Plugin
+
+
+
+
+
+
+
+
diff --git a/xdoc/src/test/org/apache/maven/NavBeanTest.java b/xdoc/src/test/org/apache/maven/NavBeanTest.java
new file mode 100644
index 00000000..843d6c9b
--- /dev/null
+++ b/xdoc/src/test/org/apache/maven/NavBeanTest.java
@@ -0,0 +1,140 @@
+package org.apache.maven;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Maven" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache Maven", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ * ====================================================================
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import junit.framework.TestCase;
+
+import org.dom4j.Document;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+
+/**
+ * @author Ben Walding
+ * @version $Id: NavBeanTest.java,v 1.1 2003/02/16 23:03:37 bwalding Exp $
+ */
+public class NavBeanTest extends TestCase
+{
+
+ private File testResources;
+ public void setUp() {
+ testResources = new File(System.getProperty("basedir") + "/src/test-resources");
+ }
+
+ class Test
+ {
+ String href;
+ boolean collapsed;
+ public Test(String href, boolean collapsed)
+ {
+ this.href = href;
+ this.collapsed = collapsed;
+ }
+ }
+
+ private Test[] testAlpha =
+ {
+ new Test("/alpha/index.html", false),
+ new Test("/alpha/one/index.html", false),
+ new Test("/alpha/two/index.html", false),
+ new Test("/beta/index.html", true)};
+
+ private Test[] testBeta =
+ {
+ new Test("/alpha/index.html", false),
+ new Test("/alpha/one/index.html", false),
+ new Test("/alpha/two/index.html", false),
+ new Test("/beta/index.html", false),
+ new Test("/beta/one/index.html", true),
+ new Test("/beta/two/index.html", true)};
+
+ public void testAlpha() throws Exception
+ {
+ testGroup("/alpha/index.html", testAlpha);
+ }
+
+ public void testBeta() throws Exception
+ {
+ testGroup("/beta/index.html", testBeta);
+ }
+
+ protected Document getTestDocument() throws Exception
+ {
+ SAXReader reader = new SAXReader();
+ return reader.read(new FileInputStream(new File(testResources, "navigation.xml")));
+ }
+
+ public void testGroup(String location, Test[] tests) throws Exception
+ {
+ NavBean nb = new NavBean();
+ nb.setDocument(getTestDocument());
+ nb.setLocation(location);
+
+ for (int i = 0; i < tests.length; i++)
+ {
+ Test test = tests[i];
+ Node node = nb.getFirstNodeByHREF(test.href);
+ assertNotNull(node);
+ assertEquals(test.href + ".isCollapsed()", test.collapsed, nb.isCollapsed(node));
+ }
+
+ }
+
+}
+
diff --git a/xdoc/src/test/xdocs/alpha/index.xml b/xdoc/src/test/xdocs/alpha/index.xml
index 5a9c2df5..7da1650b 100644
--- a/xdoc/src/test/xdocs/alpha/index.xml
+++ b/xdoc/src/test/xdocs/alpha/index.xml
@@ -4,6 +4,7 @@
ALPHA
Ben Walding
+ /alpha/index.html
diff --git a/xdoc/src/test/xdocs/alpha/one/index.xml b/xdoc/src/test/xdocs/alpha/one/index.xml
index d7655c4d..4cfe6197 100644
--- a/xdoc/src/test/xdocs/alpha/one/index.xml
+++ b/xdoc/src/test/xdocs/alpha/one/index.xml
@@ -4,6 +4,7 @@
ALPHA / ONE
Ben Walding
+ /alpha/one/index.html
diff --git a/xdoc/src/test/xdocs/alpha/two/index.xml b/xdoc/src/test/xdocs/alpha/two/index.xml
index 33fc1096..192a6277 100644
--- a/xdoc/src/test/xdocs/alpha/two/index.xml
+++ b/xdoc/src/test/xdocs/alpha/two/index.xml
@@ -4,6 +4,7 @@
ALPHA / TWO
Ben Walding
+ /alpha/two/index.html
diff --git a/xdoc/src/test/xdocs/beta/index.xml b/xdoc/src/test/xdocs/beta/index.xml
index c7f057e0..da3d2798 100644
--- a/xdoc/src/test/xdocs/beta/index.xml
+++ b/xdoc/src/test/xdocs/beta/index.xml
@@ -4,6 +4,7 @@
BETA
Ben Walding
+ /beta/index.html
diff --git a/xdoc/src/test/xdocs/beta/one/index.xml b/xdoc/src/test/xdocs/beta/one/index.xml
index 57798a08..859c22fb 100644
--- a/xdoc/src/test/xdocs/beta/one/index.xml
+++ b/xdoc/src/test/xdocs/beta/one/index.xml
@@ -4,6 +4,7 @@
BETA / ONE
Ben Walding
+ /beta/one/index.html
diff --git a/xdoc/src/test/xdocs/beta/two/index.xml b/xdoc/src/test/xdocs/beta/two/index.xml
index 33a13c61..57123738 100644
--- a/xdoc/src/test/xdocs/beta/two/index.xml
+++ b/xdoc/src/test/xdocs/beta/two/index.xml
@@ -4,6 +4,7 @@
BETA / TWO
Ben Walding
+ /beta/two/index.html
diff --git a/xdoc/src/test/xdocs/index.xml b/xdoc/src/test/xdocs/index.xml
index 602d16c6..954f6180 100644
--- a/xdoc/src/test/xdocs/index.xml
+++ b/xdoc/src/test/xdocs/index.xml
@@ -4,6 +4,7 @@
ROOT
Ben Walding
+ /index.html
diff --git a/xdoc/src/test/xdocs/navigation.xml b/xdoc/src/test/xdocs/navigation.xml
index 020b50a4..c0496bfc 100644
--- a/xdoc/src/test/xdocs/navigation.xml
+++ b/xdoc/src/test/xdocs/navigation.xml
@@ -12,7 +12,7 @@
- -
+
-