Skip to content

Commit c817f14

Browse files
authored
Finish implementing all XML Schema simple data types (#44)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 481f2da commit c817f14

2 files changed

Lines changed: 161 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "W3C XML Schema NOTATION",
4+
"description": "Represents the NOTATION attribute type from XML 1.0 (§3.2.16). The value space of NOTATION is the set of QNames of notations declared in the current schema. The lexical space consists of QName strings that reference notation declarations. Note that the semantic constraint requiring the QName to reference an actual notation declaration in the schema cannot be validated in isolation by this schema",
5+
"examples": [ "jpeg", "png", "gif", "svg", "mime:image-jpeg", "format:pdf" ],
6+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
7+
"x-links": [
8+
"https://www.w3.org/TR/xmlschema-2/#NOTATION",
9+
"https://www.w3.org/TR/2000/REC-xml-20001006#NT-NotationType"
10+
],
11+
"$ref": "qname.json"
12+
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
3+
"target": "../../../../schemas/w3c/xmlschema/2001/notation.json",
4+
"tests": [
5+
{
6+
"description": "Valid - simple unprefixed notation name",
7+
"data": "jpeg",
8+
"valid": true
9+
},
10+
{
11+
"description": "Valid - unprefixed notation name",
12+
"data": "png",
13+
"valid": true
14+
},
15+
{
16+
"description": "Valid - unprefixed with hyphen",
17+
"data": "image-jpeg",
18+
"valid": true
19+
},
20+
{
21+
"description": "Valid - unprefixed with dot",
22+
"data": "text.plain",
23+
"valid": true
24+
},
25+
{
26+
"description": "Valid - unprefixed with underscore",
27+
"data": "video_mpeg",
28+
"valid": true
29+
},
30+
{
31+
"description": "Valid - prefixed notation name",
32+
"data": "mime:image-jpeg",
33+
"valid": true
34+
},
35+
{
36+
"description": "Valid - prefixed with namespace",
37+
"data": "format:pdf",
38+
"valid": true
39+
},
40+
{
41+
"description": "Valid - prefixed with uppercase",
42+
"data": "MIME:JPEG",
43+
"valid": true
44+
},
45+
{
46+
"description": "Valid - prefixed complex name",
47+
"data": "media.type:application-xml",
48+
"valid": true
49+
},
50+
{
51+
"description": "Valid - single character",
52+
"data": "x",
53+
"valid": true
54+
},
55+
{
56+
"description": "Valid - Unicode notation name",
57+
"data": "图像",
58+
"valid": true
59+
},
60+
{
61+
"description": "Valid - prefixed Unicode",
62+
"data": "类型:图像",
63+
"valid": true
64+
},
65+
{
66+
"description": "Invalid: empty string",
67+
"data": "",
68+
"valid": false
69+
},
70+
{
71+
"description": "Invalid: starts with digit",
72+
"data": "123format",
73+
"valid": false
74+
},
75+
{
76+
"description": "Invalid: starts with hyphen",
77+
"data": "-format",
78+
"valid": false
79+
},
80+
{
81+
"description": "Invalid: contains space",
82+
"data": "image jpeg",
83+
"valid": false
84+
},
85+
{
86+
"description": "Invalid: contains tab",
87+
"data": "image\tjpeg",
88+
"valid": false
89+
},
90+
{
91+
"description": "Invalid: multiple colons",
92+
"data": "mime:type:jpeg",
93+
"valid": false
94+
},
95+
{
96+
"description": "Invalid: colon at start",
97+
"data": ":jpeg",
98+
"valid": false
99+
},
100+
{
101+
"description": "Invalid: colon at end",
102+
"data": "jpeg:",
103+
"valid": false
104+
},
105+
{
106+
"description": "Invalid: contains special character",
107+
"data": "image@jpeg",
108+
"valid": false
109+
},
110+
{
111+
"description": "Invalid: prefix starts with digit",
112+
"data": "123mime:jpeg",
113+
"valid": false
114+
},
115+
{
116+
"description": "Invalid: local part starts with digit",
117+
"data": "mime:123jpeg",
118+
"valid": false
119+
},
120+
{
121+
"description": "Type validation: not a string (number)",
122+
"data": 123,
123+
"valid": false
124+
},
125+
{
126+
"description": "Type validation: not a string (boolean)",
127+
"data": true,
128+
"valid": false
129+
},
130+
{
131+
"description": "Type validation: not a string (null)",
132+
"data": null,
133+
"valid": false
134+
},
135+
{
136+
"description": "Type validation: not a string (array)",
137+
"data": [ "mime", "jpeg" ],
138+
"valid": false
139+
},
140+
{
141+
"description": "Type validation: not a string (object)",
142+
"data": {
143+
"prefix": "mime",
144+
"localPart": "jpeg"
145+
},
146+
"valid": false
147+
}
148+
]
149+
}

0 commit comments

Comments
 (0)