1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
6 cxml-rng: Relax NG for Closure XML
8 <link rel=
"stylesheet" type=
"text/css" href=
"index.css">
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>
15 <b> Relax NG for Closure XML
</b>
18 <div id=
"homepage" class=
"main">
21 of
<a href=
"http://relaxng.org/spec-20011203.html">Relax
22 NG
</a> schema validation
24 Lisp, including support for compact syntax and the XSD type
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.
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>).
41 <h3>Download and Installation
</h3>
45 <a href=
"http://www.lichteblau.com/cxml-rng/download/">tarballs
</a>
46 or get it from git:
<tt>http://www.lichteblau.com/git/cxml-rng.git
</tt>
50 <a href=
"http://common-lisp.net/project/cxml">Closure XML
</a>,
51 <a href=
"http://weitz.de/cl-ppcre/">CL-PPCE
</a>,
52 <a href=
"http://www.pps.jussieu.fr/~jch/software/cl-yacc/">CL-Yacc
</a>,
53 <a href=
"http://www.cliki.net/PARSE-NUMBER">parse-number
</a>,
54 and
<a href=
"http://www.cliki.net/cl-base64">cl-base64
</a>.
55 <a href=
"http://www.cliki.net/asdf">ASDF
</a> is used for
56 compilation. Register the .asd file, e.g. by symlinking it,
57 then compile cxml-rng using
<tt>asdf:operate
</tt>.
59 <pre>$ ln -sf `pwd`/cxml-rng.asd /path/to/your/registry/
60 * (asdf:operate 'asdf:load-op :cxml-rng)
</pre>
62 <h3>Implementation-specific notes
</h3>
64 At this point, cxml-rng is written to work with Lisp strings
65 (as opposed to runes and rods), and is meant to be used on
66 Lisp implementations with Unicode support.
71 Use
<a href=
"doc/pages/cxml-rng__parse-schema.html">cxml-rng:parse-schema
</a>
72 to parse a Relax NG schema file. The
73 resulting
<a href=
"doc/pages/cxml-rng__schema.html">schema
</a>
74 object is a representation of a simplified schema using Lisp
75 objects, which has gone through most stages of simplification as
76 described the Relax NG
77 specification.
<a href=
"doc/pages/cxml-rng__serialize-schema.html">cxml-rng:serialize-schema
</a>
78 can be used to write a Relax NG file in XML syntax for this
82 In order to validate XML against a schema, create a
83 validation handler for the grammar
84 using
<a href=
"doc/pages/cxml-rng__make-validator.html">cxml-rng:make-validator
</a>.
86 handler processes SAX events and can be used with any
87 function generating such events, in particular
88 with
<a href=
"http://common-lisp.net/project/cxml/sax.html#parser">cxml:parse-file
</a>.
90 <pre class=
"code">(cxml:parse-file
"example.xml"
91 <span style=
"color: black">(cxml-rng:make-validator
92 (cxml-rng:parse-schema #p
"example.rng"))
</span>)
</pre>
94 The validator accepts another SAX handler as an optional
95 second argument. For example, to parse XML into DOM while also
96 validating it, use the validator like this:
98 <pre class=
"code" style=
"color: #777777">(cxml:parse-file
"example.xml"
99 <span style=
"color: black">(cxml-rng:make-validator
</span>
100 (cxml-rng:parse-schema #p
"example.rng")
101 <span style=
"color: black">(cxml-dom:make-dom-builder))
</span>)
</pre>
103 When using the klacks parser, create a validating source.
105 <pre class=
"code" style=
"color: #777777">(klacks:with-open-source
106 (s
<span style=
"color: black">(cxml-rng:make-validating-source
108 (cxml-rng:parse-schema #p
"example.rng"))
</span>)
109 (loop for key = (klacks:peek-next s) while key do (print key)))
</pre>
111 <h3>Documentation
</h3>
113 <a href=
"doc/index.html">API documentation
</a> is available.