Skip to content

Commit

Permalink
Addresses usnistgov/OSCAL#870 - misalignment of documentation with JS…
Browse files Browse the repository at this point in the history
…ON schema (min-occurs on optional array items); also cleanup
  • Loading branch information
wendellpiez committed Mar 30, 2021
1 parent b1d12de commit d1843dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 74 deletions.
22 changes: 1 addition & 21 deletions toolchains/xslt-M4/document/json/object-map-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ details:not([open]) .show-closed { display: inline }

<xsl:template match="m:schema-name | m:schema-version"/>

<!-- string object singleton-or-array array group-by-key -->

<xsl:template match="m:string">
<xsl:variable name="last-appearing" select="position() eq last()"/>
<div class="OM-entry">
Expand Down Expand Up @@ -99,7 +97,6 @@ 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:call-template name="cardinality-note"/>-->
<xsl:text>: </xsl:text>
<span class="OM-lit">
<xsl:text>{</xsl:text>
Expand All @@ -113,10 +110,6 @@ details:not([open]) .show-closed { display: inline }
</div>
</summary>
<div class="OM-map">
<!--<p class="OM-map-name">
<xsl:apply-templates select="@formal-name"/>
<xsl:text>, an object with properties</xsl:text>
</p>-->
<xsl:apply-templates select="." mode="contents"/>
<p>
<span class="OM-lit">
Expand All @@ -140,16 +133,9 @@ details:not([open]) .show-closed { display: inline }
<xsl:call-template name="cardinality-note"/>
<xsl:if test="not(empty(*))">
<span class="OM-lit"> { </span>
<!--<span class="show-closed">
<xsl:text> &#8230; }</xsl:text>
<xsl:if test="not(position() eq last())">, </xsl:if>
</span>-->
</xsl:if>

</p>
<!--<p class="OM-map-name">
<xsl:apply-templates select="@formal-name"/>
</p>-->
<xsl:if test="not(empty(*))">
<xsl:apply-templates select="." mode="contents"/>
<p>
Expand Down Expand Up @@ -178,9 +164,6 @@ details:not([open]) .show-closed { display: inline }
<xsl:with-param name="has-subsequent" select="not(position() eq last())"/>
</xsl:apply-templates>
</span>
<!--<span class="sq cardinality">
<xsl:call-template name="cardinality-note"/>
</span>-->
</div>
</summary>
<!--<div class="OM-map">
Expand Down Expand Up @@ -283,11 +266,8 @@ 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:string">
<span class="OM-datatype">string</span>
</xsl:template>-->

<xsl:template mode="contents" match="m:array | m:object | m:singleton-or-array | m:group-by-key">
<xsl:template mode="contents" match="m:array | m:object | m:singleton-or-array | m:group-by-key">
<div class="OM-map">
<xsl:apply-templates select="*"/>
</div>
Expand Down
11 changes: 11 additions & 0 deletions toolchains/xslt-M4/document/json/object-tree.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@
</object>
</xsl:template>

<!-- Within an array, an assembly is always required even for min-occurs='0' because the array is optional. -->
<xsl:template match="group[@group-json='ARRAY']/assembly">
<object min-occurs="1">
<xsl:call-template name="global-id"/>
<xsl:apply-templates select="@key,@name,@min-occurs,@max-occurs,@formal-name"/>
<xsl:apply-templates/>
</object>
</xsl:template>

<xsl:template match="group[@group-json='ARRAY']/assembly/@min-occurs[.='0']"/>

<xsl:template name="global-id">
<xsl:if test="@scope = 'global'">
<xsl:attribute name="id" select="'global_' || @name"/>
Expand Down
55 changes: 2 additions & 53 deletions toolchains/xslt-M4/document/xml/element-map-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ div.OM-map p { margin: 0ex }
</xsl:template>

<xsl:template match="m:element">
<!--<xsl:variable name="contents">
<xsl:apply-templates select="." mode="contents"/>
</xsl:variable>-->
<details class="OM-entry">
<xsl:for-each select="parent::m:map">
<xsl:attribute name="open">open</xsl:attribute>
Expand All @@ -108,9 +105,6 @@ div.OM-map p { margin: 0ex }
</xsl:template>

<xsl:template match="m:element[empty(* except (m:attribute|m:value))]">
<!--<xsl:variable name="contents">
<xsl:apply-templates select="." mode="contents"/>
</xsl:variable>-->
<div class="OM-entry">
<p class="OM-line">
<!--<div class="OM-flex">-->
Expand Down Expand Up @@ -147,51 +141,7 @@ div.OM-map p { margin: 0ex }
</span>
</xsl:template>

<!--<xsl:template match="m:element[empty(* except m:flag)]">
<xsl:variable name="contents">
<xsl:apply-templates select="." mode="contents"/>
</xsl:variable>
<p class="OM-entry">
<span class="sq">
<xsl:call-template name="cardinality-note"/>
</span>
<span class="sq">
<span class="nobr">
<xsl:text>&lt;</xsl:text>
<xsl:apply-templates select="." mode="linked-name"/>
</span>
<xsl:apply-templates select="m:attribute" mode="as-attribute"/>
<xsl:if test="not(matches($contents, '\S'))">/</xsl:if>
<xsl:text>></xsl:text>
<xsl:if test="matches($contents, '\S')">
<xsl:sequence select="$contents"/>
<span class="nobr">
<xsl:text>&lt;/</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>></xsl:text>
</span>
</xsl:if>
</span>
</p>
</xsl:template>
<xsl:template match="m:element[m:value/@as-type='empty']">
<p class="OM-entry">
<span class="sq">
<xsl:call-template name="cardinality-note"/>
</span>
<span class="OM-sq">
<span class="nobr">
<xsl:text>&lt;</xsl:text>
<xsl:apply-templates select="." mode="linked-name"/>
</span>
<xsl:apply-templates select="m:attribute" mode="as-attribute"/>
<xsl:text>/&gt;</xsl:text>
</span>
</p>
</xsl:template>-->


<xsl:template match="m:attribute" mode="as-attribute">
<xsl:text> </xsl:text>
<span class="nobr">
Expand Down Expand Up @@ -302,8 +252,7 @@ div.OM-map p { margin: 0ex }
<xsl:template mode="summary-contents" match="m:element[@id=ancestor::*/@id]" priority="10" expand-text="true">
<span class="OM-lit OM-gloss"> (recursive: model like ancestor <span class="OM-ref">{ @gi }</span>) </span>
</xsl:template>



<xsl:template name="cardinality-note">
<xsl:text> </xsl:text>
<span class="OM-cardinality">
Expand Down

0 comments on commit d1843dd

Please sign in to comment.