Skip to content

Commit 0760a53

Browse files
committed
Finish describing all XML Schema derived data types
Signed-off-by: Juan Cruz Viotti <[email protected]>
1 parent b5d8938 commit 0760a53

File tree

18 files changed

+1290
-3
lines changed

18 files changed

+1290
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema ENTITIES",
4+
"description": "Represents a list of references to unparsed entities (§3.3.12)",
5+
"$comment": "ENTITIES is a space-separated list of ENTITY values. In JSON Schema, this is represented as an array with at least one item",
6+
"examples": [
7+
[ "entity1", "entity2" ],
8+
[ "_img1", "_img2", "_img3" ],
9+
[ "singleEntity" ],
10+
[ "logo", "banner", "icon" ]
11+
],
12+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
13+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#ENTITIES" ],
14+
"type": "array",
15+
"minItems": 1,
16+
"items": {
17+
"$ref": "entity.json"
18+
}
19+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema ENTITY",
4+
"description": "Represents references to unparsed entities declared in the DTD (§3.3.11)",
5+
"$comment": "ENTITY is syntactically an NCName. The constraint that it references a declared unparsed entity is DTD validation, not a schema concern",
6+
"examples": [ "imageEntity", "_entity1", "logo-ref", "attachment_99" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#ENTITY" ],
9+
"$ref": "ncname.json"
10+
}

