Skip to content

Commit

Permalink
Add jx:targetNamespace to JSD(x) spec, re #9
Browse files Browse the repository at this point in the history
  • Loading branch information
safris committed Jun 8, 2023
1 parent 4ca5593 commit 5a2ed1a
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 44 deletions.
51 changes: 29 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ This document specifies the <ins>JSON Schema Definition Language</ins>, which al
<samp>&nbsp;&nbsp;</samp>6 [<ins>Sample Schemas</ins>](#6-sample-schemas)<br>
<samp>&nbsp;&nbsp;&nbsp;&nbsp;</samp>6.1 [`structure.jsdx`](#61-structurejsdx)<br>
<samp>&nbsp;&nbsp;&nbsp;&nbsp;</samp>6.2 [`structure.jsd`](#62-structurejsd)<br>
<samp>&nbsp;&nbsp;&nbsp;&nbsp;</samp>6.3 [`datatype.jsdx`](#63-datatypesjsdx)<br>
<samp>&nbsp;&nbsp;&nbsp;&nbsp;</samp>6.4 [`datatype.jsd`](#64-datatypesjsd)<br>
<samp>&nbsp;&nbsp;&nbsp;&nbsp;</samp>6.5 [`bindings.jsdx`](#65-bindingsjsdx)<br>
<samp>&nbsp;&nbsp;&nbsp;&nbsp;</samp>6.6 [`bindings.jsd`](#65-bindingsjsd)<br>
<samp>&nbsp;&nbsp;&nbsp;&nbsp;</samp>6.3 [`datatype.jsdx`](#63-datatypejsdx)<br>
<samp>&nbsp;&nbsp;&nbsp;&nbsp;</samp>6.4 [`datatype.jsd`](#64-datatypejsd)<br>
<samp>&nbsp;&nbsp;&nbsp;&nbsp;</samp>6.5 [`binding.jsdx`](#65-bindingjsdx)<br>
<samp>&nbsp;&nbsp;&nbsp;&nbsp;</samp>6.6 [`binding.jsd`](#65-bindingjsd)<br>
<samp>&nbsp;&nbsp;</samp>7 [<ins>Contributing</ins>](#7-contributing)<br>
<samp>&nbsp;&nbsp;</samp>8 [<ins>Special Thanks</ins>](#8-special-thanks)<br>
<samp>&nbsp;&nbsp;</samp>9 [<ins>License</ins>](#9-license)
Expand Down Expand Up @@ -165,7 +165,7 @@ The <samp>**schema**</samp> is the root object of the JSD, and contains [type][#

| <samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</samp> | **Property&nbsp;Name**<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</samp> | **Property&nbsp;Value**<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</samp> |
|:-|:-|:-|
| <samp>( **schema** )</samp><br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp; | <samp>jx:ns</samp><br>&nbsp;<br>&nbsp;<br><samp>jx:schemaLocation</samp><br>&nbsp;<br>&nbsp;<br>&nbsp;<br><samp>doc</samp><br><samp>[a-zA-Z_$][-a-zA-Z\\d_$]*</samp><br>&nbsp;<br>&nbsp; | _Namespace of the JSON Schema._ Required.<br>&nbsp;&nbsp;Used by schema processors to determine to which<br>&nbsp;&nbsp;version of the JSON Schema the JSD is written.<br>_Location URL of namespace._ Optional.<br>&nbsp;&nbsp;Specified as: `"%NAMESPACE_URI% %LOCATION_URL%"`<br>&nbsp;&nbsp;Used by schema processors to determine location of<br>&nbsp;&nbsp;schema definition for a namespace.<br>Text comments. Optional.<br>_[Type Declaration][#type-declarations]_. Optional.<br>&nbsp;&nbsp;Root object definitions that are referenceable<br>&nbsp;&nbsp;throughout the schema. |
| <samp>( **schema** )</samp><br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp; | <samp>jx:ns</samp><br>&nbsp;<br>&nbsp;<br><samp>jx:schemaLocation</samp><br>&nbsp;<br>&nbsp;<br>&nbsp;<br><samp>jx:targetNamespace</samp><br>&nbsp;<br>&nbsp;<br>&nbsp;<br><samp>doc</samp><br><samp>[a-zA-Z_$][-a-zA-Z\\d_$]*</samp><br>&nbsp;<br>&nbsp; | _Namespace of the JSON Schema._ Required.<br>&nbsp;&nbsp;Used by schema processors to determine to which<br>&nbsp;&nbsp;version of the JSON Schema the JSD is written.<br>_Location URL of namespace._ Optional.<br>&nbsp;&nbsp;Specified as: `"%NAMESPACE_URI% %LOCATION_URL%"`<br>&nbsp;&nbsp;Used by schema processors to determine location of<br>&nbsp;&nbsp;schema definition for a namespace.<br>_Target namespace of schema document._ Optional.<br>&nbsp;&nbsp;Specified as: `"%NAMESPACE_URI%"`<br>&nbsp;&nbsp;Represents the namespace of elements declared<br>&nbsp;&nbsp;within the schema document.<br>Text comments. Optional.<br>_[Type Declaration][#type-declarations]_. Optional.<br>&nbsp;&nbsp;Root object definitions that are referenceable<br>&nbsp;&nbsp;throughout the schema. |

<!-- tabs:start -->

Expand All @@ -175,6 +175,7 @@ The <samp>**schema**</samp> is the root object of the JSD, and contains [type][#
{
"jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"jx:schemaLocation": "http://www.jsonx.org/schema-0.4.jsd http://www.jsonx.org/schema.jsd",
"jx:targetNamespace": "https://www.jsonx.org/example.jsd"
...
}
```
Expand All @@ -183,8 +184,10 @@ The <samp>**schema**</samp> is the root object of the JSD, and contains [type][#

```xml
<schema
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
targetNamespace="https://www.jsonx.org/example.jsdx">
...
</schema>
```
Expand Down Expand Up @@ -1344,10 +1347,10 @@ These bindings are allowed on [Object Properties of type `boolean`, `number`, or

#### <b>4.6.4</b> Examples

1. [`datatypes.jsdx`](#63-datatypesjsdx)
1. [`datatypes.jsd`](#64-datatypesjsd)
1. [`bindings.jsdx`](#65-bindingsjsdx)
1. [`bindings.jsd`](#66-bindingsjsd)
1. [`datatype.jsdx`](#63-datatypejsdx)
1. [`datatype.jsd`](#64-datatypejsd)
1. [`binding.jsdx`](#65-bindingjsdx)
1. [`binding.jsd`](#66-bindingjsd)

## <b>5</b> <ins>Related Resources for JSON Schema</ins>

Expand Down Expand Up @@ -1399,7 +1402,8 @@ This section provides sample schemas in both `jsdx` and `jsd` representations.
<schema
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
doc="Schema expressing complex nested structures">
<array name="array">
<boolean nullable="true"/>
<number range="[-1,1)" nullable="true"/>
Expand Down Expand Up @@ -1464,6 +1468,7 @@ This section provides sample schemas in both `jsdx` and `jsd` representations.
{
"jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"jx:schemaLocation": "http://www.jsonx.org/schema-0.4.jsd http://www.jsonx.org/schema.jsd",
"doc": "Schema expressing complex nested structures",
"array": {
"jx:type": "array",
"elements": [{
Expand Down Expand Up @@ -1621,14 +1626,15 @@ This section provides sample schemas in both `jsdx` and `jsd` representations.
}
```

#### <b>6.3</b> `datatypes.jsdx`
#### <b>6.3</b> `datatype.jsdx`

```xml
<schema
doc="Schema intended to express full variability of type declarations"
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
targetNamespace="http://www.jsonx.org/generator/test/datatype.jsdx"
doc="Schema intended to express full variability of type declarations">
<array name="arrayArr" doc="Array of arrays">
<reference type="arrayBool" maxOccurs="1" doc="Reference to array of booleans"/>
<reference type="arrayNum" maxOccurs="1" doc="Reference to array of numbers"/>
Expand Down Expand Up @@ -1857,13 +1863,14 @@ This section provides sample schemas in both `jsdx` and `jsd` representations.
</schema>
```

#### <b>6.4</b> `datatypes.jsd`
#### <b>6.4</b> `datatype.jsd`

```json
{
"doc": "Schema intended to express full variability of type declarations",
"jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"jx:schemaLocation": "http://www.jsonx.org/schema-0.4.jsd http://www.jsonx.org/schema-0.4.jsd",
"jx:targetNamespace": "http://www.jsonx.org/generator/test/datatype.jsdx",
"doc": "Schema intended to express full variability of type declarations",
"arrayArr": {
"jx:type": "array",
"doc": "Array of arrays",
Expand Down Expand Up @@ -2821,14 +2828,14 @@ This section provides sample schemas in both `jsdx` and `jsd` representations.
}
```

#### <b>6.5</b> `bindings.jsdx`
#### <b>6.5</b> `binding.jsdx`

```xml
<schema
doc="Schema focusing on bindings"
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
doc="Schema focusing on bindings">

<boolean name="StringBoolean">
<binding lang="java" type="java.lang.String"/>
Expand Down Expand Up @@ -2936,13 +2943,13 @@ This section provides sample schemas in both `jsdx` and `jsd` representations.
</schema>
```

#### <b>6.6</b> `bindings.jsd`
#### <b>6.6</b> `binding.jsd`

```json
{
"doc": "Schema focusing on bindings",
"jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"jx:schemaLocation": "http://www.jsonx.org/schema-0.4.jsd http://www.jsonx.org/schema-0.4.jsd",
"doc": "Schema focusing on bindings",
"StringBoolean": {
"jx:type": "boolean",
"bindings": [{
Expand Down
3 changes: 2 additions & 1 deletion examples/array.jsdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<schema
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
targetNamespace="http://www.jsonx.org/examples/array.jsdx">
<array name="bar-rootArray1">
<reference type="rootBoolean" minOccurs="5" maxOccurs="6"/>
</array>
Expand Down
5 changes: 3 additions & 2 deletions examples/complete.jsdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
program. If not, see <http://opensource.org/licenses/MIT/>.
-->
<schema
doc="Schema intended to provide a complete set of variations of declarations"
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
targetNamespace="http://www.jsonx.org/examples/complete.jsdx"
doc="Schema intended to provide a complete set of variations of declarations">
<array name="rootArrayBool" doc="Root array boolean">
<boolean doc="Plain boolean"/>
</array>
Expand Down
5 changes: 3 additions & 2 deletions examples/datatype.jsdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
program. If not, see <http://opensource.org/licenses/MIT/>.
-->
<schema
doc="Schema intended to express full variability of type declarations"
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
targetNamespace="http://www.jsonx.org/examples/datatype.jsdx"
doc="Schema intended to express full variability of type declarations">
<array name="arrayArr" doc="Array of arrays">
<reference type="arrayBool" maxOccurs="1" doc="Reference to array of booleans"/>
<reference type="arrayNum" maxOccurs="1" doc="Reference to array of numbers"/>
Expand Down
5 changes: 3 additions & 2 deletions examples/reference.jsdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
program. If not, see <http://opensource.org/licenses/MIT/>.
-->
<schema
doc="Schema focusing on references"
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
targetNamespace="http://www.jsonx.org/examples/reference.jsdx"
doc="Schema focusing on references">
<array name="arrayObj">
<reference type="objArr" maxOccurs="1"/>
</array>
Expand Down
5 changes: 3 additions & 2 deletions examples/reserved.jsdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
program. If not, see <http://opensource.org/licenses/MIT/>.
-->
<schema
doc="Schema with names that overlap with Java's reserved words"
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
targetNamespace="http://www.jsonx.org/examples/reserved.jsdx"
doc="Schema with names that overlap with Java's reserved words">
<array name="break" maxIterate="2">
<reference type="extends" minOccurs="9" maxOccurs="10"/>
<reference type="import" minOccurs="7" maxOccurs="8"/>
Expand Down
5 changes: 3 additions & 2 deletions examples/structure.jsdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
program. If not, see <http://opensource.org/licenses/MIT/>.
-->
<schema
doc="Schema expressing complex nested structures"
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
targetNamespace="http://www.jsonx.org/examples/structure.jsdx"
doc="Schema expressing complex nested structures">
<array name="array">
<boolean minOccurs="1" maxOccurs="unbounded" nullable="true"/>
<number scale="5" range="[-1,1)" minOccurs="1" maxOccurs="unbounded" nullable="true"/>
Expand Down
5 changes: 3 additions & 2 deletions examples/template.jsdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
program. If not, see <http://opensource.org/licenses/MIT/>.
-->
<schema
doc="Schema expressing the variations of templates"
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
targetNamespace="http://www.jsonx.org/examples/template.jsdx"
doc="Schema expressing the variations of templates">
<array name="arrayDepthFour" minIterate="4" maxIterate="4" doc="Array template">
<reference type="arrayDepthThree" minOccurs="9" maxOccurs="10" doc="Reference to arrayDepthThree"/>
<reference type="arrayDepthTwo" minOccurs="7" maxOccurs="8" doc="Referene to arrayDepthTwo"/>
Expand Down
15 changes: 11 additions & 4 deletions schema-0.4/schema-0.4.jsd
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"jx:schemaLocation": "http://www.jsonx.org/schema-0.4.jsd http://www.jsonx.org/schema-0.4.jsd",
"jx:targetNamespace": "http://www.jsonx.org/schema-0.4.jsd",
"min": {
"jx:type": "string",
"pattern": "[\\d]+"
"pattern": "\\d+"
},
"max": {
"jx:type": "string",
"pattern": "([\\d]+|unbounded)"
"pattern": "\\d+|unbounded"
},
"use": {
"jx:type": "string",
"pattern": "(required|optional)"
"pattern": "required|optional"
},
"nonEmptyString": {
"jx:type": "string",
"pattern": "\\S+( \\S+)*"
"pattern": "\\S|\\S.*\\S"
},
"documented": {
"jx:type": "object",
Expand Down Expand Up @@ -47,6 +48,12 @@
"use": "optional",
"nullable": false
},
"jx:targetNamespace": {
"jx:type": "reference",
"type": "nonEmptyString",
"use": "optional",
"nullable": false
},
"[a-zA-Z_][-a-zA-Z\\d_]*": {
"jx:type": "any",
"types": "array boolean number objectType string",
Expand Down
12 changes: 7 additions & 5 deletions schema-0.4/schema-0.4.jsdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
<schema
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd schema-0.4.xsd">
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd schema-0.4.xsd"
targetNamespace="http://www.jsonx.org/schema-0.4.jsdx">

<string name="min" pattern="[\d]+"/>
<string name="max" pattern="([\d]+|unbounded)"/>
<string name="use" pattern="(required|optional)"/>
<string name="nonEmptyString" pattern="\S+( \S+)*"/>
<string name="min" pattern="\d+"/>
<string name="max" pattern="\d+|unbounded"/>
<string name="use" pattern="required|optional"/>
<string name="nonEmptyString" pattern="\S|\S.*\S"/>

<object name="documented" abstract="true">
<property name="doc" xsi:type="string" doc="Defines text comments. Optional."/>
Expand All @@ -33,6 +34,7 @@
<object name="schema" extends="documented">
<property name="jx:ns" xsi:type="string" pattern="http://www.jsonx.org/schema-0.4.jsd" nullable="false"/>
<property name="jx:schemaLocation" xsi:type="string" pattern="http://www.jsonx.org/schema-0.4.jsd [^ ]+" use="optional" nullable="false"/>
<property name="jx:targetNamespace" xsi:type="reference" type="nonEmptyString" nullable="false" use="optional"/>
<property names="[a-zA-Z_][-a-zA-Z\d_]*" xsi:type="any" types="array boolean number objectType string" nullable="false">
<binding lang="java" field="declarations"/>
</property>
Expand Down
7 changes: 7 additions & 0 deletions schema-0.4/schema-0.4.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,13 @@
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="targetNamespace">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="(\S)|(\S.*\S)"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Expand Down

0 comments on commit 5a2ed1a

Please sign in to comment.