You are viewing a plain text version of this content. The canonical link for it is here.
Posted to alexandria-dev@jakarta.apache.org by ru...@apache.org on 2001/10/06 23:22:16 UTC
cvs commit: jakarta-alexandria/proposal/gump/stylesheet update.xsl
rubys 01/10/06 14:22:16
Modified: proposal/gump/java Jenny.java Module.java
proposal/gump/stylesheet update.xsl
Added: proposal/gump/java Repository.java
Log:
XSL => Java
Revision Changes Path
1.3 +1 -1 jakarta-alexandria/proposal/gump/java/Jenny.java
Index: Jenny.java
===================================================================
RCS file: /home/cvs/jakarta-alexandria/proposal/gump/java/Jenny.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Jenny.java 2001/09/30 16:32:58 1.2
+++ Jenny.java 2001/10/06 21:22:16 1.3
@@ -179,9 +179,9 @@
Workspace.init(workspace);
expand(workspace);
+ Repository.load(merge("repository", workspace).elements());
Module.load(merge("module",workspace).elements());
Project.load(merge("project",workspace).elements());
- merge("repository", workspace);
output (doc, "work/merge.xml");
Node sorted = transform(doc, "sortdep.xsl");
1.3 +36 -0 jakarta-alexandria/proposal/gump/java/Module.java
Index: Module.java
===================================================================
RCS file: /home/cvs/jakarta-alexandria/proposal/gump/java/Module.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Module.java 2001/09/30 16:32:58 1.2
+++ Module.java 2001/10/06 21:22:16 1.3
@@ -43,6 +43,7 @@
computeSrcDir();
promoteProjects();
+ resolveRepository();
modules.put(name, this);
}
@@ -98,4 +99,39 @@
}
}
+ /**
+ * Resolves a repository name into a cvsroot. In the process it also
+ * decorates the cvs tag with the module name and tag info.
+ */
+ private void resolveRepository() throws Exception {
+ Node child=element.getFirstChild();
+ for (; child != null; child=child.getNextSibling()) {
+ if (! child.getNodeName().equals("cvs")) continue;
+ Element cvs = (Element) child;
+
+ cvs.setAttribute("srcdir", name);
+ if (cvs.getAttributeNode("module") == null) {
+ cvs.setAttribute("module", name);
+ }
+
+ String tag = element.getAttribute("tag");
+ if (!tag.equals("")) cvs.setAttribute("tag", tag);
+
+ Repository r = Repository.find(cvs.getAttribute("repository"));
+ String repository = ":" + r.get("method");
+ repository += ":" + r.get("user");
+
+ repository += "@";
+ if (cvs.getAttributeNode("host-prefix") != null)
+ repository += cvs.getAttribute("host-prefix") + ".";
+ repository += r.get("hostname");
+
+ repository += ":" + r.get("path");
+ if (cvs.getAttributeNode("dir") != null)
+ repository += "/" + cvs.getAttribute("dir");
+
+ cvs.setAttribute("repository", repository);
+ cvs.setAttribute("password", r.get("password"));
+ }
+ }
}
1.1 jakarta-alexandria/proposal/gump/java/Repository.java
Index: Repository.java
===================================================================
// DOM classes
import org.w3c.dom.Element;
import org.w3c.dom.Node;
// Java classes
import java.util.Enumeration;
import java.util.Vector;
import java.util.Hashtable;
public class Repository {
static private Hashtable repositories = new Hashtable();
private Element element;
private String name;
/**
* Create a set of Repository definitions based on XML nodes.
* @param moudules list of <module> elements
*/
public static void load(Enumeration repositories) throws Exception {
while (repositories.hasMoreElements()) {
new Repository((Element)repositories.nextElement());
}
}
/**
* Find a Repository given its name.
* @param name module name
* @return Repository
*/
public static Repository find(String name) {
return (Repository) repositories.get(name);
}
/**
* Constructor.
* @param element <module> element
*/
public Repository(Element element) throws Exception {
this.element = element;
name = element.getAttribute("name");
resolve(element);
repositories.put(name, this);
}
/**
* General attribute accessor.
* @param name attribute name
* @return Value of the specified attribute.
*/
public String get(String name) {
return element.getAttribute(name);
}
/**
* Use text nodes under root elements to fill in defaults for repository
* attributes.
*/
private void resolve(Node node) throws Exception {
// recurse through all children
Node child=node.getFirstChild();
for (; child != null; child=child.getNextSibling()) {
resolve(child);
}
// <parent>text<parent> => <element parent="text">
if (node.getNodeType() != Node.TEXT_NODE) return;
Node parent = node.getParentNode();
Node gparent = parent.getParentNode();
if (!gparent.getNodeName().equals("root")) return;
if (element.getAttributeNode(parent.getNodeName()) == null) {
element.setAttribute(parent.getNodeName(), node.getNodeValue());
}
}
}
1.13 +0 -96 jakarta-alexandria/proposal/gump/stylesheet/update.xsl
Index: update.xsl
===================================================================
RCS file: /home/cvs/jakarta-alexandria/proposal/gump/stylesheet/update.xsl,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- update.xsl 2001/09/20 21:20:31 1.12
+++ update.xsl 2001/10/06 21:22:16 1.13
@@ -134,100 +134,4 @@
<xsl:template match="module[not(cvs)]"/>
- <!-- =================================================================== -->
- <!-- pre-resolve repository for later convenience -->
- <!-- =================================================================== -->
-
- <xsl:template match="cvs">
- <xsl:variable name="repository" select="@repository"/>
- <cvs srcdir="{ancestor::module/@name}">
-
- <xsl:variable name="dir" select="@dir"/>
- <xsl:variable name="host-prefix" select="@host-prefix"/>
-
- <xsl:attribute name="repository">
- <xsl:for-each select="//repository[@name=$repository]">
-
- <!-- method -->
- <xsl:text>:</xsl:text>
- <xsl:choose>
- <xsl:when test="@method">
- <xsl:value-of select="@method"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="root/method"/>
- </xsl:otherwise>
- </xsl:choose>
-
- <!-- user -->
- <xsl:text>:</xsl:text>
- <xsl:choose>
- <xsl:when test="@user">
- <xsl:value-of select="@user"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="root/user"/>
- </xsl:otherwise>
- </xsl:choose>
-
- <!-- host -->
- <xsl:text>@</xsl:text>
- <xsl:if test="$host-prefix">
- <xsl:value-of select="$host-prefix"/>
- <xsl:text>.</xsl:text>
- </xsl:if>
- <xsl:choose>
- <xsl:when test="@hostname">
- <xsl:value-of select="@hostname"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="root/hostname"/>
- </xsl:otherwise>
- </xsl:choose>
-
- <!-- path -->
- <xsl:text>:</xsl:text>
- <xsl:choose>
- <xsl:when test="@path">
- <xsl:value-of select="@path"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="root/path"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:if test="$dir">
- <xsl:text>/</xsl:text>
- <xsl:value-of select="$dir"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:attribute>
-
- <!-- specify the module (defaults to module name) -->
- <xsl:attribute name="module">
- <xsl:choose>
- <xsl:when test="@module">
- <xsl:value-of select="@module"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="ancestor::module/@name"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <!-- optionally add a tag -->
- <xsl:choose>
- <xsl:when test="ancestor::module/@tag">
- <xsl:attribute name="tag">
- <xsl:value-of select="ancestor::module/@tag"/>
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="@tag">
- <xsl:attribute name="tag">
- <xsl:value-of select="@tag"/>
- </xsl:attribute>
- </xsl:when>
- </xsl:choose>
- </cvs>
- </xsl:template>
-
</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: alexandria-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: alexandria-dev-help@jakarta.apache.org