base64 und hex
[cxml-rng.git] / package.lisp
blob43557f6823cc04d85f1c2f5be355a7240e721747
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 #:data-type
113 #:find-type
114 #:type-library
115 #:type-name
116 #:type-context-dependent-p
117 #:parse
118 #:equal-using-type
119 #:validp
120 #:validation-context
121 #:sax-validation-context-mixin
122 #:klacks-validation-context
123 #:make-klacks-validation-context
124 #:context-find-namespace-binding
125 #:rng-type
126 #:token-type
127 #:string-type
128 #:xsd-type
130 #:duration-type
131 #:date-time-type
132 #:time-type
133 #:date-type
134 #:year-month-type
135 #:year-type
136 #:month-day-type
137 #:day-type
138 #:month-type
139 #:boolean-type
140 #:base64-binary-type
141 #:hex-binary-type
142 #:float-type
143 #:decimal-type
144 #:double-type
145 #:any-uri-type
146 #:qname-type
147 #:notation-type
148 #:xsd-string-type
149 #:normalized-string-type
150 #:xsd-token-type
151 #:language-type
152 #:name-type
153 #:ncname-type
154 #:id-type
155 #:idref-type
156 #:idrefs-type
157 #:entity-type
158 #:entities-type
159 #:nmtoken-type
160 #:nmtokens-type
161 #:integer-type
162 #:non-positive-integer-type
163 #:negative-integer-type
164 #:long-type
165 #:int-type
166 #:short-type
167 #:bite-type
168 #:non-negative-integer-type
169 #:unsigned-long-type
170 #:unsigned-int-type
171 #:unsigned-short-type
172 #:unsigned-byte-type
173 #:positive-integer-type)
174 (:documentation
175 "@code{cxml-types} defines an extensible interface for XML-related
176 data types as required for use in Relax NG validation.
177 It includes Relax NG's minimal built-in type library, which is named
178 @code{:||} and defines the types \"string\" and \"token\".
179 In addition, it implements the built-in types of
180 @a[http://www.w3.org/TR/xmlschema-2/]{XML Schema Datatypes}
181 as specified in @a[http://relaxng.org/xsd-20010907.html]{Guidelines for
182 using W3C XML Schema Datatypes with RELAX NG}. The XSD type library
183 is named @code{:|http://www.w3.org/2001/XMLSchema-datatypes|}.
185 @begin[Example]{section}
186 @begin{pre}
187 * (setf ttt (cxml-types:find-type :|| \"token\"))
188 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
189 * (cxml-types:parse ttt \"a b\")
190 \"a b\"
191 * (cxml-types:parse ttt \"a b\")
192 \"a b\"
193 * (cxml-types:equal-using-type ttt ** *)
195 @end{pre}
196 @end{section}
197 @begin[Type instances]{section}
198 Each type, together with its parameters, is represented by an
199 instance of @code{data-type}. The generic function @fun{find-type},
200 defined for each library, creates type instances. A type's properties
201 are accessible using @fun{type-name}, @fun{type-library}, and
202 @fun{type-context-dependent-p}.
204 @aboutclass{data-type}
205 @aboutclass{rng-type}
206 @aboutclass{xsd-type}
207 @aboutfun{find-type}
208 @aboutfun{type-name}
209 @aboutfun{type-library}
210 @aboutfun{type-context-dependent-p}
211 @end{section}
212 @begin[Using types]{section}
213 Types allow strings to be tested for validity and equality.
214 @fun{validp} checks whether a string can be parsed. If it is valid,
215 @fun{parse} will compute the string's @emph{value}, and return a
216 Lisp object of a type-specific class as a representation of that value.
217 Values returned by @fun{parse} can be compared for equality using
218 @fun{equal-using-type}.
220 @aboutfun{validp}
221 @aboutfun{parse}
222 @aboutfun{equal-using-type}
223 @end{section}
224 @begin[The validation context]{section}
225 Some types are context dependent, as indicated by
226 @fun{type-context-dependent-p}. Those types need access to state
227 computed by the XML parser implicitly, like namespace bindings or
228 the Base URI.
230 An abstract class @class{validation-context} is defined that
231 users of this API can implement a subclass of
232 to define methods for the generic functions listed below.
234 In addition, two pre-defined validation context implementations are
235 provided, one for use with SAX, the other based on Klacks.
237 @aboutclass{validation-context}
238 @aboutclass{sax-validation-context-mixin}
239 @aboutclass{klacks-validation-context}
240 @aboutfun{context-find-namespace-binding}
241 @end{section}"))