dokumentation fertig
[cxml-rng.git] / package.lisp
blobd6c401679cef677c423b006cc690bf11ffb08867
1 (defpackage :cxml-rng
2 (:use :cl)
3 (:export #:rng-error
5 #:schema
6 #:schema-start
8 #:parse-schema
9 #:serialize-schema
10 #:make-validator
12 #:pattern
13 #:element
14 #:attribute
15 #:group
16 #:interleave
17 #:choice
18 #:one-or-more
19 #:ref
20 #:empty
21 #:text
22 #:value
23 #:data
24 #:not-allowed
25 #:list-pattern
27 #:pattern-a
28 #:pattern-b
29 #:pattern-child
30 #:pattern-element
31 #:pattern-except
32 #:pattern-name
33 #:pattern-params
34 #:pattern-string
35 #:pattern-type
36 #:pattern-value
38 #:name-class
39 #:any-name
40 #:name
41 #:ns-name
42 #:name-class-choice
44 #:any-name-except
45 #:name-uri
46 #:name-lname
47 #:ns-name-uri
48 #:ns-name-except
49 #:name-class-choice-a
50 #:name-class-choice-b)
51 (:documentation
52 "@code{cxml-rng} implements @a[http://relaxng.org/spec-20011203.html]{
53 Relax NG} schema validation for Closure XML.
55 @begin[Example]{section}
56 @begin{code}
57 (cxml:parse-file \"test.xml\"
58 (cxml-rng:make-validator
59 (cxml-rng:parse-schema #p\"test.rng\")))
60 @end{code}
61 @end{section}
62 @begin[Classes]{section}
63 @aboutclass{schema}
64 @aboutclass{rng-error}
65 @end{section}
66 @begin[Parsing and validating]{section}
67 @aboutfun{parse-schema}
68 @aboutfun{make-validator}
69 @aboutfun{serialize-grammar}
70 @end{section}
71 @begin[Grammar introspection]{section}
72 The following classes and function are exported so that users can
73 take a peek at the internals of the parsed and simplified grammar.
75 @aboutfun{schema-start}
76 @aboutclass{attribute}
77 @aboutclass{choice}
78 @aboutclass{data}
79 @aboutclass{element}
80 @aboutclass{empty}
81 @aboutclass{group}
82 @aboutclass{interleave}
83 @aboutclass{list-pattern}
84 @aboutclass{not-allowed}
85 @aboutclass{one-or-more}
86 @aboutclass{pattern}
87 @aboutclass{ref}
88 @aboutclass{text}
89 @aboutclass{value}
90 @aboutfun{pattern-child}
91 @aboutfun{pattern-a}
92 @aboutfun{pattern-b}
93 @aboutfun{pattern-name}
94 @aboutfun{pattern-element}
95 @aboutfun{pattern-type}
96 @aboutfun{pattern-string}
97 @aboutfun{pattern-value}
98 @aboutfun{pattern-params}
99 @aboutfun{pattern-except}
100 @end{section}"))
102 (defpackage :cxml-types
103 (:use :cl)
104 (:export #:data-type
105 #:find-type
106 #:type-library
107 #:type-name
108 #:type-context-dependent-p
109 #:parse
110 #:equal-using-type
111 #:validp
112 #:validation-context
113 #:sax-validation-context-mixin
114 #:klacks-validation-context
115 #:make-klacks-validation-context
116 #:context-find-namespace-binding
117 #:rng-type
118 #:token-type
119 #:string-type
120 #:xsd-type)
121 (:documentation
122 "@code{cxml-types} defines an extensible interface for XML-related
123 data types as required for use in Relax NG validation.
124 It includes Relax NG's minimal built-in type library, which is named
125 @code{:||} and defines the types \"string\" and \"token\".
126 In addition, it implements the built-in types of
127 @a[http://www.w3.org/TR/xmlschema-2/]{XML Schema Datatypes}
128 as specified in @a[http://relaxng.org/xsd-20010907.html]{Guidelines for
129 using W3C XML Schema Datatypes with RELAX NG}. The XSD type library
130 is named @code{:|http://www.w3.org/2001/XMLSchema-datatypes|}.
132 @begin[Example]{section}
133 @begin{pre}
134 * (setf ttt (cxml-types:find-type :|| \"token\"))
135 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
136 * (cxml-types:parse ttt \"a b\")
137 \"a b\"
138 * (cxml-types:parse ttt \"a b\")
139 \"a b\"
140 * (cxml-types:equal-using-type ttt ** *)
142 @end{pre}
143 @end{section}
144 @begin[Type instances]{section}
145 Each type, together with its parameters, is represented by an
146 instance of @code{data-type}. The generic function @fun{find-type},
147 defined for each library, creates type instances. A type's properties
148 are accessible using @fun{type-name}, @fun{type-library}, and
149 @fun{type-context-dependent-p}.
151 @aboutclass{data-type}
152 @aboutclass{rng-type}
153 @aboutclass{xsd-type}
154 @aboutfun{find-type}
155 @aboutfun{type-name}
156 @aboutfun{type-library}
157 @aboutfun{type-context-dependent-p}
158 @end{section}
159 @begin[Using types]{section}
160 Types allow strings to be tested for validity and equality.
161 @fun{validp} checks whether a string can be parsed. If it is valid,
162 @fun{parse} will compute the string's @emph{value}, and return a
163 Lisp object of a type-specific class as a representation of that value.
164 Values returned by @fun{parse} can be compared for equality using
165 @fun{equal-using-type}.
167 @aboutfun{validp}
168 @aboutfun{parse}
169 @aboutfun{equal-using-type}
170 @end{section}
171 @begin[The validation context]{section}
172 Some types are context dependent, as indicated by
173 @fun{type-context-dependent-p}. Those types need access to state
174 computed by the XML parser implicitly, like namespace bindings or
175 the Base URI.
177 An abstract class @class{validation-context} is defined that
178 users of this API can implement a subclass of
179 to define methods for the generic functions listed below.
181 In addition, two pre-defined validation context implementations are
182 provided, one for use with SAX, the other based on Klacks.
184 @aboutclass{validation-context}
185 @aboutclass{sax-validation-context-mixin}
186 @aboutclass{klacks-validation-context}
187 @aboutfun{context-find-namespace-binding}
188 @end{section}"))