typos
[cxml-rng.git] / package.lisp
blobe74fc1f89a723da2470ad4a2423fcc2ba042aa95
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{code}
64 (cxml:parse-file \"test.xml\"
65 (cxml-rng:make-validator
66 (cxml-rng:parse-schema #p\"test.rng\")))
67 @end{code}
68 @end{section}
69 @begin[Classes]{section}
70 @aboutclass{schema}
71 @aboutclass{rng-error}
72 @end{section}
73 @begin[Parsing and validating]{section}
74 @aboutfun{parse-schema}
75 @aboutfun{parse-compact}
76 @aboutfun{make-validator}
77 @aboutfun{serialize-grammar}
78 @end{section}
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}
85 @aboutclass{choice}
86 @aboutclass{data}
87 @aboutclass{element}
88 @aboutclass{empty}
89 @aboutclass{group}
90 @aboutclass{interleave}
91 @aboutclass{list-pattern}
92 @aboutclass{not-allowed}
93 @aboutclass{one-or-more}
94 @aboutclass{pattern}
95 @aboutclass{ref}
96 @aboutclass{text}
97 @aboutclass{value}
98 @aboutfun{pattern-child}
99 @aboutfun{pattern-a}
100 @aboutfun{pattern-b}
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}
108 @end{section}"))
110 (defpackage :cxml-types
111 (:use :cl)
112 (:export #:param
113 #:make-param
114 #:param-name
115 #:param-value
117 #:data-type
118 #:find-type
119 #:type-library
120 #:type-name
121 #:type-context-dependent-p
122 #:parse
123 #:equal-using-type
124 #:lessp-using-type
125 #:validp
126 #:validation-context
127 #:sax-validation-context-mixin
128 #:klacks-validation-context
129 #:make-klacks-validation-context
130 #:context-find-namespace-binding
131 #:context-find-unparsed-entity
132 #:rng-type
133 #:token-type
134 #:string-type
136 #:xsd-type
137 #:patterns
139 #:duration-type
140 #:date-time-type
141 #:time-type
142 #:date-type
143 #:year-month-type
144 #:year-type
145 #:month-day-type
146 #:day-type
147 #:month-type
148 #:boolean-type
149 #:base64-binary-type
150 #:hex-binary-type
151 #:float-type
152 #:decimal-type
153 #:double-type
154 #:any-uri-type
155 #:qname-type
156 #:notation-type
157 #:xsd-string-type
158 #:normalized-string-type
159 #:xsd-token-type
160 #:language-type
161 #:name-type
162 #:ncname-type
163 #:id-type
164 #:idref-type
165 #:idrefs-type
166 #:entity-type
167 #:entities-type
168 #:nmtoken-type
169 #:nmtokens-type
170 #:integer-type
171 #:non-positive-integer-type
172 #:negative-integer-type
173 #:long-type
174 #:int-type
175 #:short-type
176 #:bite-type
177 #:non-negative-integer-type
178 #:unsigned-long-type
179 #:unsigned-int-type
180 #:unsigned-short-type
181 #:unsigned-byte-type
182 #:positive-integer-type)
183 (:documentation
184 "@code{cxml-types} defines an extensible interface for XML-related
185 data types as required for use in Relax NG validation.
186 It includes Relax NG's minimal built-in type library, which is named
187 @code{:||} and defines the types \"string\" and \"token\".
188 In addition, it implements the built-in types of
189 @a[http://www.w3.org/TR/xmlschema-2/]{XML Schema Datatypes}
190 as specified in @a[http://relaxng.org/xsd-20010907.html]{Guidelines for
191 using W3C XML Schema Datatypes with RELAX NG}. The XSD type library
192 is named @code{:|http://www.w3.org/2001/XMLSchema-datatypes|}.
194 @begin[Example]{section}
195 @begin{pre}
196 * (setf ttt (cxml-types:find-type :|| \"token\"))
197 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
198 * (cxml-types:parse ttt \"a b\")
199 \"a b\"
200 * (cxml-types:parse ttt \"a b\")
201 \"a b\"
202 * (cxml-types:equal-using-type ttt ** *)
204 @end{pre}
205 @end{section}
206 @begin[Type instances]{section}
207 Each type, together with its parameters, is represented by an
208 instance of @code{data-type}. The generic function @fun{find-type},
209 defined for each library, creates type instances. A type's properties
210 are accessible using @fun{type-name}, @fun{type-library}, and
211 @fun{type-context-dependent-p}.
213 @aboutclass{data-type}
214 @aboutclass{rng-type}
215 @aboutclass{xsd-type}
216 @aboutfun{find-type}
217 @aboutfun{type-name}
218 @aboutfun{type-library}
219 @aboutfun{type-context-dependent-p}
220 @end{section}
221 @begin[Using types]{section}
222 Types allow strings to be tested for validity and equality.
223 @fun{validp} checks whether a string can be parsed. If it is valid,
224 @fun{parse} will compute the string's @emph{value}, and return a
225 Lisp object of a type-specific class as a representation of that value.
226 Values returned by @fun{parse} can be compared for equality using
227 @fun{equal-using-type}. Some types also define a partial ordering,
228 which can be queried using @fun{lessp-using-type}.
230 @aboutfun{validp}
231 @aboutfun{parse}
232 @aboutfun{equal-using-type}
233 @aboutfun{lessp-using-type}
234 @end{section}
235 @begin[The validation context]{section}
236 Some types are context dependent, as indicated by
237 @fun{type-context-dependent-p}. Those types need access to state
238 computed by the XML parser implicitly, like namespace bindings or
239 the Base URI.
241 An abstract class @class{validation-context} is defined that
242 users of this API can implement a subclass of
243 to define methods for the generic functions listed below.
245 In addition, two pre-defined validation context implementations are
246 provided, one for use with SAX, the other based on Klacks.
248 @aboutclass{validation-context}
249 @aboutclass{sax-validation-context-mixin}
250 @aboutclass{klacks-validation-context}
251 @aboutfun{context-find-namespace-binding}
252 @aboutfun{context-find-unparsed-entity}
253 @end{section}
254 @begin[Primitive XSD built-in types]{section}
255 The following primitive types are part of the XSD built-in data type
256 library:
258 @aboutclass{duration-type}
259 @aboutclass{date-time-type}
260 @aboutclass{time-type}
261 @aboutclass{date-type}
262 @aboutclass{year-month-type}
263 @aboutclass{year-type}
264 @aboutclass{month-day-type}
265 @aboutclass{day-type}
266 @aboutclass{month-type}
267 @aboutclass{boolean-type}
268 @aboutclass{base64-binary-type}
269 @aboutclass{hex-binary-type}
270 @aboutclass{float-type}
271 @aboutclass{decimal-type}
272 @aboutclass{double-type}
273 @aboutclass{any-uri-type}
274 @aboutclass{qname-type}
275 @aboutclass{notation-type}
276 @aboutclass{xsd-string-type}
277 @end{section}
278 @begin[Enumerated XSD built-in types]{section}
279 The following types are part of the XSD built-in data type
280 library, and are defined as derived types through enumeration.
281 Relax NG does not implement the enumeration facet, so although these
282 types are described as \"derived\", they are implemented directly.
284 @aboutclass{idrefs-type}
285 @aboutclass{entities-type}
286 @aboutclass{nmtokens-type}
287 @end{section}
288 @begin[Derived 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 restriction.
292 @aboutclass{normalized-string-type}
293 @aboutclass{xsd-token-type}
294 @aboutclass{language-type}
295 @aboutclass{name-type}
296 @aboutclass{ncname-type}
297 @aboutclass{id-type}
298 @aboutclass{idref-type}
299 @aboutclass{entity-type}
300 @aboutclass{nmtoken-type}
301 @aboutclass{integer-type}
302 @aboutclass{non-positive-integer-type}
303 @aboutclass{negative-integer-type}
304 @aboutclass{long-type}
305 @aboutclass{int-type}
306 @aboutclass{short-type}
307 @aboutclass{bite-type}
308 @aboutclass{non-negative-integer-type}
309 @aboutclass{unsigned-long-type}
310 @aboutclass{unsigned-int-type}
311 @aboutclass{unsigned-short-type}
312 @aboutclass{unsigned-byte-type}
313 @aboutclass{positive-integer-type}
314 @end{section}"))