Skip to content

Commit

Permalink
Addressing several small display and linking glitches in docs generat…
Browse files Browse the repository at this point in the history
…ion (#146)
  • Loading branch information
wendellpiez authored May 28, 2021
1 parent ba4b495 commit fc43884
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 59 deletions.
15 changes: 9 additions & 6 deletions toolchains/xslt-M4/document/common-definitions.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,15 @@
@name }</code></xsl:template>



<xsl:template match="define-assembly | define-field" mode="model">
<ul class="model">
<xsl:apply-templates select="flag | define-flag" mode="model-view"/>
<xsl:apply-templates select="model/*" mode="model-view"/>
</ul>
<xsl:template match="define-field" mode="model"/>

<xsl:template match="define-assembly" mode="model">
<xsl:where-populated>
<ul class="model">
<xsl:apply-templates select="flag | define-flag" mode="model-view"/>
<xsl:apply-templates select="model/*" mode="model-view"/>
</ul>
</xsl:where-populated>
</xsl:template>

<xsl:template match="define-flag" mode="model"/>
Expand Down
36 changes: 21 additions & 15 deletions toolchains/xslt-M4/document/common-reference.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
<xsl:apply-templates select="." mode="report-context"/>
<span class="cnstr-tag">cardinality rule</span>
<xsl:text> the cardinality of </xsl:text>
<code>{ @target }</code>
<code>{ (@target,'.')[1] }</code>
<xsl:text> is constrained: </xsl:text>
<b>{ (@min-occurs,0)[1] }</b>
<xsl:text>; maximum </xsl:text>
Expand All @@ -189,12 +189,7 @@
<xsl:text>this value must correspond to a listing in the index </xsl:text>
<code>{ @name }</code>
<xsl:text> using a key constructed of key field(s) </xsl:text>
<xsl:for-each select="key-field">
<xsl:if test="position() gt 1">; </xsl:if>
<code>
<xsl:value-of select="@target"/>
</code>
</xsl:for-each>
<xsl:call-template name="construct-key"/>
</p>
</div>
</xsl:template>
Expand All @@ -207,19 +202,30 @@
<span class="cnstr-tag">index definition</span>
<xsl:text> an index </xsl:text>
<code>{ @name }</code>
<xsl:text> shall list values returned by targets </xsl:text>
<code>{ @target }</code>
<xsl:choose>
<xsl:when test="matches(@target,'\S')">
<xsl:text> shall list values returned by targets </xsl:text>
<code>{ @target }</code>
</xsl:when>
<xsl:otherwise>
<xsl:text> shall contain values </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> using keys constructed of key field(s) </xsl:text>
<xsl:for-each select="key-field">
<xsl:if test="position() gt 1">; </xsl:if>
<code>
<xsl:value-of select="@target"/>
</code>
</xsl:for-each>
<xsl:call-template name="construct-key"/>
</p>
</div>
</xsl:template>

<xsl:template name="construct-key">
<xsl:for-each select="key-field">
<xsl:if test="position() gt 1">; </xsl:if>
<code>
<xsl:value-of select="(@target, 'its value')[1]"/>
</code>
</xsl:for-each>
</xsl:template>

<!-- XXX consolidate this w/ JSON code? -->
<xsl:template mode="occurrence-code" match="*">
<xsl:param name="require-member" select="false()"/>
Expand Down
15 changes: 12 additions & 3 deletions toolchains/xslt-M4/document/json/object-index-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,23 @@
</span>
<xsl:text> - </xsl:text>
<span class="formal-name">
<a href="{ $definitions-link }#{ @_metaschema-json-id }">
<xsl:text>{ formal-name }</xsl:text>
<xsl:if test="empty(formal-name)" expand-text="true">{ name() }</xsl:if>
<xsl:variable name="target" select="(@_metaschema-json-id,*/@_metaschema-json-id)[1]"/>
<xsl:if test="empty($target)">
<xsl:message>Missing link?</xsl:message>
</xsl:if>
<a href="{ $definitions-link }#{ $target }">
<xsl:apply-templates select="." mode="formal-name"/>
</a>
</span>
</li>
</xsl:template>

<xsl:template mode="formal-name" match="*" expand-text="true">{ @name }</xsl:template>

<xsl:template mode="formal-name" match="*[exists(formal-name)]" expand-text="true">{ formal-name }</xsl:template>

<xsl:template mode="formal-name" match="array[exists(*/formal-name)]" expand-text="true">{ */formal-name }</xsl:template>

