Skip to content

Commit

Permalink
Merge pull request #13 from jsonx-org/binding
Browse files Browse the repository at this point in the history
External binding schema
  • Loading branch information
safris committed Sep 29, 2023
2 parents 45ae077 + 99e89df commit 3ec70c0
Show file tree
Hide file tree
Showing 13 changed files with 1,477 additions and 917 deletions.
1 change: 1 addition & 0 deletions binding.jsd
1 change: 1 addition & 0 deletions binding.jsdx
1 change: 1 addition & 0 deletions binding.xsd
1 change: 1 addition & 0 deletions include.jsd
1 change: 1 addition & 0 deletions include.jsdx
200 changes: 200 additions & 0 deletions schema-0.5/binding-0.5.jsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
{
"@ns": "http://www.jsonx.org/schema-0.5.jsd",
"@schemaLocation": "http://www.jsonx.org/schema-0.5.jsd http://www.jsonx.org/schema-0.5.jsd",
"@targetNamespace": "http://www.jsonx.org/binding-0.5.jsd",
"nonEmptyString": {
"@": "string",
"@pattern": "\\S|\\S.*\\S"
},
"typeIdentifier": {
"@": "string",
"@pattern": "(([a-zA-Z_$][a-zA-Z\\d_$]*)\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*(\\[\\])?"
},
"methodIdentifier": {
"@": "string",
"@pattern": "(([a-zA-Z_$][a-zA-Z\\d_$]*)\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*(\\.<init>)?"
},
"fieldIdentifier": {
"@": "string",
"@pattern": "[a-zA-Z_$][a-zA-Z\\d_$]*"
},
"fieldBinding": {
"@": "object",
"@doc": "Specifies language-specific binding.",
"@properties": {
"@field": {
"@": "reference",
"@doc": "Specifies the \"field\" identifier.",
"@nullable": false,
"@type": "fieldIdentifier",
"@use": "optional"
}
}
},
"typeBinding": {
"@": "object",
"@doc": "Specifies language-specific binding.",
"@properties": {
"@type": {
"@": "reference",
"@doc": "Specifies the \"type\" qualified identifier.",
"@nullable": false,
"@type": "typeIdentifier",
"@use": "optional"
},
"@decode": {
"@": "reference",
"@doc": "Specifies the \"decode\" qualified function identifier that accepts input as a string, or as the native JSON type of this property, and returns an output of the specified \"type\" (or the default type if \"type\" is unspecified).",
"@nullable": false,
"@type": "methodIdentifier",
"@use": "optional"
},
"@encode": {
"@": "reference",
"@doc": "Specifies the \"encode\" qualified function identifier that accepts input of the type specified in \"type\" (or the default type if \"type\" is unspecified), and returns an output as a string, or as the native JSON type of this property.",
"@nullable": false,
"@type": "methodIdentifier",
"@use": "optional"
}
}
},
"typeFieldBinding": {
"@": "object",
"@doc": "Specifies language-specific binding.",
"@extends": "typeBinding",
"@properties": {
"@field": {
"@": "reference",
"@doc": "Specifies the \"field\" identifier.",
"@nullable": false,
"@type": "fieldIdentifier",
"@use": "optional"
}
}
},
"fieldBindings": {
"@": "object",
"@abstract": true,
"@properties": {
"\\S|\\S.*\\S": {
"@": "any",
"@nullable": false,
"@types": "fieldBinding"
}
}
},
"typeFieldBindings": {
"@": "object",
"@abstract": true,
"@properties": {
"\\S|\\S.*\\S": {
"@": "any",
"@nullable": false,
"@types": "typeFieldBinding"
}
}
},
"any": {
"@": "object",
"@extends": "fieldBindings",
"@properties": {
"@": {
"@": "string",
"@nullable": false,
"@pattern": "any"
}
}
},
"reference": {
"@": "object",
"@extends": "fieldBindings",
"@properties": {
"@": {
"@": "string",
"@nullable": false,
"@pattern": "reference"
}
}
},
"array": {
"@": "object",
"@extends": "fieldBindings",
"@properties": {
"@": {
"@": "string",
"@nullable": false,
"@pattern": "array"
}
}
},
"object": {
"@": "object",
"@extends": "fieldBindings",
"@properties": {
"@": {
"@": "string",
"@nullable": false,
"@pattern": "object"
}
}
},
"boolean": {
"@": "object",
"@extends": "typeFieldBindings",
"@properties": {
"@": {
"@": "string",
"@nullable": false,
"@pattern": "boolean"
}
}
},
"number": {
"@": "object",
"@extends": "typeFieldBindings",
"@properties": {
"@": {
"@": "string",
"@nullable": false,
"@pattern": "number"
}
}
},
"string": {
"@": "object",
"@extends": "typeFieldBindings",
"@properties": {
"@": {
"@": "string",
"@nullable": false,
"@pattern": "string"
}
}
},
"binding": {
"@": "object",
"@properties": {
"@ns": {
"@": "string",
"@nullable": false,
"@pattern": "http://www.jsonx.org/binding-0.5.jsd"
},
"@schemaLocation": {
"@": "string",
"@nullable": false,
"@pattern": "((\\S|\\S.*\\S) (\\S|\\S.*\\S))+",
"@use": "optional"
},
"@schema": {
"@": "any",
"@nullable": false,
"@types": "schema include"
},
"\\S|\\S.*\\S": {
"@": "any",
"@nullable": false,
"@types": "any reference array object boolean number string"
}
}
}
}
94 changes: 94 additions & 0 deletions schema-0.5/binding-0.5.jsdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!--
Copyright (c) 2023 JSONx

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

