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/09/19 00:48:14 UTC

cvs commit: jakarta-alexandria/proposal/gump/stylesheet defaults.xsl

rubys       01/09/18 15:48:14

  Modified:    proposal/gump gen.java
               proposal/gump/stylesheet defaults.xsl
  Log:
  Move 1/2 of defaults.xsl to java
  
  Revision  Changes    Path
  1.12      +47 -7     jakarta-alexandria/proposal/gump/gen.java
  
  Index: gen.java
  ===================================================================
  RCS file: /home/cvs/jakarta-alexandria/proposal/gump/gen.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- gen.java	2001/09/18 16:27:46	1.11
  +++ gen.java	2001/09/18 22:48:14	1.12
  @@ -32,6 +32,8 @@
   
   public class gen {
   
  +    static final String GUMP_VERSION = "0.3";
  +
       DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
       TransformerFactory tFactory = TransformerFactory.newInstance();
   
  @@ -246,20 +248,58 @@
       }
   
       /**
  +      * Default and verify various workspace attributes.
  +      * If not specified:
  +      *   banner-image="http://jakarta.apache.org/images/jakarta-logo.gif"
  +      *   banner-link="http://jakarta.apache.org"
  +      *   logdir=basedir+"/log"
  +      *   cvsdir=basedir+"/cvs"
  +      * @param Workspace element to be updated
  +      */
  +    private void workspaceDefaults(Element workspace) throws Exception {
  +        if (!workspace.getAttribute("version").equals(GUMP_VERSION)) {
  +            throw new Exception("workspace version " + GUMP_VERSION + 
  +                                " required.");
  +        }
  +
  +        String basedir = workspace.getAttribute("basedir");
  +
  +        if (workspace.getAttribute("banner-image").equals("")) {
  +            workspace.setAttribute("banner-image", 
  +                "http://jakarta.apache.org/images/jakarta-logo.gif");
  +        }
  +
  +        if (workspace.getAttribute("banner-link").equals("")) {
  +            workspace.setAttribute("banner-link", "http://jakarta.apache.org");
  +        }
  +
  +        if (workspace.getAttribute("logdir").equals("")) {
  +            workspace.setAttribute("logdir", basedir + "/log");
  +        }
  +
  +        if (workspace.getAttribute("cvsdir").equals("")) {
  +            workspace.setAttribute("cvsdir", basedir + "/cvs");
  +        }
  +    }
  +
  +    /**
         * merge, sort, and insert defaults into a workspace
         * @param DOM to be transformed
         * @param sheet to be used
         * @return Node
         */
       private gen(String source) throws Exception {
  -	Document workspace = parse(source);
  -	expand((Element)workspace.getFirstChild());
  -	flatten("project", workspace.getFirstChild());
  -	flatten("repository", workspace.getFirstChild());
  -	antDependsToProperties(workspace);
  -        computeSrcdir((Element) workspace.getFirstChild());
  +	Document doc = parse(source);
  +	Element workspace = (Element)doc.getFirstChild();
  +        workspaceDefaults(workspace);
  +
  +	expand((Element)workspace);
  +	flatten("project", workspace);
  +	flatten("repository", workspace);
  +	antDependsToProperties(doc);
  +        computeSrcdir((Element) workspace);
   
  -	Node resolved = transform(workspace, "defaults.xsl");
  +	Node resolved = transform(doc, "defaults.xsl");
   	output (resolved, "work/merge.xml");
   
   	Node sorted   = transform(resolved, "sortdep.xsl");
  
  
  
  1.11      +0 -65     jakarta-alexandria/proposal/gump/stylesheet/defaults.xsl
  
  Index: defaults.xsl
  ===================================================================
  RCS file: /home/cvs/jakarta-alexandria/proposal/gump/stylesheet/defaults.xsl,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- defaults.xsl	2001/09/18 21:25:59	1.10
  +++ defaults.xsl	2001/09/18 22:48:14	1.11
  @@ -11,71 +11,6 @@
     </xsl:template>
   
     <!-- =================================================================== -->
  -  <!--           process all projects referenced in a workspace            -->
  -  <!-- =================================================================== -->
  -
  -  <xsl:template match="workspace">
  -    <xsl:variable name="basedir" select="@basedir"/>
  -    <xsl:variable name="version">0.3</xsl:variable>
  -
  -    <xsl:if test="not(@version)">
  -      <xsl:message terminate="yes">
  -        <xsl:text>Cannot find version number, should be </xsl:text>
  -        <xsl:text>&lt;workspace version="</xsl:text>
  -        <xsl:value-of select="$version"/>
  -        <xsl:text>"&gt;</xsl:text>
  -      </xsl:message>
  -    </xsl:if>
  -
  -    <xsl:if test="not(@version=$version)">
  -      <xsl:message terminate="yes">
  -        <xsl:text>Hmm, looks like the wrong version </xsl:text>
  -        <xsl:value-of select="@version"/>
  -        <xsl:text>, expecting </xsl:text>
  -        <xsl:value-of select="$version"/>
  -      </xsl:message>
  -    </xsl:if>
  -
  -    <xsl:copy>
  -
  -      <!-- default banner-image, if not present -->
  -      <xsl:if test="not(@banner-image)">
  -        <xsl:attribute name="banner-image">
  -          <xsl:text>http://jakarta.apache.org/images/jakarta-logo.gif</xsl:text>
  -        </xsl:attribute>
  -      </xsl:if>
  -
  -      <!-- default banner-link, if not present -->
  -      <xsl:if test="not(@banner-link)">
  -        <xsl:attribute name="banner-link">
  -          <xsl:text>http://jakarta.apache.org</xsl:text>
  -        </xsl:attribute>
  -      </xsl:if>
  -
  -      <!-- default log directory, if not present -->
  -      <xsl:if test="not(@logdir)">
  -        <xsl:attribute name="logdir">
  -          <xsl:value-of select="$basedir"/>
  -          <xsl:text>/log</xsl:text>
  -        </xsl:attribute>
  -      </xsl:if>
  -
  -      <!-- default cvs directory, if not present -->
  -      <xsl:if test="not(@cvsdir)">
  -        <xsl:attribute name="cvsdir">
  -          <xsl:value-of select="$basedir"/>
  -          <xsl:text>/cvs</xsl:text>
  -        </xsl:attribute>
  -      </xsl:if>
  -
  -      <!-- copy the rest -->
  -      <xsl:apply-templates select="* | @* | text()"/>
  -
  -    </xsl:copy>
  -
  -  </xsl:template>
  -
  -  <!-- =================================================================== -->
     <!--      resolve paths and add implicit dependencies to a project       -->
     <!-- =================================================================== -->
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: alexandria-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: alexandria-dev-help@jakarta.apache.org