4 #:dtd-compatibility-error
5 #:rng-error-line-number
6 #:rng-error-column-number
16 #:make-validating-source
17 #:make-dtd-compatibility-handler
57 #:name-class-choice-b
)
59 "@code{cxml-rng} implements @a[http://relaxng.org/spec-20011203.html]{
60 Relax NG} schema validation for Closure XML.
62 Support for @a[http://relaxng.org/compact-20021121.html]{Compact Syntax}
63 and @a[http://relaxng.org/compatibility-20011203.html]{DTD Compatibility}
66 @begin[Example]{section}
67 @begin{pre}(cxml:parse-file \"test.xml\"
68 (cxml-rng:make-validator
69 (cxml-rng:parse-schema #p\"test.rng\")))
72 @begin[Classes]{section}
74 @aboutclass{rng-error}
75 @aboutclass{dtd-compatibility-error}
77 @begin[Parsing and validating]{section}
78 @aboutfun{parse-schema}
79 @aboutfun{parse-compact}
80 @aboutfun{make-validator}
81 @aboutfun{make-dtd-compatibility-handler}
82 @aboutfun{serialize-grammar}
84 @begin[Grammar introspection]{section}
85 The following classes and function are exported so that users can
86 take a peek at the internals of the parsed and simplified grammar.
88 @aboutfun{schema-start}
89 @aboutclass{attribute}
95 @aboutclass{interleave}
96 @aboutclass{list-pattern}
97 @aboutclass{not-allowed}
98 @aboutclass{one-or-more}
103 @aboutfun{pattern-child}
106 @aboutfun{pattern-name}
107 @aboutfun{pattern-element}
108 @aboutfun{pattern-type}
109 @aboutfun{pattern-string}
110 @aboutfun{pattern-value}
111 @aboutfun{pattern-params}
112 @aboutfun{pattern-except}
115 (defpackage :cxml-types
126 #:type-context-dependent-p
133 #:sax-validation-context-mixin
134 #:klacks-validation-context
135 #:make-klacks-validation-context
136 #:context-find-namespace-binding
137 #:context-find-unparsed-entity
142 #:dtd-compatibility-type
178 #:normalized-string-type
191 #:non-positive-integer-type
192 #:negative-integer-type
197 #:non-negative-integer-type
200 #:unsigned-short-type
202 #:positive-integer-type
)
204 "@code{cxml-types} defines an extensible interface for XML-related
205 data types as required for use in Relax NG validation.
207 It includes Relax NG's minimal built-in type library, which is named
208 @code{:||} and defines the types \"string\" and \"token\".
210 In addition, it implements the built-in types of
211 @a[http://www.w3.org/TR/xmlschema-2/]{XML Schema Datatypes}
212 as specified in @a[http://relaxng.org/xsd-20010907.html]{Guidelines for
213 using W3C XML Schema Datatypes with RELAX NG}. The XSD type library
214 is named @code{:|http://www.w3.org/2001/XMLSchema-datatypes|}.
216 The types defined by @a[http://relaxng.org/compatibility-20011203.html]{
217 RELAX NG DTD Compatibility}
218 are available through the data type library named
219 @code{:|http://relaxng.org/ns/compatibility/datatypes/1.0|}.
221 @begin[Example]{section}
223 * (setf ttt (cxml-types:find-type :|| \"token\"))
224 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
225 * (cxml-types:parse ttt \"a b\")
227 * (cxml-types:parse ttt \"a b\")
229 * (cxml-types:equal-using-type ttt ** *)
233 @begin[Type instances]{section}
234 Each type, together with its parameters, is represented by an
235 instance of @code{data-type}. The generic function @fun{find-type},
236 defined for each library, creates type instances. A type's properties
237 are accessible using @fun{type-name}, @fun{type-library}, and
238 @fun{type-context-dependent-p}.
240 @aboutclass{data-type}
241 @aboutclass{rng-type}
242 @aboutclass{xsd-type}
245 @aboutfun{type-library}
246 @aboutfun{type-context-dependent-p}
248 @begin[Using types]{section}
249 Types allow strings to be tested for validity and equality.
250 @fun{validp} checks whether a string can be parsed. If it is valid,
251 @fun{parse} will compute the string's @emph{value}, and return a
252 Lisp object of a type-specific class as a representation of that value.
253 Values returned by @fun{parse} can be compared for equality using
254 @fun{equal-using-type}. Some types also define a partial ordering,
255 which can be queried using @fun{lessp-using-type}.
259 @aboutfun{equal-using-type}
260 @aboutfun{lessp-using-type}
262 @begin[The validation context]{section}
263 Some types are context dependent, as indicated by
264 @fun{type-context-dependent-p}. Those types need access to state
265 computed by the XML parser implicitly, like namespace bindings or
268 An abstract class @class{validation-context} is defined that
269 users of this API can implement a subclass of
270 to define methods for the generic functions listed below.
272 In addition, two pre-defined validation context implementations are
273 provided, one for use with SAX, the other based on Klacks.
275 @aboutclass{validation-context}
276 @aboutclass{sax-validation-context-mixin}
277 @aboutclass{klacks-validation-context}
278 @aboutfun{context-find-namespace-binding}
279 @aboutfun{context-find-unparsed-entity}
281 @begin[Relax NG built-in types]{section}
282 The following primitive types are defined by Relax NG:
284 @aboutclass{string-type}
285 @aboutclass{token-type}
287 @begin[DTD compatibility types]{section}
288 The following primitive types are defined by Relax NG DTD
292 @aboutclass{idref-type}
293 @aboutclass{idrefs-type}
295 @begin[Primitive XSD built-in types]{section}
296 The following primitive types are part of the XSD built-in data type
299 @aboutclass{duration-type}
300 @aboutclass{date-time-type}
301 @aboutclass{time-type}
302 @aboutclass{date-type}
303 @aboutclass{year-month-type}
304 @aboutclass{year-type}
305 @aboutclass{month-day-type}
306 @aboutclass{day-type}
307 @aboutclass{month-type}
308 @aboutclass{boolean-type}
309 @aboutclass{base64-binary-type}
310 @aboutclass{hex-binary-type}
311 @aboutclass{float-type}
312 @aboutclass{decimal-type}
313 @aboutclass{double-type}
314 @aboutclass{any-uri-type}
315 @aboutclass{qname-type}
316 @aboutclass{notation-type}
317 @aboutclass{xsd-string-type}
319 @begin[Enumerated XSD built-in types]{section}
320 The following types are part of the XSD built-in data type
321 library, and are defined as derived types through enumeration.
322 Relax NG does not implement the enumeration facet, so although these
323 types are described as \"derived\", they are implemented directly.
325 @aboutclass{xsd-idrefs-type}
326 @aboutclass{entities-type}
327 @aboutclass{nmtokens-type}
329 @begin[Derived XSD built-in types]{section}
330 The following types are part of the XSD built-in data type
331 library, and are defined as derived types through restriction.
333 @aboutclass{normalized-string-type}
334 @aboutclass{xsd-token-type}
335 @aboutclass{language-type}
336 @aboutclass{name-type}
337 @aboutclass{ncname-type}
338 @aboutclass{xsd-id-type}
339 @aboutclass{xsd-idref-type}
340 @aboutclass{entity-type}
341 @aboutclass{nmtoken-type}
342 @aboutclass{integer-type}
343 @aboutclass{non-positive-integer-type}
344 @aboutclass{negative-integer-type}
345 @aboutclass{long-type}
346 @aboutclass{int-type}
347 @aboutclass{short-type}
348 @aboutclass{byte-type}
349 @aboutclass{non-negative-integer-type}
350 @aboutclass{unsigned-long-type}
351 @aboutclass{unsigned-int-type}
352 @aboutclass{unsigned-short-type}
353 @aboutclass{unsigned-byte-type}
354 @aboutclass{positive-integer-type}