xslt: relpipe-out-xhtml: customizable strings and CSS
This commands now accepts following parameters:
--title
--css-appendix
--description
--record-count-prefix
--record-count-suffix
--relation-name-prefix
--relation-name-suffix
and allows to customize (e.g. localize) the XHTML output or override CSS rules by providing own.
Attribute names, types and record counts have CSS classes and can be styled or (visually) removed.
--- a/xslt-examples/__relpipe-out-xml_xslt.sh Sat Jun 06 01:50:44 2020 +0200
+++ b/xslt-examples/__relpipe-out-xml_xslt.sh Fri Jul 31 00:07:04 2020 +0200
@@ -19,8 +19,24 @@
BASE="$(basename $0)"
XSL="$DIR/$BASE.xsl"
+xsltParams=();
+
+while [[ $# -gt 0 ]]; do
+ argument="$1";
+ case "$argument" in
+ "--title") xsltParams+=("--stringparam" "title" "$2"); shift; shift; ;;
+ "--css-appendix") xsltParams+=("--stringparam" "cssAppendix" "$2"); shift; shift; ;;
+ "--description") xsltParams+=("--stringparam" "description" "$2"); shift; shift; ;;
+ "--record-count-prefix") xsltParams+=("--stringparam" "recordCountPrefix" "$2"); shift; shift; ;;
+ "--record-count-suffix") xsltParams+=("--stringparam" "recordCountSuffix" "$2"); shift; shift; ;;
+ "--relation-name-prefix") xsltParams+=("--stringparam" "relationNamePrefix" "$2"); shift; shift; ;;
+ "--relation-name-suffix") xsltParams+=("--stringparam" "relationNameSuffix" "$2"); shift; shift; ;;
+ *) echo "Unknown option: $argument" >&2; exit 1;
+ esac
+done
+
if [[ -f "$XSL" ]]; then
- relpipe-out-xml | xsltproc "$XSL" -
+ relpipe-out-xml | xsltproc "${xsltParams[@]}" "$XSL" -
else
echo "unable to find XSLT template: $XSL" 1>&2
exit 1;
--- a/xslt-examples/relpipe-out-xhtml.xsl Sat Jun 06 01:50:44 2020 +0200
+++ b/xslt-examples/relpipe-out-xhtml.xsl Fri Jul 31 00:07:04 2020 +0200
@@ -32,26 +32,23 @@
doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
<xsl:param name="title" select="'Relational pipes XHTML output'"/>
+ <xsl:param name="description">This is output of <code>relpipe-out-xml</code> converted to XHTML web page.</xsl:param>
+ <xsl:param name="recordCountPrefix">Record count: </xsl:param>
+ <xsl:param name="recordCountSuffix"></xsl:param>
+ <xsl:param name="relationNamePrefix"></xsl:param>
+ <xsl:param name="relationNameSuffix"></xsl:param>
+ <xsl:param name="cssAppendix"></xsl:param>
<!--
TODO:
Parameters:
- title / h1
- introduction and footer for whole report
- introduction and footer for every relation
- custom CSS + optionaly remove default CSS
custom JavaScript
- whether to display or hide types in table headers
whether to insert CSS classes for data types in each <td/>
custom pre regex (see below)
metadata relation name (will be hidden and we will get texts or custom titles for particular relations)
CSS:
- clean-up, better style
- attribute name
- attribute type
- relation name
table class for each relation (if [a-zA-Z0-9]+)
-->
@@ -64,42 +61,39 @@
<meta name="generator" content="Relational pipes: https://relational-pipes.globalcode.info/"/>
<style type="text/css">
body {
- font-family: sans;
- background-color: #eee;
+ font-family: "Latin Modern Sans", sans;
+ background-color: #efefef;
color: black;
padding-left: 20px;
}
p {
- max-width: 800px;
- }
-
- h1,h2 {
- max-width: 800px;
- border-radius: 8px;
- border: 1px solid #ddd;
- background-color: #e8e8e8;
- padding: 6px;
- text-shadow: 2px 2px 2px #aaa;
+ max-width: 1200px;
}
h1 {
- font-size: 150%
+ font-size: 160%;
+ font-weight: bolder;
}
+
h2 {
- font-size: 100%;
- font-weight: bold;
+ font-size: 130%;
+ font-weight: bolder;
+ }
+
+ code {
+ font-family: "Latin Modern Mono", "Dejavu Sans Mono", monospace;
}
pre,code {
- color: #a00;
+ font-family: "Latin Modern Mono", "Dejavu Sans Mono", monospace;
}
table {
border-collapse:collapse;
- box-shadow: 3px 3px 3px grey;
margin-top: 10px;
margin-bottom: 10px;
+ box-shadow: 3px 3px 2px 0px rgba(0,0,0,0.2);
}
td, th {
border: 1px solid black;
@@ -120,7 +114,7 @@
background-color: silver;
color:black;
}
-
+ <xsl:value-of select="$cssAppendix"/>
</style>
</head>
<body>
@@ -128,13 +122,15 @@
<xsl:value-of select="$title"/>
</h1>
- <p>
- This is output of <code>relpipe-out-xml</code> converted to XHTML web page.
+ <p class="description">
+ <xsl:copy-of select="$description"/>
</p>
<xsl:for-each select="/rp:relpipe/rp:relation">
<h2>
+ <xsl:copy-of select="$relationNamePrefix"/>
<xsl:value-of select="rp:name"/>
+ <xsl:copy-of select="$relationNameSuffix"/>
</h2>
<table>
@@ -142,10 +138,14 @@
<tr>
<xsl:for-each select="rp:attributes-metadata/rp:attribute-metadata">
<td>
- <xsl:value-of select="@name"/>
- <xsl:text> (</xsl:text>
- <xsl:value-of select="@type"/>
- <xsl:text>)</xsl:text>
+ <span class="attributeName">
+ <xsl:value-of select="@name"/>
+ </span>
+ <span class="attributeType">
+ <xsl:text> (</xsl:text>
+ <xsl:value-of select="@type"/>
+ <xsl:text>)</xsl:text>
+ </span>
</td>
</xsl:for-each>
</tr>
@@ -165,8 +165,12 @@
</tbody>
</table>
- <p>
- Record count: <xsl:value-of select="count(rp:record)"/>
+ <p class="recordCount">
+ <xsl:copy-of select="$recordCountPrefix"/>
+ <span class="recordCount">
+ <xsl:value-of select="count(rp:record)"/>
+ </span>
+ <xsl:copy-of select="$recordCountSuffix"/>
</p>
</xsl:for-each>