Use 21 bit characters on Lisps offering them.
[cxml-rng.git] / index.html
blob646b8f9ad492739980815a6822d3559174d32699
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>
6 cxml-rng: Relax NG for Closure XML
7 </title>
8 <link rel="stylesheet" type="text/css" href="index.css">
9 </head>
10 <body style="width: 62em">
11 <div id="header"><table cellspacing="0" cellpadding="0" width="100%"><tr>
12 <td width="176"><img src="doc/logo.png"></td>
13 <td valign="center">
14
15 <b> Relax NG for Closure XML</b>
16 </td>
17 </tr></table></div>
18 <div id="homepage" class="main">
19 <p>
20 An implementation
21 of <a href="http://relaxng.org/spec-20011203.html">Relax
22 NG</a> schema validation
23 written in Common
24 Lisp, including support for compact syntax, DTD Compatibility, and
25 the XSD type library.
26 </p>
27 <p>
28 cxml-rng was written
29 by <a href="mailto:david@lichteblau.com">David
30 Lichteblau</a> and is designed as an add-on library for
31 <a href="http://common-lisp.net/project/cxml">Closure XML</a>.
32 It is available under an X11-style license.
33 </p>
34 <p>
35 Please send bug reports
36 to <a href="mailto:cxml-devel@common-lisp.net">
37 cxml-devel@common-lisp.net</a>
38 (<a href="http://common-lisp.net/cgi-bin/mailman/listinfo/cxml-devel">list information</a>).
39 </p>
41 <h3>Download and Installation</h3>
43 <!--
44 <p>
45 Download cxml-rng
46 <a href="http://www.lichteblau.com/cxml-rng/download/">tarballs</a>
47 or get it from git: <tt>http://www.lichteblau.com/git/cxml-rng.git</tt>
48 </p>
49 -->
50 <p>
51 Download a cxml-rng
52 <a href="http://www.lichteblau.com/cxml-rng/download/">tarball</a>.
53 </p>
54 <p>
55 cxml-rng needs
56 <a href="http://common-lisp.net/project/cxml">Closure XML</a>,
57 <a href="http://weitz.de/cl-ppcre/">CL-PPCE</a>,
58 <a href="http://www.pps.jussieu.fr/~jch/software/cl-yacc/">CL-Yacc</a>,
59 <a href="http://www.cliki.net/PARSE-NUMBER">parse-number</a>,
60 and <a href="http://www.cliki.net/cl-base64">cl-base64</a>.
61 <a href="http://www.cliki.net/asdf">ASDF</a> is used for
62 compilation. Register the .asd file, e.g. by symlinking it,
63 then compile cxml-rng using <tt>asdf:operate</tt>.
64 </p>
65 <pre>$ ln -sf `pwd`/cxml-rng.asd /path/to/your/registry/
66 * (asdf:operate 'asdf:load-op :cxml-rng)</pre>
68 <h3>Implementation-specific notes</h3>
69 <p>
70 At this point, cxml-rng is written to work with Lisp strings
71 (as opposed to runes and rods), and is meant to be used on
72 Lisp implementations with Unicode support.
73 </p>
75 <h3>Example</h3>
76 <p>
77 Use <a href="doc/pages/cxml-rng__parse-schema.html">cxml-rng:parse-schema</a>
78 to parse a Relax NG schema file. The
79 resulting <a href="doc/pages/cxml-rng__schema.html">schema</a>
80 object is a representation of a simplified schema using Lisp
81 objects, which has gone through simplification as
82 described the Relax NG
83 specification. <a href="doc/pages/cxml-rng__serialize-schema.html">cxml-rng:serialize-schema</a>
84 can be used to write a Relax NG file in XML syntax for this
85 grammar.
86 </p>
87 <p>
88 In order to validate XML against a schema, create a
89 validation handler for the grammar
90 using <a href="doc/pages/cxml-rng__make-validator.html">cxml-rng:make-validator</a>.
91 The validation
92 handler processes SAX events and can be used with any
93 function generating such events, in particular
94 with <a href="http://common-lisp.net/project/cxml/sax.html#parser">cxml:parse-file</a>.
95 </p>
96 <pre class="code">(cxml:parse-file "example.xml"
97 <span style="color: black">(cxml-rng:make-validator
98 (cxml-rng:parse-schema #p"example.rng"))</span>)</pre>
99 <p>
100 The validator accepts another SAX handler as an optional
101 second argument. For example, to parse XML into DOM while also
102 validating it, use the validator like this:
103 </p>
104 <pre class="code" style="color: #777777">(cxml:parse-file "example.xml"
105 <span style="color: black">(cxml-rng:make-validator</span>
106 (cxml-rng:parse-schema #p"example.rng")
107 <span style="color: black">(cxml-dom:make-dom-builder))</span>)</pre>
109 When using the klacks parser, create a validating source.
110 </p>
111 <pre class="code" style="color: #777777">(klacks:with-open-source
112 (s <span style="color: black">(cxml-rng:make-validating-source
113 #p"example.xml"
114 (cxml-rng:parse-schema #p"example.rng"))</span>)
115 (loop for key = (klacks:peek-next s) while key do (print key)))</pre>
117 DTD Compatibility processing (basically, checking of IDs and
118 addition of default values) is done using a
119 <a href="doc/pages/cxml-rng__make-dtd-compatibility-handler.html">DTD Compatibility handler</a>.
120 You can use this handler together with a validator or by its own.
121 </p>
122 <pre class="code" style="color: #777777">(cxml:parse-file "example.xml"
123 <span style="color: black">(cxml-rng:make-dtd-compatibility-handler</span>
124 (cxml-rng:parse-schema #p"example.rng")
125 <span style="color: black">(cxml-dom:make-dom-builder))</span>)</pre>
127 <h3>Documentation</h3>
129 <a href="doc/index.html">API documentation</a> is available.
130 </p>
131 </div>
132 </body>
133 </html>