rnc+:// URIs
[cxml-rng.git] / package.lisp
blob7bf61183d279db93a26a3f2e8544e842898c681a
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{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 #:data-type
112 #:find-type
113 #:type-library
114 #:type-name
115 #:type-context-dependent-p
116 #:parse
117 #:equal-using-type
118 #:validp
119 #:validation-context
120 #:sax-validation-context-mixin
121 #:klacks-validation-context
122 #:make-klacks-validation-context
123 #:context-find-namespace-binding
124 #:rng-type
125 #:token-type
126 #:string-type
127 #:xsd-type)
128 (:documentation
129 "@code{cxml-types} defines an extensible interface for XML-related
130 data types as required for use in Relax NG validation.
131 It includes Relax NG's minimal built-in type library, which is named
132 @code{:||} and defines the types \"string\" and \"token\".
133 In addition, it implements the built-in types of
134 @a[http://www.w3.org/TR/xmlschema-2/]{XML Schema Datatypes}
135 as specified in @a[http://relaxng.org/xsd-20010907.html]{Guidelines for
136 using W3C XML Schema Datatypes with RELAX NG}. The XSD type library
137 is named @code{:|http://www.w3.org/2001/XMLSchema-datatypes|}.
139 @begin[Example]{section}
140 @begin{pre}
141 * (setf ttt (cxml-types:find-type :|| \"token\"))
142 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
143 * (cxml-types:parse ttt \"a b\")
144 \"a b\"
145 * (cxml-types:parse ttt \"a b\")
146 \"a b\"
147 * (cxml-types:equal-using-type ttt ** *)
149 @end{pre}
150 @end{section}
151 @begin[Type instances]{section}
152 Each type, together with its parameters, is represented by an
153 instance of @code{data-type}. The generic function @fun{find-type},
154 defined for each library, creates type instances. A type's properties
155 are accessible using @fun{type-name}, @fun{type-library}, and
156 @fun{type-context-dependent-p}.
158 @aboutclass{data-type}
159 @aboutclass{rng-type}
160 @aboutclass{xsd-type}
161 @aboutfun{find-type}
162 @aboutfun{type-name}
163 @aboutfun{type-library}
164 @aboutfun{type-context-dependent-p}
165 @end{section}
166 @begin[Using types]{section}
167 Types allow strings to be tested for validity and equality.
168 @fun{validp} checks whether a string can be parsed. If it is valid,
169 @fun{parse} will compute the string's @emph{value}, and return a
170 Lisp object of a type-specific class as a representation of that value.
171 Values returned by @fun{parse} can be compared for equality using
172 @fun{equal-using-type}.
174 @aboutfun{validp}
175 @aboutfun{parse}
176 @aboutfun{equal-using-type}
177 @end{section}
178 @begin[The validation context]{section}
179 Some types are context dependent, as indicated by
180 @fun{type-context-dependent-p}. Those types need access to state
181 computed by the XML parser implicitly, like namespace bindings or
182 the Base URI.
184 An abstract class @class{validation-context} is defined that
185 users of this API can implement a subclass of
186 to define methods for the generic functions listed below.
188 In addition, two pre-defined validation context implementations are
189 provided, one for use with SAX, the other based on Klacks.
191 @aboutclass{validation-context}
192 @aboutclass{sax-validation-context-mixin}
193 @aboutclass{klacks-validation-context}
194 @aboutfun{context-find-namespace-binding}
195 @end{section}"))