Claudenw commented on code in PR #405:
URL: https://github.com/apache/creadur-rat/pull/405#discussion_r1868987478


##########
apache-rat-core/src/main/resources/org/apache/rat/plain-rat.xsl:
##########
@@ -19,59 +19,94 @@
 -->
 <xsl:stylesheet version="1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
-    <xsl:variable name='newline'><xsl:text>&#xa;</xsl:text></xsl:variable>
-
-<xsl:output method='text'/>
-<xsl:template match='/'>
-*****************************************************
-Summary
-*****************************************************
-Generated at: <xsl:value-of select='rat-report/@timestamp'/>
-
-Counters:
-    <xsl:for-each select='descendant::statistic'>
-            <xsl:value-of select='concat($newline, substring(concat(@name, ":  
                "), 1, 20),
-            @count)' />
-            <xsl:if test='@approval="false"'> (Exceeded limits)</xsl:if>
-            <xsl:value-of select='concat("    ", @description)' />
-    </xsl:for-each>
-
-
-Licenses detected:
-    <xsl:for-each select='descendant::licenseName'>
-    <xsl:value-of select='concat($newline, @name, ": ", @count, " ")' />
-    </xsl:for-each>
-
-License Categories detected:
-    <xsl:for-each select='descendant::licenseCategory'>
-        <xsl:value-of select='concat($newline, @name, ": ", @count, " ")' />
-    </xsl:for-each>
-
-Document Types detected:
-    <xsl:for-each select='descendant::documentType'>
-        <xsl:value-of select='concat($newline, @name, ": ", @count, " ")' />
-    </xsl:for-each>
-
-<xsl:if test="descendant::resource[license/@approval='false']">
-
-*****************************************************
-
-Files with unapproved licenses:
-
-<xsl:for-each select='descendant::resource[license/@approval="false"]'>
-  <xsl:value-of select='concat("  ",@name, $newline)'/>
-</xsl:for-each>
-*****************************************************
-</xsl:if>
-<xsl:if test="descendant::resource[@type='ARCHIVE']">
-Archives:
-<xsl:for-each select='descendant::resource[@type="ARCHIVE"]'>
-  <xsl:value-of select='concat(" ", @name, $newline)'/>
-</xsl:for-each>
-</xsl:if>
-<xsl:text>
-*****************************************************
-  Documents with unapproved licenses will start with a '!'
+    <xsl:variable name='newline'>
+        <xsl:text>&#xa;</xsl:text>
+    </xsl:variable>
+    <xsl:variable name="sectionPartition">
+        
<xsl:text>*****************************************************</xsl:text>
+    </xsl:variable>
+    <xsl:variable name="subsectionPartition">
+        
<xsl:text>-----------------------------------------------------</xsl:text>
+    </xsl:variable>
+
+    <xsl:output method='text'/>
+    <xsl:template match='/'>
+        <xsl:call-template name="section">
+            <xsl:with-param name="title">Summary</xsl:with-param>
+        </xsl:call-template>
+        <xsl:value-of select='concat("Generated at: ", rat-report/@timestamp, 
$newline, "    by ",
+    rat-report/version/@product, " ", rat-report/version/@version, " (", 
rat-report/version/@vendor, ")")'/>
+
+        <xsl:call-template name="subsection">
+            <xsl:with-param name="title">Counters</xsl:with-param>
+        </xsl:call-template>
+
+        <xsl:text>    (Entries starting with '!' exceed the minimum or maximum 
values)</xsl:text>
+        <xsl:value-of select='$newline'/>
+        <xsl:for-each select='descendant::statistic'>
+            <xsl:call-template name="statistic">
+                <xsl:with-param name="name"><xsl:value-of 
select="@name"/></xsl:with-param>
+                <xsl:with-param name="count"><xsl:value-of 
select="@count"/></xsl:with-param>
+                <xsl:with-param name="description"><xsl:value-of 
select="@description"/></xsl:with-param>
+                <xsl:with-param name="leadin"><xsl:choose>
+                    <xsl:when test='@approval="false"'><xsl:text>! 
</xsl:text></xsl:when>
+                    <xsl:otherwise><xsl:text>  </xsl:text></xsl:otherwise>
+                </xsl:choose></xsl:with-param>
+            </xsl:call-template>
+        </xsl:for-each>
+
+        <xsl:call-template name="subsection">
+            <xsl:with-param name="title">Licenses detected</xsl:with-param>
+        </xsl:call-template>
+
+        <xsl:for-each select='descendant::licenseName'>
+            <xsl:value-of select='concat($newline, @name, ": ", @count, " ")'/>
+        </xsl:for-each>
+
+        <xsl:call-template name="subsection">
+            <xsl:with-param name="title">License Categories 
detected</xsl:with-param>
+        </xsl:call-template>
+
+        <xsl:for-each select='descendant::licenseCategory'>
+            <xsl:value-of select='concat($newline, @name, ": ", @count, " ")'/>
+        </xsl:for-each>
+
+        <xsl:call-template name="subsection">
+            <xsl:with-param name="title">Document Types 
detected</xsl:with-param>
+        </xsl:call-template>
+
+        <xsl:for-each select='descendant::documentType'>
+            <xsl:value-of select='concat($newline, @name, ": ", @count, " ")'/>
+        </xsl:for-each>
+
+        <xsl:if test="descendant::resource[license/@approval='false']">
+            <xsl:value-of select="concat($newline, $newline)" />
+            <xsl:call-template name="section">
+                <xsl:with-param name="title">Files with unapproved 
licenses</xsl:with-param>
+            </xsl:call-template>
+
+            <xsl:for-each 
select='descendant::resource[license/@approval="false"]'>
+                <xsl:value-of select='concat($newline, "  ", @name)'/>
+            </xsl:for-each>
+
+        </xsl:if>
+
+        <xsl:if test="descendant::resource[@type='ARCHIVE']">
+            <xsl:value-of select="concat($newline, $newline)" />
+            <xsl:call-template name="section">
+                <xsl:with-param name="title">Archives</xsl:with-param>
+            </xsl:call-template>
+
+            <xsl:for-each select='descendant::resource[@type="ARCHIVE"]'>
+                <xsl:value-of select='concat($newline, " ", @name)'/>
+            </xsl:for-each>
+        </xsl:if>
+        <xsl:value-of select="concat($newline, $newline)" />
+        <xsl:call-template name="section">
+            <xsl:with-param name="title">Detail</xsl:with-param>
+        </xsl:call-template>
+        <xsl:text>
+  The line following documents with unapproved licenses will start with a '!'

