maven-plugin-pmd-build: whitespace for xsl

This commit is contained in:
Andreas Dangel
2015-03-14 11:47:56 +01:00
parent 9860ded4c8
commit 08c89fb4f5
5 changed files with 237 additions and 204 deletions

View File

@ -1,23 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
BSD-style license; for more info see http://pmd.sourceforge.net/license.html
-->
<!-- BSD-style license; for more info see http://pmd.sourceforge.net/license.html -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:param name="menufile"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:param name="menufile" />
<!-- Copy all nodes from here. Can be overridden by a more specific XPath -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="//menu[@name='Rule Sets']">
<!-- <xsl:message>Edit existing site.xml with <xsl:value-of select="$menufile"/></xsl:message> -->
<xsl:variable name="items_to_add" select="document($menufile)"/>
<xsl:copy-of select="$items_to_add"/>
<xsl:apply-templates/>
<!-- <xsl:message>Edit existing site.xml with <xsl:value-of select="$menufile"/></xsl:message> -->
<xsl:variable name="items_to_add" select="document($menufile)" />
<xsl:copy-of select="$items_to_add" />
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>

View File

@ -1,37 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
BSD-style license; for more info see http://pmd.sourceforge.net/license.html
-->
<!-- BSD-style license; for more info see http://pmd.sourceforge.net/license.html -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="root">
<xsl:comment>THIS FILE HAS BEEN AUTOMATICLY GENERATED.</xsl:comment>
<menu name="Rule Sets">
<xsl:apply-templates/>
</menu>
</xsl:template>
<xsl:template match="root">
<xsl:comment>
THIS FILE HAS BEEN AUTOMATICLY GENERATED.
</xsl:comment>
<menu name="Rule Sets">
<xsl:apply-templates />
</menu>
</xsl:template>
<xsl:template match="language">
<xsl:variable name="language"><xsl:value-of select="@name"/></xsl:variable>
<xsl:element name="item">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="collapse"><xsl:value-of select="'false'"/></xsl:attribute>
<xsl:attribute name="href">/rules/index.html</xsl:attribute>
<xsl:template match="language">
<xsl:variable name="language">
<xsl:value-of select="@name" />
</xsl:variable>
<xsl:element name="item">
<xsl:attribute name="name"><xsl:value-of select="@name" /></xsl:attribute>
<xsl:attribute name="collapse"><xsl:value-of select="'false'" /></xsl:attribute>
<xsl:attribute name="href">/rules/index.html</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="ruleset">
<xsl:variable name="ruleset_file" select="document(@file)"/>
<!--
<xsl:message>Looking in <xsl:value-of select="@file"/> to find ruleset "pretty" name: <xsl:value-of select="document(@file)//attribute::name"/></xsl:message>
!-->
<xsl:element name="item">
<xsl:attribute name="name"><xsl:value-of select="$ruleset_file//attribute::name"/></xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="concat('/rules/',concat(@language,concat('/',concat(substring-before(@filename,'.'),'.html'))))"/></xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="ruleset">
<xsl:variable name="ruleset_file" select="document(@file)" />
<!-- <xsl:message>Looking in <xsl:value-of select="@file"/> to find ruleset "pretty" name: <xsl:value-of select="document(@file)//attribute::name"/></xsl:message>
! -->
<xsl:element name="item">
<xsl:attribute name="name"><xsl:value-of select="$ruleset_file//attribute::name" /></xsl:attribute>
<xsl:attribute name="href"><xsl:value-of
select="concat('/rules/',concat(@language,concat('/',concat(substring-before(@filename,'.'),'.html'))))" /></xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

View File