<xsl:template match="." mode="linked-path">
<xsl:apply-templates select="parent::*" mode="linked-path"/>
<xsl:apply-templates select="@key" mode="linked-path"/>
Expand Down
51 changes: 27 additions & 24 deletions toolchains/xslt-M4/document/json/object-map-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
exclude-result-prefixes="#all">


<xsl:output omit-xml-declaration="true" indent="no"/>
<xsl:output omit-xml-declaration="true" indent="yes"/>


<xsl:param as="xs:string" name="outline-page" select="'json/outline'"/>
Expand Down Expand Up @@ -81,7 +81,7 @@ details:not([open]) .show-closed { display: inline }
<xsl:call-template name="cardinality-note"/>
</span>
<span class="sq">-->
<xsl:apply-templates select="." mode="json-key"/>
<xsl:apply-templates select="." mode="json-group-description"/>
<xsl:call-template name="cardinality-note"/>
<xsl:text>: </xsl:text>
<xsl:apply-templates select="." mode="inline-link-to"/>
Expand Down Expand Up @@ -109,7 +109,7 @@ details:not([open]) .show-closed { display: inline }
<xsl:call-template name="cardinality-note"/>
</span>-->
<!--<span class="sq">-->
<xsl:apply-templates select="." mode="json-key"/>
<xsl:apply-templates select="." mode="json-group-description"/>
<xsl:call-template name="cardinality-note"/>
<xsl:text>: </xsl:text>
<span class="OM-lit">
Expand Down Expand Up @@ -140,7 +140,7 @@ details:not([open]) .show-closed { display: inline }
<xsl:template match="m:array/m:object | m:singleton-or-array/m:object | m:object[empty(*)]">
<div class="OM-entry">
<p>
<xsl:apply-templates select="." mode="json-key"/>
<xsl:apply-templates select="." mode="json-group-description"/>
<xsl:text> </xsl:text>
<xsl:call-template name="cardinality-note"/>
<xsl:if test="not(empty(*))">
Expand Down Expand Up @@ -168,7 +168,7 @@ details:not([open]) .show-closed { display: inline }
<xsl:call-template name="cardinality-note"/>
</span>-->
<span class="sq">
<xsl:apply-templates select="." mode="json-key"/>
<xsl:apply-templates select="." mode="json-group-description"/>
<xsl:call-template name="cardinality-note"/>
<xsl:text>: </xsl:text>

Expand All @@ -193,35 +193,37 @@ details:not([open]) .show-closed { display: inline }
</xsl:template>


<xsl:template match="*[exists(@key)]" mode="json-key">
<a class="OM-name" href="{ $reference-link }#{ @_tree-json-id }">
<xsl:value-of select="@key"/>
</a>
</xsl:template>

<xsl:template match="*" mode="json-key">
<xsl:value-of select="(@key,@name)[1]"/>
<xsl:template match="*" mode="json-group-description">
<xsl:apply-templates select="." mode="json-object-link"/>
</xsl:template>

<xsl:template priority="3" match="m:array/*" mode="json-key">
<xsl:template priority="3" match="m:array/*" mode="json-group-description">
<span class="OM-lit">
<xsl:text>An array of </xsl:text>
<xsl:next-match/>
<xsl:apply-templates select="." mode="json-object-link"/>
<xsl:text expand-text="true"> { local-name() }{ if (@max-occurs != '1') then 's' else '' }</xsl:text>
</span>
</xsl:template>

<xsl:template priority="3" match="m:singleton-or-array/*" mode="json-key" expand-text="true">
<xsl:template priority="3" match="m:singleton-or-array/*" mode="json-group-description" expand-text="true">
<span class="OM-lit">
<xsl:text>Array members, or a singleton </xsl:text>
<span class="OM-name">
<xsl:value-of select="(@key,@gi,use-name,@name)[1]"/>
</span>
<xsl:apply-templates select="." mode="json-object-link"/>
<xsl:text expand-text="true"> { local-name() }</xsl:text>
</span>
</xsl:template>

<xsl:template priority="2" match="*[exists(@json-key-flag)]" mode="json-key" expand-text="true">
<xsl:template match="*" mode="json-object-link">
<xsl:if test="empty(@_tree-json-id)">
<xsl:message expand-text="true">not seeing json tree id for { name(.) }</xsl:message>
</xsl:if>
<a class="OM-name" href="{ $reference-link }#{ @_tree-json-id }">
<xsl:value-of select="(@key,@gi,@name)[1]"/>
</a>
</xsl:template>


