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