You should have received a copy of The MIT License (MIT) along with this
program. If not, see <http://opensource.org/licenses/MIT/>.
-->
<schema
xmlns="http://www.jsonx.org/schema-0.5.xsd"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:jxns="http://www.jsonx.org/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.5.xsd schema-0.5.xsd"

jxns:jx="http://www.jsonx.org/schema-0.5.jsdx"
jxns:ji="http://www.jsonx.org/include-0.5.jsdx"
targetNamespace="http://www.jsonx.org/binding-0.5.jsdx">

<import namespace="http://www.jsonx.org/schema-0.5.jsdx" schemaLocation="http://www.jsonx.org/schema-0.5.jsdx"><xi:include href="http://www.jsonx.org/schema-0.5.jsdx"/></import>
<import namespace="http://www.jsonx.org/include-0.5.jsdx" schemaLocation="http://www.jsonx.org/include-0.5.jsdx"><xi:include href="http://www.jsonx.org/include-0.5.jsdx"/></import>

<string name="nonEmptyString" pattern="\S|\S.*\S"/>
<string name="typeIdentifier" pattern="(([a-zA-Z_$][a-zA-Z\d_$]*)\.)*[a-zA-Z_$][a-zA-Z\d_$]*(\[\])?"/>
<string name="methodIdentifier" pattern="(([a-zA-Z_$][a-zA-Z\d_$]*)\.)*[a-zA-Z_$][a-zA-Z\d_$]*(\.&lt;init&gt;)?"/>
<string name="fieldIdentifier" pattern="[a-zA-Z_$][a-zA-Z\d_$]*"/>

<object name="fieldBinding" doc="Specifies language-specific binding.">
<property name="@field" xsi:type="reference" type="fieldIdentifier" use="optional" nullable="false" doc="Specifies the &quot;field&quot; identifier."/>
</object>

<object name="typeBinding" doc="Specifies language-specific binding.">
<property name="@type" xsi:type="reference" type="typeIdentifier" use="optional" nullable="false" doc="Specifies the &quot;type&quot; qualified identifier."/>
<property name="@decode" xsi:type="reference" type="methodIdentifier" use="optional" nullable="false" doc="Specifies the &quot;decode&quot; qualified function identifier that accepts input as a string, or as the native JSON type of this property, and returns an output of the specified &quot;type&quot; (or the default type if &quot;type&quot; is unspecified)."/>
<property name="@encode" xsi:type="reference" type="methodIdentifier" use="optional" nullable="false" doc="Specifies the &quot;encode&quot; qualified function identifier that accepts input of the type specified in &quot;type&quot; (or the default type if &quot;type&quot; is unspecified), and returns an output as a string, or as the native JSON type of this property."/>
</object>

<object name="typeFieldBinding" extends="typeBinding" doc="Specifies language-specific binding.">
<!-- FIXME: Equivalent of <xs:assert test="some $path in ../@path satisfies not(@field) or count(tokenize($path, '([^\\]|\\\\)\[')) = 1 and count(tokenize($path, '([^\\]|\\\\)\.')) > 1"/> is not yet possible in JSDx -->
<property name="@field" xsi:type="reference" type="fieldIdentifier" use="optional" nullable="false" doc="Specifies the &quot;field&quot; identifier."/>
</object>

<object name="fieldBindings" abstract="true">
<property names="\S|\S.*\S" xsi:type="any" types="fieldBinding" nullable="false"/>
</object>

<object name="typeFieldBindings" abstract="true">
<property names="\S|\S.*\S" xsi:type="any" types="typeFieldBinding" nullable="false"/>
</object>

<object name="any" extends="fieldBindings">
<property name="@" xsi:type="string" pattern="any" nullable="false"/>
</object>

<object name="reference" extends="fieldBindings">
<property name="@" xsi:type="string" pattern="reference" nullable="false"/>
</object>

<object name="array" extends="fieldBindings">
<property name="@" xsi:type="string" pattern="array" nullable="false"/>
</object>

<object name="object" extends="fieldBindings">
<property name="@" xsi:type="string" pattern="object" nullable="false"/>
</object>

<object name="boolean" extends="typeFieldBindings">
<property name="@" xsi:type="string" pattern="boolean" nullable="false"/>
</object>

<object name="number" extends="typeFieldBindings">
<property name="@" xsi:type="string" pattern="number" nullable="false"/>
</object>

<object name="string" extends="typeFieldBindings">
<property name="@" xsi:type="string" pattern="string" nullable="false"/>
</object>

<object name="binding">
<property name="@ns" xsi:type="string" pattern="http://www.jsonx.org/binding-0.5.jsd" nullable="false"/>
<property name="@schemaLocation" xsi:type="string" pattern="((\S|\S.*\S) (\S|\S.*\S))+" use="optional" nullable="false"/>
<property names="@schema" xsi:type="any" types="jx:schema ji:include" nullable="false"/>
<property names="\S|\S.*\S" xsi:type="any" types="any reference array object boolean number string" nullable="false"/>
</object>

</schema>
Loading

0 comments on commit 3ec70c0

Please sign in to comment.