ovidiu      02/05/23 14:09:30

  Added:       tools/src check-jars.xsl
  Log:
  This is the program that does the actual work of verifying whether all
  the files in the lib/ directory are properly defined in lib/jars.xml.
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/tools/src/check-jars.xsl
  
  Index: check-jars.xsl
  ===================================================================
  <?xml version="1.0" encoding="utf-8"?>
  
  <!--
  
       Simple stylesheet to verify that files defined in lib/jars.xml
       actually appear in the lib/ directory, and vice-versa, that files
       that appear in the lib/ directory have an entry with a
       description in the lib/jars.xml file.
  
       Author: Ovidiu Predescu "[EMAIL PROTECTED]"
       Date: May 22, 2002
  
  -->
  
  <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  
    <xsl:output indent="yes"/>
    <xsl:param name="current-files"/>
  
    <xsl:variable name="directory" select="document($current-files)"/>
    <xsl:variable name="jars.xml" select="/"/>
  
    <xsl:template match="/">
      <xsl:variable name="declared" select="jars/*"/>
  
      <!-- Verify if files declared in jars.xml appear in the lib/ directory -->
      <xsl:for-each select="$declared">
        <xsl:apply-templates select="." mode="declared-but-doesnt-appear"/>
      </xsl:for-each>
  
      <!-- Verify that files that appear in lib/ are declared in jars.xml -->
      <xsl:for-each select="$directory/jars/*">
        <xsl:apply-templates select="." mode="appears-but-not-declared"/>
      </xsl:for-each>
  
      <!-- Verify that all the entries in lib/jars.xml have a description
         attribute
         -->
      <xsl:apply-templates select="//file" mode="no-description-attribute"/>
  
      <!-- Verify that all the file entries are unique -->
      <xsl:for-each select="$jars.xml/jars/file">
        <xsl:variable name="this" select="normalize-space(text())"/>
        <xsl:if test="count($jars.xml/jars/file[normalize-space(text()) = $this]) > 1">
          <xsl:message terminate="yes">
    Duplicate entry for file <xsl:value-of select="$this"/>.
          </xsl:message>
        </xsl:if>
      </xsl:for-each>
    </xsl:template>
  
  
    <!-- Template to verify if files declared in jars.xml appear in the
         lib/ directory
         -->
    <xsl:template match="node()" mode="declared-but-doesnt-appear">
      <xsl:variable name="this" select="normalize-space(text())"/>
      <xsl:if test="count($directory/jars/jar[normalize-space(text()) = $this]) = 0">
        <xsl:message terminate="yes">
    File <xsl:value-of select="$this"/> is declared in lib/jars.xml, but doesn't 
appear in the lib/ directory.
  
    If this file was removed, please update the lib/jars.xml file to remove this file 
entry.</xsl:message>
      </xsl:if>
    </xsl:template>
  
  
    <!-- Template to verify that files that appear in lib/ are declared
         in jars.xml
         -->
    <xsl:template match="node()" mode="appears-but-not-declared">
      <xsl:variable name="this" select="normalize-space(text())"/>
      <xsl:if test="count($jars.xml/jars/file[normalize-space(text()) = $this]) = 0">
        <xsl:message terminate="yes">
    File <xsl:value-of select="$this"/> appears in the lib/ directory, but is not 
declared in lib/jars.xml.
  
    Please update the lib/jars.xml file to include the <xsl:value-of select="$this"/> 
file together with a description.</xsl:message>
      </xsl:if>
    </xsl:template>
  
    <!-- Verify if a file element has a "description" attribute -->
    <xsl:template match="file[not(@description)]" mode="no-description-attribute">
      <xsl:message terminate="yes">
    Entry for file <xsl:value-of select="normalize-space(text())"/> in the 
lib/jars.xml does not have a "description" attribute.
  
    Please add a description attribute before continuing.</xsl:message>
    </xsl:template>
  
  
    <!-- Verify if a file element has an "used-by" attribute -->
    <xsl:template match="file[not(@used-by)]" mode="no-description-attribute">
      <xsl:message terminate="yes">
    Entry for file <xsl:value-of select="normalize-space(text())"/> in the 
lib/jars.xml does not have a "used-by" attribute.
  
    Please add an "used-by" attribute before continuing.</xsl:message>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to