xref: /aosp_15_r20/external/libxml2/doc/devhelp/libxml2-schematron.html (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>schematron: XML Schematron implementation</title>
5<meta name="generator" content="Libxml2 devhelp stylesheet">
6<link rel="start" href="index.html" title="libxml2 Reference Manual">
7<link rel="up" href="general.html" title="API">
8<link rel="stylesheet" href="style.css" type="text/css">
9<link rel="chapter" href="general.html" title="API">
10</head>
11<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
12<table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
13<td><a accesskey="p" href="libxml2-schemasInternals.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
14<td><a accesskey="u" href="general.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
15<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
16<td><a accesskey="n" href="libxml2-threads.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
17<th width="100%" align="center">libxml2 Reference Manual</th>
18</tr></table>
19<h2><span class="refentrytitle">schematron</span></h2>
20<p>schematron - XML Schematron implementation</p>
21<p>interface to the XML Schematron validity checking. </p>
22<p>Author(s): Daniel Veillard </p>
23<div class="refsynopsisdiv">
24<h2>Synopsis</h2>
25<pre class="synopsis">typedef struct _xmlSchematron <a href="#xmlSchematron">xmlSchematron</a>;
26typedef struct _xmlSchematronParserCtxt <a href="#xmlSchematronParserCtxt">xmlSchematronParserCtxt</a>;
27typedef <a href="libxml2-schematron.html#xmlSchematronParserCtxt">xmlSchematronParserCtxt</a> * <a href="#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a>;
28typedef <a href="libxml2-schematron.html#xmlSchematron">xmlSchematron</a> * <a href="#xmlSchematronPtr">xmlSchematronPtr</a>;
29typedef struct _xmlSchematronValidCtxt <a href="#xmlSchematronValidCtxt">xmlSchematronValidCtxt</a>;
30typedef <a href="libxml2-schematron.html#xmlSchematronValidCtxt">xmlSchematronValidCtxt</a> * <a href="#xmlSchematronValidCtxtPtr">xmlSchematronValidCtxtPtr</a>;
31typedef enum <a href="#xmlSchematronValidOptions">xmlSchematronValidOptions</a>;
32void	<a href="#xmlSchematronFree">xmlSchematronFree</a>		(<a href="libxml2-schematron.html#xmlSchematronPtr">xmlSchematronPtr</a> schema);
33void	<a href="#xmlSchematronFreeParserCtxt">xmlSchematronFreeParserCtxt</a>	(<a href="libxml2-schematron.html#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a> ctxt);
34void	<a href="#xmlSchematronFreeValidCtxt">xmlSchematronFreeValidCtxt</a>	(<a href="libxml2-schematron.html#xmlSchematronValidCtxtPtr">xmlSchematronValidCtxtPtr</a> ctxt);
35<a href="libxml2-schematron.html#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a>	<a href="#xmlSchematronNewDocParserCtxt">xmlSchematronNewDocParserCtxt</a>	(<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc);
36<a href="libxml2-schematron.html#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a>	<a href="#xmlSchematronNewMemParserCtxt">xmlSchematronNewMemParserCtxt</a>	(const char * buffer, <br>							 int size);
37<a href="libxml2-schematron.html#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a>	<a href="#xmlSchematronNewParserCtxt">xmlSchematronNewParserCtxt</a>	(const char * URL);
38<a href="libxml2-schematron.html#xmlSchematronValidCtxtPtr">xmlSchematronValidCtxtPtr</a>	<a href="#xmlSchematronNewValidCtxt">xmlSchematronNewValidCtxt</a>	(<a href="libxml2-schematron.html#xmlSchematronPtr">xmlSchematronPtr</a> schema, <br>							 int options);
39<a href="libxml2-schematron.html#xmlSchematronPtr">xmlSchematronPtr</a>	<a href="#xmlSchematronParse">xmlSchematronParse</a>	(<a href="libxml2-schematron.html#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a> ctxt);
40void	<a href="#xmlSchematronSetValidStructuredErrors">xmlSchematronSetValidStructuredErrors</a>	(<a href="libxml2-schematron.html#xmlSchematronValidCtxtPtr">xmlSchematronValidCtxtPtr</a> ctxt, <br>						 <a href="libxml2-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> serror, <br>						 void * ctx);
41int	<a href="#xmlSchematronValidateDoc">xmlSchematronValidateDoc</a>	(<a href="libxml2-schematron.html#xmlSchematronValidCtxtPtr">xmlSchematronValidCtxtPtr</a> ctxt, <br>					 <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> instance);
42typedef void <a href="#xmlSchematronValidityErrorFunc">xmlSchematronValidityErrorFunc</a>	(void * ctx, <br>					 const char * msg, <br>					 ... ...);
43typedef void <a href="#xmlSchematronValidityWarningFunc">xmlSchematronValidityWarningFunc</a>	(void * ctx, <br>						 const char * msg, <br>						 ... ...);
44</pre>
45</div>
46<div class="refsect1" lang="en"><h2>Description</h2></div>
47<div class="refsect1" lang="en">
48<h2>Details</h2>
49<div class="refsect2" lang="en">
50<div class="refsect2" lang="en">
51<h3>
52<a name="xmlSchematron">Structure </a>xmlSchematron</h3>
53<pre class="programlisting">struct _xmlSchematron {
54The content of this structure is not made public by the API.
55} xmlSchematron;
56</pre>
57<p></p>
58</div>
59<hr>
60<div class="refsect2" lang="en">
61<h3>
62<a name="xmlSchematronParserCtxt">Structure </a>xmlSchematronParserCtxt</h3>
63<pre class="programlisting">struct _xmlSchematronParserCtxt {
64The content of this structure is not made public by the API.
65} xmlSchematronParserCtxt;
66</pre>
67<p></p>
68</div>
69<hr>
70<div class="refsect2" lang="en">
71<h3>
72<a name="xmlSchematronParserCtxtPtr">Typedef </a>xmlSchematronParserCtxtPtr</h3>
73<pre class="programlisting"><a href="libxml2-schematron.html#xmlSchematronParserCtxt">xmlSchematronParserCtxt</a> * xmlSchematronParserCtxtPtr;
74</pre>
75<p></p>
76</div>
77<hr>
78<div class="refsect2" lang="en">
79<h3>
80<a name="xmlSchematronPtr">Typedef </a>xmlSchematronPtr</h3>
81<pre class="programlisting"><a href="libxml2-schematron.html#xmlSchematron">xmlSchematron</a> * xmlSchematronPtr;
82</pre>
83<p></p>
84</div>
85<hr>
86<div class="refsect2" lang="en">
87<h3>
88<a name="xmlSchematronValidCtxt">Structure </a>xmlSchematronValidCtxt</h3>
89<pre class="programlisting">struct _xmlSchematronValidCtxt {
90The content of this structure is not made public by the API.
91} xmlSchematronValidCtxt;
92</pre>
93<p></p>
94</div>
95<hr>
96<div class="refsect2" lang="en">
97<h3>
98<a name="xmlSchematronValidCtxtPtr">Typedef </a>xmlSchematronValidCtxtPtr</h3>
99<pre class="programlisting"><a href="libxml2-schematron.html#xmlSchematronValidCtxt">xmlSchematronValidCtxt</a> * xmlSchematronValidCtxtPtr;
100</pre>
101<p></p>
102</div>
103<hr>
104<div class="refsect2" lang="en">
105<h3>
106<a name="xmlSchematronValidOptions">Enum </a>xmlSchematronValidOptions</h3>
107<pre class="programlisting">enum <a href="#xmlSchematronValidOptions">xmlSchematronValidOptions</a> {
108    <a name="XML_SCHEMATRON_OUT_QUIET">XML_SCHEMATRON_OUT_QUIET</a> = 1 /* quiet no report */
109    <a name="XML_SCHEMATRON_OUT_TEXT">XML_SCHEMATRON_OUT_TEXT</a> = 2 /* build a textual report */
110    <a name="XML_SCHEMATRON_OUT_XML">XML_SCHEMATRON_OUT_XML</a> = 4 /* output SVRL */
111    <a name="XML_SCHEMATRON_OUT_ERROR">XML_SCHEMATRON_OUT_ERROR</a> = 8 /* output via xmlStructuredErrorFunc */
112    <a name="XML_SCHEMATRON_OUT_FILE">XML_SCHEMATRON_OUT_FILE</a> = 256 /* output to a file descriptor */
113    <a name="XML_SCHEMATRON_OUT_BUFFER">XML_SCHEMATRON_OUT_BUFFER</a> = 512 /* output to a buffer */
114    <a name="XML_SCHEMATRON_OUT_IO">XML_SCHEMATRON_OUT_IO</a> = 1024 /*  output to I/O mechanism */
115};
116</pre>
117<p></p>
118</div>
119<hr>
120<div class="refsect2" lang="en">
121<h3>
122<a name="xmlSchematronValidityErrorFunc"></a>Function type xmlSchematronValidityErrorFunc</h3>
123<pre class="programlisting">void	xmlSchematronValidityErrorFunc	(void * ctx, <br>					 const char * msg, <br>					 ... ...)<br>
124</pre>
125<p>Signature of an error callback from a Schematron validation</p>
126<div class="variablelist"><table border="0">
127<col align="left">
128<tbody>
129<tr>
130<td><span class="term"><i><tt>ctx</tt></i>:</span></td>
131<td>the validation context</td>
132</tr>
133<tr>
134<td><span class="term"><i><tt>msg</tt></i>:</span></td>
135<td>the message</td>
136</tr>
137<tr>
138<td><span class="term"><i><tt>...</tt></i>:</span></td>
139<td>extra arguments</td>
140</tr>
141</tbody>
142</table></div>
143</div>
144<hr>
145<div class="refsect2" lang="en">
146<h3>
147<a name="xmlSchematronValidityWarningFunc"></a>Function type xmlSchematronValidityWarningFunc</h3>
148<pre class="programlisting">void	xmlSchematronValidityWarningFunc	(void * ctx, <br>						 const char * msg, <br>						 ... ...)<br>
149</pre>
150<p>Signature of a warning callback from a Schematron validation</p>
151<div class="variablelist"><table border="0">
152<col align="left">
153<tbody>
154<tr>
155<td><span class="term"><i><tt>ctx</tt></i>:</span></td>
156<td>the validation context</td>
157</tr>
158<tr>
159<td><span class="term"><i><tt>msg</tt></i>:</span></td>
160<td>the message</td>
161</tr>
162<tr>
163<td><span class="term"><i><tt>...</tt></i>:</span></td>
164<td>extra arguments</td>
165</tr>
166</tbody>
167</table></div>
168</div>
169<hr>
170<div class="refsect2" lang="en">
171<h3>
172<a name="xmlSchematronFree"></a>xmlSchematronFree ()</h3>
173<pre class="programlisting">void	xmlSchematronFree		(<a href="libxml2-schematron.html#xmlSchematronPtr">xmlSchematronPtr</a> schema)<br>
174</pre>
175<p>Deallocate a Schematron structure.</p>
176<div class="variablelist"><table border="0">
177<col align="left">
178<tbody><tr>
179<td><span class="term"><i><tt>schema</tt></i>:</span></td>
180<td>a schema structure</td>
181</tr></tbody>
182</table></div>
183</div>
184<hr>
185<div class="refsect2" lang="en">
186<h3>
187<a name="xmlSchematronFreeParserCtxt"></a>xmlSchematronFreeParserCtxt ()</h3>
188<pre class="programlisting">void	xmlSchematronFreeParserCtxt	(<a href="libxml2-schematron.html#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a> ctxt)<br>
189</pre>
190<p>Free the resources associated to the schema parser context</p>
191<div class="variablelist"><table border="0">
192<col align="left">
193<tbody><tr>
194<td><span class="term"><i><tt>ctxt</tt></i>:</span></td>
195<td>the schema parser context</td>
196</tr></tbody>
197</table></div>
198</div>
199<hr>
200<div class="refsect2" lang="en">
201<h3>
202<a name="xmlSchematronFreeValidCtxt"></a>xmlSchematronFreeValidCtxt ()</h3>
203<pre class="programlisting">void	xmlSchematronFreeValidCtxt	(<a href="libxml2-schematron.html#xmlSchematronValidCtxtPtr">xmlSchematronValidCtxtPtr</a> ctxt)<br>
204</pre>
205<p>Free the resources associated to the schema validation context</p>
206<div class="variablelist"><table border="0">
207<col align="left">
208<tbody><tr>
209<td><span class="term"><i><tt>ctxt</tt></i>:</span></td>
210<td>the schema validation context</td>
211</tr></tbody>
212</table></div>
213</div>
214<hr>
215<div class="refsect2" lang="en">
216<h3>
217<a name="xmlSchematronNewDocParserCtxt"></a>xmlSchematronNewDocParserCtxt ()</h3>
218<pre class="programlisting"><a href="libxml2-schematron.html#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a>	xmlSchematronNewDocParserCtxt	(<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc)<br>
219</pre>
220<p>Create an XML Schematrons parse context for that document. NB. The document may be modified during the parsing process.</p>
221<div class="variablelist"><table border="0">
222<col align="left">
223<tbody>
224<tr>
225<td><span class="term"><i><tt>doc</tt></i>:</span></td>
226<td>a preparsed document tree</td>
227</tr>
228<tr>
229<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
230<td>the parser context or NULL in case of error</td>
231</tr>
232</tbody>
233</table></div>
234</div>
235<hr>
236<div class="refsect2" lang="en">
237<h3>
238<a name="xmlSchematronNewMemParserCtxt"></a>xmlSchematronNewMemParserCtxt ()</h3>
239<pre class="programlisting"><a href="libxml2-schematron.html#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a>	xmlSchematronNewMemParserCtxt	(const char * buffer, <br>							 int size)<br>
240</pre>
241<p>Create an XML Schematrons parse context for that memory buffer expected to contain an XML Schematrons file.</p>
242<div class="variablelist"><table border="0">
243<col align="left">
244<tbody>
245<tr>
246<td><span class="term"><i><tt>buffer</tt></i>:</span></td>
247<td>a pointer to a char array containing the schemas</td>
248</tr>
249<tr>
250<td><span class="term"><i><tt>size</tt></i>:</span></td>
251<td>the size of the array</td>
252</tr>
253<tr>
254<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
255<td>the parser context or NULL in case of error</td>
256</tr>
257</tbody>
258</table></div>
259</div>
260<hr>
261<div class="refsect2" lang="en">
262<h3>
263<a name="xmlSchematronNewParserCtxt"></a>xmlSchematronNewParserCtxt ()</h3>
264<pre class="programlisting"><a href="libxml2-schematron.html#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a>	xmlSchematronNewParserCtxt	(const char * URL)<br>
265</pre>
266<p>Create an XML Schematrons parse context for that file/resource expected to contain an XML Schematrons file.</p>
267<div class="variablelist"><table border="0">
268<col align="left">
269<tbody>
270<tr>
271<td><span class="term"><i><tt>URL</tt></i>:</span></td>
272<td>the location of the schema</td>
273</tr>
274<tr>
275<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
276<td>the parser context or NULL in case of error</td>
277</tr>
278</tbody>
279</table></div>
280</div>
281<hr>
282<div class="refsect2" lang="en">
283<h3>
284<a name="xmlSchematronNewValidCtxt"></a>xmlSchematronNewValidCtxt ()</h3>
285<pre class="programlisting"><a href="libxml2-schematron.html#xmlSchematronValidCtxtPtr">xmlSchematronValidCtxtPtr</a>	xmlSchematronNewValidCtxt	(<a href="libxml2-schematron.html#xmlSchematronPtr">xmlSchematronPtr</a> schema, <br>							 int options)<br>
286</pre>
287<p>Create an XML Schematrons validation context based on the given schema.</p>
288<div class="variablelist"><table border="0">
289<col align="left">
290<tbody>
291<tr>
292<td><span class="term"><i><tt>schema</tt></i>:</span></td>
293<td>a precompiled XML Schematrons</td>
294</tr>
295<tr>
296<td><span class="term"><i><tt>options</tt></i>:</span></td>
297<td>a set of <a href="libxml2-schematron.html#xmlSchematronValidOptions">xmlSchematronValidOptions</a>
298</td>
299</tr>
300<tr>
301<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
302<td>the validation context or NULL in case of error</td>
303</tr>
304</tbody>
305</table></div>
306</div>
307<hr>
308<div class="refsect2" lang="en">
309<h3>
310<a name="xmlSchematronParse"></a>xmlSchematronParse ()</h3>
311<pre class="programlisting"><a href="libxml2-schematron.html#xmlSchematronPtr">xmlSchematronPtr</a>	xmlSchematronParse	(<a href="libxml2-schematron.html#xmlSchematronParserCtxtPtr">xmlSchematronParserCtxtPtr</a> ctxt)<br>
312</pre>
313<p>parse a schema definition resource and build an internal XML Schema structure which can be used to validate instances.</p>
314<div class="variablelist"><table border="0">
315<col align="left">
316<tbody>
317<tr>
318<td><span class="term"><i><tt>ctxt</tt></i>:</span></td>
319<td>a schema validation context</td>
320</tr>
321<tr>
322<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
323<td>the internal XML Schematron structure built from the resource or NULL in case of error</td>
324</tr>
325</tbody>
326</table></div>
327</div>
328<hr>
329<div class="refsect2" lang="en">
330<h3>
331<a name="xmlSchematronSetValidStructuredErrors"></a>xmlSchematronSetValidStructuredErrors ()</h3>
332<pre class="programlisting">void	xmlSchematronSetValidStructuredErrors	(<a href="libxml2-schematron.html#xmlSchematronValidCtxtPtr">xmlSchematronValidCtxtPtr</a> ctxt, <br>						 <a href="libxml2-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> serror, <br>						 void * ctx)<br>
333</pre>
334<p>Set the structured error callback</p>
335<div class="variablelist"><table border="0">
336<col align="left">
337<tbody>
338<tr>
339<td><span class="term"><i><tt>ctxt</tt></i>:</span></td>
340<td>a Schematron validation context</td>
341</tr>
342<tr>
343<td><span class="term"><i><tt>serror</tt></i>:</span></td>
344<td>the structured error function</td>
345</tr>
346<tr>
347<td><span class="term"><i><tt>ctx</tt></i>:</span></td>
348<td>the functions context</td>
349</tr>
350</tbody>
351</table></div>
352</div>
353<hr>
354<div class="refsect2" lang="en">
355<h3>
356<a name="xmlSchematronValidateDoc"></a>xmlSchematronValidateDoc ()</h3>
357<pre class="programlisting">int	xmlSchematronValidateDoc	(<a href="libxml2-schematron.html#xmlSchematronValidCtxtPtr">xmlSchematronValidCtxtPtr</a> ctxt, <br>					 <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> instance)<br>
358</pre>
359<p>Validate a tree instance against the schematron</p>
360<div class="variablelist"><table border="0">
361<col align="left">
362<tbody>
363<tr>
364<td><span class="term"><i><tt>ctxt</tt></i>:</span></td>
365<td>the schema validation context</td>
366</tr>
367<tr>
368<td><span class="term"><i><tt>instance</tt></i>:</span></td>
369<td>the document instance tree</td>
370</tr>
371<tr>
372<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
373<td>0 in case of success, -1 in case of internal error and an error count otherwise.</td>
374</tr>
375</tbody>
376</table></div>
377</div>
378<hr>
379</div>
380</div>
381</body>
382</html>
383