Skip to content

Commit

Permalink
Documentation / Add script to build RST documentation for schema labels.
Browse files Browse the repository at this point in the history
  • Loading branch information
François Prunayre committed Jun 6, 2014
1 parent e1191e9 commit dde4bb1
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ web/src/main/webapp/WEB-INF/metadata_subversion/
.project
schematrons/.build
docs/*/users/build
docs/schema-loc-*.rst
.props/
*.iml
.idea/
Expand Down
31 changes: 31 additions & 0 deletions docs/schema-loc-to-rst.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

GNLIB=../web/target/geonetwork/WEB-INF/lib/

function showUsage
{
echo -e "\nThis script is used to create a RST file for schema elements"
echo
echo -e "Usage: ./`basename $0 $1` iso19139 eng"
}

if [ "$1" = "-h" ]
then
showUsage
exit
fi


if [ $# -lt 2 ]
then
showUsage
exit
fi


java -classpath $GNLIB/saxon-9.1.0.8b-patch.jar net.sf.saxon.Transform \
-s:build.xml \
-xsl:schema-loc-to-rst.xsl \
-o:schema-loc-$1-$2.rst \
lang=$2 \
schema=$1
98 changes: 98 additions & 0 deletions docs/schema-loc-to-rst.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?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"
exclude-result-prefixes="xs"
version="2.0">

<xsl:output method="text"/>

<xsl:param name="lang" select="'fre'"/>
<xsl:param name="schema" select="'iso19139'"/>

<xsl:variable name="i18n">
<title>
<eng>List of element for schema:</eng>
<fre>Liste des éléments du standard :</fre>
</title>
<code>
<eng>Tag name</eng>
<fre>Nom de la balise</fre>
</code>
<desc>
<eng>Description</eng>
<fre>Description</fre>
</desc>
<moreInfo>
<eng>More details</eng>
<fre>Informations complémentaires</fre>
</moreInfo>
<helper>
<eng>Recommended values</eng>
<fre>Valeurs recommandées</fre>
</helper>
</xsl:variable>

<xsl:variable name="labels" select="document(concat('../web/src/main/webapp/WEB-INF/data/config/schema_plugins/', $schema, '/loc/eng/labels.xml'))"/>

<xsl:template match="/">

# <xsl:value-of select="concat($i18n/title/*[name() = $lang], ' ', $schema)"/>

<xsl:text>


</xsl:text>

<xsl:for-each select="$labels//element">
<xsl:sort select="name"/>

<xsl:variable name="rstRef"
select="concat('.. _', $schema, '-',
replace(@name, ':', '-'), ':')"/>

<xsl:variable name="rstContext" select="if (@context)
then concat(' (cf. `',
@context, ' &lt;#',
$schema, '-', replace(@context, ':', '-'), '&gt;',
@context, '`_)')
else ''"/>


<xsl:value-of select="$rstRef"/>

<xsl:text>

</xsl:text>

<xsl:value-of select="concat(label, $rstContext)"/>



- *<xsl:value-of select="$i18n/desc/*[name() = $lang]"/> :* <xsl:value-of select="label"/>


- *<xsl:value-of select="$i18n/code/*[name() = $lang]"/> :* <xsl:value-of select="@name"/>

- *<xsl:value-of select="$i18n/moreInfo/*[name() = $lang]"/> :*

<xsl:for-each select="help">
<xsl:value-of select="."/>
</xsl:for-each>


<xsl:if test="helper">
<xsl:value-of select="$i18n/helper/*[name() = $lang]"/>
<xsl:for-each select="helper/option">
- <xsl:value-of select="text()"/> (<xsl:value-of select="@value"/>)
</xsl:for-each>
</xsl:if>



<xsl:text>


</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

0 comments on commit dde4bb1

Please sign in to comment.