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.

608 lines
26 KiB

  1. <?xml version="1.0" encoding = "iso-8859-1" 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 faqs SYSTEM "sbk:/style/dtd/faqs.dtd">
  19. <faqs title="Programming &XercesCName;">
  20. <faq title="Does &XercesCName; support XML Schema?">
  21. <q> Does &XercesCName; support Schema?</q>
  22. <a>
  23. <p>Yes, &XercesCName; &XercesC3Version; contains an implementation
  24. of the W3C XML Schema Language, a recommendation of the Worldwide Web Consortium
  25. available in three parts:
  26. <jump href="http://www.w3.org/TR/xmlschema-0/">XML Schema: Primer</jump> and
  27. <jump href="http://www.w3.org/TR/xmlschema-1/">XML Schema: Structures</jump> and
  28. <jump href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</jump>.
  29. We consider this implementation complete. See the
  30. <jump href="schema-&XercesC3Series;.html#limitation">XML Schema Support</jump> page for limitations.</p>
  31. </a>
  32. </faq>
  33. <faq title="Does &XercesCName; support XPath?">
  34. <q> Does &XercesCName; support XPath?</q>
  35. <a>
  36. <p>&XercesCName; &XercesC3Version; provides partial XPath 1 implementation
  37. for the purposes of handling XML Schema identity constraints.
  38. The same engine is made available through the DOMDocument::evaluate API to
  39. let the user perform simple XPath queries involving DOMElement nodes only,
  40. with no predicate testing and allowing the "//" operator only as the initial
  41. step. For full XPath 1 and 2 support refer to the
  42. <jump href="http://xqilla.sourceforge.net">XQilla</jump> and
  43. <jump href="http://xml.apache.org/xalan-c/overview.html">Apache Xalan C++</jump>
  44. open source projects.
  45. </p>
  46. </a>
  47. </faq>
  48. <faq title="Why does my application crash when instantiating the parser?">
  49. <q>Why does my application crash when instantiating the parser?</q>
  50. <a>
  51. <p>In order to work with the &XercesCName; parser, you have to first
  52. initialize the XML subsystem. The most common mistake is to forget this
  53. initialization. Before you make any calls to &XercesCName; APIs, you must
  54. call XMLPlatformUtils::Initialize(): </p>
  55. <source>
  56. try {
  57. XMLPlatformUtils::Initialize();
  58. }
  59. catch (const XMLException&amp; toCatch) {
  60. // Do your failure processing here
  61. }</source>
  62. <p>This initializes the &XercesCProjectName; system and sets its internal
  63. variables. Note that you must include the <code>xercesc/util/PlatformUtils.hpp</code> file for this to work.</p>
  64. </a>
  65. </faq>
  66. <faq title="Is it OK to call the XMLPlatformUtils::Initialize/Terminate pair of routines multiple times in one program?">
  67. <q>Is it OK to call the XMLPlatformUtils::Initialize/Terminate pair of routines multiple times in one program?</q>
  68. <a>
  69. <p>Yes. Note, however, that the application needs to guarantee that the
  70. XMLPlatformUtils::Initialize() and XMLPlatformUtils::Terminate()
  71. methods are called from the same thread (usually the initial
  72. thread executing main()) or proper synchronization is performed
  73. by the application if multiple threads call
  74. XMLPlatformUtils::Initialize() and XMLPlatformUtils::Terminate()
  75. concurrently.</p>
  76. <p>If you are calling XMLPlatformUtils::Initialize() a number of times, and then follow with
  77. XMLPlatformUtils::Terminate() the same number of times, only the first XMLPlatformUtils::Initialize()
  78. will do the initialization, and only the last XMLPlatformUtils::Terminate() will clean up
  79. the memory. The other calls are ignored.
  80. </p>
  81. </a>
  82. </faq>
  83. <faq title="Why does my application crash after calling XMLPlatformUtils::Terminate()?">
  84. <q>Why does my application crash after calling XMLPlatformUtils::Terminate()?</q>
  85. <a>
  86. <p>Please make sure the XMLPlatformUtils::Terminate() is the last &XercesCName; function to be called
  87. in your program. NO explicit nor implicit &XercesCName; destructor (those local data that are
  88. destructed when going out of scope) should be called after XMLPlatformUtils::Terminate().
  89. </p>
  90. <p>
  91. For example consider the following code snippet which is incorrect:
  92. </p>
  93. <source>
  94. 1: {
  95. 2: XMLPlatformUtils::Initialize();
  96. 3: XercesDOMParser parser;
  97. 4: XMLPlatformUtils::Terminate();
  98. 5: }
  99. </source>
  100. <p>The XercesDOMParser object "parser" is destructed when going out of scope at line 5 before the closing
  101. brace. As a result, XercesDOMParser destructor is called at line 5 after
  102. XMLPlatformUtils::Terminate() which is incorrect. Correct code should be:
  103. </p>
  104. <source>
  105. 1: {
  106. 2: XMLPlatformUtils::Initialize();
  107. 2a: {
  108. 3: XercesDOMParser parser;
  109. 3a: }
  110. 4: XMLPlatformUtils::Terminate();
  111. 5: }
  112. </source>
  113. <p>The extra pair of braces (line 2a and 3a) ensures that all implicit destructors are called
  114. before terminating &XercesCName;.</p>
  115. <p>Note also that the application needs to guarantee that the
  116. XMLPlatformUtils::Initialize() and XMLPlatformUtils::Terminate()
  117. methods are called from the same thread (usually the initial
  118. thread executing main()) or proper synchronization is performed
  119. by the application if multiple threads call
  120. XMLPlatformUtils::Initialize() and XMLPlatformUtils::Terminate()
  121. concurrently.</p>
  122. </a>
  123. </faq>
  124. <faq title="Is &XercesCName; thread-safe?">
  125. <q>Is &XercesCName; thread-safe?</q>
  126. <a>
  127. <p>The answer is yes if you observe the following rules for using
  128. &XercesCName; in a multi-threaded environment:</p>
  129. <p>Within an address space, an instance of the parser may be used without
  130. restriction from a single thread, or an instance of the parser can be accessed
  131. from multiple threads, provided the application guarantees that only one thread
  132. has entered a method of the parser at any one time.</p>
  133. <p>When two or more parser instances exist in a process, the instances can
  134. be used concurrently, without external synchronization. That is, in an
  135. application containing two parsers and two threads, one parser can be running
  136. within the first thread concurrently with the second parser running within the
  137. second thread.</p>
  138. <p>The same rules apply to &XercesCName; DOM documents. Multiple document
  139. instances may be concurrently accessed from different threads, but any given
  140. document instance can only be accessed by one thread at a time.</p>
  141. <p>The application also needs to guarantee that the
  142. XMLPlatformUtils::Initialize() and XMLPlatformUtils::Terminate()
  143. methods are called from the same thread (usually the initial
  144. thread executing main()) or proper synchronization is performed
  145. by the application if multiple threads call
  146. XMLPlatformUtils::Initialize() and XMLPlatformUtils::Terminate()
  147. concurrently.</p>
  148. </a>
  149. </faq>
  150. <faq title="I am seeing memory leaks in &XercesCName;. Are they real?">
  151. <q>I am seeing memory leaks in &XercesCName;. Are they real?</q>
  152. <a>
  153. <p>The &XercesCName; library allocates and caches some commonly reused
  154. items. The storage for these may be reported as memory leaks by some heap
  155. analysis tools; to avoid the problem, call the function <code>XMLPlatformUtils::Terminate()</code> before your application exits. This will free all memory that was being
  156. held by the library.</p>
  157. <p>For most applications, the use of <code>Terminate()</code> is optional. The system will recover all memory when the application
  158. process shuts down. The exception to this is the use of &XercesCName; from DLLs
  159. that will be repeatedly loaded and unloaded from within the same process. To
  160. avoid memory leaks with this kind of use, <code>Terminate()</code> must be called before unloading the &XercesCName; library</p>
  161. <p>To ensure all the memory held by the parser are freed, the number of XMLPlatformUtils::Terminate() calls
  162. should match the number of XMLPlatformUtils::Initialize() calls.
  163. </p>
  164. <p>If you have built &XercesCName; with dependency on ICU then you may
  165. want to call the u_cleanup() ICU function to clean up
  166. ICU static data. Refer to the ICU documentation for details.
  167. </p>
  168. </a>
  169. </faq>
  170. <faq title="Can &XercesCName; create an XML skeleton based on a DTD">
  171. <q>Is there a function that creates an XML file from a DTD (obviously
  172. with the values missing, a skeleton)?</q>
  173. <a>
  174. <p>No, there is no such functionality.</p>
  175. </a>
  176. </faq>
  177. <faq title="Can I use &XercesCName; to perform write validation">
  178. <q>Can I use &XercesCName; to perform "write validation"? That is, having an
  179. appropriate Grammar and being able to add elements to the DOM whilst validating
  180. against the grammar?</q>
  181. <a>
  182. <p>No, there is no such functionality.</p>
  183. <p>The best you can do for now is to create the DOM document, write it back
  184. as XML and re-parse it with validation turned on.</p>
  185. </a>
  186. </faq>
  187. <faq title="Can I validate the data contained in a DOM tree?">
  188. <q>Is there a facility in &XercesCName; to validate the data contained in a
  189. DOM tree? That is, without saving and re-parsing the source document?</q>
  190. <a>
  191. <p>No, there is no such functionality. The best you can do for now is to create the DOM document, write it back
  192. as XML and re-parse it with validation turned on.</p>
  193. </a>
  194. </faq>
  195. <faq title="How to write out a DOM tree into a string or an XML file?">
  196. <q>How to write out a DOM tree into a string or an XML file?</q>
  197. <a>
  198. <p>You can use
  199. the DOMLSSerializer::writeToString, or DOMLSSerializer::writeNode to serialize a DOM tree.
  200. Please refer to the sample DOMPrint or the API documentation for more details of
  201. DOMLSSerializer.</p>
  202. </a>
  203. </faq>
  204. <faq title="Why doesn't DOMNode::cloneNode() clone the pointer assigned to a DOMNode via DOMNode::setUserData()?">
  205. <q>Why doesn't DOMNode::cloneNode() clone the pointer assigned to a DOMNode via DOMNode::setUserData()?</q>
  206. <a>
  207. <p>&XercesCName; supports the DOMNode::userData specified
  208. in <jump href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-3A0ED0A4">
  209. the DOM level 3 Node interface</jump>. As
  210. is made clear in the description of the behavior of
  211. <code>cloneNode()</code>, userData that has been set on the
  212. Node is not cloned. Thus, if the userData is to be copied
  213. to the new Node, this copy must be effected manually.
  214. Note further that the operation of <code>importNode()</code>
  215. is specified similarly.
  216. </p>
  217. </a>
  218. </faq>
  219. <faq title="How are entity reference nodes handled in DOM?">
  220. <q>How are entity reference nodes handled in DOM?</q>
  221. <a>
  222. <p>If you are using the native DOM classes, the function <code>setCreateEntityReferenceNodes</code>
  223. controls how entities appear in the DOM tree. When
  224. setCreateEntityReferenceNodes is set to true (the default), an occurrence of an
  225. entity reference in the XML document will be represented by a subtree with an
  226. EntityReference node at the root whose children represent the entity expansion.
  227. Entity expansion will be a DOM tree representing the structure of the entity
  228. expansion, not a text node containing the entity expansion as text.</p>
  229. <p>If setCreateEntityReferenceNodes is false, an entity reference in the XML
  230. document is represented by only the nodes that represent the entity expansion.
  231. The DOM tree will not contain any entityReference nodes.</p>
  232. </a>
  233. </faq>
  234. <faq title="Can I use &XercesCName; to parse HTML?">
  235. <q>Can I use &XercesCName; to parse HTML?</q>
  236. <a>
  237. <p>Yes, but only if the HTML follows the rules given in the
  238. <jump href="http://www.w3.org/TR/REC-xml">XML specification</jump>. Most HTML,
  239. however, does not follow the XML rules, and will generate XML well-formedness
  240. errors.</p>
  241. </a>
  242. </faq>
  243. <faq title="I keep getting an error: &quot;invalid UTF-8 character&quot;. What's wrong?">
  244. <q>I keep getting an error: "invalid UTF-8 character". What's wrong?</q>
  245. <a>
  246. <p>Most commonly, the XML <code>encoding =</code> declaration is either incorrect or missing. Without a declaration, XML
  247. defaults to the use utf-8 character encoding, which is not compatible with the
  248. default text file encoding on most systems.</p>
  249. <p>The XML declaration should look something like this:</p>
  250. <p><code>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;</code></p>
  251. <p>Make sure to specify the encoding that is actually used by file. The
  252. encoding for "plain" text files depends both on the operating system and the
  253. locale (country and language) in use.</p>
  254. <p>Another common source of problems is characters that are not
  255. allowed in XML documents, according to the XML spec. Typical disallowed
  256. characters are control characters, even if you escape them using the Character
  257. Reference form. See the XML specification, sections 2.2 and 4.1 for details.
  258. If the parser is generating an <code>Invalid character (Unicode: 0x???)</code> error, it is very likely that there's a character in there that you
  259. can't see. You can generally use a UNIX command like "od -hc" to find it.</p>
  260. </a>
  261. </faq>
  262. <faq title="What encodings are supported by &XercesCName;?">
  263. <q>What encodings are supported by &XercesCName;?</q>
  264. <a>
  265. <p>&XercesCName; has intrinsic support for ASCII, UTF-8, UTF-16 (Big/Small
  266. Endian), UCS4 (Big/Small Endian), EBCDIC code pages IBM037, IBM1047 and IBM1140
  267. encodings, ISO-8859-1 (aka Latin1) and Windows-1252. This means that it can
  268. always parse input XML files in these above mentioned encodings.</p>
  269. <p>Furthermore, if you build &XercesCName; with the International Components
  270. for Unicode (ICU) as a transcoder then the list of supported encodings
  271. extends to over 100 different encodings that are supported by
  272. ICU. In particular, all the encodings registered with the
  273. Internet Assigned Numbers Authority (IANA) are supported
  274. in this configuration.</p>
  275. </a>
  276. </faq>
  277. <faq title="What character encoding should I use when creating XML documents?">
  278. <q>What character encoding should I use when creating XML documents?</q>
  279. <a>
  280. <p>The best choice in most cases is either utf-8 or utf-16. Advantages of
  281. these encodings include:</p>
  282. <ul>
  283. <li>The best portability. These encodings are more widely supported by
  284. XML processors than any others, meaning that your documents will have the best
  285. possible chance of being read correctly, no matter where they end up.</li>
  286. <li>Full international character support. Both utf-8 and utf-16 cover the
  287. full Unicode character set, which includes all of the characters from all major
  288. national, international and industry character sets.</li>
  289. <li>Efficient. utf-8 has the smaller storage requirements for documents
  290. that are primarily composed of characters from the Latin alphabet. utf-16 is
  291. more efficient for encoding Asian languages. But both encodings cover all
  292. languages without loss.</li>
  293. </ul>
  294. <p>The only drawback of utf-8 or utf-16 is that they are not the native
  295. text file format for most systems, meaning that some text file editors
  296. and viewers can not be directly used.</p>
  297. <p>A second choice of encoding would be any of the others listed in the
  298. table above. This works best when the xml encoding is the same as the default
  299. system encoding on the machine where the XML document is being prepared,
  300. because the document will then display correctly as a plain text file. For UNIX
  301. systems in countries speaking Western European languages, the encoding will
  302. usually be iso-8859-1.</p>
  303. <p>A word of caution for Windows users: The default character set on
  304. Windows systems is windows-1252, not iso-8859-1. While &XercesCName; does
  305. recognize this Windows encoding, it is a poor choice for portable XML data
  306. because it is not widely recognized by other XML processing tools. If you are
  307. using a Windows-based editing tool to generate XML, check which character set
  308. it generates, and make sure that the resulting XML specifies the correct name
  309. in the <code>encoding="..."</code> declaration.</p>
  310. </a>
  311. </faq>
  312. <faq title="Why does deleting a transcoded string result in assertion on windows?">
  313. <q>Why does deleting a transcoded string result in assertion on windows?</q>
  314. <a>
  315. <p>Both your application program and the &XercesCName; DLL must use the same DLL version of the
  316. runtime library. If either statically links to the runtime library, this
  317. problem will still occur.</p>
  318. <p>For a Visual Studio build the runtime library setting MUST
  319. be "Multithreaded DLL" for release builds and "Debug Multithreaded DLL" for
  320. debug builds.</p>
  321. <p>To bypass such problem, instead of calling operator delete[] directly, you can use the
  322. provided function XMLString::release to delete any string that was allocated by the parser.
  323. This will ensure the string is allocated and deleted by the same DLL and such assertion
  324. problem should be resolved.</p>
  325. </a>
  326. </faq>
  327. <faq title="How do I transcode to/from something besides the local code page?">
  328. <q>How do I transcode to/from something besides the local code page?</q>
  329. <a>
  330. <p>XMLString::transcode() will transcode from XMLCh to the local code page, and
  331. other APIs which take a char* assume that the source text is in the local
  332. code page. If this is not true, you must transcode the text yourself. You
  333. can do this using local transcoding support on your OS, such as Iconv on
  334. Unix or IBM's ICU package. However, if your transcoding needs are simple,
  335. you can achieve better portability by using the &XercesCName; parser's
  336. transcoder wrappers. You get a transcoder like this:
  337. </p>
  338. <ul>
  339. <li>
  340. Call XMLPlatformUtils::fgTransServer->MakeNewTranscoderFor() and provide
  341. the name of the encoding you wish to create a transcoder for. This will
  342. return a transcoder to you, which you own and must delete when you are
  343. through with it.
  344. NOTE: You must provide a maximum block size that you will pass to the transcoder
  345. at one time, and you must pass blocks of characters of this count or smaller when
  346. you do your transcoding. The reason for this is that this is really an
  347. internal API and is used by the parser itself to do transcoding. The parser
  348. always does transcoding in known block sizes, and this allows transcoders to
  349. be much more efficient for internal use since it knows the max size it will
  350. ever have to deal with and can set itself up for that internally. In
  351. general, you should stick to block sizes in the 4 to 64K range.
  352. </li>
  353. <li>
  354. The returned transcoder is something derived from XMLTranscoder, so they
  355. are all returned to you via that interface.
  356. </li>
  357. <li>
  358. This object is really just a wrapper around the underlying transcoding
  359. system actually in use by your version of &XercesCName;, and does whatever is
  360. necessary to handle differences between the XMLCh representation and the
  361. representation used by that underlying transcoding system.
  362. </li>
  363. <li>
  364. The transcoder object has two primary APIs, transcodeFrom() and
  365. transcodeTo(). These transcode between the XMLCh format and the encoding you
  366. indicated.
  367. </li>
  368. <li>
  369. These APIs will transcode as much of the source data as will fit into the
  370. outgoing buffer you provide. They will tell you how much of the source they
  371. ate and how much of the target they filled. You can use this information to
  372. continue the process until all source is consumed.
  373. </li>
  374. <li>
  375. char* data is always dealt with in terms of bytes, and XMLCh data is
  376. always dealt with in terms of characters. Don't mix up which you are dealing
  377. with or you will not get the correct results, since many encodings don't
  378. have a one to one relationship of characters to bytes.
  379. </li>
  380. <li>
  381. When transcoding from XMLCh to the target encoding, the transcodeTo()
  382. method provides an 'unrepresentable flag' parameter, which tells the
  383. transcoder how to deal with an XMLCh code point that cannot be converted
  384. legally to the target encoding, which can easily happen since XMLCh is
  385. Unicode and can represent thousands of code points. The options are to use a
  386. default replacement character (which the underlying transcoding service will
  387. choose, and which is guaranteed to be legal for the target encoding), or to
  388. throw an exception.
  389. </li>
  390. </ul>
  391. <p>Here is an example:</p>
  392. <source>
  393. // Create an XMLTranscoder that is able to transcode between
  394. // Unicode and UTF-8.
  395. //
  396. XMLTranscoder* t = XMLPlatformUtils::fgTransService->makeNewTranscoderFor(
  397. "UTF-8", failReason, 16*1024);
  398. // Source string is in Unicode, want to transcode to UTF-8
  399. t-&gt;transcodeTo(source_unicode,
  400. length,
  401. result_utf8,
  402. length,
  403. charsEaten,
  404. XMLTranscoder::UnRep_Throw);
  405. // Source string in UTF-8, want to transcode to Unicode.
  406. t-&gt;transcodeFrom(source_utf8,
  407. length,
  408. result_unicode,
  409. length,
  410. bytesEaten,
  411. (unsigned char*)charSz);
  412. </source>
  413. <p>An even simpler way to transcode to a different encoding is
  414. to use the TranscodeToStr and TranscodeFromStr wrapper classes
  415. which represent a one-time transcoding and encapsulate all the
  416. memory management. Refer to the API Reference for more information.</p>
  417. </a>
  418. </faq>
  419. <faq title="Why does the parser still try to locate the DTD even validation is turned off
  420. and how to ignore external DTD reference?">
  421. <q>Why does the parser still try to locate the DTD even validation is turned off
  422. and how to ignore external DTD reference?</q>
  423. <a>
  424. <p>When DTD is referenced, the parser will try to read it, because DTDs can
  425. provide a lot more information than just validation. It defines entities and
  426. notations, external unparsed entities, default attributes, character
  427. entities, etc. Therefore the parser will always try to read it if present, even if
  428. validation is turned off.
  429. </p>
  430. <p>To ignore external DTDs completely you can call
  431. <code>setLoadExternalDTD(false)</code> (or
  432. <code>setFeature(XMLUni::fgXercesLoadExternalDTD, false)</code>
  433. to disable the loading of external DTD. The parser will then ignore
  434. any external DTD completely if the validationScheme is set to Val_Never.
  435. </p>
  436. <p>Note: This flag is ignored if the validationScheme is set to Val_Always or Val_Auto.
  437. </p>
  438. </a>
  439. </faq>
  440. <faq title="Why does the XML data generated by the DOMLSSerializer does not match my original XML input?">
  441. <q>Why does the XML data generated by the DOMLSSerializer does not match my original XML input?</q>
  442. <a>
  443. <p>If you parse an xml document using XercesDOMParser or DOMLSParser and pass such DOMNode
  444. to DOMLSSerializer for serialization, you may not get something that is exactly the same
  445. as the original XML data. The parser may have done normalization, end of line conversion,
  446. or has expanded the entity reference as per the XML 1.0 specification, 4.4 XML Processor Treatment of
  447. Entities and References. From DOMLSSerializer perspective, it does not know what the original
  448. string was, all it sees is a processed DOMNode generated by the parser.
  449. But since the DOMLSSerializer is supposed to generate something that is parsable if sent
  450. back to the parser, it will not print the DOMNode node value as is. The DOMLSSerializer
  451. may do some "touch up" to the output data for it to be parsable.</p>
  452. <p>See <jump href="program-dom-&XercesC3Series;.html#DOMLSSerializerEntityRef">How does DOMLSSerializer handle built-in entity
  453. Reference in node value?</jump> to understand further how DOMLSSerializer touches up the entity reference.
  454. </p>
  455. </a>
  456. </faq>
  457. <faq title="Why does my application crash when deleting the parser after releasing a document?">
  458. <q>Why does my application crash when deleting the parser after releasing a document?</q>
  459. <a>
  460. <p>In most cases, the parser handles deleting documents when the parser gets deleted. However, if an application
  461. needs to release a document, it shall adopt the document before releasing it, so that the parser
  462. knows that the ownership of this particular document is transfered to the application and will not
  463. try to delete it once the parser gets deleted.
  464. </p>
  465. <source>
  466. XercesDOMParser *parser = new XercesDOMParser;
  467. ...
  468. try
  469. {
  470. parser->parse(xml_file);
  471. }
  472. catch ()
  473. {
  474. ...
  475. }
  476. DOMNode *doc = parser->getDocument();
  477. ...
  478. parser->adoptDocument();
  479. doc->release();
  480. ...
  481. delete parser;
  482. </source>
  483. <p>The alternative to release document is to call parser's resetDocumentPool(), which releases
  484. all the documents parsed.
  485. </p>
  486. </a>
  487. </faq>
  488. </faqs>