4 #:dtd-compatibility-error
5 #:rng-error-line-number
6 #:rng-error-column-number
16 #:make-validating-source
56 #:name-class-choice-b
)
58 "@code{cxml-rng} implements @a[http://relaxng.org/spec-20011203.html]{
59 Relax NG} schema validation for Closure XML.
61 Support for @a[http://relaxng.org/compact-20021121.html]{Compact Syntax}
64 @begin[Example]{section}
65 @begin{pre}(cxml:parse-file \"test.xml\"
66 (cxml-rng:make-validator
67 (cxml-rng:parse-schema #p\"test.rng\")))
70 @begin[Classes]{section}
72 @aboutclass{rng-error}
73 @aboutclass{dtd-compatibility-error}
75 @begin[Parsing and validating]{section}
76 @aboutfun{parse-schema}
77 @aboutfun{parse-compact}
78 @aboutfun{make-validator}
79 @aboutfun{serialize-grammar}
81 @begin[Grammar introspection]{section}
82 The following classes and function are exported so that users can
83 take a peek at the internals of the parsed and simplified grammar.
85 @aboutfun{schema-start}
86 @aboutclass{attribute}
92 @aboutclass{interleave}
93 @aboutclass{list-pattern}
94 @aboutclass{not-allowed}
95 @aboutclass{one-or-more}
100 @aboutfun{pattern-child}
103 @aboutfun{pattern-name}
104 @aboutfun{pattern-element}
105 @aboutfun{pattern-type}
106 @aboutfun{pattern-string}
107 @aboutfun{pattern-value}
108 @aboutfun{pattern-params}
109 @aboutfun{pattern-except}
112 (defpackage :cxml-types
123 #:type-context-dependent-p
130 #:sax-validation-context-mixin
131 #:klacks-validation-context
132 #:make-klacks-validation-context
133 #:context-find-namespace-binding
134 #:context-find-unparsed-entity
139 #:dtd-compatibility-type
175 #:normalized-string-type
188 #:non-positive-integer-type
189 #:negative-integer-type
194 #:non-negative-integer-type
197 #:unsigned-short-type
199 #:positive-integer-type
)
201 "@code{cxml-types} defines an extensible interface for XML-related
202 data types as required for use in Relax NG validation.
204 It includes Relax NG's minimal built-in type library, which is named
205 @code{:||} and defines the types \"string\" and \"token\".
207 In addition, it implements the built-in types of
208 @a[http://www.w3.org/TR/xmlschema-2/]{XML Schema Datatypes}
209 as specified in @a[http://relaxng.org/xsd-20010907.html]{Guidelines for
210 using W3C XML Schema Datatypes with RELAX NG}. The XSD type library
211 is named @code{:|http://www.w3.org/2001/XMLSchema-datatypes|}.
213 The types defined by @a[http://relaxng.org/compatibility-20011203.html]{
214 RELAX NG DTD Compatibility}
215 are available through the data type library named
216 @code{:|http://relaxng.org/ns/compatibility/datatypes/1.0|}.
218 @begin[Example]{section}
220 * (setf ttt (cxml-types:find-type :|| \"token\"))
221 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
222 * (cxml-types:parse ttt \"a b\")
224 * (cxml-types:parse ttt \"a b\")
226 * (cxml-types:equal-using-type ttt ** *)
230 @begin[Type instances]{section}
231 Each type, together with its parameters, is represented by an
232 instance of @code{data-type}. The generic function @fun{find-type},
233 defined for each library, creates type instances. A type's properties
234 are accessible using @fun{type-name}, @fun{type-library}, and
235 @fun{type-context-dependent-p}.
237 @aboutclass{data-type}
238 @aboutclass{rng-type}
239 @aboutclass{xsd-type}
242 @aboutfun{type-library}
243 @aboutfun{type-context-dependent-p}
245 @begin[Using types]{section}
246 Types allow strings to be tested for validity and equality.
247 @fun{validp} checks whether a string can be parsed. If it is valid,
248 @fun{parse} will compute the string's @emph{value}, and return a
249 Lisp object of a type-specific class as a representation of that value.
250 Values returned by @fun{parse} can be compared for equality using
251 @fun{equal-using-type}. Some types also define a partial ordering,
252 which can be queried using @fun{lessp-using-type}.
256 @aboutfun{equal-using-type}
257 @aboutfun{lessp-using-type}
259 @begin[The validation context]{section}
260 Some types are context dependent, as indicated by
261 @fun{type-context-dependent-p}. Those types need access to state
262 computed by the XML parser implicitly, like namespace bindings or
265 An abstract class @class{validation-context} is defined that
266 users of this API can implement a subclass of
267 to define methods for the generic functions listed below.
269 In addition, two pre-defined validation context implementations are
270 provided, one for use with SAX, the other based on Klacks.
272 @aboutclass{validation-context}
273 @aboutclass{sax-validation-context-mixin}
274 @aboutclass{klacks-validation-context}
275 @aboutfun{context-find-namespace-binding}
276 @aboutfun{context-find-unparsed-entity}
278 @begin[Relax NG built-in types]{section}
279 The following primitive types are defined by Relax NG:
281 @aboutclass{string-type}
282 @aboutclass{token-type}
284 @begin[DTD compatibility types]{section}
285 The following primitive types are defined by Relax NG DTD
289 @aboutclass{idref-type}
290 @aboutclass{idrefs-type}
292 @begin[Primitive XSD built-in types]{section}
293 The following primitive types are part of the XSD built-in data type
296 @aboutclass{duration-type}
297 @aboutclass{date-time-type}
298 @aboutclass{time-type}
299 @aboutclass{date-type}
300 @aboutclass{year-month-type}
301 @aboutclass{year-type}
302 @aboutclass{month-day-type}
303 @aboutclass{day-type}
304 @aboutclass{month-type}
305 @aboutclass{boolean-type}
306 @aboutclass{base64-binary-type}
307 @aboutclass{hex-binary-type}
308 @aboutclass{float-type}
309 @aboutclass{decimal-type}
310 @aboutclass{double-type}
311 @aboutclass{any-uri-type}
312 @aboutclass{qname-type}
313 @aboutclass{notation-type}
314 @aboutclass{xsd-string-type}
316 @begin[Enumerated XSD built-in types]{section}
317 The following types are part of the XSD built-in data type
318 library, and are defined as derived types through enumeration.
319 Relax NG does not implement the enumeration facet, so although these
320 types are described as \"derived\", they are implemented directly.
322 @aboutclass{xsd-idrefs-type}
323 @aboutclass{entities-type}
324 @aboutclass{nmtokens-type}
326 @begin[Derived XSD built-in types]{section}
327 The following types are part of the XSD built-in data type
328 library, and are defined as derived types through restriction.
330 @aboutclass{normalized-string-type}
331 @aboutclass{xsd-token-type}
332 @aboutclass{language-type}
333 @aboutclass{name-type}
334 @aboutclass{ncname-type}
335 @aboutclass{xsd-id-type}
336 @aboutclass{xsd-idref-type}
337 @aboutclass{entity-type}
338 @aboutclass{nmtoken-type}
339 @aboutclass{integer-type}
340 @aboutclass{non-positive-integer-type}
341 @aboutclass{negative-integer-type}
342 @aboutclass{long-type}
343 @aboutclass{int-type}
344 @aboutclass{short-type}
345 @aboutclass{byte-type}
346 @aboutclass{non-negative-integer-type}
347 @aboutclass{unsigned-long-type}
348 @aboutclass{unsigned-int-type}
349 @aboutclass{unsigned-short-type}
350 @aboutclass{unsigned-byte-type}
351 @aboutclass{positive-integer-type}