schemas/w3c/xmlschema/2001/id.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema ID",
4+
"description": "Represents unique identifiers within an XML document (§3.3.8)",
5+
"$comment": "ID is syntactically an NCName. The uniqueness constraint is a validation concern, not a schema concern",
6+
"examples": [ "uniqueId", "_id123", "user-profile", "element_42" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#ID" ],
9+
"$ref": "ncname.json"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema IDREF",
4+
"description": "Represents references to ID values within an XML document (§3.3.9)",
5+
"$comment": "IDREF is syntactically an NCName. The constraint that it references an existing ID is a validation concern, not a schema concern",
6+
"examples": [ "refToId", "_ref123", "user-link", "target_42" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#IDREF" ],
9+
"$ref": "ncname.json"
10+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema IDREFS",
4+
"description": "Represents a list of references to ID values (§3.3.10)",
5+
"$comment": "IDREFS is a space-separated list of IDREF values. In JSON Schema, this is represented as an array with at least one item",
6+
"examples": [
7+
[ "ref1", "ref2" ],
8+
[ "_id1", "_id2", "_id3" ],
9+
[ "singleRef" ],
10+
[ "link-a", "link-b", "link-c" ]
11+
],
12+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
13+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#IDREFS" ],
14+
"type": "array",
15+
"minItems": 1,
16+
"items": {
17+
"$ref": "idref.json"
18+
}
19+
}

schemas/w3c/xmlschema/2001/name.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

schemas/w3c/xmlschema/2001/ncname.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

schemas/w3c/xmlschema/2001/nmtoken.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema NMTOKENS",
4+
"description": "Represents a list of XML name tokens (§3.3.4)",
5+
"$comment": "NMTOKENS is a space-separated list of NMTOKEN values. In JSON Schema, this is represented as an array with at least one item",
6+
"examples": [
7+
[ "token1", "token2" ],
8+
[ "abc", "123", "data-value" ],
9+
[ "single" ],
10+
[ "one", "two", "three", "four" ]
11+
],
12+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
13+
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#NMTOKENS" ],
14+
"type": "array",
15+
"minItems": 1,
16+
"items": {
17+
"$ref": "nmtoken.json"
18+
}
19+
}
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
{
2+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
3+
"target": "../../../../schemas/w3c/xmlschema/2001/entities.json",
4+
"tests": [
5+
{
6+
"description": "Valid - two entities",
7+
"data": [ "entity1", "entity2" ],
8+
"valid": true
9+
},
10+
{
11+
"description": "Valid - single entity",
12+
"data": [ "singleEntity" ],
13+
"valid": true
14+
},
15+
{
16+
"description": "Valid - multiple entities",
17+
"data": [ "_img1", "_img2", "_img3" ],
18+
"valid": true
19+
},
20+
{
21+
"description": "Valid - entities with special chars",
22+
"data": [ "logo-main", "banner.v2", "icon_small" ],
23+
"valid": true
24+
},
25+
{
26+
"description": "Valid - many entities",
27+
"data": [ "e1", "e2", "e3", "e4", "e5" ],
28+
"valid": true
29+
},
30+
{
31+
"description": "Valid - Unicode entities",
32+
"data": [ "логотип", "изображение", "アイコン" ],
33+
"valid": true
34+
},
35+
{
36+
"description": "Valid - mixed script entities",
37+
"data": [ "image", "画像", "зображення" ],
38+
"valid": true
39+
},
40+
{
41+
"description": "Valid - long list",
42+
"data": [
43+
"entity0",
44+
"entity1",
45+
"entity2",
46+
"entity3",
47+
"entity4",
48+
"entity5",
49+
"entity6",
50+
"entity7",
51+
"entity8",
52+
"entity9",
53+
"entity10",
54+
"entity11",
55+
"entity12",
56+
"entity13",
57+
"entity14",
58+
"entity15",
59+
"entity16",
60+
"entity17",
61+
"entity18",
62+
"entity19",
63+
"entity20",
64+
"entity21",
65+
"entity22",
66+
"entity23",
67+
"entity24",
68+
"entity25",
69+
"entity26",
70+
"entity27",
71+
"entity28",
72+
"entity29",
73+
"entity30",
74+
"entity31",
75+
"entity32",
76+
"entity33",
77+
"entity34",
78+
"entity35",
79+
"entity36",
80+
"entity37",
81+
"entity38",
82+
"entity39",
83+
"entity40",
84+
"entity41",
85+
"entity42",
86+
"entity43",
87+
"entity44",
88+
"entity45",
89+
"entity46",
90+
"entity47",
91+
"entity48",
92+
"entity49"
93+
],
94+
"valid": true
95+
},
96+
{
97+
"description": "Invalid: empty array",
98+
"data": [],
99+
"valid": false
100+
},
101+
{
102+
"description": "Invalid: entity contains colon",
103+
"data": [ "valid", "ns:entity" ],
104+
"valid": false
105+
},
106+
{
107+
"description": "Invalid: entity starts with digit",
108+
"data": [ "valid", "5entity" ],
109+
"valid": false
110+
},
111+
{
112+
"description": "Invalid: entity contains space",
113+
"data": [ "valid", "my entity" ],
114+
"valid": false
115+
},
116+
{
117+
"description": "Invalid: entity is empty",
118+
"data": [ "valid", "" ],
119+
"valid": false
120+
},
121+
{
122+
"description": "Invalid: entity contains special char",
123+
"data": [ "valid", "entity$ref" ],
124+
"valid": false
125+
},
126+
{
127+
"description": "Invalid: not an array (string)",
128+
"data": "entity1 entity2",
129+
"valid": false
130+
},
131+
{
132+
"description": "Invalid: not an array (number)",
133+
"data": 999,
134+
"valid": false
135+
},
136+
{
137+
"description": "Invalid: not an array (boolean)",
138+
"data": true,
139+
"valid": false
140+
},
141+
{
142+
"description": "Invalid: not an array (null)",
143+
"data": null,
144+
"valid": false
145+
},
146+
{
147+
"description": "Invalid: not an array (object)",
148+
"data": {
149+
"entities": [ "a", "b" ]
150+
},
151+
"valid": false
152+
},
153+
{
154+
"description": "Invalid: array contains number",
155+
"data": [ "valid", 111 ],
156+
"valid": false
157+
},
158+
{
159+
"description": "Invalid: array contains boolean",
160+
"data": [ "valid", true ],
161+
"valid": false
162+
},
163+
{
164+
"description": "Invalid: array contains null",
165+
"data": [ "valid", null ],
166+
"valid": false
167+
},
168+
{
169+
"description": "Invalid: array contains object",
170+
"data": [
171+
"valid",
172+
{
173+
"entity": "x"
174+
}
175+
],
176+
"valid": false
177+
},
178+
{
179+
"description": "Invalid: array contains array",
180+
"data": [
181+
"valid",
182+
[ "nested" ]
183+
],
184+
"valid": false
185+
}
186+
]
187+
}

0 commit comments

Comments
 (0)