You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

662 lines
37 KiB

  1. <?xml version="1.0" standalone="no"?>
  2. <!--
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. -->
  18. <!DOCTYPE s1 SYSTEM "sbk:/style/dtd/document.dtd">
  19. <s1 title="SAX2 Programming Guide">
  20. <anchor name="UsingSAX2API"/>
  21. <s2 title="Using the SAX2 API">
  22. <p>The SAX2 API for XML parsers was originally developed for
  23. Java. Please be aware that there is no standard SAX2 API for
  24. C++, and that use of the &XercesCName; SAX2 API does not
  25. guarantee client code compatibility with other C++ XML
  26. parsers.</p>
  27. <p>The SAX2 API presents a callback based API to the parser. An
  28. application that uses SAX2 provides an instance of a handler
  29. class to the parser. When the parser detects XML constructs,
  30. it calls the methods of the handler class, passing them
  31. information about the construct that was detected. The most
  32. commonly used handler classes are ContentHandler which is
  33. called when XML constructs are recognized, and ErrorHandler
  34. which is called when an error occurs. The header files for the
  35. various SAX2 handler classes are in the <code>xercesc/sax2/</code>
  36. directory.</p>
  37. <p>As a convenience, &XercesCName; provides DefaultHandler,
  38. a single class which is publicly derived
  39. from all the Handler classes. DefaultHandler's default
  40. implementation of the handler callback methods is to do
  41. nothing. A convenient way to get started with &XercesCName; is
  42. to derive your own handler class from DefaultHandler and override
  43. just those methods in HandlerBase which you are interested in
  44. customizing. This simple example shows how to create a handler
  45. which will print element names, and print fatal error
  46. messages. The source code for the sample applications show
  47. additional examples of how to write handler classes.</p>
  48. <p>This is the header file MySAX2Handler.hpp:</p>
  49. <source>#include &lt;xercesc/sax2/DefaultHandler.hpp>
  50. class MySAX2Handler : public DefaultHandler {
  51. public:
  52. void startElement(
  53. const XMLCh* const uri,
  54. const XMLCh* const localname,
  55. const XMLCh* const qname,
  56. const Attributes&amp; attrs
  57. );
  58. void fatalError(const SAXParseException&amp;);
  59. };</source>
  60. <p>This is the implementation file MySAX2Handler.cpp:</p>
  61. <source>#include "MySAX2Handler.hpp"
  62. #include &lt;iostream>
  63. using namespace std;
  64. MySAX2Handler::MySAX2Handler()
  65. {
  66. }
  67. void MySAX2Handler::startElement(const XMLCh* const uri,
  68. const XMLCh* const localname,
  69. const XMLCh* const qname,
  70. const Attributes&amp; attrs)
  71. {
  72. char* message = XMLString::transcode(localname);
  73. cout &lt;&lt; "I saw element: "&lt;&lt; message &lt;&lt; endl;
  74. XMLString::release(&amp;message);
  75. }
  76. void MySAX2Handler::fatalError(const SAXParseException&amp; exception)
  77. {
  78. char* message = XMLString::transcode(exception.getMessage());
  79. cout &lt;&lt; "Fatal Error: " &lt;&lt; message
  80. &lt;&lt; " at line: " &lt;&lt; exception.getLineNumber()
  81. &lt;&lt; endl;
  82. XMLString::release(&amp;message);
  83. }</source>
  84. <p>The XMLCh and Attributes types are supplied by
  85. &XercesCName; and are documented in the API Reference.
  86. Examples of their usage appear in the source code to
  87. the sample applications.</p>
  88. </s2>
  89. <anchor name="SAX2XMLReader"/>
  90. <s2 title="SAX2XMLReader">
  91. <anchor name="ConstructParser2"/>
  92. <s3 title="Constructing an XML Reader">
  93. <p>In order to use &XercesCName; SAX2 to parse XML files, you will
  94. need to create an instance of the SAX2XMLReader class. The example
  95. below shows the code you need in order to create an instance
  96. of SAX2XMLReader. The ContentHandler and ErrorHandler instances
  97. required by the SAX2 API are provided using the DefaultHandler
  98. class supplied with &XercesCName;.</p>
  99. <source>
  100. #include &lt;xercesc/sax2/SAX2XMLReader.hpp>
  101. #include &lt;xercesc/sax2/XMLReaderFactory.hpp>
  102. #include &lt;xercesc/sax2/DefaultHandler.hpp>
  103. #include &lt;xercesc/util/XMLString.hpp>
  104. #include &lt;iostream>
  105. using namespace std;
  106. using namespace xercesc;
  107. int main (int argc, char* args[]) {
  108. try {
  109. XMLPlatformUtils::Initialize();
  110. }
  111. catch (const XMLException&amp; toCatch) {
  112. char* message = XMLString::transcode(toCatch.getMessage());
  113. cout &lt;&lt; "Error during initialization! :\n";
  114. cout &lt;&lt; "Exception message is: \n"
  115. &lt;&lt; message &lt;&lt; "\n";
  116. XMLString::release(&amp;message);
  117. return 1;
  118. }
  119. char* xmlFile = "x1.xml";
  120. SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
  121. parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
  122. parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true); // optional
  123. DefaultHandler* defaultHandler = new DefaultHandler();
  124. parser->setContentHandler(defaultHandler);
  125. parser->setErrorHandler(defaultHandler);
  126. try {
  127. parser->parse(xmlFile);
  128. }
  129. catch (const XMLException&amp; toCatch) {
  130. char* message = XMLString::transcode(toCatch.getMessage());
  131. cout &lt;&lt; "Exception message is: \n"
  132. &lt;&lt; message &lt;&lt; "\n";
  133. XMLString::release(&amp;message);
  134. return -1;
  135. }
  136. catch (const SAXParseException&amp; toCatch) {
  137. char* message = XMLString::transcode(toCatch.getMessage());
  138. cout &lt;&lt; "Exception message is: \n"
  139. &lt;&lt; message &lt;&lt; "\n";
  140. XMLString::release(&amp;message);
  141. return -1;
  142. }
  143. catch (...) {
  144. cout &lt;&lt; "Unexpected Exception \n" ;
  145. return -1;
  146. }
  147. delete parser;
  148. delete defaultHandler;
  149. return 0;
  150. }</source>
  151. </s3>
  152. <anchor name="SAX2Features"/>
  153. <s3 title="Supported Features in SAX2XMLReader">
  154. <p>The behavior of the SAX2XMLReader is dependant on the values of the following features.
  155. All of the features below can be set using the function <code>SAX2XMLReader::setFeature(cons XMLCh* const, const bool)</code>.
  156. And can be queried using the function <code>bool SAX2XMLReader::getFeature(const XMLCh* const)</code>.
  157. </p>
  158. <p>None of these features can be modified in the middle of a parse, or an exception will be thrown.</p>
  159. <s4 title="SAX2 Features">
  160. <anchor name="namespaces"/>
  161. <table>
  162. <tr><th colspan="2"><em>http://xml.org/sax/features/namespaces</em></th></tr>
  163. <tr><th><em>true:</em></th><td> Perform Namespace processing. </td></tr>
  164. <tr><th><em>false:</em></th><td> Do not perform Namespace processing. </td></tr>
  165. <tr><th><em>default:</em></th><td> true </td></tr>
  166. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgSAX2CoreNameSpaces </td></tr>
  167. <tr><th><em>note:</em></th><td> If the validation feature is set to true, then the
  168. document must contain a grammar that supports the use of namespaces. </td></tr>
  169. <tr><th><em>see:</em></th><td>
  170. <link anchor="namespace-prefixes">http://xml.org/sax/features/namespace-prefixes </link>
  171. </td></tr>
  172. <tr><th><em>see:</em></th><td>
  173. <link anchor="validation">http://xml.org/sax/features/validation</link>
  174. </td></tr>
  175. </table>
  176. <p/>
  177. <anchor name="namespace-prefixes"/>
  178. <table>
  179. <tr><th colspan="2"><em>http://xml.org/sax/features/namespace-prefixes</em></th></tr>
  180. <tr><th><em>true:</em></th><td> Report the original prefixed names and attributes used for Namespace declarations. </td></tr>
  181. <tr><th><em>false:</em></th><td> Do not report attributes used for Namespace declarations, and optionally do not report original prefixed names. </td></tr>
  182. <tr><th><em>default:</em></th><td> false </td></tr>
  183. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgSAX2CoreNameSpacePrefixes </td></tr>
  184. </table>
  185. <p/>
  186. <anchor name="validation"/>
  187. <table>
  188. <tr><th colspan="2"><em>http://xml.org/sax/features/validation</em></th></tr>
  189. <tr><th><em>true:</em></th><td> Report all validation errors. </td></tr>
  190. <tr><th><em>false:</em></th><td> Do not report validation errors. </td></tr>
  191. <tr><th><em>default:</em></th><td> false </td></tr>
  192. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgSAX2CoreValidation </td></tr>
  193. <tr><th><em>note:</em></th><td> If this feature is set to true, the document must
  194. specify a grammar. If this feature is set to false and document specifies a grammar,
  195. that grammar might be parsed but no validation of the document contents will be
  196. performed. </td></tr>
  197. <tr><th><em>see:</em></th><td>
  198. <link anchor="validation-dynamic">http://apache.org/xml/features/validation/dynamic</link>
  199. </td></tr>
  200. <tr><th><em>see:</em></th><td>
  201. <link anchor="load-external-dtd">http://apache.org/xml/features/nonvalidating/load-external-dtd</link>
  202. </td></tr>
  203. </table>
  204. </s4>
  205. <s4 title="Xerces Features">
  206. <anchor name="validation-dynamic"/>
  207. <table>
  208. <tr><th colspan="2"><em>http://apache.org/xml/features/validation/dynamic</em></th></tr>
  209. <tr><th><em>true:</em></th><td> The parser will validate the document only if a grammar is specified. (http://xml.org/sax/features/validation must be true). </td></tr>
  210. <tr><th><em>false:</em></th><td> Validation is determined by the state of the http://xml.org/sax/features/validation feature. </td></tr>
  211. <tr><th><em>default:</em></th><td> false </td></tr>
  212. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesDynamic </td></tr>
  213. <tr><th><em>see:</em></th><td>
  214. <link anchor="validation">http://xml.org/sax/features/validation</link>
  215. </td></tr>
  216. </table>
  217. <p/>
  218. <anchor name="schema"/>
  219. <table>
  220. <tr><th colspan="2"><em>http://apache.org/xml/features/validation/schema</em></th></tr>
  221. <tr><th><em>true:</em></th><td> Enable the parser's schema support. </td></tr>
  222. <tr><th><em>false:</em></th><td> Disable the parser's schema support. </td></tr>
  223. <tr><th><em>default:</em></th><td> true </td></tr>
  224. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesSchema </td></tr>
  225. <tr><th><em>note</em></th><td> If set to true, namespace processing must also be turned on. </td></tr>
  226. <tr><th><em>see:</em></th><td>
  227. <link anchor="namespaces">http://xml.org/sax/features/namespaces</link>
  228. </td></tr>
  229. </table>
  230. <p/>
  231. <table>
  232. <tr><th colspan="2"><em>http://apache.org/xml/features/validation/schema-full-checking</em></th></tr>
  233. <tr><th><em>true:</em></th><td> Enable full schema constraint checking, including checking
  234. which may be time-consuming or memory intensive. Currently, particle unique
  235. attribution constraint checking and particle derivation restriction checking
  236. are controlled by this option. </td></tr>
  237. <tr><th><em>false:</em></th><td> Disable full schema constraint checking. </td></tr>
  238. <tr><th><em>default:</em></th><td> false </td></tr>
  239. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesSchemaFullChecking </td></tr>
  240. <tr><th><em>note:</em></th><td> This feature checks the schema grammar itself for
  241. additional errors that are time-consuming or memory intensive. It does <em>not</em> affect the
  242. level of checking performed on document instances that use schema grammars. </td></tr>
  243. <tr><th><em>see:</em></th><td>
  244. <link anchor="schema">http://apache.org/xml/features/validation/schema</link>
  245. </td></tr>
  246. </table>
  247. <p/>
  248. <anchor name="load-schema"/>
  249. <table>
  250. <tr><th colspan="2"><em>http://apache.org/xml/features/validating/load-schema</em></th></tr>
  251. <tr><th><em>true:</em></th><td> Load the schema. </td></tr>
  252. <tr><th><em>false:</em></th><td> Don't load the schema if it wasn't found in the grammar pool. </td></tr>
  253. <tr><th><em>default:</em></th><td> true </td></tr>
  254. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesLoadSchema </td></tr>
  255. <tr><th><em>note:</em></th><td> This feature is ignored and no schemas are loaded if schema processing is disabled. </td></tr>
  256. <tr><th><em>see:</em></th><td>
  257. <link anchor="schema">http://apache.org/xml/features/validation/schema</link>
  258. </td></tr>
  259. </table>
  260. <p/>
  261. <anchor name="load-external-dtd"/>
  262. <table>
  263. <tr><th colspan="2"><em>http://apache.org/xml/features/nonvalidating/load-external-dtd</em></th></tr>
  264. <tr><th><em>true:</em></th><td> Load the external DTD. </td></tr>
  265. <tr><th><em>false:</em></th><td> Ignore the external DTD completely. </td></tr>
  266. <tr><th><em>default:</em></th><td> true </td></tr>
  267. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesLoadExternalDTD </td></tr>
  268. <tr><th><em>note</em></th><td> This feature is ignored and DTD is always loaded when validation is on. </td></tr>
  269. <tr><th><em>see:</em></th><td>
  270. <link anchor="validation">http://xml.org/sax/features/validation</link>
  271. </td></tr>
  272. </table>
  273. <p/>
  274. <anchor name="continue-after-fatal"/>
  275. <table>
  276. <tr><th colspan="2"><em>http://apache.org/xml/features/continue-after-fatal-error</em></th></tr>
  277. <tr><th><em>true:</em></th><td> Attempt to continue parsing after a fatal error. </td></tr>
  278. <tr><th><em>false:</em></th><td> Stops parse on first fatal error. </td></tr>
  279. <tr><th><em>default:</em></th><td> false </td></tr>
  280. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesContinueAfterFatalError </td></tr>
  281. <tr><th><em>note:</em></th><td> The behavior of the parser when this feature is set to
  282. true is <em>undetermined</em>! Therefore use this feature with extreme caution because
  283. the parser may get stuck in an infinite loop or worse. </td></tr>
  284. </table>
  285. <p/>
  286. <table>
  287. <tr><th colspan="2"><em>http://apache.org/xml/features/validation-error-as-fatal</em></th></tr>
  288. <tr><th><em>true:</em></th><td> The parser will treat validation error as fatal and will
  289. exit depends on the state of
  290. <link anchor="continue-after-fatal">http://apache.org/xml/features/continue-after-fatal-error</link>.
  291. </td></tr>
  292. <tr><th><em>false:</em></th><td> The parser will report the error and continue processing. </td></tr>
  293. <tr><th><em>default:</em></th><td> false </td></tr>
  294. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesValidationErrorAsFatal </td></tr>
  295. <tr><th><em>note:</em></th><td> Setting this true does not mean the validation error will
  296. be printed with the word "Fatal Error". It is still printed as "Error", but the parser
  297. will exit if
  298. <link anchor="continue-after-fatal">http://apache.org/xml/features/continue-after-fatal-error</link>
  299. is set to false. </td></tr>
  300. <tr><th><em>see:</em></th><td>
  301. <link anchor="continue-after-fatal">http://apache.org/xml/features/continue-after-fatal-error</link>
  302. </td></tr>
  303. </table>
  304. <p/>
  305. <anchor name="use-cached"/>
  306. <table>
  307. <tr><th colspan="2"><em>http://apache.org/xml/features/validation/use-cachedGrammarInParse</em></th></tr>
  308. <tr><th><em>true:</em></th><td>Use cached grammar if it exists in the pool.</td></tr>
  309. <tr><th><em>false:</em></th><td>Parse the schema grammar.</td></tr>
  310. <tr><th><em>default:</em></th><td> false </td></tr>
  311. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesUseCachedGrammarInParse </td></tr>
  312. <tr><th><em>note:</em></th><td>If http://apache.org/xml/features/validation/cache-grammarFromParse is enabled,
  313. this feature is set to true automatically and any setting to this feature by the user is a no-op.</td></tr>
  314. <tr><th><em>see:</em></th><td>
  315. <link anchor="cache-grammar">http://apache.org/xml/features/validation/cache-grammarFromParse</link>
  316. </td></tr>
  317. </table>
  318. <p/>
  319. <anchor name="cache-grammar"/>
  320. <table>
  321. <tr><th colspan="2"><em>http://apache.org/xml/features/validation/cache-grammarFromParse</em></th></tr>
  322. <tr><th><em>true:</em></th><td>Cache the grammar in the pool for re-use in subsequent parses.</td></tr>
  323. <tr><th><em>false:</em></th><td>Do not cache the grammar in the pool</td></tr>
  324. <tr><th><em>default:</em></th><td> false </td></tr>
  325. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesCacheGrammarFromParse </td></tr>
  326. <tr><th><em>note:</em></th><td> If set to true, the http://apache.org/xml/features/validation/use-cachedGrammarInParse
  327. is also set to true automatically.</td></tr>
  328. <tr><th><em>see:</em></th><td>
  329. <link anchor="use-cached">http://apache.org/xml/features/validation/use-cachedGrammarInParse</link>
  330. </td></tr>
  331. </table>
  332. <p/>
  333. <anchor name="StandardUriConformant"/>
  334. <table>
  335. <tr><th colspan="2"><em>http://apache.org/xml/features/standard-uri-conformant</em></th></tr>
  336. <tr><th><em>true:</em></th><td> Force standard uri conformance. </td></tr>
  337. <tr><th><em>false:</em></th><td> Do not force standard uri conformance. </td></tr>
  338. <tr><th><em>default:</em></th><td> false </td></tr>
  339. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesStandardUriConformant </td></tr>
  340. <tr><th><em>note:</em></th><td> If set to true, malformed uri will be rejected
  341. and fatal error will be issued. </td></tr>
  342. </table>
  343. <p/>
  344. <anchor name="CalculateSrcOffset"/>
  345. <table>
  346. <tr><th colspan="2"><em>http://apache.org/xml/features/calculate-src-ofs</em></th></tr>
  347. <tr><th><em>true:</em></th><td> Enable src offset calculation. </td></tr>
  348. <tr><th><em>false:</em></th><td> Disable src offset calculation. </td></tr>
  349. <tr><th><em>default:</em></th><td> false </td></tr>
  350. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesCalculateSrcOfs </td></tr>
  351. <tr><th><em>note:</em></th><td> If set to true, the user can inquire about
  352. the current src offset within the input source. Setting it to false (default)
  353. improves the performance.</td></tr>
  354. </table>
  355. <p/>
  356. <anchor name="IdentityConstraintChecking"/>
  357. <table>
  358. <tr><th colspan="2"><em>http://apache.org/xml/features/validation/identity-constraint-checking</em></th></tr>
  359. <tr><th><em>true:</em></th><td> Enable identity constraint checking. </td></tr>
  360. <tr><th><em>false:</em></th><td> Disable identity constraint checking. </td></tr>
  361. <tr><th><em>default:</em></th><td> true </td></tr>
  362. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesIdentityConstraintChecking </td></tr>
  363. </table>
  364. <p/>
  365. <anchor name="GenerateSyntheticAnnotations"/>
  366. <table>
  367. <tr><th colspan="2"><em>http://apache.org/xml/features/generate-synthetic-annotations</em></th></tr>
  368. <tr><th><em>true:</em></th><td> Enable generation of synthetic annotations. A synthetic annotation will be
  369. generated when a schema component has non-schema attributes but no child annotation. </td></tr>
  370. <tr><th><em>false:</em></th><td> Disable generation of synthetic annotations. </td></tr>
  371. <tr><th><em>default:</em></th><td> false </td></tr>
  372. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesGenerateSyntheticAnnotations </td></tr>
  373. </table>
  374. <p/>
  375. <anchor name="XercesValidateAnnotations"/>
  376. <table>
  377. <tr><th colspan="2"><em>http://apache.org/xml/features/validate-annotations</em></th></tr>
  378. <tr><th><em>true:</em></th><td> Enable validation of annotations. </td></tr>
  379. <tr><th><em>false:</em></th><td> Disable validation of annotations. </td></tr>
  380. <tr><th><em>default:</em></th><td> false </td></tr>
  381. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesValidateAnnotations </td></tr>
  382. <tr><th><em>note:</em></th><td> Each annotation is validated independently. </td></tr>
  383. </table>
  384. <p/>
  385. <anchor name="IgnoreAnnotations"/>
  386. <table>
  387. <tr><th colspan="2"><em>http://apache.org/xml/features/schema/ignore-annotations</em></th></tr>
  388. <tr><th><em>true:</em></th><td> Do not generate XSAnnotations when traversing a schema.</td></tr>
  389. <tr><th><em>false:</em></th><td> Generate XSAnnotations when traversing a schema.</td></tr>
  390. <tr><th><em>default:</em></th><td> false </td></tr>
  391. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesIgnoreAnnotations </td></tr>
  392. </table>
  393. <p/>
  394. <anchor name="DisableDefaultEntityResolution"/>
  395. <table>
  396. <tr><th colspan="2"><em>http://apache.org/xml/features/disable-default-entity-resolution</em></th></tr>
  397. <tr><th><em>true:</em></th><td> The parser will not attempt to resolve the entity when the resolveEntity method returns NULL.</td></tr>
  398. <tr><th><em>false:</em></th><td> The parser will attempt to resolve the entity when the resolveEntity method returns NULL.</td></tr>
  399. <tr><th><em>default:</em></th><td> false </td></tr>
  400. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesDisableDefaultEntityResolution </td></tr>
  401. </table>
  402. <p/>
  403. <anchor name="SkipDTDValidation"/>
  404. <table>
  405. <tr><th colspan="2"><em>http://apache.org/xml/features/validation/schema/skip-dtd-validation</em></th></tr>
  406. <tr><th><em>true:</em></th><td> When schema validation is on the parser will ignore the DTD, except for entities.</td></tr>
  407. <tr><th><em>false:</em></th><td> The parser will not ignore DTDs when validating.</td></tr>
  408. <tr><th><em>default:</em></th><td> false </td></tr>
  409. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesSkipDTDValidation </td></tr>
  410. <tr><th><em>see:</em></th><td>
  411. <link anchor="schema">Schema Validation</link></td></tr>
  412. </table>
  413. <p/>
  414. <anchor name="IgnoreCachedDTD"/>
  415. <table>
  416. <tr><th colspan="2"><em>http://apache.org/xml/features/validation/ignoreCachedDTD</em></th></tr>
  417. <tr><th><em>true:</em></th><td> Ignore a cached DTD when an XML document contains both an
  418. internal and external DTD, and the use cached grammar from parse option
  419. is enabled. Currently, we do not allow using cached DTD grammar when an
  420. internal subset is present in the document. This option will only affect
  421. the behavior of the parser when an internal and external DTD both exist
  422. in a document (i.e. no effect if document has no internal subset).</td></tr>
  423. <tr><th><em>false:</em></th><td> Don't ignore cached DTD. </td></tr>
  424. <tr><th><em>default:</em></th><td> false </td></tr>
  425. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesIgnoreCachedDTD </td></tr>
  426. <tr><th><em>see:</em></th><td>
  427. <link anchor="use-cached">http://apache.org/xml/features/validation/use-cachedGrammarInParse</link>
  428. </td></tr>
  429. </table>
  430. <p/>
  431. <anchor name="HandleMultipleImports"/>
  432. <table>
  433. <tr><th colspan="2"><em>http://apache.org/xml/features/validation/schema/handle-multiple-imports</em></th></tr>
  434. <tr><th><em>true:</em></th><td> During schema validation allow multiple schemas with the same namespace
  435. to be imported.</td></tr>
  436. <tr><th><em>false:</em></th><td> Don't import multiple schemas with the same namespace. </td></tr>
  437. <tr><th><em>default:</em></th><td> false </td></tr>
  438. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesHandleMultipleImports </td></tr>
  439. </table>
  440. <p/>
  441. </s4>
  442. </s3>
  443. <anchor name="SAX2Properties"/>
  444. <s3 title="Supported Properties in SAX2XMLReader">
  445. <p>The behavior of the SAX2XMLReader is dependant on the values of the following properties.
  446. All of the properties below can be set using the function <code>SAX2XMLReader::setProperty(const XMLCh* const, void*)</code>.
  447. It takes a void pointer as the property value. Application is required to initialize this void
  448. pointer to a correct type. Please check the column "Value Type" below
  449. to learn exactly what type of property value each property expects for processing.
  450. Passing a void pointer that was initialized with a wrong type will lead to unexpected result.
  451. If the same property is set more than once, the last one takes effect.</p>
  452. <p>Property values can be queried using the function <code>void* SAX2XMLReader::getProperty(const XMLCh* const)</code>.
  453. The parser owns the returned pointer, and the memory allocated for the returned pointer will
  454. be destroyed when the parser is deleted. To ensure accessibility of the returned information after
  455. the parser is deleted, callers need to copy and store the returned information somewhere else.
  456. Since the returned pointer is a generic void pointer, check the column "Value Type" below to learn
  457. exactly what type of object each property returns for replication.</p>
  458. <p>None of these properties can be modified in the middle of a parse, or an exception will be thrown.</p>
  459. <s4 title="Xerces Properties">
  460. <table>
  461. <tr><th colspan="2"><em>http://apache.org/xml/properties/schema/external-schemaLocation</em></th></tr>
  462. <tr><th><em>Description</em></th><td> The XML Schema Recommendation explicitly states that
  463. the inclusion of schemaLocation/ noNamespaceSchemaLocation attributes in the
  464. instance document is only a hint; it does not mandate that these attributes
  465. must be used to locate schemas. Similar situation happens to &lt;import&gt;
  466. element in schema documents. This property allows the user to specify a list
  467. of schemas to use. If the targetNamespace of a schema specified using this
  468. method matches the targetNamespace of a schema occurring in the instance
  469. document in schemaLocation attribute, or
  470. if the targetNamespace matches the namespace attribute of &lt;import&gt;
  471. element, the schema specified by the user using this property will
  472. be used (i.e., the schemaLocation attribute in the instance document
  473. or on the &lt;import&gt; element will be effectively ignored). </td></tr>
  474. <tr><th><em>Value</em></th><td> The syntax is the same as for schemaLocation attributes
  475. in instance documents: e.g, "http://www.example.com file_name.xsd".
  476. The user can specify more than one XML Schema in the list. </td></tr>
  477. <tr><th><em>Value Type</em></th><td> XMLCh* </td></tr>
  478. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesSchemaExternalSchemaLocation </td></tr>
  479. </table>
  480. <p/>
  481. <table>
  482. <tr><th colspan="2"><em>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation</em></th></tr>
  483. <tr><th><em>Description</em></th><td> The XML Schema Recommendation explicitly states that
  484. the inclusion of schemaLocation/ noNamespaceSchemaLocation attributes in the
  485. instance document is only a hint; it does not mandate that these attributes
  486. must be used to locate schemas. This property allows the user to specify the
  487. no target namespace XML Schema Location externally. If specified, the instance
  488. document's noNamespaceSchemaLocation attribute will be effectively ignored. </td></tr>
  489. <tr><th><em>Value</em></th><td> The syntax is the same as for the noNamespaceSchemaLocation
  490. attribute that may occur in an instance document: e.g."file_name.xsd". </td></tr>
  491. <tr><th><em>Value Type</em></th><td> XMLCh* </td></tr>
  492. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesSchemaExternalNoNameSpaceSchemaLocation </td></tr>
  493. </table>
  494. <p/>
  495. <table>
  496. <tr><th colspan="2"><em>http://apache.org/xml/properties/scannerName</em></th></tr>
  497. <tr><th><em>Description</em></th><td> This property allows the user to specify the name of
  498. the XMLScanner to use for scanning XML documents. If not specified, the default
  499. scanner "IGXMLScanner" is used.</td></tr>
  500. <tr><th><em>Value</em></th><td> The recognized scanner names are: <br/>
  501. 1."WFXMLScanner" - scanner that performs well-formedness checking only.<br/>
  502. 2. "DGXMLScanner" - scanner that handles XML documents with DTD grammar information.<br/>
  503. 3. "SGXMLScanner" - scanner that handles XML documents with XML schema grammar information.<br/>
  504. 4. "IGXMLScanner" - scanner that handles XML documents with DTD or/and XML schema grammar information.<br/>
  505. Users can use the predefined constants defined in XMLUni directly (fgWFXMLScanner, fgDGXMLScanner,
  506. fgSGXMLScanner, or fgIGXMLScanner) or a string that matches the value of
  507. one of those constants.</td></tr>
  508. <tr><th><em>Value Type</em></th><td> XMLCh* </td></tr>
  509. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesScannerName </td></tr>
  510. <tr><th><em>note: </em></th><td> See <jump href="program-others-&XercesC3Series;.html#UseSpecificScanner">Use Specific Scanner</jump>
  511. for more programming details. </td></tr>
  512. </table>
  513. <p/>
  514. <table>
  515. <tr><th colspan="2"><em>http://apache.org/xml/properties/security-manager</em></th></tr>
  516. <tr><th><em>Description</em></th>
  517. <td>
  518. Certain valid XML and XML Schema constructs can force a
  519. processor to consume more system resources than an
  520. application may wish. In fact, certain features could
  521. be exploited by malicious document writers to produce a
  522. denial-of-service attack. This property allows
  523. applications to impose limits on the amount of
  524. resources the processor will consume while processing
  525. these constructs.
  526. </td></tr>
  527. <tr><th><em>Value</em></th>
  528. <td>
  529. An instance of the SecurityManager class (see
  530. <code>xercesc/util/SecurityManager</code>). This
  531. class's documentation describes the particular limits
  532. that may be set. Note that, when instantiated, default
  533. values for limits that should be appropriate in most
  534. settings are provided. The default implementation is
  535. not thread-safe; if thread-safety is required, the
  536. application should extend this class, overriding
  537. methods appropriately. The parser will not adopt the
  538. SecurityManager instance; the application is
  539. responsible for deleting it when it is finished with
  540. it. If no SecurityManager instance has been provided to
  541. the parser (the default) then processing strictly
  542. conforming to the relevant specifications will be
  543. performed.
  544. </td></tr>
  545. <tr><th><em>Value Type</em></th><td> SecurityManager* </td></tr>
  546. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesSecurityManager </td></tr>
  547. </table>
  548. <p/>
  549. <table>
  550. <tr><th
  551. colspan="2"><em>http://apache.org/xml/properties/low-water-mark</em></th></tr>
  552. <tr><th><em>Description</em></th>
  553. <td>
  554. If the number of available bytes in the raw buffer is less than
  555. the low water mark the parser will attempt to read more data before
  556. continuing parsing. By default the value for this parameter is 100
  557. bytes. You may want to set this parameter to 0 if you would like
  558. the parser to parse the available data immediately without
  559. potentially blocking while waiting for more date.
  560. </td></tr>
  561. <tr><th><em>Value</em></th>
  562. <td>
  563. New low water mark.
  564. </td></tr>
  565. <tr><th><em>Value Type</em></th><td> XMLSize_t* </td></tr>
  566. <tr><th><em>XMLUni Predefined Constant:</em></th><td> fgXercesLowWaterMark </td></tr>
  567. </table>
  568. <p/>
  569. <table>
  570. <tr><th
  571. colspan="2"><em>setInputBufferSize(const size_t bufferSize)</em></th></tr>
  572. <tr><th><em>Description</em></th>
  573. <td>
  574. Set maximum input buffer size.
  575. This method allows users to limit the size of buffers used in parsing
  576. XML character data. The effect of setting this size is to limit the
  577. size of a ContentHandler::characters() call.
  578. The parser's default input buffer size is 1 megabyte.
  579. </td></tr>
  580. <tr><th><em>Value</em></th>
  581. <td>
  582. The maximum input buffer size
  583. </td></tr>
  584. <tr><th><em>Value Type</em></th><td> XMLCh* </td></tr>
  585. </table>
  586. <p/>
  587. </s4>
  588. </s3>
  589. </s2>
  590. </s1>