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

GlobalFieldDefinitionType missing definition for collapsible causing failure in test-suite sample #36

Open
ronaldtse opened this issue Oct 22, 2024 · 2 comments · May be fixed by #37
Open
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ronaldtse
Copy link

ronaldtse commented Oct 22, 2024

Describe the bug

The metaschema.xsd file defines a number of types for Metaschema.

The GlobalFieldDefinitionType has the following definition:

  <xs:complexType name="GlobalFieldDefinitionType">
    <xs:annotation>
      <xs:documentation>In JSON, an object with a nominal string value (potentially with internal
        inline - not fully structured - markup). In XML, an element with string or markup
        content. Defined globally, a field can be assigned to appear in the <code>model</code> of any assembly by <code>field</code> reference.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:group ref="DefinitionMetadataGroup"/>
      <xs:group ref="UseNamingGroup"/>
      <xs:element name="json-key" type="JsonKeyType" minOccurs="0"/>
      <xs:group ref="JsonValueKeyChoiceGroup"/>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="flag" type="FlagReferenceType"/>
        <xs:element name="define-flag" type="InlineFlagDefinitionType" minOccurs="0" maxOccurs="unbounded"/>
      </xs:choice>
      <xs:element name="constraint" type="DefineFieldConstraintsType" minOccurs="0"/>
      <xs:element name="remarks" type="RemarksType" minOccurs="0"/>
      <xs:element name="example" type="ExampleType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attributeGroup ref="FieldValueAttributeGroup"/>
    <xs:attributeGroup ref="DefinitionNamingGroup"/>
    <xs:attribute name="scope" type="ScopeType" default="global"/>
    <xs:attributeGroup ref="DeprecationAttributeGroup"/>
  </xs:complexType>

Notice there is no definition of collapsible.

However, the test suite contains the following file:

  • test-suite/schema-generation/collapsible/collapsible-no-op_metaschema.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../../../toolchains/xslt-M4/validate/metaschema-composition-check.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<!-- OSCAL CATALOG METASCHEMA -->
<!-- validate with XSD and Schematron (linked) -->
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0">
   <schema-name>Metaschema Unit Test: collapsible-no-op</schema-name>
   <schema-version>1.0-milestone1</schema-version>
   <short-name>metaschema-collapsible-no-op</short-name>
   <namespace>http://csrc.nist.gov/ns/metaschema/unit-test/collapsible-no-op</namespace>
   <json-base-uri>http://csrc.nist.gov/ns/metaschema/unit-test/collapsible-no-op</json-base-uri>
   <define-assembly name="parent">
      <formal-name>parent</formal-name>
      <description>parent assembly</description>
      <root-name>parent</root-name>
      <model>
         <field ref="prop" min-occurs="1" max-occurs="unbounded">
            <group-as name="props" in-json="SINGLETON_OR_ARRAY"/>
         </field>
      </model>
   </define-assembly>
   <define-field name="prop" as-type="string" collapsible="yes">
      <formal-name>prop</formal-name>
      <description>prop field</description>
   </define-field>
</METASCHEMA>

Notice that this line:

   <define-field name="prop" as-type="string" collapsible="yes">

Clearly indicates that define-field supports the collapsible attribute. define-field is exactly of the type GlobalFieldDefinitionType, because it directly belongs to <METASCHEMA>:

  <xs:element name="METASCHEMA">
    <xs:annotation>
      <xs:documentation>Root element of a Metaschema definition. Defines a family of data
        structures representing a model.</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <!-- -->
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="define-assembly" type="GlobalAssemblyDefinitionType"/>
          <xs:element name="define-field" type="GlobalFieldDefinitionType"/>
          <xs:element name="define-flag" type="GlobalFlagDefinitionType"/>
        </xs:choice>
      </xs:sequence>

Expected behavior (i.e. solution)

The solution is to update the definition of GlobalFieldDefinitionType to support collapsible.

Other Comments

I will submit a PR that addresses this issue.

(This is a ported PR from usnistgov/metaschema#774)

@ronaldtse ronaldtse added the bug Something isn't working label Oct 22, 2024
@ronaldtse ronaldtse linked a pull request Oct 22, 2024 that will close this issue
8 tasks
@david-waltermire
Copy link
Contributor

Support for the unused and confusing collapse Metaschema feature was removed in usnistgov/metaschema#405. It looks like the unit tests need to be cleaned up.

@david-waltermire david-waltermire moved this from To Triage to In progress in Tooling Work Board Oct 26, 2024
@david-waltermire david-waltermire added the help wanted Extra attention is needed label Oct 26, 2024
@ronaldtse
Copy link
Author

@david-waltermire does this mean that all instances of the "collapse" attributes and any associated documentation are to be removed from the project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

2 participants