4 #:rng-error-line-number
5 #:rng-error-column-number
54 #:name-class-choice-b
)
56 "@code{cxml-rng} implements @a[http://relaxng.org/spec-20011203.html]{
57 Relax NG} schema validation for Closure XML.
59 Support for @a[http://relaxng.org/compact-20021121.html]{Compact Syntax}
62 @begin[Example]{section}
63 @begin{pre}(cxml:parse-file \"test.xml\"
64 (cxml-rng:make-validator
65 (cxml-rng:parse-schema #p\"test.rng\")))
68 @begin[Classes]{section}
70 @aboutclass{rng-error}
72 @begin[Parsing and validating]{section}
73 @aboutfun{parse-schema}
74 @aboutfun{parse-compact}
75 @aboutfun{make-validator}
76 @aboutfun{serialize-grammar}
78 @begin[Grammar introspection]{section}
79 The following classes and function are exported so that users can
80 take a peek at the internals of the parsed and simplified grammar.
82 @aboutfun{schema-start}
83 @aboutclass{attribute}
89 @aboutclass{interleave}
90 @aboutclass{list-pattern}
91 @aboutclass{not-allowed}
92 @aboutclass{one-or-more}
97 @aboutfun{pattern-child}
100 @aboutfun{pattern-name}
101 @aboutfun{pattern-element}
102 @aboutfun{pattern-type}
103 @aboutfun{pattern-string}
104 @aboutfun{pattern-value}
105 @aboutfun{pattern-params}
106 @aboutfun{pattern-except}
109 (defpackage :cxml-types
120 #:type-context-dependent-p
126 #:sax-validation-context-mixin
127 #:klacks-validation-context
128 #:make-klacks-validation-context
129 #:context-find-namespace-binding
130 #:context-find-unparsed-entity
166 #:normalized-string-type
179 #:non-positive-integer-type
180 #:negative-integer-type
185 #:non-negative-integer-type
188 #:unsigned-short-type
190 #:positive-integer-type
)
192 "@code{cxml-types} defines an extensible interface for XML-related
193 data types as required for use in Relax NG validation.
195 It includes Relax NG's minimal built-in type library, which is named
196 @code{:||} and defines the types \"string\" and \"token\".
198 In addition, it implements the built-in types of
199 @a[http://www.w3.org/TR/xmlschema-2/]{XML Schema Datatypes}
200 as specified in @a[http://relaxng.org/xsd-20010907.html]{Guidelines for
201 using W3C XML Schema Datatypes with RELAX NG}. The XSD type library
202 is named @code{:|http://www.w3.org/2001/XMLSchema-datatypes|}.
204 @begin[Example]{section}
206 * (setf ttt (cxml-types:find-type :|| \"token\"))
207 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
208 * (cxml-types:parse ttt \"a b\")
210 * (cxml-types:parse ttt \"a b\")
212 * (cxml-types:equal-using-type ttt ** *)
216 @begin[Type instances]{section}
217 Each type, together with its parameters, is represented by an
218 instance of @code{data-type}. The generic function @fun{find-type},
219 defined for each library, creates type instances. A type's properties
220 are accessible using @fun{type-name}, @fun{type-library}, and
221 @fun{type-context-dependent-p}.
223 @aboutclass{data-type}
224 @aboutclass{rng-type}
225 @aboutclass{xsd-type}
228 @aboutfun{type-library}
229 @aboutfun{type-context-dependent-p}
231 @begin[Using types]{section}
232 Types allow strings to be tested for validity and equality.
233 @fun{validp} checks whether a string can be parsed. If it is valid,
234 @fun{parse} will compute the string's @emph{value}, and return a
235 Lisp object of a type-specific class as a representation of that value.
236 Values returned by @fun{parse} can be compared for equality using
237 @fun{equal-using-type}. Some types also define a partial ordering,
238 which can be queried using @fun{lessp-using-type}.
242 @aboutfun{equal-using-type}
243 @aboutfun{lessp-using-type}
245 @begin[The validation context]{section}
246 Some types are context dependent, as indicated by
247 @fun{type-context-dependent-p}. Those types need access to state
248 computed by the XML parser implicitly, like namespace bindings or
251 An abstract class @class{validation-context} is defined that
252 users of this API can implement a subclass of
253 to define methods for the generic functions listed below.
255 In addition, two pre-defined validation context implementations are
256 provided, one for use with SAX, the other based on Klacks.
258 @aboutclass{validation-context}
259 @aboutclass{sax-validation-context-mixin}
260 @aboutclass{klacks-validation-context}
261 @aboutfun{context-find-namespace-binding}
262 @aboutfun{context-find-unparsed-entity}
264 @begin[Primitive XSD built-in types]{section}
265 The following primitive types are part of the XSD built-in data type
268 @aboutclass{duration-type}
269 @aboutclass{date-time-type}
270 @aboutclass{time-type}
271 @aboutclass{date-type}
272 @aboutclass{year-month-type}
273 @aboutclass{year-type}
274 @aboutclass{month-day-type}
275 @aboutclass{day-type}
276 @aboutclass{month-type}
277 @aboutclass{boolean-type}
278 @aboutclass{base64-binary-type}
279 @aboutclass{hex-binary-type}
280 @aboutclass{float-type}
281 @aboutclass{decimal-type}
282 @aboutclass{double-type}
283 @aboutclass{any-uri-type}
284 @aboutclass{qname-type}
285 @aboutclass{notation-type}
286 @aboutclass{xsd-string-type}
288 @begin[Enumerated XSD built-in types]{section}
289 The following types are part of the XSD built-in data type
290 library, and are defined as derived types through enumeration.
291 Relax NG does not implement the enumeration facet, so although these
292 types are described as \"derived\", they are implemented directly.
294 @aboutclass{idrefs-type}
295 @aboutclass{entities-type}
296 @aboutclass{nmtokens-type}
298 @begin[Derived XSD built-in types]{section}
299 The following types are part of the XSD built-in data type
300 library, and are defined as derived types through restriction.
302 @aboutclass{normalized-string-type}
303 @aboutclass{xsd-token-type}
304 @aboutclass{language-type}
305 @aboutclass{name-type}
306 @aboutclass{ncname-type}
308 @aboutclass{idref-type}
309 @aboutclass{entity-type}
310 @aboutclass{nmtoken-type}
311 @aboutclass{integer-type}
312 @aboutclass{non-positive-integer-type}
313 @aboutclass{negative-integer-type}
314 @aboutclass{long-type}
315 @aboutclass{int-type}
316 @aboutclass{short-type}
317 @aboutclass{byte-type}
318 @aboutclass{non-negative-integer-type}
319 @aboutclass{unsigned-long-type}
320 @aboutclass{unsigned-int-type}
321 @aboutclass{unsigned-short-type}
322 @aboutclass{unsigned-byte-type}
323 @aboutclass{positive-integer-type}