3 An XML object model for Common Lisp.
7 by <a href="mailto:david@lichteblau.com">David Lichteblau</a>
8 as an add-on library for
9 <a href="http://common-lisp.net/project/cxml">Closure XML</a>.
10 It is available under an X11-style license.
13 Please send bug reports
14 to <a href="mailto:cxml-devel@common-lisp.net">
15 cxml-devel@common-lisp.net</a>
16 (<a href="http://common-lisp.net/cgi-bin/mailman/listinfo/cxml-devel">list information</a>).
19 <h3>Download and Installation</h3>
23 <a href="http://www.lichteblau.com/cxml-stp/download/">tarball</a>.
27 <a href="http://common-lisp.net/project/cxml">Closure XML</a>.
28 <a href="http://www.cliki.net/asdf">ASDF</a> is used for
29 compilation. Register the .asd file, e.g. by symlinking it,
30 then compile cxml-stp using <tt>asdf:operate</tt>.
32 <pre>$ ln -sf `pwd`/cxml-stp.asd /path/to/your/registry/
33 * (asdf:operate 'asdf:load-op :cxml-stp)</pre>
35 <h3>Implementation-specific notes</h3>
37 At this point, cxml-stp is written to work with Lisp strings
38 (as opposed to runes and rods), and is meant to be used on
39 Lisp implementations with Unicode support.
44 Use <a href="doc/pages/cxml-stp__parse-schema.html">cxml-stp:parse-schema</a>
45 to parse a Relax NG schema file. The
47 href="doc/pages/cxml-stp__schema.html">schema</a>
48 object is a representation of a simplified schema using Lisp
49 objects, which has gone through simplification as
50 described the Relax NG
51 specification. <a href="doc/pages/cxml-stp__serialize-schema.html">cxml-stp:serialize-schema</a>
52 can be used to write a Relax NG file in XML syntax for this
56 In order to validate XML against a schema, create a
57 validation handler for the grammar
58 using <a href="doc/pages/cxml-stp__make-validator.html">cxml-stp:make-validator</a>.
60 handler processes SAX events and can be used with any
61 function generating such events, in particular
63 href="http://common-lisp.net/project/cxml/sax.html#parser">cxml:parse-file</a>.
65 <pre class="code">(cxml:parse-file "example.xml"
66 <blau>(cxml-stp:make-validator
67 (cxml-stp:parse-schema #p"example.stp"))</blau>)</pre>
69 The validator accepts another SAX handler as an optional
70 second argument. For example, to parse XML into DOM while also
71 validating it, use the validator like this:
73 <pre class="code" style="color: #777777">(cxml:parse-file "example.xml"
74 <blau>(cxml-stp:make-validator</blau>
75 (cxml-stp:parse-schema #p"example.stp")
76 <blau>(cxml-dom:make-dom-builder))</blau>)</pre>
78 When using the klacks parser, create a validating source.
80 <pre class="code" style="color: #777777">(klacks:with-open-source
81 (s <blau>(cxml-stp:make-validating-source
83 (cxml-stp:parse-schema #p"example.stp"))</blau>)
84 (loop for key = (klacks:peek-next s) while key do (print key)))</pre>
86 DTD Compatibility processing (basically, checking of IDs and
87 addition of default values) is done using a
88 <a href="doc/pages/cxml-stp__make-dtd-compatibility-handler.html">DTD Compatibility handler</a>.
89 You can use this handler together with a validator or by its own.
91 <pre class="code" style="color: #777777">(cxml:parse-file "example.xml"
92 <blau>(cxml-stp:make-dtd-compatibility-handler</blau>
93 (cxml-stp:parse-schema #p"example.stp")
94 <blau>(cxml-dom:make-dom-builder))</blau>)</pre>
96 <h3>Documentation</h3>
98 <a href="doc/index.html">API documentation</a> is available.