dtd-tests korrigiert
[cxml-rng.git] / package.lisp
blob0645aa56d0ac79d880e987e8b7e9c32113cde336
1 (defpackage :cxml-rng
2 (:use :cl)
3 (:export #:rng-error
4 #:rng-error-line-number
5 #:rng-error-column-number
6 #:rng-error-system-id
8 #:schema
9 #:schema-start
11 #:parse-schema
12 #:parse-compact
13 #:serialize-schema
14 #:make-validator
15 #:make-validating-source
17 #:pattern
18 #:element
19 #:attribute
20 #:group
21 #:interleave
22 #:choice
23 #:one-or-more
24 #:ref
25 #:empty
26 #:text
27 #:value
28 #:data
29 #:not-allowed
30 #:list-pattern
32 #:pattern-a
33 #:pattern-b
34 #:pattern-child
35 #:pattern-element
36 #:pattern-except
37 #:pattern-name
38 #:pattern-params
39 #:pattern-string
40 #:pattern-type
41 #:pattern-value
43 #:name-class
44 #:any-name
45 #:name
46 #:ns-name
47 #:name-class-choice
49 #:any-name-except
50 #:name-uri
51 #:name-lname
52 #:ns-name-uri
53 #:ns-name-except
54 #:name-class-choice-a
55 #:name-class-choice-b)
56 (:documentation
57 "@code{cxml-rng} implements @a[http://relaxng.org/spec-20011203.html]{
58 Relax NG} schema validation for Closure XML.
60 Support for @a[http://relaxng.org/compact-20021121.html]{Compact Syntax}
61 is included.
63 @begin[Example]{section}
64 @begin{pre}(cxml:parse-file \"test.xml\"
65 (cxml-rng:make-validator
66 (cxml-rng:parse-schema #p\"test.rng\")))
67 @end{pre}
68 @end{section}
69 @begin[Classes]{section}
70 @aboutclass{schema}
71 @aboutclass{rng-error}
72 @end{section}
73 @begin[Parsing and validating]{section}
74 @aboutfun{parse-schema}
75 @aboutfun{parse-compact}
76 @aboutfun{make-validator}
77 @aboutfun{serialize-grammar}
78 @end{section}
79 @begin[Grammar introspection]{section}
80 The following classes and function are exported so that users can
81 take a peek at the internals of the parsed and simplified grammar.
83 @aboutfun{schema-start}
84 @aboutclass{attribute}
85 @aboutclass{choice}
86 @aboutclass{data}
87 @aboutclass{element}
88 @aboutclass{empty}
89 @aboutclass{group}
90 @aboutclass{interleave}
91 @aboutclass{list-pattern}
92 @aboutclass{not-allowed}
93 @aboutclass{one-or-more}
94 @aboutclass{pattern}
95 @aboutclass{ref}
96 @aboutclass{text}
97 @aboutclass{value}
98 @aboutfun{pattern-child}
99 @aboutfun{pattern-a}
100 @aboutfun{pattern-b}
101 @aboutfun{pattern-name}
102 @aboutfun{pattern-element}
103 @aboutfun{pattern-type}
104 @aboutfun{pattern-string}
105 @aboutfun{pattern-value}
106 @aboutfun{pattern-params}
107 @aboutfun{pattern-except}
108 @end{section}"))
110 (defpackage :cxml-types
111 (:use :cl)
112 (:export #:param
113 #:make-param
114 #:param-name
115 #:param-value
117 #:data-type
118 #:find-type
119 #:type-library
120 #:type-name
121 #:type-context-dependent-p
122 #:parse
123 #:equal-using-type
124 #:lessp-using-type
125 #:validp
126 #:validation-context
127 #:sax-validation-context-mixin
128 #:klacks-validation-context
129 #:make-klacks-validation-context
130 #:context-find-namespace-binding
131 #:context-find-unparsed-entity
132 #:rng-type
133 #:token-type
134 #:string-type
136 #:xsd-type
137 #:patterns
138 #:min-exclusive
139 #:max-exclusive
140 #:min-inclusive
141 #:max-inclusive
142 #:min-length
143 #:max-length
144 #:exact-length
145 #:fraction-digits
146 #:total-digits
148 #:duration-type
149 #:date-time-type
150 #:time-type
151 #:date-type
152 #:year-month-type
153 #:year-type
154 #:month-day-type
155 #:day-type
156 #:month-type
157 #:boolean-type
158 #:base64-binary-type
159 #:hex-binary-type
160 #:float-type
161 #:decimal-type
162 #:double-type
163 #:any-uri-type
164 #:qname-type
165 #:notation-type
166 #:xsd-string-type
167 #:normalized-string-type
168 #:xsd-token-type
169 #:language-type
170 #:name-type
171 #:ncname-type
172 #:id-type
173 #:idref-type
174 #:idrefs-type
175 #:entity-type
176 #:entities-type
177 #:nmtoken-type
178 #:nmtokens-type
179 #:integer-type
180 #:non-positive-integer-type
181 #:negative-integer-type
182 #:long-type
183 #:int-type
184 #:short-type
185 #:byte-type
186 #:non-negative-integer-type
187 #:unsigned-long-type
188 #:unsigned-int-type
189 #:unsigned-short-type
190 #:unsigned-byte-type
191 #:positive-integer-type)
192 (:documentation
193 "@code{cxml-types} defines an extensible interface for XML-related
194 data types as required for use in Relax NG validation.
196 It includes Relax NG's minimal built-in type library, which is named
197 @code{:||} and defines the types \"string\" and \"token\".
199 In addition, it implements the built-in types of
200 @a[http://www.w3.org/TR/xmlschema-2/]{XML Schema Datatypes}
201 as specified in @a[http://relaxng.org/xsd-20010907.html]{Guidelines for
202 using W3C XML Schema Datatypes with RELAX NG}. The XSD type library
203 is named @code{:|http://www.w3.org/2001/XMLSchema-datatypes|}.
205 @begin[Example]{section}
206 @begin{pre}
207 * (setf ttt (cxml-types:find-type :|| \"token\"))
208 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
209 * (cxml-types:parse ttt \"a b\")
210 \"a b\"
211 * (cxml-types:parse ttt \"a b\")
212 \"a b\"
213 * (cxml-types:equal-using-type ttt ** *)
215 @end{pre}
216 @end{section}
217 @begin[Type instances]{section}
218 Each type, together with its parameters, is represented by an
219 instance of @code{data-type}. The generic function @fun{find-type},
220 defined for each library, creates type instances. A type's properties
221 are accessible using @fun{type-name}, @fun{type-library}, and
222 @fun{type-context-dependent-p}.
224 @aboutclass{data-type}
225 @aboutclass{rng-type}
226 @aboutclass{xsd-type}
227 @aboutfun{find-type}
228 @aboutfun{type-name}
229 @aboutfun{type-library}
230 @aboutfun{type-context-dependent-p}
231 @end{section}
232 @begin[Using types]{section}
233 Types allow strings to be tested for validity and equality.
234 @fun{validp} checks whether a string can be parsed. If it is valid,
235 @fun{parse} will compute the string's @emph{value}, and return a
236 Lisp object of a type-specific class as a representation of that value.
237 Values returned by @fun{parse} can be compared for equality using
238 @fun{equal-using-type}. Some types also define a partial ordering,
239 which can be queried using @fun{lessp-using-type}.
241 @aboutfun{validp}
242 @aboutfun{parse}
243 @aboutfun{equal-using-type}
244 @aboutfun{lessp-using-type}
245 @end{section}
246 @begin[The validation context]{section}
247 Some types are context dependent, as indicated by
248 @fun{type-context-dependent-p}. Those types need access to state
249 computed by the XML parser implicitly, like namespace bindings or
250 the Base URI.
252 An abstract class @class{validation-context} is defined that
253 users of this API can implement a subclass of
254 to define methods for the generic functions listed below.
256 In addition, two pre-defined validation context implementations are
257 provided, one for use with SAX, the other based on Klacks.
259 @aboutclass{validation-context}
260 @aboutclass{sax-validation-context-mixin}
261 @aboutclass{klacks-validation-context}
262 @aboutfun{context-find-namespace-binding}
263 @aboutfun{context-find-unparsed-entity}
264 @end{section}
265 @begin[Primitive XSD built-in types]{section}
266 The following primitive types are part of the XSD built-in data type
267 library:
269 @aboutclass{duration-type}
270 @aboutclass{date-time-type}
271 @aboutclass{time-type}
272 @aboutclass{date-type}
273 @aboutclass{year-month-type}
274 @aboutclass{year-type}
275 @aboutclass{month-day-type}
276 @aboutclass{day-type}
277 @aboutclass{month-type}
278 @aboutclass{boolean-type}
279 @aboutclass{base64-binary-type}
280 @aboutclass{hex-binary-type}
281 @aboutclass{float-type}
282 @aboutclass{decimal-type}
283 @aboutclass{double-type}
284 @aboutclass{any-uri-type}
285 @aboutclass{qname-type}
286 @aboutclass{notation-type}
287 @aboutclass{xsd-string-type}
288 @end{section}
289 @begin[Enumerated XSD built-in types]{section}
290 The following types are part of the XSD built-in data type
291 library, and are defined as derived types through enumeration.
292 Relax NG does not implement the enumeration facet, so although these
293 types are described as \"derived\", they are implemented directly.
295 @aboutclass{idrefs-type}
296 @aboutclass{entities-type}
297 @aboutclass{nmtokens-type}
298 @end{section}
299 @begin[Derived XSD built-in types]{section}
300 The following types are part of the XSD built-in data type
301 library, and are defined as derived types through restriction.
303 @aboutclass{normalized-string-type}
304 @aboutclass{xsd-token-type}
305 @aboutclass{language-type}
306 @aboutclass{name-type}
307 @aboutclass{ncname-type}
308 @aboutclass{id-type}
309 @aboutclass{idref-type}
310 @aboutclass{entity-type}
311 @aboutclass{nmtoken-type}
312 @aboutclass{integer-type}
313 @aboutclass{non-positive-integer-type}
314 @aboutclass{negative-integer-type}
315 @aboutclass{long-type}
316 @aboutclass{int-type}
317 @aboutclass{short-type}
318 @aboutclass{byte-type}
319 @aboutclass{non-negative-integer-type}
320 @aboutclass{unsigned-long-type}
321 @aboutclass{unsigned-int-type}
322 @aboutclass{unsigned-short-type}
323 @aboutclass{unsigned-byte-type}
324 @aboutclass{positive-integer-type}
325 @end{section}"))