Initial commit
[cxml-stp.git] / index.xml
blob25621ed3dc4d961d3bb385213f0ec735391501bc
1 <page>
2   <p>
3     An XML object model for Common Lisp.
4   </p>
5   <p>
6     cxml-stp was written
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.
11   </p>
12   <p>
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>).
17   </p>
19   <h3>Download and Installation</h3>
21   <p>
22     Download a cxml-stp
23     <a href="http://www.lichteblau.com/cxml-stp/download/">tarball</a>.
24   </p>
25   <p>
26     cxml-stp needs
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>.
31   </p>
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>
36   <p>
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.
40   </p>
42   <h3>Example</h3>
43   <p>
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
46     resulting <a
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
53     grammar.
54   </p>
55   <p>
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>.
59     The validation
60     handler processes SAX events and can be used with any
61     function generating such events, in particular
62     with <a
63             href="http://common-lisp.net/project/cxml/sax.html#parser">cxml:parse-file</a>.
64   </p>
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>
68   <p>
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:
72   </p>
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>
77   <p>
78     When using the klacks parser, create a validating source.
79   </p>
80   <pre class="code" style="color: #777777">(klacks:with-open-source
81     (s <blau>(cxml-stp:make-validating-source
82         #p"example.xml"
83         (cxml-stp:parse-schema #p"example.stp"))</blau>)
84   (loop for key = (klacks:peek-next s) while key do (print key)))</pre>
85   <p>
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.
90   </p>
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>
97   <p>
98     <a href="doc/index.html">API documentation</a> is available.
99   </p>
100 </page>