4 #:rng-error-line-number
5 #:rng-error-column-number
54 #:name-class-choice-b
)
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}
62 @begin[Example]{section}
64 (cxml:parse-file \"test.xml\"
65 (cxml-rng:make-validator
66 (cxml-rng:parse-schema #p\"test.rng\")))
69 @begin[Classes]{section}
71 @aboutclass{rng-error}
73 @begin[Parsing and validating]{section}
74 @aboutfun{parse-schema}
75 @aboutfun{make-validator}
76 @aboutfun{serialize-grammar}
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}
89 @aboutclass{interleave}
90 @aboutclass{list-pattern}
91 @aboutclass{not-allowed}
92 @aboutclass{one-or-more}
97 @aboutfun{pattern-child}
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}
109 (defpackage :cxml-types
115 #:type-context-dependent-p
120 #:sax-validation-context-mixin
121 #:klacks-validation-context
122 #:make-klacks-validation-context
123 #:context-find-namespace-binding
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}
141 * (setf ttt (cxml-types:find-type :|| \"token\"))
142 #<CXML-TYPES:TOKEN-TYPE {1002D16B71@}>
143 * (cxml-types:parse ttt \"a b\")
145 * (cxml-types:parse ttt \"a b\")
147 * (cxml-types:equal-using-type ttt ** *)
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}
163 @aboutfun{type-library}
164 @aboutfun{type-context-dependent-p}
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}.
176 @aboutfun{equal-using-type}
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
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}