Skip to content

Commit

Permalink
Restrict object.extends to only refer to object.name(s), re #8
Browse files Browse the repository at this point in the history
  • Loading branch information
safris committed May 30, 2023
1 parent efda595 commit 9a05b10
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ Any application that consumes well-formed JSON can use the <ins>JSON Schema Defi

### <b>1.1</b> Dependencies on Other Specifications

The definition of the <ins>JSON Schema Definition Language</ins> depends on the following specifications: [RFC4627<sup>❐</sup>][rfc4627] and [XMLSchema<sup>❐</sup>][xmlschema].
The definition of the <ins>JSON Schema Definition Language</ins> depends on the following specifications: [RFC4627<sup>❐</sup>][rfc4627], [RFC7159<sup>❐</sup>][rfc7159], and [XMLSchema<sup>❐</sup>][xmlschema].

### <b>1.2</b> Conventions Used in This Document

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119](https://www.ietf.org/rfc/rfc2119.txt).
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119][rfc2119].

## <b>2</b> <ins>Purpose</ins>

Expand All @@ -106,7 +106,7 @@ Provide a <ins>schema language</ins> to describe normative contracts between pro

1. The <ins>schema language</ins> MUST provide meaningful and useful constraint rules for the 5 JSON value types: `boolean`, `number`, `string`, `object`, and `array`.

1. The <ins>schema language</ins> MUST support schema descriptions for any and all legal JSON documents, as specified by [RFC2119](https://www.ietf.org/rfc/rfc2119.txt).
1. The <ins>schema language</ins> MUST support schema descriptions for any and all legal JSON documents, as specified by [RFC2119][rfc2119].

1. The <ins>schema language</ins> MUST be free-of and agnostic-to patterns specific to any particular programming language.

Expand Down Expand Up @@ -1697,13 +1697,13 @@ This section provides sample schemas in both `jsdx` and `jsd` representations.
</number>
<number name="numRange" range="[1e10,]" doc="Template for number type with range"/>
<number name="cachedInteger" scale="0" range="[1,]" doc="Template for integer number type with range">
<binding lang="java" decode="org.libj.math.BigIntegers.of"/>
<binding lang="java" type="java.math.BigInteger" decode="org.libj.math.BigIntegers.intern"/>
</number>
<number name="plainDecimal" scale="2" doc="Template cached BigDecimal">
<binding lang="java" encode="this.toPlainString"/>
<binding lang="java" type="java.math.BigDecimal" encode="this.toPlainString"/>
</number>
<number name="cachedPlainDecimal" scale="3" range="[-2.222e-12,]" doc="First template for real number type with range">
<binding lang="java" decode="org.libj.math.BigDecimals.of" encode="this.toPlainString"/>
<binding lang="java" type="java.math.BigDecimal" decode="org.libj.math.BigDecimals.intern" encode="this.toPlainString"/>
</number>
<number name="defaultDecimalRange2" scale="3" range="[-2.222e-12,]" doc="Second template for real number type with range"/>

Expand Down Expand Up @@ -2164,7 +2164,8 @@ This section provides sample schemas in both `jsdx` and `jsd` representations.
"doc": "Template for integer number type with range",
"bindings": [{
"lang": "java",
"decode": "org.libj.math.BigIntegers.of"
"type": "java.math.BigInteger",
"decode": "org.libj.math.BigIntegers.intern"
}]
},
"plainDecimal": {
Expand All @@ -2173,6 +2174,7 @@ This section provides sample schemas in both `jsdx` and `jsd` representations.
"doc": "Template cached BigDecimal",
"bindings": [{
"lang": "java",
"type": "java.math.BigDecimal",
"encode": "this.toPlainString"
}]
},
Expand All @@ -2183,7 +2185,8 @@ This section provides sample schemas in both `jsdx` and `jsd` representations.
"doc": "First template for real number type with range",
"bindings": [{
"lang": "java",
"decode": "org.libj.math.BigDecimals.of",
"type": "java.math.BigInteger",
"decode": "org.libj.math.BigDecimals.intern",
"encode": "this.toPlainString"
}]
},
Expand Down Expand Up @@ -3250,5 +3253,7 @@ This project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.t
[ecma262]: http://www.ecma-international.org/publications/standards/Ecma-262.htm
[interval-notation]: https://en.wikipedia.org/wiki/Interval_(mathematics)#Classification_of_intervals
[oxygenxml]: https://www.oxygenxml.com/xml_editor/download_oxygenxml_editor.html
[rfc2119]: https://www.ietf.org/rfc/rfc2119.txt
[rfc4627]: https://www.ietf.org/rfc/rfc4627.txt
[rfc7159]: https://www.ietf.org/rfc/rfc7159.txt
[xmlschema]: http://www.w3.org/2001/XMLSchema
44 changes: 20 additions & 24 deletions schema-0.4/schema-0.4.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</xs:attribute>
</xs:attributeGroup>

