Skip to content

Commit 13bdeb9

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

45 files changed

Lines changed: 5837 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ expressed as JSON Schema definitions.
5353
| IEEE | [IEEE Std 754-2019](https://ieeexplore.ieee.org/document/8766229) | IEEE Standard for Floating-Point Arithmetic |
5454
| IEEE | [IEEE Std 1003.1-2017](https://pubs.opengroup.org/onlinepubs/9699919799/) | IEEE Standard for Information Technology—Portable Operating System Interface (POSIX) Base Specifications, Issue 7 |
5555
| IETF | [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) | Uniform Resource Identifier (URI): Generic Syntax |
56+
| IETF | [RFC 4648](https://www.rfc-editor.org/rfc/rfc4648) | The Base16, Base32, and Base64 Data Encodings |
5657
| IETF | [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918) | HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) |
5758
| IETF | [RFC 5322](https://www.rfc-editor.org/rfc/rfc5322) | Internet Message Format |
5859
| IETF | [RFC 5646](https://www.rfc-editor.org/rfc/rfc5646) | Tags for Identifying Languages (BCP 47) |
@@ -71,6 +72,7 @@ expressed as JSON Schema definitions.
7172
| ISO/IEC | [ISO/IEC 9899:2024](https://www.iso.org/standard/82075.html) | Programming languages — C |
7273
| JSON-RPC | [JSON-RPC 2.0](https://www.jsonrpc.org/specification) | JSON-RPC 2.0 Specification |
7374
| 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 |
7476

7577
To request coverage of another standard, please [open an issue on
7678
GitHub](https://github.com/sourcemeta/std/issues).

schemas/ietf/encoding/base16.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 4648 Base16 Encoding",
4+
"description": "Uses digits 0-9 and letters A-F (case-insensitive). Each byte encodes to exactly 2 characters, no padding required",
5+
"examples": [
6+
"48656C6C6F20576F726C6421",
7+
"DEADBEEF",
8+
"0FB7",
9+
"666F6F626172",
10+
""
11+
],
12+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
13+
"x-links": [ "https://www.rfc-editor.org/rfc/rfc4648.html#section-8" ],
14+
"type": "string",
15+
"not": {
16+
"pattern": "[\\x00-\\x1F]"
17+
},
18+
"pattern": "^([0-9A-Fa-f]{2})*$",
19+
"contentEncoding": "base16"
20+
}

schemas/ietf/encoding/base32.json

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": "RFC 4648 Base32 Encoding",
4+
"description": "Uses uppercase letters A-Z and digits 2-7 (32 characters total). Padding with = to multiple of 8 characters",
5+
"examples": [
6+
"JBSWY3DPEBLW64TMMQ======",
7+
"MFRGG===",
8+
"MZXW6===",
9+
"MZXW6YQ=",
10+
"MZXW6YTB",
11+
""
12+
],
13+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
14+
"x-links": [ "https://www.rfc-editor.org/rfc/rfc4648.html#section-6" ],
15+
"type": "string",
16+
"pattern": "^([A-Z2-7]{8})*([A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}=)?$",
17+
"contentEncoding": "base32"
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": "RFC 4648 Base32hex Encoding",
4+
"description": "Uses digits 0-9 and uppercase letters A-V (32 characters total). Padding with = to multiple of 8 characters",
5+
"examples": [
6+
"91IMOR3F41BMUSJCCG======",
7+
"C5H66===",
8+
"CPNMU===",
9+
"CPNMUO8=",
10+
"CPNMUOJ1",
11+
""
12+
],
13+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
14+
"x-links": [ "https://www.rfc-editor.org/rfc/rfc4648.html#section-7" ],
15+
"type": "string",
16+
"pattern": "^([0-9A-V]{8})*([0-9A-V]{2}={6}|[0-9A-V]{4}={4}|[0-9A-V]{5}={3}|[0-9A-V]{7}=)?$",
17+
"contentEncoding": "base32hex"
18+
}

schemas/ietf/encoding/base64.json

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": "RFC 4648 Base64 Encoding",
4+
"description": "Uses uppercase letters A-Z, lowercase letters a-z, digits 0-9, plus sign (+), and forward slash (/), with equals sign (=) used for padding",
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.rfc-editor.org/rfc/rfc4648.html#section-4" ],
15+
"type": "string",
16+
"pattern": "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
17+
"contentEncoding": "base64"
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": "RFC 4648 Base64url Encoding",
4+
"description": "Base64 encoding with URL and filename safe alphabet as defined in RFC 4648 section 5. Uses hyphen (-) and underscore (_) instead of plus (+) and slash (/)",
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.rfc-editor.org/rfc/rfc4648.html#section-5" ],
15+
"type": "string",
16+
"pattern": "^([A-Za-z0-9_-]{4})*([A-Za-z0-9_-]{2}==|[A-Za-z0-9_-]{3}=)?$",
17+
"contentEncoding": "base64url"
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 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+
}

0 commit comments

Comments
 (0)