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