@ -1,32 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
BSD-style license; for more info see http://pmd.sourceforge.net/license.html
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- BSD-style license; for more info see http://pmd.sourceforge.net/license.html -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="root">
<xsl:comment>
THIS FILE HAS BEEN AUTOMATICLY GENERATED.
<xsl:comment>
THIS FILE HAS BEEN AUTOMATICLY GENERATED.
</xsl:comment>
<rulesets>
<xsl:apply-templates/>
</rulesets>
<rulesets>
<xsl:apply-templates />
</rulesets>
</xsl:template>
<xsl:template match="ruleset">
<!-- Opening the appropriate file -->
<xsl:variable name="filename" select="@file"/>
<!-- Opening the appropriate file -->
<xsl:variable name="filename" select="@file" />
<xsl:element name="language">
<xsl:attribute name="name"><xsl:value-of select="@language"/></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="@language" /></xsl:attribute>
<!-- Adding to our tree all the nodes present there -->
<xsl:variable name="rules_file" select="document($filename)"/>
<xsl:copy-of select="$rules_file"/>
</xsl:element>
<!-- Adding to our tree all the nodes present there -->
<xsl:variable name="rules_file" select="document($filename)" />
<xsl:copy-of select="$rules_file" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>

View File

@ -1,110 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
BSD-style license; for more info see http://pmd.sourceforge.net/license.html
-->
<!-- BSD-style license; for more info see http://pmd.sourceforge.net/license.html -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<!-- FUTURE: Externalising text to allow i18n generation -->
<xsl:variable name="Since" select="'Since: PMD '"/>
<xsl:variable name="definedByJavaClass" select="'This rule is defined by the following Java class'"/>
<xsl:variable name="ExampleLabel" select="'Example(s)'"/>
<xsl:variable name="PropertiesLabel" select="'This rule has the following properties'"/>
<xsl:variable name="Property.Name" select="'Name'"/>
<xsl:variable name="Property.DefaultValue" select="'Default Value'"/>
<xsl:variable name="Property.Desc" select="'Description'"/>
<xsl:variable name="RuleSet" select="'Ruleset'"/>
<!-- FUTURE: Externalising text to allow i18n generation -->
<xsl:variable name="Since" select="'Since: PMD '" />
<xsl:variable name="definedByJavaClass" select="'This rule is defined by the following Java class'" />
<xsl:variable name="ExampleLabel" select="'Example(s)'" />
<xsl:variable name="PropertiesLabel" select="'This rule has the following properties'" />
<xsl:variable name="Property.Name" select="'Name'" />
<xsl:variable name="Property.DefaultValue" select="'Default Value'" />
<xsl:variable name="Property.Desc" select="'Description'" />
<xsl:variable name="RuleSet" select="'Ruleset'" />
<xsl:template match="ruleset">
<document>
<xsl:variable name="rulesetname" select="@name"/>
<properties>
<author email="tom@infoether.com">Tom Copeland</author>
<title><xsl:value-of select="$RuleSet"/>: <xsl:value-of select="$rulesetname"/></title>
</properties>
<body>
<section>
<xsl:attribute name="name">
<xsl:value-of select="$rulesetname"/>
</xsl:attribute>
<xsl:apply-templates/>
</section>
</body>
</document>
</xsl:template>
<xsl:template match="ruleset">
<document>
<xsl:variable name="rulesetname" select="@name" />
<properties>
<author email="tom@infoether.com">Tom Copeland</author>
<title>
<xsl:value-of select="$RuleSet" />: <xsl:value-of select="$rulesetname" />
</title>
</properties>
<body>
<section>
<xsl:attribute name="name">
<xsl:value-of select="$rulesetname" />
</xsl:attribute>
<xsl:apply-templates />
</section>
</body>
</document>
</xsl:template>
<xsl:template match="rule[@name]">
<xsl:variable name="rulename" select="@name"/>
<xsl:variable name="classname" select="@class"/>
<xsl:template match="rule[@name]">
<xsl:variable name="rulename" select="@name" />
<xsl:variable name="classname" select="@class" />
<subsection>
<xsl:attribute name="name">
<xsl:value-of select="$rulename"/>
</xsl:attribute>
<p><xsl:value-of select="$Since"/><xsl:value-of select="@since"/></p>
<p><xsl:value-of select="description"/></p>
<xsl:choose>
<xsl:when test="count(properties/property[@name='xpath']) != 0">
<source>
<xsl:value-of select="properties/property/value"/>
</source>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="classfile">
<xsl:call-template name="url-maker">
<xsl:with-param name="classname" select="$classname"/>
</xsl:call-template>
</xsl:variable>
<p><xsl:value-of select="$definedByJavaClass"/>: <a><xsl:attribute name="href"><xsl:value-of select="concat(concat('../../xref/',$classfile),'.html')"/></xsl:attribute><xsl:value-of select="@class"/></a>
</p>
</xsl:otherwise>
</xsl:choose>
<subsection>
<xsl:attribute name="name">
<xsl:value-of select="$rulename" />
</xsl:attribute>
<p>
<xsl:value-of select="$Since" />
<xsl:value-of select="@since" />
</p>
<p>
<xsl:value-of select="description" />
</p>
<xsl:choose>
<xsl:when test="count(properties/property[@name='xpath']) != 0">
<source>
<xsl:value-of select="properties/property/value" />
</source>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="classfile">
<xsl:call-template name="url-maker">
<xsl:with-param name="classname" select="$classname" />
</xsl:call-template>
</xsl:variable>
<p>
<xsl:value-of select="$definedByJavaClass" />
:
<a>
<xsl:attribute name="href"><xsl:value-of
select="concat(concat('../../xref/',$classfile),'.html')" /></xsl:attribute>
<xsl:value-of select="@class" />
</a>
</p>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="./example">
<xsl:for-each select="./example">
<xsl:value-of select="$ExampleLabel"/>:
<source>
<xsl:value-of select="."/>
</source>
</xsl:for-each>
<xsl:value-of select="$ExampleLabel" />:
<source>
<xsl:value-of select="." />
</source>
</xsl:for-each>
<xsl:variable name="hasproperties" select="count(properties/property[@name!='xpath'])"/>
<xsl:choose>
<xsl:when test="$hasproperties != 0">
<p><xsl:value-of select="$PropertiesLabel"/>:</p>
<table><th><xsl:value-of select="$Property.Name"/></th><th><xsl:value-of select="$Property.DefaultValue"/></th><th><xsl:value-of select="$Property.Desc"/></th>
<xsl:for-each select="properties/property[@name != 'xpath']">
<tr>
<td><xsl:value-of select="@name"/></td>
<td><xsl:value-of select="@value"/></td>
<td><xsl:value-of select="@description"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:when>
</xsl:choose>
<xsl:variable name="hasproperties" select="count(properties/property[@name!='xpath'])" />
<xsl:choose>
<xsl:when test="$hasproperties != 0">
<p>
<xsl:value-of select="$PropertiesLabel" />:
</p>
<table>
<th>
<xsl:value-of select="$Property.Name" />
</th>
<th>
<xsl:value-of select="$Property.DefaultValue" />
</th>
<th>
<xsl:value-of select="$Property.Desc" />
</th>
<xsl:for-each select="properties/property[@name != 'xpath']">
<tr>
<td>
<xsl:value-of select="@name" />
</td>
<td>
<xsl:value-of select="@value" />
</td>
<td>
<xsl:value-of select="@description" />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:when>
</xsl:choose>
</subsection>
</xsl:template>
</subsection>
</xsl:template>
<!-- Watch out, recursing function... -->
<xsl:template name="url-maker">
<xsl:param name="classname" select="."/>
<!--
<xsl:message>classname is:<xsl:value-of select="$classname"/></xsl:message>
-->
<!-- Watch out, recursing function... -->
<xsl:template name="url-maker">
<xsl:param name="classname" select="." />
<!-- <xsl:message>classname is:<xsl:value-of select="$classname"/></xsl:message> -->
<xsl:choose>
<xsl:when test="contains($classname,'.')">
<xsl:variable name="pre" select="concat(substring-before($classname,'.'),'/')" />
<xsl:when test="contains($classname,'.')">
<xsl:variable name="pre" select="concat(substring-before($classname,'.'),'/')" />
<xsl:variable name="post" select="substring-after($classname,'.')" />
<xsl:call-template name="url-maker">
<xsl:with-param name="classname" select="concat($pre,$post)"/>
<xsl:with-param name="classname" select="concat($pre,$post)" />
</xsl:call-template>
</xsl:when>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$classname"/>
<xsl:value-of select="$classname" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:template>
</xsl:stylesheet>

