Skip to content

Commit c30c061

Browse files
committed
Implement most W3C XML Schema 2004 primitive data types
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent a923fa6 commit c30c061

35 files changed

Lines changed: 3174 additions & 0 deletions

README.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ expressed as JSON Schema definitions.
7272
| ISO/IEC | [ISO/IEC 9899:2024](https://www.iso.org/standard/82075.html) | Programming languages — C |
7373
| JSON-RPC | [JSON-RPC 2.0](https://www.jsonrpc.org/specification) | JSON-RPC 2.0 Specification |
7474
| JSON Schema | [Draft 2020-12](https://json-schema.org/draft/2020-12/json-schema-core) | JSON Schema: A Media Type for Describing JSON Documents |
75+
| W3C | [XML Schema Part 2: Datatypes Second Edition](https://www.w3.org/TR/xmlschema-2/) | W3C Recommendation 28 October 2004 |
7576

7677
To request coverage of another standard, please [open an issue on
7778
GitHub](https://github.com/sourcemeta/std/issues).
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema anyURI",
4+
"description": "The anyURI datatype represents a Uniform Resource Identifier Reference (URI) (§3.2.17)",
5+
"examples": [
6+
"http://www.example.com",
7+
"https://www.example.com/path/to/resource",
8+
"ftp://ftp.example.com/file.txt",
9+
"mailto:user@example.com",
10+
"../relative/path.html",
11+
"http://www.example.com/path#fragment",
12+
"urn:isbn:0-395-36341-1",
13+
""
14+
],
15+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
16+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#anyURI" ],
17+
"$ref": "../../../ietf/uri/uri-reference.json"
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema base64Binary",
4+
"description": "The base64Binary datatype represents Base64-encoded arbitrary binary data (§3.2.16)",
5+
"examples": [
6+
"R0lGODlhAQABAAAAACw=",
7+
"SGVsbG8gV29ybGQh",
8+
"YQ==",
9+
"YWI=",
10+
"YWJj",
11+
""
12+
],
13+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
14+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#base64Binary" ],
15+
"$ref": "../../../ietf/encoding/base64.json",
16+
"contentEncoding": "base64",
17+
"contentMediaType": "application/octet-stream"
18+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema boolean",
4+
"description": "The boolean datatype represents binary logic values (§3.2.2)",
5+
"examples": [ true, false ],
6+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
7+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#boolean" ],
8+
"type": "boolean"
9+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema dateTime",
4+
"description": "The dateTime datatype represents a specific instant of time (§3.2.7)",
5+
"$comment": "Year 0000 is not allowed in XML Schema 1.0. Leap year validation is consumer responsibility",
6+
"examples": [
7+
"2002-10-10T12:00:00-05:00",
8+
"2002-10-10T17:00:00Z",
9+
"2002-10-10T12:00:00",
10+
"2002-05-30T09:00:00",
11+
"-2002-10-10T12:00:00"
12+
],
13+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
14+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#dateTime" ],
15+
"type": "string",
16+
"pattern": "^-?((?!0000)[0-9]{4}-(0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01])|(?!0000)[0-9]{4}-(0[469]|11)-(0[1-9]|[12][0-9]|30)|(?!0000)[0-9]{4}-02-(0[1-9]|1[0-9]|2[0-9]))T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])?$"
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema date",
4+
"description": "The date datatype represents a calendar date (§3.2.9)",
5+
"$comment": "Year 0000 is not allowed in XML Schema 1.0. Leap year validation is consumer responsibility",
6+
"examples": [ "2002-10-10", "2002-10-10+13:00", "2002-10-10Z", "-2002-10-10" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#date" ],
9+
"type": "string",
10+
"pattern": "^-?((?!0000)[0-9]{4}-(0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01])|(?!0000)[0-9]{4}-(0[469]|11)-(0[1-9]|[12][0-9]|30)|(?!0000)[0-9]{4}-02-(0[1-9]|1[0-9]|2[0-9]))(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])?$"
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema decimal",
4+
"description": "The decimal datatype represents arbitrary precision decimal numbers (§3.2.3)",
5+
"examples": [
6+
"-1.23",
7+
"12678967.543233",
8+
"+100000.00",
9+
"210",
10+
"0",
11+
"-0",
12+
"3.14159265358979323846"
13+
],
14+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
15+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#decimal" ],
16+
"type": "string",
17+
"pattern": "^[+-]?([0-9]+\\.[0-9]+|[0-9]+)$"
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema double",
4+
"description": "The double datatype corresponds to IEEE double-precision 64-bit floating point (§3.2.5)",
5+
"examples": [ 0.0, 1.5, -3.14159, "INF", "-INF", "NaN" ],
6+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
7+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#double" ],
8+
"anyOf": [
9+
{
10+
"$ref": "../../../ieee/floating-point/2019/binary64.json"
11+
},
12+
{
13+
"enum": [ "INF", "-INF", "NaN" ]
14+
}
15+
]
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema duration",
4+
"description": "The duration datatype represents a duration of time in ISO 8601 format with optional minus sign for negative durations (§3.2.6)",
5+
"examples": [
6+
"P1Y2M3DT10H30M",
7+
"-P120D",
8+
"P1347Y",
9+
"P1347M",
10+
"P1Y2MT2H",
11+
"-P1347M"
12+
],
13+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
14+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#duration" ],
15+
"$ref": "../../../iso/datetime/2019/duration/designator-extension.json"
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema float",
4+
"description": "The float datatype corresponds to IEEE single-precision 32-bit floating point (§3.2.4)",
5+
"examples": [ 0.0, 1.5, -3.14, "INF", "-INF", "NaN" ],
6+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
7+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#float" ],
8+
"anyOf": [
9+
{
10+
"$ref": "../../../ieee/floating-point/2019/binary32.json"
11+
},
12+
{
13+
"enum": [ "INF", "-INF", "NaN" ]
14+
}
15+
]
16+
}

0 commit comments

Comments
 (0)