50 #:name-class-choice-b
)
52 "@code{cxml-rng} implements @a[http://relaxng.org/spec-20011203.html]{
53 Relax NG} schema validation for Closure XML.
55 @begin[Example]{section}
57 (cxml:parse-file \"test.xml\"
58 (cxml-rng:make-validator
59 (cxml-rng:parse-schema #p\"test.rng\")))
62 @begin[Classes]{section}
64 @aboutclass{rng-error}
66 @begin[Parsing and validating]{section}
67 @aboutfun{parse-schema}
68 @aboutfun{make-validator}
69 @aboutfun{serialize-grammar}
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}
82 @aboutclass{interleave}
83 @aboutclass{list-pattern}
84 @aboutclass{not-allowed}
85 @aboutclass{one-or-more}
90 @aboutfun{pattern-child}
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}
102 (defpackage :cxml-types
108 #:type-context-dependent-p
113 #:sax-validation-context-mixin
114 #:klacks-validation-context
115 #:make-klacks-validation-context
116 #:context-find-namespace-binding
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}
134 * (setf ttt (cxml-types:find-type :|| \"token\"))
135 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
136 * (cxml-types:parse ttt \"a b\")
138 * (cxml-types:parse ttt \"a b\")
140 * (cxml-types:equal-using-type ttt ** *)
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}
156 @aboutfun{type-library}
157 @aboutfun{type-context-dependent-p}
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}.
169 @aboutfun{equal-using-type}
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
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}