doc raus
[cxml-rng.git] / package.lisp
blobbdebe1d7f0d52543b9af1782d90891308d11ac2c
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
16 #:pattern
17 #:element
18 #:attribute
19 #:group
20 #:interleave
21 #:choice
22 #:one-or-more
23 #:ref
24 #:empty
25 #:text
26 #:value
27 #:data
28 #:not-allowed
29 #:list-pattern
31 #:pattern-a
32 #:pattern-b
33 #:pattern-child
34 #:pattern-element
35 #:pattern-except
36 #:pattern-name
37 #:pattern-params
38 #:pattern-string
39 #:pattern-type
40 #:pattern-value
42 #:name-class
43 #:any-name
44 #:name
45 #:ns-name
46 #:name-class-choice
48 #:any-name-except
49 #:name-uri
50 #:name-lname
51 #:ns-name-uri
52 #:ns-name-except
53 #:name-class-choice-a
54 #:name-class-choice-b)
55 (:documentation
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}
60 is included.
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\")))
66 @end{pre}
67 @end{section}
68 @begin[Classes]{section}
69 @aboutclass{schema}
70 @aboutclass{rng-error}
71 @end{section}
72 @begin[Parsing and validating]{section}
73 @aboutfun{parse-schema}
74 @aboutfun{parse-compact}
75 @aboutfun{make-validator}
76 @aboutfun{serialize-grammar}
77 @end{section}
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}
84 @aboutclass{choice}
85 @aboutclass{data}
86 @aboutclass{element}
87 @aboutclass{empty}
88 @aboutclass{group}
89 @aboutclass{interleave}
90 @aboutclass{list-pattern}
91 @aboutclass{not-allowed}
92 @aboutclass{one-or-more}
93 @aboutclass{pattern}
94 @aboutclass{ref}
95 @aboutclass{text}
96 @aboutclass{value}
97 @aboutfun{pattern-child}
98 @aboutfun{pattern-a}
99 @aboutfun{pattern-b}
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}
107 @end{section}"))
109 (defpackage :cxml-types
110 (:use :cl)
111 (:export #:param
112 #:make-param
113 #:param-name
114 #:param-value
116 #:data-type
117 #:find-type
118 #:type-library
119 #:type-name
120 #:type-context-dependent-p
121 #:parse
122 #:equal-using-type
123 #:lessp-using-type
124 #:validp
125 #:validation-context
126 #:sax-validation-context-mixin
127 #:klacks-validation-context
128 #:make-klacks-validation-context
129 #:context-find-namespace-binding
130 #:context-find-unparsed-entity
131 #:rng-type
132 #:token-type
133 #:string-type
135 #:xsd-type
136 #:patterns
137 #:min-exclusive
138 #:max-exclusive
139 #:min-inclusive
140 #:max-inclusive
141 #:min-length
142 #:max-length
143 #:exact-length
144 #:fraction-digits
145 #:total-digits
147 #:duration-type
148 #:date-time-type
149 #:time-type
150 #:date-type
151 #:year-month-type
152 #:year-type
153 #:month-day-type
154 #:day-type
155 #:month-type
156 #:boolean-type
157 #:base64-binary-type
158 #:hex-binary-type
159 #:float-type
160 #:decimal-type
161 #:double-type
162 #:any-uri-type
163 #:qname-type
164 #:notation-type
165 #:xsd-string-type
166 #:normalized-string-type
167 #:xsd-token-type
168 #:language-type
169 #:name-type
170 #:ncname-type
171 #:id-type
172 #:idref-type
173 #:idrefs-type
174 #:entity-type
175 #:entities-type
176 #:nmtoken-type
177 #:nmtokens-type
178 #:integer-type
179 #:non-positive-integer-type
180 #:negative-integer-type
181 #:long-type
182 #:int-type
183 #:short-type
184 #:byte-type
185 #:non-negative-integer-type
186 #:unsigned-long-type
187 #:unsigned-int-type
188 #:unsigned-short-type
189 #:unsigned-byte-type
190 #:positive-integer-type)
191 (:documentation
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}
205 @begin{pre}
206 * (setf ttt (cxml-types:find-type :|| \"token\"))
207 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
208 * (cxml-types:parse ttt \"a b\")
209 \"a b\"
210 * (cxml-types:parse ttt \"a b\")
211 \"a b\"
212 * (cxml-types:equal-using-type ttt ** *)
214 @end{pre}
215 @end{section}
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}
226 @aboutfun{find-type}
227 @aboutfun{type-name}
228 @aboutfun{type-library}
229 @aboutfun{type-context-dependent-p}
230 @end{section}
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}.
240 @aboutfun{validp}
241 @aboutfun{parse}
242 @aboutfun{equal-using-type}
243 @aboutfun{lessp-using-type}
244 @end{section}
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
249 the Base URI.
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}
263 @end{section}
264 @begin[Primitive XSD built-in types]{section}
265 The following primitive types are part of the XSD built-in data type
266 library:
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}
287 @end{section}
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}
297 @end{section}
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}
307 @aboutclass{id-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}
324 @end{section}"))