Review Comment:
   The proposed output looks like this:
   
   ```
   The line following documents with unapproved licenses will start with a '!'
     The next character identifies the document type.
   
      char         type
       A       Archive file
       B       Binary file
       G       Generated file
       N       Notice file
       S       Standard file
       U       Unknown file.
   
   /ILoggerFactory.java
     S         text/x-java-source    ISO-8859-1
       MIT      MIT           The MIT License
   
   /Image.png
     B         image/png
   
   /LICENSE
     N         text/plain
   
   /NOTICE
     N         text/plain
   
   /Source.java
    !S         text/x-java-source    ISO-8859-1
       ?????    ?????         Unknown license (Unapproved)
   
   ```
   
   So the '!' is on the line following the file name.  Note that file names can 
be very long, particularly when provided by the --input-source option.
   
   I wanted to keep the filename as the first entry in a block, and I wanted to 
distinguish the mime type and encoding from the licenses so that it would be 
fairly easy to scan the output.
   
   We could also expand the character prefix to the description or name.  For 
example `/Source.java` would look like
   
   ```
   /Source.java
    !Standard file         text/x-java-source    ISO-8859-1
       ?????    ?????         Unknown license (Unapproved)
   ```
   or
   ```
   /Source.java
    !Standard         text/x-java-source    ISO-8859-1
       ?????    ?????         Unknown license (Unapproved)
   ```
   
   but that looks a bit busy.
   
   I could put the "! " at the beginning of the files that have problems
   
   ```
   /ILoggerFactory.java
     S         text/x-java-source    ISO-8859-1
       MIT      MIT           The MIT License
   
   ! /Source.java
     S         text/x-java-source    ISO-8859-1
       ?????    ?????         Unknown license (Unapproved)
   ```
   
   As a final suggestion in this response we could intend the file names by 2 
spaces and leave the "!" hanging out there to be quickly found
   
   ```
     /ILoggerFactory.java
     S         text/x-java-source    ISO-8859-1
       MIT      MIT           The MIT License
   
     /Image.png
     B         image/png
   
     /LICENSE
     N         text/plain
   
     /NOTICE
     N         text/plain
   
   ! /Source.java
     S         text/x-java-source    ISO-8859-1
       ?????    ?????         Unknown license (Unapproved)
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@creadur.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to