rnc+:// URIs
[cxml-rng.git] / index.xml
blobb53a8e55f20f41923a4bf690cbb3255e4665a9db
1 <page>
2   <p>
3     An implementation
4     of <a href="http://relaxng.org/spec-20011203.html">Relax
5       NG</a> schema validation
6     written in Common
7     Lisp.
8     <!--
9     <a href="http://relaxng.org/compact-20021121.html">Compact
10     Syntax</a>, and the XSD data type library are included.
11     -->
12   </p>
13   <p>
14     cxml-rng was written
15     by <a href="mailto:david@lichteblau.com">David
16       Lichteblau</a> and is designed as an add-on library for
17     <a href="http://common-lisp.net/project/cxml">Closure XML</a>.
18     It is available under an X11-style license.
19   </p>
20   <p>
21     Please send bug reports
22     to <a href="mailto:cxml-devel@common-lisp.net">
23       cxml-devel@common-lisp.net</a>
24     (<a href="http://common-lisp.net/cgi-bin/mailman/listinfo/cxml-devel">list information</a>).
25   </p>
27   <h3>Download and Installation</h3>
29   <p>
30     Download
31     cxml-rng <a
32                 href="http://www.lichteblau.com/cxml-rng/download/">tarballs</a>
33     or get it from
34     git: <tt>http://www.lichteblau.com/git/cxml-rng.git</tt>
35   </p>
36   <p>
37     cxml-rng
38     needs <a href="http://common-lisp.net/project/cxml">Closure
39       XML</a>, <a href="http://weitz.de/cl-ppcre/">CL-PPCE</a>,
40     and <a href="http://www.pps.jussieu.fr/~jch/software/cl-yacc/">CL-Yacc</a>.
41     <a href="http://www.cliki.net/asdf">ASDF</a> is used for
42     compilation.  Register the .asd file, e.g. by symlinking it,
43     then compile cxml-rng using <tt>asdf:operate</tt>.
44   </p>
45   <pre>$ ln -sf `pwd`/cxml-rng.asd /path/to/your/registry/
46 * (asdf:operate 'asdf:load-op :cxml-rng)</pre>
48   <h3>Implementation-specific notes</h3>
49   <p>
50     At this point, cxml-rng is written to work with Lisp strings
51     (as opposed to runes and rods), and is meant to be used on
52     Lisp implementations with Unicode support.
53   </p>
55   <h3>Example</h3>
56   <p>
57     Use <a href="doc/pages/cxml-rng__parse-schema.html">cxml-rng:parse-schema</a>
58     to parse a Relax NG schema file.  The
59     resulting <a
60                  href="doc/pages/cxml-rng__schema.html">schema</a>
61     object is a representation of a simplified schema using Lisp
62     objects, which has gone through most stages of simplification as
63     described the Relax NG
64     specification.  <a href="doc/pages/cxml-rng__serialize-schema.html">cxml-rng:serialize-schema</a>
65     can be used to write a Relax NG file in XML syntax for this
66     grammar.
67   </p>
68   <p>
69     In order to validate XML against a schema, create a
70     validation handler for the grammar
71     using <a href="doc/pages/cxml-rng__make-validator.html">cxml-rng:make-validator</a>.
72     The validation
73     handler processes SAX events and can be used with any
74     function generating such events, in particular
75     with <a
76             href="http://common-lisp.net/project/cxml/sax.html#parser">cxml:parse-file</a>.
77   </p>
78   <pre class="code">(cxml:parse-file "example.xml"
79                  <blau>(cxml-rng:make-validator
80                   (cxml-rng:parse-schema #p"example.rng"))</blau>)</pre>
81   <p>
82     In order to validate while also processing events with
83     another handler, use a broadcast handler.  For example, to
84     parse XML into DOM while also validating it, broadcast to
85     the validator and DOM builder (in that order):
86   </p>
87   <pre class="code" style="color: #777777">(cxml:parse-file "example.xml"
88                  <blau>(cxml:make-broadcast-handler</blau>
89                   (cxml-rng:make-validator
90                    (cxml-rng:parse-schema #p"example.rng"))
91                   <blau>(cxml-dom:make-dom-builder))</blau>)</pre>
92   <p>
93     To validate with the klacks parser, use a tapping source.
94   </p>
95   <pre class="code" style="color: #777777">(klacks:with-open-source
96     (s <blau>(klacks:make-tapping-source</blau>
97         (cxml:make-source #p"example.xml")
98         <blau>(cxml-rng:make-validator 
99          (cxml-rng:parse-schema #p"example.rng"))</blau>))
100   (loop for key = (klacks:peek-next s) while key do (print key)))</pre>
102   <h3>Documentation</h3>
103   <p>
104     <a href="doc/index.html">API documentation</a> is available.
105   </p>
106 </page>