View File

@ -1,61 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
BSD-style license; for more info see http://pmd.sourceforge.net/license.html
-->
<!-- BSD-style license; for more info see http://pmd.sourceforge.net/license.html -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<!-- FUTURE: Externalising text to allow i18n documnetation -->
<xsl:variable name="Title" select="'PMD Rulesets index'"/>
<xsl:variable name="PageDesc" select="'List of rulesets and rules contained in each ruleset.'"/>
<!-- FUTURE: Externalising text to allow i18n documnetation -->
<xsl:variable name="Title" select="'PMD Rulesets index'" />
<xsl:variable name="PageDesc" select="'List of rulesets and rules contained in each ruleset.'" />
<xsl:template match="rulesets">
<document>
<properties>
<author email="mikkey@sourceforge.net">Miguel Griffa</author>
<title><xsl:value-of select="$Title"/></title>
</properties>
<body>
<section name="Current Rulesets">
<p><xsl:value-of select="$PageDesc"/></p>
<ul>
<xsl:for-each select="./language/ruleset">
<xsl:sort select="@name"/>
<li>
<a>
<xsl:attribute name="href">#<xsl:value-of select="translate(normalize-space(@name),' ','_')"/></xsl:attribute>
<xsl:value-of select="@name"/>
</a>: <xsl:value-of select="description"/>
</li>
</xsl:for-each>
</ul>
<xsl:template match="rulesets">
<document>
<properties>
<author email="mikkey@sourceforge.net">Miguel Griffa</author>
<title>
<xsl:value-of select="$Title" />
</title>
</properties>
<body>
<section name="Current Rulesets">
<p>
<xsl:value-of select="$PageDesc" />
</p>
<ul>
<xsl:for-each select="./language/ruleset">
<xsl:sort select="@name" />
<li>
<a>
<xsl:attribute name="href">#<xsl:value-of
select="translate(normalize-space(@name),' ','_')" /></xsl:attribute>
<xsl:value-of select="@name" />
</a>: <xsl:value-of select="description" />
</li>
</xsl:for-each>
</ul>
<xsl:variable name="urlPrefixLength"><xsl:value-of select="string-length('${pmd.website.baseurl}/rules/')"/></xsl:variable>
<xsl:variable name="urlPrefixLength">
<xsl:value-of select="string-length('${pmd.website.baseurl}/rules/')" />
</xsl:variable>
<xsl:for-each select="language">
<xsl:variable name="language"><xsl:value-of select="@name"/></xsl:variable>
<xsl:for-each select="ruleset">
<xsl:element name="a">
<xsl:attribute name="name">
<xsl:value-of select="translate(normalize-space(@name),' ','_')"/>
</xsl:attribute>
</xsl:element>
<subsection>
<xsl:attribute name="name"><xsl:value-of select="@name"/> (<xsl:value-of select="$language"/>)</xsl:attribute>
<ul>
<xsl:for-each select="./rule[@name]">
<li>
<a>
<xsl:attribute name="href"><xsl:value-of select="substring(@externalInfoUrl,$urlPrefixLength + 1)"/></xsl:attribute>
<xsl:value-of select="@name"/>
</a>: <xsl:value-of select="description"/></li>
</xsl:for-each>
</ul>
</subsection>
</xsl:for-each>
</xsl:for-each>
</section>
</body>
</document>
</xsl:template>
<xsl:for-each select="language">
<xsl:variable name="language">
<xsl:value-of select="@name" />
</xsl:variable>
<xsl:for-each select="ruleset">
<xsl:element name="a">
<xsl:attribute name="name">
<xsl:value-of select="translate(normalize-space(@name),' ','_')" />
</xsl:attribute>
</xsl:element>
<subsection>
<xsl:attribute name="name"><xsl:value-of select="@name" /> (<xsl:value-of
select="$language" />)</xsl:attribute>
<ul>
<xsl:for-each select="./rule[@name]">
<li>
<a>
<xsl:attribute name="href"><xsl:value-of
select="substring(@externalInfoUrl,$urlPrefixLength + 1)" /></xsl:attribute>
<xsl:value-of select="@name" />
</a>: <xsl:value-of select="description" />
</li>
</xsl:for-each>
</ul>
</subsection>
</xsl:for-each>
</xsl:for-each>
</section>
</body>
</document>
</xsl:template>
</xsl:stylesheet>