While your method is a bit cleaner, this is how xdocs works, and I don't think it is appropriate to break it at this juncture.

public void testCalculateLink()
{
testCalculateLink("/bob.html", "/absolute//bob.html", "..");
testCalculateLink("http://crazyhorse.com";, "/absolute/http://crazyhorse.com";, "..");
testCalculateLink("http://crazyhorse.com";, "http://crazyhorse.com";, "..");
testCalculateLink("../index.html", "/index.html", "..");
testCalculateLink("index.html", "/index.html", ".");
testCalculateLink("../other-module/index.html", "../other-module/index.html", ".");
testCalculateLink("../../other-module/index.html", "../other-module/index.html", "..");
}


public void testCalculateLink(String expected, String link, String relativePath)
{
String actual = DVSLPathTool.calculateLink(link, relativePath);
String function = "DVSLPathTool.calculateLink(" + link + "," + relativePath + ")";
if (!expected.equals(actual)) {
System.out.println("Function:" + function);
System.out.println("Actual:" + actual);
System.out.println("Expected:" + expected); }
assertEquals(function, expected, actual);
}



Rafal Krzewski wrote:


Ben Walding wrote:


What version of Maven?

Make sure your navigation links start with / as there is a hole in the
tests which means that it can get confused if your links don't start
with / or one of the other special tags (site or absolute). Your link
should look like <item href="/foo.html" name="Foot"/>. Maven will
generate the appropriate link depending on the page you are viewing.



I don't quite understand what special tags you are talking about. There was some special handling of links that begin with '/site/' string, but I removed that with MAVEN-283 patch, because I thought it was residual after some quick and and dirty hack.

Could someone clarify what is the general policy for links in xdocs?

I'll give my undestading here, so please correct me if I'm wrong:

1) Any link that starts with schema specification (ie http://) is left
  untouched.

2) Any link that starts with a / is left untouched - it's relative to
  the root of the site's destination server, let the browser handle it.

3) If the link does not match the above, it's treated as relative to the
  location of the file that contains it. If the generated html file
  would reside in the directory analogous to the directory where the
  source xdoc is, the link is left untouched. If the generated html
  file would reside in another directory, the link should be prepended
  with the relative path pointing from the html file's destination
  directory to the directory analogous to the source xdocs location.

Example:

Assume that the xdocs/navigation.xml contains the following links:

<item name="Maven"        href="http://jakarta.apache.org/maven"/>
<item name="Home"         href="/index.html"/>
<item name="Home rel"     href="index.html"/>
<item name="User's guide" href="reference/usres-guide.html"/>
<item name="Install"      href="start/install.html"/>

depending on the directory, the links would rener as:

/
Maven         http://jakarta.apache.org/maven
Home          /index.html
Home rel      index.html
User's guide  reference/usres-guide.html
Install       start/install.html

/start
Maven         http://jakarta.apache.org/maven
Home          /index.html
Home rel      ../index.html
User's guide  ../reference/usres-guide.html
Install       install.html

/reference
Maven         http://jakarta.apache.org/maven
Home          /index.html
Home rel      ../index.html
User's guide  usres-guide.html
Install       ../start/install.html

/reference/somedir
Maven         http://jakarta.apache.org/maven
Home          /index.html
Home rel      ../../index.html
User's guide  ../usres-guide.html
Install       ../../start/install.html

Is this how it's done now? If not, don't you think that it's the correct
way of handling relative paths?

R.


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







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



Reply via email to