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

repairing XSD simple type definition defect #227

Merged
Merged
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
24 changes: 23 additions & 1 deletion toolchains/xslt-M4/schema-gen/make-metaschema-xsd.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,32 @@
<!--<xsl:message expand-text="true">Types in library: { $types-library/xs:simpleType/@name }</xsl:message>-->
<xsl:variable name="all-used-types" select="//@as-type => distinct-values()"/>
<xsl:variable name="used-atomic-types" select="$type-map[@as-type = $all-used-types]"/>
<xsl:copy-of select="$types-library/xs:simpleType[@name = $used-atomic-types]"/>

<!-- these aren't enough as some of them have further dependencies -->
<!--<xsl:copy-of select="$types-library/xs:simpleType[@name = $used-atomic-types]"/>-->
<xsl:sequence select="$types-library/xs:simpleType[@name = $used-atomic-types] => m:gather-types()"/>
</xs:schema>
</xsl:template>

<xsl:key name="simpleType-by-name" match="xs:simpleType" use="@name"/>

<!--Given a set of simpletypes such as in ../../../schema/xml/metaschema-datatypes.xsd i.e. $types-library -->
<xsl:function name="m:gather-types">
<xsl:param name="so-far" as="element()*"/>
<!-- picks up all types referenced as a restriction/@base -->
<xsl:variable name="base-types" select="$so-far/xs:restriction/key('simpleType-by-name',@base)"/>
<xsl:choose>
<!-- if there are any new ones, add and recurse -->
<xsl:when test="exists($base-types except $so-far)">
<xsl:sequence select="m:gather-types($so-far | $base-types)"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="$so-far"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>


<xsl:template match="namespace | json-base-uri"/>

<xsl:template mode="top-level-docs" match="*"/>
Expand Down