<xs:simpleType name="typeName">
<xs:simpleType name="typeRef">
<xs:annotation>
<xs:documentation>Identifier pattern that must start with either a capital letter, or must include a '$' followed by a capital letter.</xs:documentation>
</xs:annotation>
Expand All @@ -89,18 +89,10 @@
</xs:attribute>
</xs:attributeGroup>

<xs:attributeGroup name="idrefs">
<xs:attribute name="types" type="xs:IDREFS">
<xs:annotation>
<xs:documentation>Specifies a list of type names. Optional.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>

<xs:complexType name="referenceMember" abstract="true">
<xs:complexContent>
<xs:extension base="jx:member">
<xs:attribute name="type" type="jx:typeName" use="required">
<xs:attribute name="type" type="jx:typeRef" use="required">
<xs:annotation>
<xs:documentation>Specifies the name of the referenced type. Required.</xs:documentation>
</xs:annotation>
Expand Down Expand Up @@ -200,7 +192,14 @@

<xs:complexType name="anyMember" abstract="true">
<xs:complexContent>
<xs:extension base="jx:member"/>
<xs:extension base="jx:member">
<xs:attribute name="types" type="xs:IDREFS">
<xs:annotation>
<xs:documentation>Specifies a list of type names. Optional.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attributeGroup ref="jx:annullable"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>

Expand All @@ -214,8 +213,6 @@
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attributeGroup ref="jx:idrefs"/>
<xs:attributeGroup ref="jx:annullable"/>
<xs:attributeGroup ref="jx:use"/>
<xs:attribute name="names" type="dt:stringNonEmpty" use="required">
<xs:annotation>
Expand Down Expand Up @@ -249,13 +246,6 @@
</xs:complexContent>
</xs:complexType>

<xs:simpleType name="form">
<xs:restriction base="xs:string">
<xs:enumeration value="integer"/>
<xs:enumeration value="real"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="numberMember" abstract="true">
<xs:complexContent>
<xs:extension base="jx:member">
Expand All @@ -274,7 +264,7 @@
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="scale" type="xs:nonNegativeInteger">
<xs:attribute name="scale" type="xs:long">
<xs:annotation>
<xs:documentation>
The number of digits to the right of the decimal point. If a value is not specified, the scale is unbounded.
Expand Down Expand Up @@ -359,8 +349,6 @@
<xs:complexType>
<xs:complexContent>
<xs:extension base="jx:anyMember">
<xs:attributeGroup ref="jx:idrefs"/>
<xs:attributeGroup ref="jx:annullable"/>
<xs:attributeGroup ref="jx:recurrable"/>
</xs:extension>
</xs:complexContent>
Expand Down Expand Up @@ -511,7 +499,7 @@
</xs:unique>
</xs:element>
</xs:sequence>
<xs:attribute name="extends" type="jx:typeName">
<xs:attribute name="extends" type="jx:typeRef">
<xs:annotation>
<xs:documentation>Specifies the name of the type to extend. Optional.</xs:documentation>
</xs:annotation>
Expand Down Expand Up @@ -647,6 +635,14 @@
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:key name="object_name">
<xs:selector xpath="./jx:object"/>
<xs:field xpath="@name"/>
</xs:key>
<xs:keyref name="extends_must_match_object_name" refer="jx:object_name">
<xs:selector xpath=".//jx:object"/>
<xs:field xpath="@extends"/>
</xs:keyref>
</xs:element>

</xs:schema>

0 comments on commit 9a05b10

Please sign in to comment.