columns
[cxml-rng.git] / package.lisp
blob6aa93aa1a27b7528d94895a5ef8f530fce0dbf7a
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)
37 (:documentation
38 "@code{cxml-rng} implements @a[http://relaxng.org/spec-20011203.html]{
39 Relax NG} schema validation for Closure XML.
41 @begin[Example]{section}
42 @begin{code}
43 (cxml:parse-file \"test.xml\"
44 (cxml-rng:make-validator
45 (cxml-rng:parse-schema #p\"test.rng\")))
46 @end{code}
47 @end{section}
48 @begin[Classes]{section}
49 @aboutclass{parsed-grammar}
50 @aboutclass{rng-error}
51 @end{section}
52 @begin[Parsing and validating]{section}
53 @aboutfun{parse-schema}
54 @aboutfun{make-validator}
55 @aboutfun{serialize-grammar}
56 @end{section}
57 @begin[Grammar introspection]{section}
58 The following classes and function are exported so that users can
59 take a peek at the internals of the parsed and simplified grammar.
61 @aboutfun{parsed-grammar-pattern}
62 @aboutclass{attribute}
63 @aboutclass{choice}
64 @aboutclass{data}
65 @aboutclass{element}
66 @aboutclass{empty}
67 @aboutclass{group}
68 @aboutclass{interleave}
69 @aboutclass{list-pattern}
70 @aboutclass{not-allowed}
71 @aboutclass{one-or-more}
72 @aboutclass{pattern}
73 @aboutclass{ref}
74 @aboutclass{text}
75 @aboutclass{value}
76 @aboutfun{pattern-child}
77 @aboutfun{pattern-a}
78 @aboutfun{pattern-b}
79 @aboutfun{pattern-name}
80 @aboutfun{pattern-resolved-target}
81 @aboutfun{pattern-type}
82 @aboutfun{pattern-string}
83 @aboutfun{pattern-value}
84 @aboutfun{pattern-params}
85 @aboutfun{pattern-except}
86 @end{section}"))
88 (defpackage :cxml-types
89 (:use :cl)
90 (:export #:data-type
91 #:find-type
92 #:type-library
93 #:type-name
94 #:type-context-dependent-p
95 #:parse
96 #:equal-using-type
97 #:validp
98 #:validation-context
99 #:sax-validation-context-mixin
100 #:klacks-validation-context
101 #:make-klacks-validation-context
102 #:context-find-namespace-binding)
103 (:documentation
104 "@code{cxml-types} defines an extensible interface for XML-related
105 data types as required for use in Relax NG validation.
106 It includes Relax NG's minimal built-in type library, which is named
107 @code{:||} and defines the types \"string\" and \"token\".
108 In addition, it implements the built-in types of
109 @a[http://www.w3.org/TR/xmlschema-2/]{XML Schema Datatypes}
110 as specified in @a[http://relaxng.org/xsd-20010907.html]{Guidelines for
111 using W3C XML Schema Datatypes with RELAX NG}. The XSD type library
112 is named @code{:|http://www.w3.org/2001/XMLSchema-datatypes|}.
114 @begin[Type instances]{section}
115 Each type, together with its parameters, is represented by an
116 instance of @code{data-type}. The generic function @fun{find-type},
117 defined for each library, creates type instances. A type's properties
118 are accessible using @fun{type-name}, @fun{type-library}, and
119 @fun{type-context-dependent-p}.
121 @aboutclass{datatype}
122 @aboutfun{find-type}
123 @aboutfun{type-name}
124 @aboutfun{type-library}
125 @aboutfun{type-context-dependent-p}
126 @end{section}
127 @begin[Using types]{section}
128 Types allow strings to be tested for validity and equality.
129 @fun{validp} checks whether a string can be parsed. If it is valid,
130 @fun{parse} will compute the string's @emph{value}, and return a
131 Lisp object of a type-specific class as a representation of that value.
132 Values returned by @fun{parse} can be compared for equality using
133 @fun{equal-using-type}.
135 @aboutfun{validp}
136 @aboutfun{parse}
137 @aboutfun{equal-using-type}
138 @end{section}
139 @begin[The validation context]{section}
140 Some types are context dependent, as indicated by
141 @fun{type-context-dependent-p}. Those type need access to state
142 computed by the XML parser implicitly, like namespace bindings or
143 the Base URI.
145 An abstract class @class{validation-context} is defined.
146 Users of this API can implement a subclass of @class{validation-context}
147 and define methods for the generic functions listed below.
149 In addition, two pre-defined validation context implementations are
150 provided, one for use with SAX, the other based on Klacks.
152 @aboutclass{validation-context}
153 @aboutclass{sax-validation-context-mixin}
154 @aboutclass{klacks-validation-context}
155 @aboutfun{context-find-namespace-binding}
156 @end{section}"))