Skip to content

Commit

Permalink
Integrate use of oscal-prose-module.xsd in metaschema.xsd (#187)
Browse files Browse the repository at this point in the history
* refactored markup use in the Metaschema XSD to make use of the oscal-prose-module.xsd
* Refactored prose module to allow img tags in markup. Resolves usnistgov/OSCAL#1132
  • Loading branch information
david-waltermire committed Apr 28, 2022
1 parent 2cedc4b commit a44b193
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 136 deletions.
137 changes: 68 additions & 69 deletions toolchains/xslt-M4/schema-gen/oscal-prose-module.xsd
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="http://csrc.nist.gov/ns/oscal/1.0" xmlns="http://csrc.nist.gov/ns/oscal/1.0">
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

<xs:complexType name="markupLineType" mixed="true">
<xs:group ref="mixedInlineMarkupGroup"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="inlineMarkupGroup"/>
</xs:choice>
</xs:complexType>

<xs:complexType name="markupMultilineType">
<xs:group ref="blockElementGroup"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="blockElementGroup"/>
</xs:choice>
</xs:complexType>

<xs:group name="blockElementGroup">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="h1" type="blockElementType"/>
<xs:element name="h2" type="blockElementType"/>
<xs:element name="h3" type="blockElementType"/>
<xs:element name="h4" type="blockElementType"/>
<xs:element name="h5" type="blockElementType"/>
<xs:element name="h6" type="blockElementType"/>
<xs:element name="p" type="blockElementType"/>
<xs:element name="ul" type="listType"/>
<xs:element name="ol" type="listType"/>
<xs:element name="pre" type="preformattedType"/>
<xs:element name="table" type="tableType"/>
<!-- TODO: need to add support for blockquote, which can contain block elements. usnistgov/metaschema#70 -->
</xs:choice>
</xs:sequence>
<xs:choice>
<xs:element name="h1" type="inlineType"/>
<xs:element name="h2" type="inlineType"/>
<xs:element name="h3" type="inlineType"/>
<xs:element name="h4" type="inlineType"/>
<xs:element name="h5" type="inlineType"/>
<xs:element name="h6" type="inlineType"/>
<xs:element name="p" type="inlineType"/>
<xs:element name="ul" type="listType"/>
<xs:element name="ol" type="listType"/>
<xs:element name="pre" type="preformattedType"/>
<xs:element name="table" type="tableType"/>
<xs:element name="img" type="imageType"/>
<!-- TODO: need to add support for blockquote, which can contain block elements. usnistgov/metaschema#70 -->
</xs:choice>
</xs:group>

<!--
Expand All @@ -38,26 +40,17 @@
-->


<xs:complexType name="blockElementType" mixed="true">
<xs:group ref="phraseInlineMarkupGroup"/>
</xs:complexType>

<xs:complexType name="headingType" mixed="true">
<xs:complexContent>
<xs:extension base="blockElementType">
<xs:annotation>
<xs:documentation>The content model is the same as blockElementType, but line endings need
to be preserved, since this is preformatted.</xs:documentation>
</xs:annotation>
</xs:extension>
</xs:complexContent>
<xs:complexType name="inlineType" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="inlineMarkupGroup"/>
</xs:choice>
</xs:complexType>

<xs:complexType name="preformattedType" mixed="true">
<xs:complexContent>
<xs:extension base="blockElementType">
<xs:extension base="inlineType">
<xs:annotation>
<xs:documentation>The content model is the same as blockElementType, but line endings need
<xs:documentation>The content model is the same as inlineType, but line endings need
to be preserved, since this is preformatted.</xs:documentation>
</xs:annotation>
</xs:extension>
Expand All @@ -71,8 +64,9 @@
</xs:complexType>

<xs:complexType name="listItemType" mixed="true">
<!-- TODO: is this the correct construction? -->
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="mixedInlineMarkupGroup"/>
<xs:group ref="inlineMarkupGroup"/>
<xs:element name="ul" type="listType"/>
<xs:element name="ol" type="listType"/>
</xs:choice>
Expand All @@ -86,17 +80,20 @@

<xs:complexType name="tableRowType">
<!-- QUESTION: Should we allow TH and TD to be mixed? -->
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="td" type="tableCellType" maxOccurs="unbounded"/>
<xs:element name="th" type="tableCellType" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>

<xs:complexType name="tableCellType" mixed="true">
<xs:group ref="mixedInlineMarkupGroup"/>
<!-- TODO: consider adding a choice between the inline or paragraphs. We need to figure out what is supported in Markdown. -->
<xs:attribute name="align" type="alignType" default="left"/>
<!-- TODO: need to add support for alignment. usnistgov/metaschema#70 -->
<xs:complexContent>
<!-- TODO: consider adding a choice between the inline or paragraphs. We need to figure out what is supported in Markdown. -->
<xs:extension base="inlineType">
<!-- TODO: need to add support for alignment. usnistgov/metaschema#70 -->
<xs:attribute name="align" type="alignType" default="left"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:simpleType name="alignType">
Expand All @@ -107,44 +104,46 @@
</xs:restriction>
</xs:simpleType>

<!-- note mix does not include anchors, which do not come for free -->
<xs:group name="mixedInlineMarkupGroup">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="phraseInlineMarkupGroup"/>
<xs:element name="img" type="imageType"/>
</xs:choice>
</xs:sequence>
<xs:group name="inlineMarkupGroup">
<xs:choice>
<xs:element name="a" type="anchorType"/>
<xs:element name="insert" type="insertType"/>
<xs:group ref="phraseMarkupGroup"/>
<xs:group ref="imageMarkupGroup"/>
</xs:choice>
</xs:group>

<xs:group name="phraseInlineMarkupGroup">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="code" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="em" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="i" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="b" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="strong" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="sub" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="sup" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="q" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="insert" type="insertType"/>
<xs:element name="a" type="anchorType"/>
</xs:choice>
</xs:sequence>
<xs:group name="imageMarkupGroup">
<xs:choice>
<xs:element name="img" type="imageType"/>
</xs:choice>
</xs:group>
<xs:group name="phraseMarkupGroup">
<xs:choice>
<xs:element name="code" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="em" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="i" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="b" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="strong" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="sub" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="sup" type="inlineMarkupType" minOccurs="1"/>
<xs:element name="q" type="inlineMarkupType" minOccurs="1"/>
</xs:choice>
</xs:group>

<xs:complexType name="inlineMarkupType" mixed="true">
<xs:group ref="phraseInlineMarkupGroup"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="inlineMarkupGroup"/>
</xs:choice>
</xs:complexType>

<xs:complexType name="imageType">
<xs:attribute name="alt" type="xs:string"/>
<xs:attribute name="src" use="required" type="xs:anyURI"/>
</xs:complexType>

<xs:complexType name="anchorType" mixed="true">
<xs:group ref="phraseInlineMarkupGroup"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="phraseMarkupGroup"/>
<xs:group ref="imageMarkupGroup"/>
</xs:choice>
<xs:attribute name="href" type="xs:anyURI"/>
</xs:complexType>

Expand Down
Loading

0 comments on commit a44b193

Please sign in to comment.