4 #:rng-error-line-number
5 #:rng-error-column-number
15 #:make-validating-source
55 #:name-class-choice-b
)
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}
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\")))
69 @begin[Classes]{section}
71 @aboutclass{rng-error}
73 @begin[Parsing and validating]{section}
74 @aboutfun{parse-schema}
75 @aboutfun{parse-compact}
76 @aboutfun{make-validator}
77 @aboutfun{serialize-grammar}
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}
90 @aboutclass{interleave}
91 @aboutclass{list-pattern}
92 @aboutclass{not-allowed}
93 @aboutclass{one-or-more}
98 @aboutfun{pattern-child}
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}
110 (defpackage :cxml-types
121 #:type-context-dependent-p
127 #:sax-validation-context-mixin
128 #:klacks-validation-context
129 #:make-klacks-validation-context
130 #:context-find-namespace-binding
131 #:context-find-unparsed-entity
167 #:normalized-string-type
180 #:non-positive-integer-type
181 #:negative-integer-type
186 #:non-negative-integer-type
189 #:unsigned-short-type
191 #:positive-integer-type
)
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}
207 * (setf ttt (cxml-types:find-type :|| \"token\"))
208 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
209 * (cxml-types:parse ttt \"a b\")
211 * (cxml-types:parse ttt \"a b\")
213 * (cxml-types:equal-using-type ttt ** *)
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}
229 @aboutfun{type-library}
230 @aboutfun{type-context-dependent-p}
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}.
243 @aboutfun{equal-using-type}
244 @aboutfun{lessp-using-type}
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
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}
265 @begin[Primitive XSD built-in types]{section}
266 The following primitive types are part of the XSD built-in data type
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}
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}
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}
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}