Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions schemas/w3c/xmlschema/2001/entities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "W3C XML Schema ENTITIES",
"description": "Represents a list of references to unparsed entities (§3.3.12)",
"$comment": "ENTITIES is a space-separated list of ENTITY values. In JSON Schema, this is represented as an array with at least one item",
"examples": [
[ "entity1", "entity2" ],
[ "_img1", "_img2", "_img3" ],
[ "singleEntity" ],
[ "logo", "banner", "icon" ]
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#ENTITIES" ],
"type": "array",
"minItems": 1,
"items": {
"$ref": "entity.json"
}
}
10 changes: 10 additions & 0 deletions schemas/w3c/xmlschema/2001/entity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "W3C XML Schema ENTITY",
"description": "Represents references to unparsed entities declared in the DTD (§3.3.11)",
"$comment": "ENTITY is syntactically an NCName. The constraint that it references a declared unparsed entity is DTD validation, not a schema concern",
"examples": [ "imageEntity", "_entity1", "logo-ref", "attachment_99" ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#ENTITY" ],
"$ref": "ncname.json"
}
10 changes: 10 additions & 0 deletions schemas/w3c/xmlschema/2001/id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "W3C XML Schema ID",
"description": "Represents unique identifiers within an XML document (§3.3.8)",
"$comment": "ID is syntactically an NCName. The uniqueness constraint is a validation concern, not a schema concern",
"examples": [ "uniqueId", "_id123", "user-profile", "element_42" ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#ID" ],
"$ref": "ncname.json"
}
10 changes: 10 additions & 0 deletions schemas/w3c/xmlschema/2001/idref.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "W3C XML Schema IDREF",
"description": "Represents references to ID values within an XML document (§3.3.9)",
"$comment": "IDREF is syntactically an NCName. The constraint that it references an existing ID is a validation concern, not a schema concern",
"examples": [ "refToId", "_ref123", "user-link", "target_42" ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#IDREF" ],
"$ref": "ncname.json"
}
19 changes: 19 additions & 0 deletions schemas/w3c/xmlschema/2001/idrefs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "W3C XML Schema IDREFS",
"description": "Represents a list of references to ID values (§3.3.10)",
"$comment": "IDREFS is a space-separated list of IDREF values. In JSON Schema, this is represented as an array with at least one item",
"examples": [
[ "ref1", "ref2" ],
[ "_id1", "_id2", "_id3" ],
[ "singleRef" ],
[ "link-a", "link-b", "link-c" ]
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#IDREFS" ],
"type": "array",
"minItems": 1,
"items": {
"$ref": "idref.json"
}
}
2 changes: 1 addition & 1 deletion schemas/w3c/xmlschema/2001/name.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion schemas/w3c/xmlschema/2001/ncname.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion schemas/w3c/xmlschema/2001/nmtoken.json

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions schemas/w3c/xmlschema/2001/nmtokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "W3C XML Schema NMTOKENS",
"description": "Represents a list of XML name tokens (§3.3.4)",
"$comment": "NMTOKENS is a space-separated list of NMTOKEN values. In JSON Schema, this is represented as an array with at least one item",
"examples": [
[ "token1", "token2" ],
[ "abc", "123", "data-value" ],
[ "single" ],
[ "one", "two", "three", "four" ]
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#NMTOKENS" ],
"type": "array",
"minItems": 1,
"items": {
"$ref": "nmtoken.json"
}
}
187 changes: 187 additions & 0 deletions test/w3c/xmlschema/2001/entities.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"target": "../../../../schemas/w3c/xmlschema/2001/entities.json",
"tests": [
{
"description": "Valid - two entities",
"data": [ "entity1", "entity2" ],
"valid": true
},
{
"description": "Valid - single entity",
"data": [ "singleEntity" ],
"valid": true
},
{
"description": "Valid - multiple entities",
"data": [ "_img1", "_img2", "_img3" ],
"valid": true
},
{
"description": "Valid - entities with special chars",
"data": [ "logo-main", "banner.v2", "icon_small" ],
"valid": true
},
{
"description": "Valid - many entities",
"data": [ "e1", "e2", "e3", "e4", "e5" ],
"valid": true
},
{
"description": "Valid - Unicode entities",
"data": [ "логотип", "изображение", "アイコン" ],
"valid": true
},
{
"description": "Valid - mixed script entities",
"data": [ "image", "画像", "зображення" ],
"valid": true
},
{
"description": "Valid - long list",
"data": [
"entity0",
"entity1",
"entity2",
"entity3",
"entity4",
"entity5",
"entity6",
"entity7",
"entity8",
"entity9",
"entity10",
"entity11",
"entity12",
"entity13",
"entity14",
"entity15",
"entity16",
"entity17",
"entity18",
"entity19",
"entity20",
"entity21",
"entity22",
"entity23",
"entity24",
"entity25",
"entity26",
"entity27",
"entity28",
"entity29",
"entity30",
"entity31",
"entity32",
"entity33",
"entity34",
"entity35",
"entity36",
"entity37",
"entity38",
"entity39",
"entity40",
"entity41",
"entity42",
"entity43",
"entity44",
"entity45",
"entity46",
"entity47",
"entity48",
"entity49"
],
"valid": true
},
{
"description": "Invalid: empty array",
"data": [],
"valid": false
},
{
"description": "Invalid: entity contains colon",
"data": [ "valid", "ns:entity" ],
"valid": false
},
{
"description": "Invalid: entity starts with digit",
"data": [ "valid", "5entity" ],
"valid": false
},
{
"description": "Invalid: entity contains space",
"data": [ "valid", "my entity" ],
"valid": false
},
{
"description": "Invalid: entity is empty",
"data": [ "valid", "" ],
"valid": false
},
{
"description": "Invalid: entity contains special char",
"data": [ "valid", "entity$ref" ],
"valid": false
},
{
"description": "Invalid: not an array (string)",
"data": "entity1 entity2",
"valid": false
},
{
"description": "Invalid: not an array (number)",
"data": 999,
"valid": false
},
{
"description": "Invalid: not an array (boolean)",
"data": true,
"valid": false
},
{
"description": "Invalid: not an array (null)",
"data": null,
"valid": false
},
{
"description": "Invalid: not an array (object)",
"data": {
"entities": [ "a", "b" ]
},
"valid": false
},
{
"description": "Invalid: array contains number",
"data": [ "valid", 111 ],
"valid": false
},
{
"description": "Invalid: array contains boolean",
"data": [ "valid", true ],
"valid": false
},
{
"description": "Invalid: array contains null",
"data": [ "valid", null ],
"valid": false
},
{
"description": "Invalid: array contains object",
"data": [
"valid",
{
"entity": "x"
}
],
"valid": false
},
{
"description": "Invalid: array contains array",
"data": [
"valid",
[ "nested" ]
],
"valid": false
}
]
}
108 changes: 108 additions & 0 deletions test/w3c/xmlschema/2001/entity.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"target": "../../../../schemas/w3c/xmlschema/2001/entity.json",
"tests": [
{
"description": "Valid - simple entity",
"data": "logo",
"valid": true
},
{
"description": "Valid - with underscore",
"data": "_image1",
"valid": true
},
{
"description": "Valid - CamelCase",
"data": "MyEntity",
"valid": true
},
{
"description": "Valid - with hyphen",
"data": "banner-img",
"valid": true
},
{
"description": "Valid - with period",
"data": "icon.v2",
"valid": true
},
{
"description": "Valid - with digits",
"data": "entity99",
"valid": true
},
{
"description": "Valid - single letter",
"data": "e",
"valid": true
},
{
"description": "Valid - complex entity",
"data": "unparsed_entity-ref.1",
"valid": true
},
{
"description": "Valid - Unicode",
"data": "сутність",
"valid": true
},
{
"description": "Invalid: contains colon",
"data": "ns:entity",
"valid": false
},
{
"description": "Invalid: starts with digit",
"data": "7entity",
"valid": false
},
{
"description": "Invalid: starts with hyphen",
"data": "-entity",
"valid": false
},
{
"description": "Invalid: empty string",
"data": "",
"valid": false
},
{
"description": "Invalid: contains space",
"data": "my entity",
"valid": false
},
{
"description": "Invalid: contains special char $",
"data": "entity$ref",
"valid": false
},
{
"description": "Invalid: number type",
"data": 789,
"valid": false
},
{
"description": "Invalid: boolean type",
"data": true,
"valid": false
},
{
"description": "Invalid: null type",
"data": null,
"valid": false
},
{
"description": "Invalid: array type",
"data": [ "entity" ],
"valid": false
},
{
"description": "Invalid: object type",
"data": {
"entity": "value"
},
"valid": false
}
]
}
Loading