Last active
February 8, 2019 02:37
-
-
Save Stwissel/cc2289fc319f468deacee7ba7649a4e6 to your computer and use it in GitHub Desktop.
XSLT Stylesheet to report on Validation formulas in Salesforce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" | |
exclude-result-prefixes="xs xd" | |
version="2.0"> | |
<xsl:output method="html" omit-xml-declaration="yes" use-character-maps="no-control-characters"/> | |
<xsl:template match="/"> | |
<html> | |
<head> | |
<title>Validation Rules Report</title> | |
<script src="excel-formula.min.js" /> | |
<style> | |
body { padding: 10px; } | |
body, td {font-family: Verdana, Arial, sans-serif; font-size: x-small} | |
tr {vertical-align: top} | |
tr.disabled { background-color: #EFEFEF; color: #666666;} | |
td { border-top: 1px solid gray; border-left: 1px solid gray; margin: 0px; padding: 5px; word-wrap: break-word; word-break:break-all;} | |
td.ruleName { color: #000066; width: 40% } | |
td.ruleMessage { border-right: 1px solid gray;} | |
td.disabled {text-decoration: line-through;} | |
td.errorDisplay {font-weight: bold; background-color: #FFEEEE;} | |
td.formula {border-bottom: 2px solid black; border-right: 1px solid gray;} | |
th {text-align: left; margin: 0px; padding-top: 15px; padding: 3px; } | |
table { width: 100%; border-spacing: 0;} | |
</style> | |
</head> | |
<body> | |
<h1>Validation Formula Report</h1> | |
<ul> | |
<li> | |
Objects with validation rules: <xsl:value-of select="count(/Validations/Validation)"/> | |
</li> | |
<li> | |
Total number of validation rules: <xsl:value-of select="count(/Validations/Validation/Rule)"/> | |
</li> | |
<li> | |
Active number of validation rules: <xsl:value-of select="count(/Validations/Validation/Rule[active='true'])"/> | |
</li> | |
<li> | |
Rules next to fields: <xsl:value-of select="count(/Validations/Validation/Rule/errorDisplayField)" /> | |
</li> | |
</ul> | |
<xsl:apply-templates /> | |
</body> | |
</html> | |
</xsl:template> | |
<xsl:template match="Validations"> | |
<table> | |
<thead> | |
<th>Name</th> | |
<th>Message</th> | |
</thead> | |
<tbody> | |
<xsl:apply-templates /> | |
</tbody> | |
</table> | |
</xsl:template> | |
<xsl:template match="Validation"> | |
<tr> | |
<th colspan="2"> | |
<xsl:value-of select="@objectName"/> (<xsl:value-of select="count(Rule)"/>) | |
</th> | |
</tr> | |
<xsl:apply-templates /> | |
</xsl:template> | |
<xsl:template match="Rule"> | |
<tr> | |
<xsl:apply-templates select="fullName" /> | |
<td class="ruleMessage"> | |
<xsl:value-of select="errorMessage" /> | |
</td> | |
</tr> | |
<tr> | |
<td colspan="2" class="formula"> | |
<xsl:variable name="apos">'</xsl:variable> | |
<xsl:variable name="repl">"</xsl:variable> | |
<script language="JavaScript"> | |
document.write(excelFormulaUtilities.formatFormulaHTML('<xsl:value-of select="translate(replace(errorConditionFormula,$apos,$repl),' 	
', '')" />')); | |
</script> | |
</td> | |
</tr> | |
</xsl:template> | |
<xsl:template match="fullName"> | |
<td class="ruleName"> | |
<xsl:value-of select="."/> | |
</td> | |
</xsl:template> | |
<xsl:template match="fullName[../errorDisplayField]"> | |
<td class="ruleName errorDisplay"> | |
<xsl:value-of select="."/> | |
(<xsl:value-of select="../errorDisplayField" />) | |
</td> | |
</xsl:template> | |
<xsl:template match="Rule[active='false']"> | |
<tr class="disabled"> | |
<td class="ruleName disabled"> | |
<xsl:value-of select="fullName"/> | |
</td> | |
<td class="ruleMessage"> | |
<xsl:value-of select="errorMessage" /> | |
</td> | |
</tr> | |
<tr class="disabled"> | |
<td colspan="2" class="formula"> | |
<xsl:value-of select="errorConditionFormula" /> | |
</td> | |
</tr> | |
</xsl:template> | |
<xsl:character-map | |
name="no-control-characters"> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="€" string=" "/> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="‚" string=" "/> | |
<xsl:output-character character="ƒ" string=" "/> | |
<xsl:output-character character="„" string=" "/> | |
<xsl:output-character character="…" string=" "/> | |
<xsl:output-character character="†" string=" "/> | |
<xsl:output-character character="‡" string=" "/> | |
<xsl:output-character character="ˆ" string=" "/> | |
<xsl:output-character character="‰" string=" "/> | |
<xsl:output-character character="Š" string=" "/> | |
<xsl:output-character character="‹" string=" "/> | |
<xsl:output-character character="Œ" string=" "/> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="Ž" string=" "/> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="‘" string=" "/> | |
<xsl:output-character character="’" string=" "/> | |
<xsl:output-character character="“" string=" "/> | |
<xsl:output-character character="”" string=" "/> | |
<xsl:output-character character="•" string=" "/> | |
<xsl:output-character character="–" string=" "/> | |
<xsl:output-character character="—" string=" "/> | |
<xsl:output-character character="˜" string=" "/> | |
<xsl:output-character character="™" string=" "/> | |
<xsl:output-character character="š" string=" "/> | |
<xsl:output-character character="›" string=" "/> | |
<xsl:output-character character="œ" string=" "/> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="ž" string=" "/> | |
<xsl:output-character character="Ÿ" string=" "/> | |
</xsl:character-map> | |
</xsl:stylesheet> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" | |
exclude-result-prefixes="xs xd" | |
version="2.0"> | |
<xsl:output method="html" omit-xml-declaration="yes" use-character-maps="no-control-characters"/> | |
<xsl:template match="/"> | |
<html> | |
<head> | |
<title>Validation Rules Report</title> | |
</head> | |
<style> | |
body { padding: 10px; } | |
body, td {font-family: Verdana, Arial, sans-serif; font-size: x-small} | |
tr {vertical-align: top} | |
tr.disabled { background-color: #EFEFEF; color: #666666;} | |
td { border-top: 1px solid gray; border-left: 1px solid gray; margin: 0px; padding: 5px; word-wrap: break-word; word-break:break-all;} | |
td.ruleName { color: #000066; width: 40% } | |
td.ruleMessage { border-right: 1px solid gray;} | |
td.disabled {text-decoration: line-through;} | |
td.errorDisplay {font-weight: bold; background-color: #FFEEEE;} | |
td.formula {border-bottom: 2px solid black; border-right: 1px solid gray;} | |
th {text-align: left; margin: 0px; padding-top: 15px; padding: 3px; } | |
table { width: 100%; border-spacing: 0;} | |
</style> | |
<body> | |
<h1>Validation Formula Report</h1> | |
<ul> | |
<li> | |
Objects with validation rules: <xsl:value-of select="count(/Validations/Validation)"/> | |
</li> | |
<li> | |
Total number of validation rules: <xsl:value-of select="count(/Validations/Validation/Rule)"/> | |
</li> | |
<li> | |
Active number of validation rules: <xsl:value-of select="count(/Validations/Validation/Rule[active='true'])"/> | |
</li> | |
<li> | |
Rules next to fields: <xsl:value-of select="count(/Validations/Validation/Rule/errorDisplayField)" /> | |
</li> | |
</ul> | |
<xsl:apply-templates /> | |
</body> | |
</html> | |
</xsl:template> | |
<xsl:template match="Validations"> | |
<table> | |
<thead> | |
<th>Name</th> | |
<th>Message</th> | |
</thead> | |
<tbody> | |
<xsl:apply-templates /> | |
</tbody> | |
</table> | |
</xsl:template> | |
<xsl:template match="Validation"> | |
<tr> | |
<th colspan="2"> | |
<xsl:value-of select="@objectName"/> (<xsl:value-of select="count(Rule)"/>) | |
</th> | |
</tr> | |
<xsl:apply-templates /> | |
</xsl:template> | |
<xsl:template match="Rule"> | |
<tr> | |
<xsl:apply-templates select="fullName" /> | |
<td class="ruleMessage"> | |
<xsl:value-of select="errorMessage" /> | |
</td> | |
</tr> | |
<tr> | |
<td colspan="2" class="formula"> | |
<xsl:value-of select="errorConditionFormula" /> | |
</td> | |
</tr> | |
</xsl:template> | |
<xsl:template match="fullName"> | |
<td class="ruleName"> | |
<xsl:value-of select="."/> | |
</td> | |
</xsl:template> | |
<xsl:template match="fullName[../errorDisplayField]"> | |
<td class="ruleName errorDisplay"> | |
<xsl:value-of select="."/> | |
(<xsl:value-of select="../errorDisplayField" />) | |
</td> | |
</xsl:template> | |
<xsl:template match="Rule[active='false']"> | |
<tr class="disabled"> | |
<td class="ruleName disabled"> | |
<xsl:value-of select="fullName"/> | |
</td> | |
<td class="ruleMessage"> | |
<xsl:value-of select="errorMessage"/> | |
</td> | |
</tr> | |
<tr class="disabled"> | |
<td colspan="2" class="formula"> | |
<xsl:value-of select="errorConditionFormula" /> | |
</td> | |
</tr> | |
</xsl:template> | |
<xsl:character-map | |
name="no-control-characters"> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="€" string=" "/> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="‚" string=" "/> | |
<xsl:output-character character="ƒ" string=" "/> | |
<xsl:output-character character="„" string=" "/> | |
<xsl:output-character character="…" string=" "/> | |
<xsl:output-character character="†" string=" "/> | |
<xsl:output-character character="‡" string=" "/> | |
<xsl:output-character character="ˆ" string=" "/> | |
<xsl:output-character character="‰" string=" "/> | |
<xsl:output-character character="Š" string=" "/> | |
<xsl:output-character character="‹" string=" "/> | |
<xsl:output-character character="Œ" string=" "/> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="Ž" string=" "/> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="‘" string=" "/> | |
<xsl:output-character character="’" string=" "/> | |
<xsl:output-character character="“" string=" "/> | |
<xsl:output-character character="”" string=" "/> | |
<xsl:output-character character="•" string=" "/> | |
<xsl:output-character character="–" string=" "/> | |
<xsl:output-character character="—" string=" "/> | |
<xsl:output-character character="˜" string=" "/> | |
<xsl:output-character character="™" string=" "/> | |
<xsl:output-character character="š" string=" "/> | |
<xsl:output-character character="›" string=" "/> | |
<xsl:output-character character="œ" string=" "/> | |
<xsl:output-character character="" string=" "/> | |
<xsl:output-character character="ž" string=" "/> | |
<xsl:output-character character="Ÿ" string=" "/> | |
</xsl:character-map> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The interactive version of the stylesheet needs the Excel formula formatter JS file