Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wendellpiez authored and david-waltermire committed Mar 16, 2021
1 parent be82f74 commit 289a623
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
26 changes: 21 additions & 5 deletions toolchains/xslt-M4/compose/metaschema-collect.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,28 @@
<!-- Same at the other end - references to module-local definitions are relabeled correspondingly
(to disambiguate from others of the same name in other modules) -->

<xsl:key name="top-level-local-definition-by-name" use="@name"
match="METASCHEMA/define-assembly[@scope='local'] |
METASCHEMA/define-field[@scope='local'] |
METASCHEMA/define-flag[@scope='local']" />
<xsl:key name="top-level-local-assembly-definition-by-name" use="@name"
match="METASCHEMA/define-assembly[@scope='local']" />

<xsl:key name="top-level-local-field-definition-by-name" use="@name"
match="METASCHEMA/define-field[@scope='local']" />

<xsl:key name="top-level-local-flag-definition-by-name" use="@name"
match="METASCHEMA/define-flag[@scope='local']" />

<xsl:template mode="acquire" match="assembly[exists( key('top-level-local-assembly-definition-by-name',@ref) )]">
<xsl:call-template name="rewrite-local-reference"/>
</xsl:template>

<xsl:template mode="acquire" match="field[exists( key('top-level-local-field-definition-by-name',@ref) )]">
<xsl:call-template name="rewrite-local-reference"/>
</xsl:template>

<xsl:template mode="acquire" match="flag[exists( key('top-level-local-flag-definition-by-name',@ref) )]">
<xsl:call-template name="rewrite-local-reference"/>
</xsl:template>

<xsl:template mode="acquire" match="model//*[exists( key('top-level-local-definition-by-name',@ref) )]">
<xsl:template name="rewrite-local-reference">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="ref" expand-text="true">{ ancestor::METASCHEMA[1]/short-name }-{ @ref }</xsl:attribute>
Expand Down
4 changes: 2 additions & 2 deletions toolchains/xslt-M4/metaschema-compose.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<p:pipe port="result" step="reduce2"/>
</p:output>

<p:serialization port="_3_digested" indent="true"/>
<p:output port="_3_digested" primary="false">
<p:serialization port="_4_digested" indent="true"/>
<p:output port="_4_digested" primary="false">
<p:pipe port="result" step="digest"/>
</p:output>

Expand Down
10 changes: 8 additions & 2 deletions toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,14 @@
<xsl:text>#/definitions/{ $lineage => string-join('-') }</xsl:text>
</xsl:template>

<xsl:template priority="100" match="METASCHEMA/define-assembly | METASCHEMA/define-field">
<map key="{ @name }">
<xsl:template priority="100" match="METASCHEMA/define-assembly">
<map key="{ $composed-metaschema/*/short-name }-{ @name }">
<xsl:next-match/>
</map>
</xsl:template>

<xsl:template priority="100" match="METASCHEMA/define-field">
<map key="{ $composed-metaschema/*/short-name }-{ @name }">
<xsl:next-match/>
</map>
</xsl:template>
Expand Down

0 comments on commit 289a623

Please sign in to comment.