<xsl:template priority="2" match="*[exists(@json-key-flag)]" mode="json-group-description" expand-text="true">
<span class="OM-lit">
<xsl:next-match/>
<xsl:text> { local-name()}s </xsl:text>
Expand Down Expand Up @@ -279,11 +281,12 @@ details:not([open]) .show-closed { display: inline }
<span class="OM-datatype"><a href="{$datatype-page}/#{lower-case(@as-type)}">{ @as-type }</a></span>
</xsl:template>


<xsl:template mode="contents" match="m:array | m:object | m:singleton-or-array | m:group-by-key">
<div class="model-container {name()}">
<xsl:apply-templates select="*"/>
</div>
<xsl:where-populated>
<div class="model-container {name()}">
<xsl:apply-templates select="*"/>
</div>
</xsl:where-populated>
</xsl:template>

<xsl:template name="datatype-link">
Expand Down
8 changes: 4 additions & 4 deletions toolchains/xslt-M4/document/json/object-reference-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
<xsl:apply-templates select="." mode="produce"/>

<xsl:apply-templates>
<xsl:with-param tunnel="true" name="constraints" select="$constraints, constraint"/>
<xsl:with-param tunnel="true" name="constraints" select="constraint"/>
<!-- for later when constraint allocation is working: -->
<!--<xsl:with-param tunnel="true" name="constraints" select="$constraints, constraint"/>-->
</xsl:apply-templates>

</section>
Expand Down Expand Up @@ -95,16 +97,14 @@
</p>-->
</xsl:template>



<xsl:template match="*" mode="produce" expand-text="true">
<xsl:param tunnel="true" name="constraints" select="()"/>
<div class="obj-desc">
<!-- target for cross-link -->
<xsl:copy-of select="@id"/>
<div class="obj-matrix">
<p class="obj-name">

<xsl:value-of select="formal-name"/>
<xsl:if test="empty(formal-name)">
<xsl:text>{ name(.) => replace('^define\-','') } of </xsl:text>
<xsl:for-each select="*/child::formal-name">
Expand Down
15 changes: 12 additions & 3 deletions toolchains/xslt-M4/document/xml/element-index-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,23 @@
</span>
<xsl:text> - </xsl:text>
<span class="formal-name">
<a href="{ $definitions-link }#{ @_metaschema-xml-id }">
<xsl:text>{ formal-name }</xsl:text>
<xsl:if test="empty(formal-name)" expand-text="true">{ name() }</xsl:if>
<xsl:variable name="target" select="(@_metaschema-xml-id,*/@_metaschema-xml-id)[1]"/>
<xsl:if test="empty($target)">
<xsl:message>Missing link?</xsl:message>
</xsl:if>
<a href="{ $definitions-link }#{ $target }">
<xsl:apply-templates select="." mode="formal-name"/>
</a>
</span>
</li>
</xsl:template>

<xsl:template mode="formal-name" match="*" expand-text="true">{ @name }</xsl:template>

<xsl:template mode="formal-name" match="*[exists(formal-name)]" expand-text="true">{ formal-name }</xsl:template>

<xsl:template mode="formal-name" match="array[exists(*/formal-name)]" expand-text="true">{ */formal-name }</xsl:template>

<xsl:template match="." mode="linked-path">
<xsl:apply-templates select="parent::*" mode="linked-path"/>
<xsl:apply-templates select="@gi" mode="linked-path"/>
Expand Down
12 changes: 8 additions & 4 deletions toolchains/xslt-M4/document/xml/element-reference-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@
<xsl:apply-templates select="." mode="produce"/>

<xsl:apply-templates>
<xsl:with-param tunnel="true" name="constraints" select="$constraints, constraint"/>
<xsl:with-param tunnel="true" name="constraints" select="constraint"/>
<!-- for later when constraint allocation is working: -->
<!--<xsl:with-param tunnel="true" name="constraints" select="$constraints, constraint"/>-->
</xsl:apply-templates>

</section>
</xsl:template>

Expand All @@ -79,9 +80,12 @@
<xsl:param tunnel="true" name="constraints" select="()"/>
<div class="obj-desc">
<!-- target for cross-linking -->
<xsl:copy-of select="@id"/>
<xsl:attribute name="id" select="@_tree-xml-id"/>
<div class="obj-matrix">
<p class="obj-name">{ name(.) => replace('^define\-','') } { formal-name }</p>
<p class="obj-name">{ (formal-name, name())[1] }</p>
<!--<xsl:if test="empty(formal-name)">
<xsl:message expand-text="true">{ name() } is missing formal-name</xsl:message>
</xsl:if>-->
<p class="occurrence">
<xsl:apply-templates select="." mode="occurrence-code"/>
</p>
Expand Down

0 comments on commit fc43884

Please sign in to comment.