Skip to content

Commit

Permalink
"title" attribute with explanation of cardinality. (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaerki authored and sgrossberndt committed Aug 23, 2022
1 parent a6e899a commit 15492f4
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/ojp-prep-to-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,41 @@
<xsl:choose>
<xsl:when test="@class = 'bold'">
<strong>
<xsl:call-template name="explain-cardinality"/>
<xsl:value-of select="."/>
</strong>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
<span>
<xsl:call-template name="explain-cardinality"/>
<xsl:value-of select="."/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<data:explained-cardinalities>
<data:case name="0:1">optional, single</data:case>
<data:case name="0:*">optional, multiple</data:case>
<data:case name="1:1">mandatory, single</data:case>
<data:case name="1:*">mandatory, at least one</data:case>
<data:case name="-0:1">optional, single, part of a choice</data:case>
<data:case name="-0:*">optional, multiple, part of a choice</data:case>
<data:case name="-1:1">mandatory, single, part of a choice</data:case>
<data:case name="-1:*">mandatory, at least one, part of a choice</data:case>
</data:explained-cardinalities>
<xsl:variable name="explained-cardinalities" select="document('')/xsl:stylesheet/data:explained-cardinalities"/>

<xsl:template name="explain-cardinality">
<xsl:param name="cardinality" select="."/>
<xsl:variable name="explanation" select="$explained-cardinalities/data:case[@name = $cardinality]"/>
<xsl:if test="$explanation">
<xsl:attribute name="title">
<xsl:value-of select="string($explanation)"/>
</xsl:attribute>
</xsl:if>
</xsl:template>

<!-- *** various *** -->

<xsl:template match="name|title">
Expand Down

0 comments on commit 15492f4

Please sign in to comment.