4 of <a href="http://relaxng.org/spec-20011203.html">Relax
5 NG</a> schema validation
6 written in Common Lisp.
10 by <a href="mailto:david@lichteblau.com">David
11 Lichteblau</a> and is designed as an add-on library for
12 <a href="http://common-lisp.net/project/cxml">Closure XML</a>.
13 It is available under an X11-style license.
16 Please send bug reports
17 to <a href="mailto:cxml-devel@common-lisp.net">
18 cxml-devel@common-lisp.net</a>
19 (<a href="http://common-lisp.net/cgi-bin/mailman/listinfo/cxml-devel">list information</a>).
22 <h3>Download and Installation</h3>
27 href="http://www.lichteblau.com/cxml-rng/download/">tarballs</a>
29 git: <tt>http://www.lichteblau.com/git/cxml-rng.git</tt>
33 needs <a href="http://common-lisp.net/project/cxml">Closure
34 XML</a> and <a href="http://weitz.de/cl-ppcre/">CL-PPCE</a>.
35 <a href="http://www.cliki.net/asdf">ASDF</a> is used for
36 compilation. Register the .asd file, e.g. by symlinking it,
37 then compile cxml-rng using <tt>asdf:operate</tt>.
39 <pre>$ ln -sf `pwd`/cxml-rng.asd /path/to/your/registry/
40 * (asdf:operate 'asdf:load-op :cxml-rng)</pre>
42 <h3>Implementation-specific notes</h3>
44 At this point, cxml-rng is written to work with Lisp strings
45 (as opposed to runes and rods), and is meant to be used on
46 Lisp implementations with Unicode support.
51 Use <a href="doc/pages/cxml-rng__parse-schema.html">cxml-rng:parse-schema</a>
52 to parse a Relax NG schema file. The
54 href="doc/pages/cxml-rng__schema.html">schema</a>
55 object is a representation of a simplified schema using Lisp
56 objects, which has gone through most stages of simplification as
57 described the Relax NG
58 specification. <a href="doc/pages/cxml-rng__serialize-schema.html">cxml-rng:serialize-schema</a>
59 can be used to write a Relax NG file in XML syntax for this
63 In order to validate XML against a schema, create a
64 validation handler for the grammar
65 using <a href="doc/pages/cxml-rng__make-validator.html">cxml-rng:make-validator</a>.
67 handler processes SAX events and can be used with any
68 function generating such events, in particular
70 href="http://common-lisp.net/project/cxml/sax.html#parser">cxml:parse-file</a>.
72 <pre class="code">(cxml:parse-file "example.xml"
73 <blau>(cxml-rng:make-validator
74 (cxml-rng:parse-schema #p"example.rng"))</blau>)</pre>
76 In order to validate while also processing events with
77 another handler, use a broadcast handler. For example, to
78 parse XML into DOM while also validating it, broadcast to
79 the validator and DOM builder (in that order):
81 <pre class="code" style="color: #777777">(cxml:parse-file "example.xml"
82 <blau>(cxml:make-broadcast-handler</blau>
83 (cxml-rng:make-validator
84 (cxml-rng:parse-schema #p"example.rng"))
85 <blau>(cxml-dom:make-dom-builder))</blau>)</pre>
87 To validate with the klacks parser, use a tapping source.
89 <pre class="code" style="color: #777777">(klacks:with-open-source
90 (s <blau>(klacks:make-tapping-source</blau>
91 (cxml:make-source #p"example.xml")
92 <blau>(cxml-rng:make-validator
93 (cxml-rng:parse-schema #p"example.rng"))</blau>))
94 (loop for key = (klacks:peek-next s) while key do (print key)))</pre>
96 <h3>Documentation</h3>
98 <a href="doc/index.html">API documentation</a> is available.