... dokumentation ...
[cxml-rng.git] / index.xml
blob593083ce792dcf52fa44950c89c56f3d75c6631a
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 Lisp.
7   </p>
8   <p>
9     cxml-rng was written
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.
14   </p>
15   <p>
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>).
20   </p>
22   <h3>Download and Installation</h3>
24   <p>
25     Download
26     cxml-rng <a
27                 href="http://www.lichteblau.com/cxml-rng/download/">tarballs</a>
28     or get it from
29     git: <tt>http://www.lichteblau.com/git/cxml-rng.git</tt>
30   </p>
31   <p>
32     cxml-rng
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>.
38   </p>
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>
43   <p>
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.
47   </p>
49   <h3>Example</h3>
50   <p>
51     Use <a href="doc/pages/cxml-rng__parse-relax-ng.html">cxml-rng:parse-relax-ng</a>
52     to parse a Relax NG schema file.  The
53     resulting <a
54                  href="doc/pages/cxml-rng__parsed-grammar.html">parsed-grammar</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-grammar.html">cxml-rng:serialize-grammar</a>
59     can be used to write a Relax NG file in XML syntax for this
60     grammar.
61   </p>
62   <p>
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>.
66     The validation
67     handler processes SAX events and can be used with any
68     function generating such events, in particular
69     with <a
70             href="http://common-lisp.net/project/cxml/sax.html#parser">cxml:parse-file</a>.
71   </p>
72   <pre class="code">(cxml:parse-file "example.xml"
73                  <blau>(cxml-rng:make-validator
74                   (cxml-rng:parse-relax-ng #p"example.rng"))</blau>)</pre>
75   <p>
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):
80   </p>
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-relax-ng #p"example.rng"))
85                   <blau>(cxml-dom:make-dom-builder))</blau>)</pre>
86   <p>
87     To validate with the klacks parser, use a tapping source.
88   </p>
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-relax-ng #p"example.rng"))</blau>))
94   (loop for key = (klacks:peek-next s) while key do (print key)))</pre>
96   <h3>Documentation</h3>
97   <p>
98     <a href="doc/index.html">API documentation</a> is available.
99   </p>
100 </page>