rubys       01/09/29 08:41:06

  Modified:    proposal/gump gen.java
               proposal/gump/stylesheet build.xsl defaults.xsl
  Log:
  More XSLT => Java
  
  Revision  Changes    Path
  1.16      +48 -3     jakarta-alexandria/proposal/gump/gen.java
  
  Index: gen.java
  ===================================================================
  RCS file: /home/cvs/jakarta-alexandria/proposal/gump/gen.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- gen.java  2001/09/28 05:50:21     1.15
  +++ gen.java  2001/09/29 15:41:06     1.16
  @@ -37,6 +37,8 @@
       DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
       TransformerFactory tFactory = TransformerFactory.newInstance();
   
  +    Hashtable modules;
  +
       /**
         * parse an XML source file into an DOM
         * @param name of source file
  @@ -242,7 +244,7 @@
         */
       private void computeSrcdir(Element workspace) throws Exception {
           String basedir = workspace.getAttribute("basedir");
  -        Hashtable modules = flatten("module", workspace);
  +        modules = flatten("module", workspace);
           for (Enumeration e=modules.keys(); e.hasMoreElements();) {
                Element module = (Element)modules.get(e.nextElement());
                String name = module.getAttribute("name");
  @@ -267,6 +269,49 @@
       }
   
       /**
  +      * Flatten all projects, and in the process resolve all home directories.
  +      */
  +    private void computeHome(Element workspace) throws Exception {
  +        String basedir = workspace.getAttribute("basedir");
  +        String pkgdir = workspace.getAttribute("pkgdir");
  +        if (pkgdir.equals("")) pkgdir = basedir;
  +
  +        Hashtable projects = flatten("project", workspace);
  +        for (Enumeration keys=projects.keys(); keys.hasMoreElements();) {
  +             String name = (String)keys.nextElement();
  +             Element project = (Element)projects.get(name);
  +
  +             String moduleName = project.getAttribute("module");
  +             Element module= (Element)modules.get(moduleName);
  +             String srcdir = module.getAttribute("srcdir");
  +             
  +             // compute home directory
  +             String home=project.getAttribute("home");
  +             if (home.equals("")) {
  +                 Element e = (Element)XPathAPI.selectSingleNode(project,"home");
  +                 if (e != null) {
  +                     String attr;
  +                     if (! (attr=e.getAttribute("parent")).equals("")) {
  +                         home = basedir + "/" + attr;
  +                     } else if (! (attr=e.getAttribute("nested")).equals("")) {
  +                         home = srcdir + "/" + attr;
  +                     } else if (! (attr=e.getAttribute("dir")).equals("")) {
  +                         home = attr;
  +                     }
  +                 }
  +
  +                 if (home.equals("")) {
  +                     String pkg = project.getAttribute("package");
  +                     if (!pkg.equals("")) home = pkgdir + "/" + pkg;
  +                 }
  +
  +                 if (home.equals("")) home=srcdir;
  +                 project.setAttribute("home", home);
  +             }
  +        }
  +    }
  +
  +    /**
         * Default and verify various workspace attributes.
         * If not specified:
         *   banner-image="http://jakarta.apache.org/images/jakarta-logo.gif";
  @@ -313,8 +358,8 @@
           workspaceDefaults(workspace);
   
           expand((Element)workspace);
  -        computeSrcdir((Element) workspace);
  -        flatten("project", workspace);
  +        computeSrcdir(workspace);
  +        computeHome(workspace);
           flatten("repository", workspace);
           antDependsToProperties(doc);
   
  
  
  
  1.31      +5 -5      jakarta-alexandria/proposal/gump/stylesheet/build.xsl
  
  Index: build.xsl
  ===================================================================
  RCS file: /home/cvs/jakarta-alexandria/proposal/gump/stylesheet/build.xsl,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- build.xsl 2001/09/28 05:28:42     1.30
  +++ build.xsl 2001/09/29 15:41:06     1.31
  @@ -177,7 +177,7 @@
               <prereq project="{@project}">
                 <xsl:for-each select="/workspace/project[@name=$dependent]">
                   <xsl:for-each select="jar">
  -                  <file path="{../home}/{@name}"/>
  +                  <file path="{../@home}/{@name}"/>
                   </xsl:for-each>
                 </xsl:for-each>
               </prereq>
  @@ -210,7 +210,7 @@
                   <xsl:variable name="dependent" select="@project"/>
                   <xsl:for-each select="/workspace/project[@name=$dependent]">
                     <xsl:for-each select="jar">
  -                    <pathelement location="{../home}/{@name}"/>
  +                    <pathelement location="{../@home}/{@name}"/>
                     </xsl:for-each>
                   </xsl:for-each>
                 </xsl:for-each>
  @@ -268,7 +268,7 @@
             <xsl:when test="@reference='home'">
               <xsl:variable name="project" select="@project"/>
               <xsl:for-each select="/workspace/project[@name=$project]">
  -              <property name="{$name}" value="{home}" type="path"/>
  +              <property name="{$name}" value="{@home}" type="path"/>
               </xsl:for-each>
             </xsl:when>
   
  @@ -292,12 +292,12 @@
               <xsl:if test="@id">
                 <xsl:variable name="id" select="@id"/>
                 <xsl:for-each select="/workspace/project[@name=$project]">
  -                <property name="{$name}" value="{home}/{jar[@id=$id]/@name}" 
type="path"/>
  +                <property name="{$name}" value="{@home}/{jar[@id=$id]/@name}" 
type="path"/>
                 </xsl:for-each>
               </xsl:if>
               <xsl:if test="not(@id)">
                 <xsl:for-each select="/workspace/project[@name=$project]/jar">
  -                <property name="{$name}" value="{../home}/{@name}" type="path"/>
  +                <property name="{$name}" value="{../@home}/{@name}" type="path"/>
                 </xsl:for-each>
               </xsl:if>
             </xsl:when>
  
  
  
  1.14      +1 -38     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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- defaults.xsl      2001/09/28 05:28:42     1.13
  +++ defaults.xsl      2001/09/29 15:41:06     1.14
  @@ -18,45 +18,8 @@
   
       <xsl:variable name="project" select="@name"/>
   
  -    <!-- determine the name of the module -->
  -
  -    <xsl:variable name="module" select="@module"/>
  -    <xsl:variable name="srcdir" select="../module[@name=$module]/@srcdir"/>
  -
       <xsl:copy>
  -      <xsl:apply-templates select="@* | *[not(self::home)] | text()"/>
  -
  -      <!-- Compute fully qualified home directory -->
  -
  -      <home>
  -        <xsl:choose>
  -          <xsl:when test="@home">
  -             <xsl:value-of select="@home"/>
  -          </xsl:when>
  -          <xsl:when test="home/@parent">
  -             <xsl:value-of select="../@basedir"/>
  -             <xsl:text>/</xsl:text>
  -             <xsl:value-of select="home/@parent"/>
  -          </xsl:when>
  -          <xsl:when test="home/@nested">
  -             <xsl:value-of select="$srcdir"/>
  -             <xsl:text>/</xsl:text>
  -             <xsl:value-of select="home/@nested"/>
  -          </xsl:when>
  -          <xsl:when test="home/@dir">
  -             <xsl:value-of select="@dir"/>
  -          </xsl:when>
  -          <xsl:when test="@package">
  -             <xsl:value-of select="../@pkgdir"/>
  -             <xsl:text>/</xsl:text>
  -             <xsl:value-of select="@package"/>
  -          </xsl:when>
  -          <xsl:otherwise>
  -             <xsl:value-of select="$srcdir"/>
  -          </xsl:otherwise>
  -        </xsl:choose>
  -      </home>
  -      <xsl:text>&#10;</xsl:text>
  +      <xsl:apply-templates select="@* | * | text()"/>
   
         <!-- Generate additional dependency entries, as needed -->
   
  
  
  

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

Reply via email to