Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair to (JSON) schema generation bug on module-local flag definition #126

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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