1 | <HTML><HEAD><META content="text/html; charset=utf8" http-equiv="Content-Type"><SCRIPT language="JavaScript" src="resources/script.js" type="text/javascript"></SCRIPT><TITLE>Programming/Parsing FAQs</TITLE></HEAD><BODY alink="#ff0000" bgcolor="#ffffff" leftmargin="4" link="#0000ff" marginheight="4" marginwidth="4" text="#000000" topmargin="4" vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0" width="620"><TR><TD align="left" height="60" rowspan="3" valign="top" width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif" vspace="0" width="135"></TD><TD align="left" colspan="4" height="5" valign="top" width="456"><IMG border="0" height="5" hspace="0" src="resources/line.gif" vspace="0" width="456"></TD><TD align="left" height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60" hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top" width="456"><IMG alt="" border="0" height="35" hspace="0" src="graphics/faq-parse-header.jpg" vspace="0" width="456"></TD></TR><TR><TD align="left" height="20" valign="top" width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif" vspace="0" width="168"></TD><TD align="left" height="20" valign="top" width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');" onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/" border="0" height="20" hspace="0" name="xml" onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');" src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD align="left" height="20" valign="top" width="96"><A href="http://www.apache.org/" onMouseOut="rolloverOff('asf');" onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/" border="0" height="20" hspace="0" name="asf" onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');" src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/" onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');" target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0" name="w3c" onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');" src="resources/button-w3c-lo.gif" vspace="0" width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG border="0" height="14" hspace="0" src="resources/join.gif" vspace="0" width="120"><BR>
|
---|
2 |
|
---|
3 |
|
---|
4 | <A href="../index.html" onMouseOut="rolloverOff('side-ext-2');" onMouseOver="rolloverOn('side-ext-2');"><IMG alt="Home" border="0" height="12" hspace="0" name="side-ext-2" onLoad="rolloverLoad('side-ext-2','graphics/ext-2-label-2.jpg','graphics/ext-2-label-3.jpg');" src="graphics/ext-2-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 | <IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
|
---|
9 |
|
---|
10 | <A href="index.html" onMouseOut="rolloverOff('side-index');" onMouseOver="rolloverOn('side-index');"><IMG alt="Readme" border="0" height="12" hspace="0" name="side-index" onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');" src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
11 | <A href="releases.html" onMouseOut="rolloverOff('side-releases');" onMouseOver="rolloverOn('side-releases');"><IMG alt="Release Info" border="0" height="12" hspace="0" name="side-releases" onLoad="rolloverLoad('side-releases','graphics/releases-label-2.jpg','graphics/releases-label-3.jpg');" src="graphics/releases-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 | <IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
|
---|
19 |
|
---|
20 | <A href="install.html" onMouseOut="rolloverOff('side-install');" onMouseOver="rolloverOn('side-install');"><IMG alt="Installation" border="0" height="12" hspace="0" name="side-install" onLoad="rolloverLoad('side-install','graphics/install-label-2.jpg','graphics/install-label-3.jpg');" src="graphics/install-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
21 | <A href="http://xml.apache.org/xerces-c/download.cgi" onMouseOut="rolloverOff('side-ext-18');" onMouseOver="rolloverOn('side-ext-18');"><IMG alt="Download" border="0" height="12" hspace="0" name="side-ext-18" onLoad="rolloverLoad('side-ext-18','graphics/ext-18-label-2.jpg','graphics/ext-18-label-3.jpg');" src="graphics/ext-18-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
22 | <A href="build.html" onMouseOut="rolloverOff('side-build');" onMouseOver="rolloverOn('side-build');"><IMG alt="Build Instructions" border="0" height="12" hspace="0" name="side-build" onLoad="rolloverLoad('side-build','graphics/build-label-2.jpg','graphics/build-label-3.jpg');" src="graphics/build-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
23 |
|
---|
24 |
|
---|
25 |
|
---|
26 |
|
---|
27 | <IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
|
---|
28 |
|
---|
29 | <A href="faqs.html" onMouseOut="rolloverOff('side-faqs');" onMouseOver="rolloverOn('side-faqs');"><IMG alt="FAQs" border="0" height="12" hspace="0" name="side-faqs" onLoad="rolloverLoad('side-faqs','graphics/faqs-label-2.jpg','graphics/faqs-label-3.jpg');" src="graphics/faqs-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
30 |
|
---|
31 | <A href="samples.html" onMouseOut="rolloverOff('side-samples');" onMouseOver="rolloverOn('side-samples');"><IMG alt="Samples" border="0" height="12" hspace="0" name="side-samples" onLoad="rolloverLoad('side-samples','graphics/samples-label-2.jpg','graphics/samples-label-3.jpg');" src="graphics/samples-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 | <A href="api.html" onMouseOut="rolloverOff('side-api');" onMouseOver="rolloverOn('side-api');"><IMG alt="API Docs" border="0" height="12" hspace="0" name="side-api" onLoad="rolloverLoad('side-api','graphics/api-label-2.jpg','graphics/api-label-3.jpg');" src="graphics/api-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
49 |
|
---|
50 | <IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
|
---|
51 |
|
---|
52 | <A href="ApacheDOMC++Binding.html" onMouseOut="rolloverOff('side-ext-68');" onMouseOver="rolloverOn('side-ext-68');"><IMG alt="DOM C++ Binding" border="0" height="12" hspace="0" name="side-ext-68" onLoad="rolloverLoad('side-ext-68','graphics/ext-68-label-2.jpg','graphics/ext-68-label-3.jpg');" src="graphics/ext-68-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
53 |
|
---|
54 | <A href="program.html" onMouseOut="rolloverOff('side-program');" onMouseOver="rolloverOn('side-program');"><IMG alt="Programming" border="0" height="12" hspace="0" name="side-program" onLoad="rolloverLoad('side-program','graphics/program-label-2.jpg','graphics/program-label-3.jpg');" src="graphics/program-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|
62 |
|
---|
63 | <A href="migrate.html" onMouseOut="rolloverOff('side-migrate');" onMouseOver="rolloverOn('side-migrate');"><IMG alt="Migration Guide" border="0" height="12" hspace="0" name="side-migrate" onLoad="rolloverLoad('side-migrate','graphics/migrate-label-2.jpg','graphics/migrate-label-3.jpg');" src="graphics/migrate-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
64 |
|
---|
65 |
|
---|
66 | <IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
|
---|
67 |
|
---|
68 | <A href="feedback.html" onMouseOut="rolloverOff('side-feedback');" onMouseOver="rolloverOn('side-feedback');"><IMG alt="Feedback" border="0" height="12" hspace="0" name="side-feedback" onLoad="rolloverLoad('side-feedback','graphics/feedback-label-2.jpg','graphics/feedback-label-3.jpg');" src="graphics/feedback-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
69 | <A href="bug-report.html" onMouseOut="rolloverOff('side-bug-report');" onMouseOver="rolloverOn('side-bug-report');"><IMG alt="Bug-Reporting" border="0" height="12" hspace="0" name="side-bug-report" onLoad="rolloverLoad('side-bug-report','graphics/bug-report-label-2.jpg','graphics/bug-report-label-3.jpg');" src="graphics/bug-report-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
70 | <A href="pdf.html" onMouseOut="rolloverOff('side-pdf');" onMouseOver="rolloverOn('side-pdf');"><IMG alt="PDF Document" border="0" height="12" hspace="0" name="side-pdf" onLoad="rolloverLoad('side-pdf','graphics/pdf-label-2.jpg','graphics/pdf-label-3.jpg');" src="graphics/pdf-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
71 |
|
---|
72 | <IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
|
---|
73 |
|
---|
74 |
|
---|
75 | <A href="http://xml.apache.org/websrc/cvsweb.cgi/xml-xerces/c/" onMouseOut="rolloverOff('side-ext-100');" onMouseOver="rolloverOn('side-ext-100');"><IMG alt="CVS Repository" border="0" height="12" hspace="0" name="side-ext-100" onLoad="rolloverLoad('side-ext-100','graphics/ext-100-label-2.jpg','graphics/ext-100-label-3.jpg');" src="graphics/ext-100-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
76 |
|
---|
77 |
|
---|
78 | <A href="http://marc.theaimsgroup.com/?l=xerces-c-dev" onMouseOut="rolloverOff('side-ext-102');" onMouseOver="rolloverOn('side-ext-102');"><IMG alt="Mail Archive" border="0" height="12" hspace="0" name="side-ext-102" onLoad="rolloverLoad('side-ext-102','graphics/ext-102-label-2.jpg','graphics/ext-102-label-3.jpg');" src="graphics/ext-102-label-3.jpg" vspace="0" width="120"></A><BR>
|
---|
79 |
|
---|
80 |
|
---|
81 | <IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0" width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE border="0" cellpadding="3" cellspacing="0"><TR><TD><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Questions</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif"><UL><LI><A href="#faq-1">Does Xerces-C++ support Schema?</A></LI><LI><A href="#faq-2">Why Xerces-C++ does not support this particular Schema feature?</A></LI><LI><A href="#faq-3">Why does my application crash when instantiating the parser?</A></LI><LI><A href="#faq-4">Is it OK to call the XMLPlatformUtils::Initialize/Terminate pair of routines multiple times in one program?</A></LI><LI><A href="#faq-5">Why does my application crash or hang if XMLPlatformUtils::Initialize()/Terminate() pair is called more than once?</A></LI><LI><A href="#faq-6">Why does my application crash after calling XMLPlatformUtils::Terminate()?</A></LI><LI><A href="#faq-7">I'm suddenly getting segfaults with Xerces-C 2.3.0; why might this be?</A></LI><LI><A href="#faq-8">Is Xerces-C++ thread-safe?</A></LI><LI><A href="#faq-9">I am seeing memory leaks in Xerces-C++. Are they real?</A></LI><LI><A href="#faq-10">I find memory leaks in Xerces-C++. How do I eliminate it?</A></LI><LI><A href="#faq-11">Can Xerces-C++ create an XML skeleton based on a DTD</A></LI><LI><A href="#faq-12">Can I use Xerces-C++ to perform write validation</A></LI><LI><A href="#faq-13">Can I validate the data contained in a DOM tree?</A></LI><LI><A href="#faq-14">How to write out a DOM tree into a string or an XML file?</A></LI><LI><A href="#faq-15">Why does DOMNode::cloneNode() not clone the pointer assigned to a DOMNode via DOMNode::setUserData()?</A></LI><LI><A href="#faq-16">How are entity reference nodes handled in DOM?</A></LI><LI><A href="#faq-17">What kinds of URLs are currently supported in Xerces-C++?</A></LI><LI><A href="#faq-18">How can I add support for URLs with HTTP/FTP protocols?</A></LI><LI><A href="#faq-19">Can I use Xerces-C++ to parse HTML?</A></LI><LI><A href="#faq-20">I keep getting an error: "invalid UTF-8 character". What's wrong?</A></LI><LI><A href="#faq-21">What encodings are supported by Xerces-C / XML4C?</A></LI><LI><A href="#faq-22">What character encoding should I use when creating XML documents?</A></LI><LI><A href="#faq-23">Is EBCDIC supported?</A></LI><LI><A href="#faq-24">Why does deleting a transcoded string result in assertion on windows?</A></LI><LI><A href="#faq-25">How do I transcode to/from something besides the local code page?</A></LI><LI><A href="#faq-26">Why does setProperty not work?</A></LI><LI><A href="#faq-27">Why does getProperty not work?</A></LI><LI><A href="#faq-28">Why does the parser still try to locate the DTD even validation is turned off and how to ignore external DTD reference?</A></LI><LI><A href="#faq-29">Why do I get segmentation fault when running on Redhat Linux?</A></LI><LI><A href="#faq-30">Why does the XML data generated by the DOMWriter does not match my original XML input?</A></LI><LI><A href="#faq-31">Why does my application crash when deleting the parser after releasing a document?</A></LI><LI><A href="#faq-32">Why do we have two versions of some XMLString methods (one with memory manager and one without)?</A></LI></UL></FONT></TD></TR></TABLE><BR><BR><A name="faq-1"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B> Does Xerces-C++ support Schema?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
82 |
|
---|
83 | <P>Yes. The Xerces-C++ 2.6.0 contains an implementation
|
---|
84 | of the W3C XML Schema Language, a recommendation of the Worldwide Web Consortium
|
---|
85 | available in three parts:
|
---|
86 | <A href="http://www.w3.org/TR/xmlschema-0/">XML Schema: Primer</A> and
|
---|
87 | <A href="http://www.w3.org/TR/xmlschema-1/">XML Schema: Structures</A> and
|
---|
88 | <A href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</A>.
|
---|
89 | We consider this implementation complete. See
|
---|
90 | <A href="schema.html#limitation">the Schema page</A> for limitations.</P>
|
---|
91 |
|
---|
92 | </FONT></TD></TR></TABLE><BR><A name="faq-2"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B> Why Xerces-C++ does not support this particular Schema feature?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
93 |
|
---|
94 | <P>The Xerces-C++ 2.6.0 contains an implementation
|
---|
95 | of the W3C XML Schema Language, a recommendation of the Worldwide Web Consortium
|
---|
96 | available in three parts:
|
---|
97 | <A href="http://www.w3.org/TR/xmlschema-0/">XML Schema: Primer</A> and
|
---|
98 | <A href="http://www.w3.org/TR/xmlschema-1/">XML Schema: Structures</A> and
|
---|
99 | <A href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</A>.
|
---|
100 | We consider this implementation complete. See
|
---|
101 | <A href="schema.html#limitation">the Schema page</A> for limitations.</P>
|
---|
102 |
|
---|
103 | <P>If you find any Schema feature which is specified in the W3C XML Schema Language
|
---|
104 | Recommendation does not work with Xerces-C++ 2.6.0, we encourage
|
---|
105 | the submission of bugs as described in
|
---|
106 | <A href="bug-report.html">Bug Reporting</A> page.
|
---|
107 | </P>
|
---|
108 |
|
---|
109 | </FONT></TD></TR></TABLE><BR><A name="faq-3"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why does my application crash when instantiating the parser?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
110 |
|
---|
111 | <P>In order to work with the Xerces-C++ parser, you have to first
|
---|
112 | initialize the XML subsystem. The most common mistake is to forget this
|
---|
113 | initialization. Before you make any calls to Xerces-C++ APIs, you must
|
---|
114 | call XMLPlatformUtils::Initialize(): </P>
|
---|
115 |
|
---|
116 | <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="4" width="464"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff" width="462"><FONT size="-1"><PRE>
|
---|
117 | try {
|
---|
118 | XMLPlatformUtils::Initialize();
|
---|
119 | }
|
---|
120 | catch (const XMLException& toCatch) {
|
---|
121 | // Do your failure processing here
|
---|
122 | }</PRE></FONT></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
|
---|
123 |
|
---|
124 | <P>This initializes the Xerces system and sets its internal
|
---|
125 | variables. Note that you must the include <CODE><FONT face="courier, monospaced">xercesc/util/PlatformUtils.hpp</FONT></CODE> file for this to work.</P>
|
---|
126 |
|
---|
127 | </FONT></TD></TR></TABLE><BR><A name="faq-4"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Is it OK to call the XMLPlatformUtils::Initialize/Terminate pair of routines multiple times in one program?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
128 | <P>Yes. Since Xerces-C++ 1.5.2, the code has been enhanced so that
|
---|
129 | calling XMLPlatformUtils::Initialize/Terminate pair of routines
|
---|
130 | multiple times in one process is now allowed.
|
---|
131 | </P>
|
---|
132 |
|
---|
133 | <P>But the application needs to guarantee that only one thread has entered either the
|
---|
134 | method XMLPlatformUtils::Initialize() or the method XMLPlatformUtils::Terminate() at any
|
---|
135 | one time.</P>
|
---|
136 |
|
---|
137 | <P>If you are calling XMLPlatformUtils::Initialize() a number of times, and then follow with
|
---|
138 | XMLPlatformUtils::Terminate() the same number of times, only the first XMLPlatformUtils::Initialize()
|
---|
139 | will do the initialization, and only the last XMLPlatformUtils::Terminate() will clean up
|
---|
140 | the memory. The other calls are ignored.
|
---|
141 | </P>
|
---|
142 |
|
---|
143 | <P>To ensure all the memory held by the parser are freed, the number of XMLPlatformUtils::Terminate() calls
|
---|
144 | should match the number of XMLPlatformUtils::Initialize() calls.
|
---|
145 | </P>
|
---|
146 |
|
---|
147 | <P>
|
---|
148 | Consider the following code snippets (for illustration simplicity the following
|
---|
149 | sample code is not coded in try/catch clause):
|
---|
150 | </P>
|
---|
151 |
|
---|
152 | <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="4" width="464"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff" width="462"><FONT size="-1"><PRE>
|
---|
153 | // The XMLPlatformUtils::Initialize/Terminate calls are paired.
|
---|
154 | {
|
---|
155 | // Initialize the parser
|
---|
156 | XMLPlatformUtils::Initialize();
|
---|
157 |
|
---|
158 | SAXParser* parser = new SAXParser;
|
---|
159 | parser->parse(xmlFile);
|
---|
160 | delete parser;
|
---|
161 |
|
---|
162 | // Free all memory that was being held by the parser
|
---|
163 | XMLPlatformUtils::Terminate();
|
---|
164 |
|
---|
165 | // Initialize the parser
|
---|
166 | XMLPlatformUtils::Initialize();
|
---|
167 |
|
---|
168 | parser = new SAXParser;
|
---|
169 | parser->parse(xmlFile);
|
---|
170 | delete parser;
|
---|
171 |
|
---|
172 | // Free all memory that was being held by the parser
|
---|
173 | XMLPlatformUtils::Terminate();
|
---|
174 | }
|
---|
175 | </PRE></FONT></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
|
---|
176 |
|
---|
177 | <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="4" width="464"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff" width="462"><FONT size="-1"><PRE>
|
---|
178 | // calls XMLPlatformUtils::Initialize() three times
|
---|
179 | // then calls XMLPlatformUtils::Terminate() numerous times
|
---|
180 | {
|
---|
181 | // Initialize the parser
|
---|
182 | XMLPlatformUtils::Initialize();
|
---|
183 |
|
---|
184 | // The next two calls are no-op
|
---|
185 | XMLPlatformUtils::Initialize();
|
---|
186 | XMLPlatformUtils::Initialize();
|
---|
187 |
|
---|
188 | SAXParser* parser = new SAXParser;
|
---|
189 | parser->parse(xmlFile);
|
---|
190 | delete parser;
|
---|
191 |
|
---|
192 | // The first two XMLPlatformUtils::Terminate() calls are no-op
|
---|
193 | XMLPlatformUtils::Terminate();
|
---|
194 | XMLPlatformUtils::Terminate();
|
---|
195 |
|
---|
196 | // This third XMLPlatformUtils::Terminate() will free all memory that was being held by the parser
|
---|
197 | XMLPlatformUtils::Terminate();
|
---|
198 |
|
---|
199 | // This extra fourth XMLPlatformUtils::Terminate() call is no-op.
|
---|
200 | // However calling XMLPlatformUtils::Terminate() without a matching XMLPlatformUtils::Initialize()
|
---|
201 | // is dangerous and should be avoided.
|
---|
202 | XMLPlatformUtils::Terminate();
|
---|
203 | }
|
---|
204 | </PRE></FONT></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
|
---|
205 | </FONT></TD></TR></TABLE><BR><A name="faq-5"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why does my application crash or hang if XMLPlatformUtils::Initialize()/Terminate() pair is called more than once?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
206 |
|
---|
207 | <P>Please make sure you are using the Xerces-C++ 1.5.2 or up.
|
---|
208 | </P>
|
---|
209 |
|
---|
210 | <P>Earlier version of Xerces-C++ does not allow XMLPlatformUtils::Initialize()/Terminate()
|
---|
211 | pair to be called more than once or has a problem.
|
---|
212 | </P>
|
---|
213 |
|
---|
214 | </FONT></TD></TR></TABLE><BR><A name="faq-6"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why does my application crash after calling XMLPlatformUtils::Terminate()?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
215 |
|
---|
216 | <P>Please make sure the XMLPlatformUtils::Terminate() is the last Xerces-C++ function to be called
|
---|
217 | in your program. NO explicit nor implicit Xerces-C++ destructor (those local data that are
|
---|
218 | destructed when going out of scope) should be called after XMLPlatformUtils::Terminate().
|
---|
219 | </P>
|
---|
220 | <P>
|
---|
221 | For example consider the following code snippets which is incorrect
|
---|
222 | (for illustration simplicity the following sample code is not coded in try/catch clause):
|
---|
223 | </P>
|
---|
224 |
|
---|
225 | <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="4" width="464"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff" width="462"><FONT size="-1"><PRE>
|
---|
226 | 1: {
|
---|
227 | 2: XMLPlatformUtils::Initialize();
|
---|
228 | 3: DOMString c("hello");
|
---|
229 | 4: XMLPlatformUtils::Terminate();
|
---|
230 | 5: }
|
---|
231 | </PRE></FONT></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
|
---|
232 |
|
---|
233 | <P>The DOMString object "c" is destructed when going out of scope at line 5 before the closing
|
---|
234 | brace. As a result, DOMString destructor is called at line 5 after
|
---|
235 | XMLPlatformUtils::Terminate() which is wrong. Correct code should be:
|
---|
236 | </P>
|
---|
237 |
|
---|
238 | <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="4" width="464"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff" width="462"><FONT size="-1"><PRE>
|
---|
239 | 1: {
|
---|
240 | 2: XMLPlatformUtils::Initialize();
|
---|
241 | 2a: {
|
---|
242 | 3: DOMString c("hello");
|
---|
243 | 3a: }
|
---|
244 | 4: XMLPlatformUtils::Terminate();
|
---|
245 | 5: }
|
---|
246 | </PRE></FONT></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
|
---|
247 |
|
---|
248 | <P>The extra pair of braces (line 2a and 3a) ensures that all implicit destructors are called
|
---|
249 | before terminating Xerces-C++.</P>
|
---|
250 |
|
---|
251 | <P>In addition the application also needs to guarantee that only one thread has entered either the
|
---|
252 | method XMLPlatformUtils::Initialize() or the method XMLPlatformUtils::Terminate() at any
|
---|
253 | one time.
|
---|
254 | </P>
|
---|
255 | </FONT></TD></TR></TABLE><BR><A name="faq-7"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>I'm suddenly getting segfaults with Xerces-C 2.3.0;
|
---|
256 | why might this be?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
257 | <P>The introduction of pluggable memory management into
|
---|
258 | Xerces-C, one of the main features of 2.3.0, means that
|
---|
259 | application writers have to be more conscious about
|
---|
260 | destructors being invoked implicitly after a call to
|
---|
261 | XMLPlatformUtils::Terminate(). For example, the
|
---|
262 | following code is guaranteed to produce a segmentation
|
---|
263 | fault under Xerces-C 2.3.0, while it happened to work
|
---|
264 | under previous versions (in fact, this was how our
|
---|
265 | SAXPrint sample was formerly written;
|
---|
266 | try-catch blocks removed for brevity):
|
---|
267 | </P>
|
---|
268 | <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="4" width="464"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff" width="462"><FONT size="-1"><PRE>
|
---|
269 | void myParsingFunction()
|
---|
270 | {
|
---|
271 | XMLPlatformUtils::Initialize();
|
---|
272 | SAXParser parser;
|
---|
273 | //parser.various method calls
|
---|
274 | XMLPlatformUtils::Terminate();
|
---|
275 | } // seg fault here!
|
---|
276 | </PRE></FONT></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
|
---|
277 | <P>The reason this will produce a segmentation fault is
|
---|
278 | that any dynamic memory the SAXParser (or any other of
|
---|
279 | Xerces's parsers) needs to allocate is now allocated
|
---|
280 | by default by a static object owned by XMLPlatformUtils.
|
---|
281 | When the XMLPlatformUtils::Terminate() call is made, this
|
---|
282 | object is destroyed--and, consequently, so are all the
|
---|
283 | objects that it directly created. This includes all the
|
---|
284 | objects dynamically allocated by the SAXParser. When the
|
---|
285 | parser object goes out of scope, its destructor is
|
---|
286 | invoked, and this attempts to destroy all the objects
|
---|
287 | that it created--which have of course just been destroyed
|
---|
288 | by the static MemoryManager in XMLPlatformUtils.
|
---|
289 | </P>
|
---|
290 | <P>
|
---|
291 | To avoid this, one must either explicitly scope the
|
---|
292 | parser object inside calls to
|
---|
293 | XMLPlatformUtils::Initialize() and
|
---|
294 | XMLPlatformUtils::Terminate(), or dynamically allocate
|
---|
295 | the parser object and destroy it explicitly before the
|
---|
296 | call to XMLPlatformUtils::Terminate() is made.
|
---|
297 | </P>
|
---|
298 | <P>Another way of producing segmentation faults--that again,
|
---|
299 | unfortunately, was employed by some of our
|
---|
300 | samples--is to have calls to XMLPlatformUtils::Terminate()
|
---|
301 | in a catch block that catches any of Xerces's exceptions.
|
---|
302 | Since the destructor of the exception will implicitly be
|
---|
303 | invoked upon exit from the catch block, and since some of
|
---|
304 | the exceptions' destructors call on Xerces's
|
---|
305 | default memory manager to destroy dynamically-allocated
|
---|
306 | objects, their destruction will provoke a segmentation
|
---|
307 | fault even if a return statement is placed in the catch
|
---|
308 | block since the default memory manager will no longer exist.
|
---|
309 | This practice is now avoided in all our samples.
|
---|
310 | </P>
|
---|
311 | </FONT></TD></TR></TABLE><BR><A name="faq-8"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Is Xerces-C++ thread-safe?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
312 |
|
---|
313 | <P>This is not a question that has a simple yes/no answer. Here are the
|
---|
314 | rules for using Xerces-C++ in a multi-threaded environment:</P>
|
---|
315 |
|
---|
316 | <P>Within an address space, an instance of the parser may be used without
|
---|
317 | restriction from a single thread, or an instance of the parser can be accessed
|
---|
318 | from multiple threads, provided the application guarantees that only one thread
|
---|
319 | has entered a method of the parser at any one time.</P>
|
---|
320 |
|
---|
321 | <P>When two or more parser instances exist in a process, the instances can
|
---|
322 | be used concurrently, without external synchronization. That is, in an
|
---|
323 | application containing two parsers and two threads, one parser can be running
|
---|
324 | within the first thread concurrently with the second parser running within the
|
---|
325 | second thread.</P>
|
---|
326 |
|
---|
327 | <P>The same rules apply to Xerces-C++ DOM documents. Multiple document
|
---|
328 | instances may be concurrently accessed from different threads, but any given
|
---|
329 | document instance can only be accessed by one thread at a time.</P>
|
---|
330 |
|
---|
331 | <P>DOMStrings allow multiple concurrent readers. All DOMString const
|
---|
332 | methods are thread safe, and can be concurrently entered by multiple threads.
|
---|
333 | Non-const DOMString methods, such as <CODE><FONT face="courier, monospaced">appendData()</FONT></CODE>, are not thread safe and the application must guarantee that no other
|
---|
334 | methods (including const methods) are executed concurrently with them.</P>
|
---|
335 |
|
---|
336 | <P>The application also needs to guarantee that only one thread has entered either the
|
---|
337 | method XMLPlatformUtils::Initialize() or the method XMLPlatformUtils::Terminate() at any
|
---|
338 | one time.</P>
|
---|
339 |
|
---|
340 | </FONT></TD></TR></TABLE><BR><A name="faq-9"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>I am seeing memory leaks in Xerces-C++. Are they real?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
341 |
|
---|
342 | <P>The Xerces-C++ library allocates and caches some commonly reused
|
---|
343 | items. The storage for these may be reported as memory leaks by some heap
|
---|
344 | analysis tools; to avoid the problem, call the function <CODE><FONT face="courier, monospaced">XMLPlatformUtils::Terminate()</FONT></CODE> before your application exits. This will free all memory that was being
|
---|
345 | held by the library.</P>
|
---|
346 |
|
---|
347 | <P>For most applications, the use of <CODE><FONT face="courier, monospaced">Terminate()</FONT></CODE> is optional. The system will recover all memory when the application
|
---|
348 | process shuts down. The exception to this is the use of Xerces-C++ from DLLs
|
---|
349 | that will be repeatedly loaded and unloaded from within the same process. To
|
---|
350 | avoid memory leaks with this kind of use, <CODE><FONT face="courier, monospaced">Terminate()</FONT></CODE> must be called before unloading the Xerces-C++ library</P>
|
---|
351 |
|
---|
352 | <P>To ensure all the memory held by the parser are freed, the number of XMLPlatformUtils::Terminate() calls
|
---|
353 | should match the number of XMLPlatformUtils::Initialize() calls.
|
---|
354 | </P>
|
---|
355 |
|
---|
356 | <P>If you are using XML4C where ICU is used, you may call ICU function u_cleanup() to clean up
|
---|
357 | ICU static data. Please see <A href="http://oss.software.ibm.com/icu/">ICU documentation</A>
|
---|
358 | for details.
|
---|
359 | </P>
|
---|
360 | </FONT></TD></TR></TABLE><BR><A name="faq-10"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>I find memory leaks in Xerces-C++. How do I eliminate it?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
361 |
|
---|
362 | <P>The "leaks" that are reported through a leak-detector or heap-analysis
|
---|
363 | tools aren't really leaks in most application, in that the memory usage does
|
---|
364 | not grow over time as the XML parser is used and re-used.</P>
|
---|
365 |
|
---|
366 | <P>What you are seeing as leaks are actually lazily evaluated data
|
---|
367 | allocated into static variables. This data gets released when the application
|
---|
368 | ends. You can make a call to <CODE><FONT face="courier, monospaced">XMLPlatformUtil::terminate()</FONT></CODE> to release all the lazily allocated variables before you exit your
|
---|
369 | program.</P>
|
---|
370 |
|
---|
371 | <P>To ensure all the memory held by the parser are freed, the number of XMLPlatformUtils::Terminate() calls
|
---|
372 | should match the number of XMLPlatformUtils::Initialize() calls.
|
---|
373 | </P>
|
---|
374 |
|
---|
375 | <P>If you are using XML4C where ICU is used, you may call ICU function u_cleanup() to clean up
|
---|
376 | ICU static data. Please see <A href="http://oss.software.ibm.com/icu/">ICU documentation</A>
|
---|
377 | for details.
|
---|
378 | </P>
|
---|
379 | </FONT></TD></TR></TABLE><BR><A name="faq-11"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Is there a function that I have totally missed that creates
|
---|
380 | an XML file from a DTD, (obviously with the values missing, a skeleton, as it
|
---|
381 | were)?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
382 |
|
---|
383 | <P>No. This is not supported.</P>
|
---|
384 |
|
---|
385 | </FONT></TD></TR></TABLE><BR><A name="faq-12"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Can I use Xerces-C++ to perform "write validation" (which is having an
|
---|
386 | appropriate Grammar and being able to add elements to the DOM whilst validating
|
---|
387 | against the grammar)?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
388 |
|
---|
389 | <P>No. This is not supported.</P>
|
---|
390 |
|
---|
391 | <P>The best you can do for now is to create the DOM document, write it back
|
---|
392 | as XML and re-parse it.</P>
|
---|
393 |
|
---|
394 | </FONT></TD></TR></TABLE><BR><A name="faq-13"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Is there a facility in Xerces-C++ to validate the data contained in a
|
---|
395 | DOM tree? That is, without saving and re-parsing the source document?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
396 |
|
---|
397 | <P>No. The best option for now is to generate XML source from the DOM and feed that back
|
---|
398 | into the parser.</P>
|
---|
399 |
|
---|
400 | </FONT></TD></TR></TABLE><BR><A name="faq-14"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>How to write out a DOM tree into a string or an XML file?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
401 | <P>Please make sure you are using Xerces-C++ 2.6.0 or up.</P>
|
---|
402 |
|
---|
403 | <P>You can use
|
---|
404 | the DOMWriter::writeToString, or DOMWriter::writeNode to serialize a DOM tree.
|
---|
405 | Please refer to the sample DOMPrint or the API documentation for more details of
|
---|
406 | DOMWriter.</P>
|
---|
407 | </FONT></TD></TR></TABLE><BR><A name="faq-15"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why does DOMNode::cloneNode() not clone the pointer assigned to a DOMNode via DOMNode::setUserData()?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
408 | <P>Xerces-C++ supports the DOMNode::userData specified
|
---|
409 | in <A href="http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-3A0ED0A4">
|
---|
410 | the DOM level 3 Node interface</A>. As
|
---|
411 | is made clear in the description of the behaviour of
|
---|
412 | <CODE><FONT face="courier, monospaced">cloneNode()</FONT></CODE>, userData that has been set on the
|
---|
413 | Node is not cloned. Thus, if the userData is to be copied
|
---|
414 | to the new Node, this copy must be effected manually.
|
---|
415 | Note further that the operation of <CODE><FONT face="courier, monospaced">importNode()</FONT></CODE>
|
---|
416 | is specified similarly.
|
---|
417 | </P>
|
---|
418 | </FONT></TD></TR></TABLE><BR><A name="faq-16"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>How are entity reference nodes handled in DOM?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
419 |
|
---|
420 | <P>If you are using the native DOM classes, the function <CODE><FONT face="courier, monospaced">setCreateEntityReferenceNodes</FONT></CODE>
|
---|
421 | controls how entities appear in the DOM tree. When
|
---|
422 | setCreateEntityReferenceNodes is set to true (the default), an occurrence of an
|
---|
423 | entity reference in the XML document will be represented by a subtree with an
|
---|
424 | EntityReference node at the root whose children represent the entity expansion.
|
---|
425 | Entity expansion will be a DOM tree representing the structure of the entity
|
---|
426 | expansion, not a text node containing the entity expansion as text.</P>
|
---|
427 |
|
---|
428 | <P>If setCreateEntityReferenceNodes is false, an entity reference in the XML
|
---|
429 | document is represented by only the nodes that represent the entity expansion.
|
---|
430 | The DOM tree will not contain any entityReference nodes.</P>
|
---|
431 |
|
---|
432 | </FONT></TD></TR></TABLE><BR><A name="faq-17"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>What kinds of URLs are currently supported in Xerces-C++?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
433 |
|
---|
434 | <P>The <CODE><FONT face="courier, monospaced">XMLURL</FONT></CODE> class provides for limited URL support. It understands the <CODE><FONT face="courier, monospaced">file://, http://</FONT></CODE>, and <CODE><FONT face="courier, monospaced">ftp://</FONT></CODE> URL types, and is capable or parsing them into their constituent
|
---|
435 | components, and normalizing them. It also supports the commonly required action
|
---|
436 | of conglomerating a base and relative URL into a single URL. In other words, it
|
---|
437 | performs the limited set of functions required by an XML parser.</P>
|
---|
438 |
|
---|
439 | <P>Another thing that URLs commonly do are to create an input stream that
|
---|
440 | provides access to the entity referenced. The parser, as shipped, only supports
|
---|
441 | this functionality on URLs in the form <CODE><FONT face="courier, monospaced">file:///</FONT></CODE> and <CODE><FONT face="courier, monospaced">file://localhost/</FONT></CODE>, i.e. only when the URL refers to a local file.</P>
|
---|
442 |
|
---|
443 | <P>You may enable support for HTTP and FTP URLs by implementing and
|
---|
444 | installing a NetAccessor object. When a NetAccessor object is installed, the
|
---|
445 | URL class will use it to create input streams for the remote entities referred
|
---|
446 | to by such URLs.</P>
|
---|
447 |
|
---|
448 | </FONT></TD></TR></TABLE><BR><A name="faq-18"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>How can I add support for URLs with HTTP/FTP protocols?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
449 |
|
---|
450 | <P>Support for the http: protocol is now included by default on all
|
---|
451 | platforms.</P>
|
---|
452 |
|
---|
453 | <P>To address the need to make remote connections to resources specified
|
---|
454 | using additional protocols, ftp for example, Xerces-C++ provides the <CODE><FONT face="courier, monospaced">NetAccessor</FONT></CODE> interface. The header file is <CODE><FONT face="courier, monospaced">src/xercesc/util/XMLNetAccessor.hpp</FONT></CODE>. This interface allows you to plug in your own implementation of URL
|
---|
455 | networking code into the Xerces-C++ parser.</P>
|
---|
456 |
|
---|
457 | </FONT></TD></TR></TABLE><BR><A name="faq-19"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Can I use Xerces-C++ to parse HTML?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
458 |
|
---|
459 | <P>Yes, but only if the HTML follows the rules given in the
|
---|
460 | <A href="http://www.w3.org/TR/REC-xml">XML specification</A>. Most HTML,
|
---|
461 | however, does not follow the XML rules, and will generate XML well-formedness
|
---|
462 | errors.</P>
|
---|
463 |
|
---|
464 | </FONT></TD></TR></TABLE><BR><A name="faq-20"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>I keep getting an error: "invalid UTF-8 character". What's wrong?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
465 |
|
---|
466 | <P>Most commonly, the XML <CODE><FONT face="courier, monospaced">encoding =</FONT></CODE> declaration is either incorrect or missing. Without a declaration, XML
|
---|
467 | defaults to the use utf-8 character encoding, which is not compatible with the
|
---|
468 | default text file encoding on most systems.</P>
|
---|
469 |
|
---|
470 | <P>The XML declaration should look something like this:</P>
|
---|
471 |
|
---|
472 | <P><CODE><FONT face="courier, monospaced"><?xml version="1.0" encoding="iso-8859-1"?></FONT></CODE></P>
|
---|
473 |
|
---|
474 | <P>Make sure to specify the encoding that is actually used by file. The
|
---|
475 | encoding for "plain" text files depends both on the operating system and the
|
---|
476 | locale (country and language) in use.</P>
|
---|
477 |
|
---|
478 | <P>Another common source of problems is that some characters are not
|
---|
479 | allowed in XML documents, according to the XML spec. Typical disallowed
|
---|
480 | characters are control characters, even if you escape them using the Character
|
---|
481 | Reference form. See the <A href="http://www.w3.org/TR/REC-xml#charsets">XML
|
---|
482 | spec</A>, sections 2.2 and 4.1 for details. If the parser is generating an <CODE><FONT face="courier, monospaced">Invalid character (Unicode: 0x???)</FONT></CODE> error, it is very likely that there's a character in there that you
|
---|
483 | can't see. You can generally use a UNIX command like "od -hc" to find it.</P>
|
---|
484 |
|
---|
485 | </FONT></TD></TR></TABLE><BR><A name="faq-21"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>What encodings are supported by Xerces-C / XML4C?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
486 |
|
---|
487 | <P>Xerces-C has intrinsic support for ASCII, UTF-8, UTF-16 (Big/Small
|
---|
488 | Endian), UCS4 (Big/Small Endian), EBCDIC code pages IBM037, IBM1047 and IBM1140
|
---|
489 | encodings, ISO-8859-1 (aka Latin1) and Windows-1252. This means that it can
|
---|
490 | parse input XML files in these above mentioned encodings.</P>
|
---|
491 |
|
---|
492 | <P>XML4C -- the version of Xerces-C available from IBM -- combines Xerces-C
|
---|
493 | and <A href="http://oss.software.ibm.com/icu/">
|
---|
494 | International Components for Unicode (ICU)</A> and
|
---|
495 | extends the encoding support to over 100 different encodings that are allowed
|
---|
496 | by ICU. In particular, all the encodings registered with the
|
---|
497 | <A href="http://www.iana.org/assignments/character-sets">
|
---|
498 | Internet Assigned Numbers Authority (IANA) </A> are supported in XML4C.</P>
|
---|
499 |
|
---|
500 | <P>Some implementations or ports of Xerces-C provide support for
|
---|
501 | additional encodings. The exact set will depend on the supplier of the parser
|
---|
502 | and on the character set transcoding services in use.</P>
|
---|
503 |
|
---|
504 | </FONT></TD></TR></TABLE><BR><A name="faq-22"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>What character encoding should I use when creating XML documents?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
505 |
|
---|
506 | <P>The best choice in most cases is either utf-8 or utf-16. Advantages of
|
---|
507 | these encodings include:</P>
|
---|
508 |
|
---|
509 | <UL>
|
---|
510 | <LI>The best portability. These encodings are more widely supported by
|
---|
511 | XML processors than any others, meaning that your documents will have the best
|
---|
512 | possible chance of being read correctly, no matter where they end up.</LI>
|
---|
513 | <LI>Full international character support. Both utf-8 and utf-16 cover the
|
---|
514 | full Unicode character set, which includes all of the characters from all major
|
---|
515 | national, international and industry character sets.</LI>
|
---|
516 | <LI>Efficient. utf-8 has the smaller storage requirements for documents
|
---|
517 | that are primarily composed of characters from the Latin alphabet. utf-16 is
|
---|
518 | more efficient for encoding Asian languages. But both encodings cover all
|
---|
519 | languages without loss.</LI>
|
---|
520 | </UL>
|
---|
521 |
|
---|
522 | <P>The only drawback of utf-8 or utf-16 is that they are not the native
|
---|
523 | text file format for most systems, meaning that common text file editors and
|
---|
524 | viewers can not be directly used.</P>
|
---|
525 |
|
---|
526 | <P>A second choice of encoding would be any of the others listed in the
|
---|
527 | table above. This works best when the xml encoding is the same as the default
|
---|
528 | system encoding on the machine where the XML document is being prepared,
|
---|
529 | because the document will then display correctly as a plain text file. For UNIX
|
---|
530 | systems in countries speaking Western European languages, the encoding will
|
---|
531 | usually be iso-8859-1.</P>
|
---|
532 |
|
---|
533 | <P>The versions of Xerces distributed by IBM, both C and Java (known
|
---|
534 | respectively as XML4C and XML4J), include all of the encodings listed in the
|
---|
535 | above table, on all platforms.</P>
|
---|
536 |
|
---|
537 | <P>A word of caution for Windows users: The default character set on
|
---|
538 | Windows systems is windows-1252, not iso-8859-1. While Xerces-C++ does
|
---|
539 | recognize this Windows encoding, it is a poor choice for portable XML data
|
---|
540 | because it is not widely recognized by other XML processing tools. If you are
|
---|
541 | using a Windows-based editing tool to generate XML, check which character set
|
---|
542 | it generates, and make sure that the resulting XML specifies the correct name
|
---|
543 | in the <CODE><FONT face="courier, monospaced">encoding="..."</FONT></CODE> declaration.</P>
|
---|
544 |
|
---|
545 | </FONT></TD></TR></TABLE><BR><A name="faq-23"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Is EBCDIC supported?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
546 |
|
---|
547 | <P>Yes, Xerces-C++ supports EBCDIC with the ibm1140, ibm037 and ibm1047 encodings.
|
---|
548 | When creating EBCDIC encoded XML data, the preferred encoding is ibm1140. The ibm037 encoding,
|
---|
549 | and its alternate name, ebcdic-cp-us, is almost the same as ibm1140, but
|
---|
550 | it lacks the Euro symbol.</P>
|
---|
551 |
|
---|
552 | <P>These three encodings, ibm1140, ibm037 and ibm1047, are available on both
|
---|
553 | Xerces-C and IBM XML4C, on all platforms.</P>
|
---|
554 |
|
---|
555 | <P>On IBM System 390, XML4C also supports three alternative forms,
|
---|
556 | ibm037-s390, ibm1140-s390, and ibm1047-s390. These are similar to the base ibm037, ibm1140, and ibm1047
|
---|
557 | encodings, but with alternate mappings of the EBCDIC new-line character, which
|
---|
558 | allows them to appear as normal text files on System 390. These encodings are
|
---|
559 | not supported on other platforms, and should not be used for portable data.</P>
|
---|
560 |
|
---|
561 | <P>XML4C on System 390 and AS/400 also provides additional EBCDIC
|
---|
562 | encodings, including those for the character sets of different countries. The
|
---|
563 | exact set supported will be platform dependent, and these encodings are not
|
---|
564 | recommended for portable XML data.</P>
|
---|
565 |
|
---|
566 | </FONT></TD></TR></TABLE><BR><A name="faq-24"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why does deleting a transcoded string result in assertion on windows?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
567 | <P>Both your application program and the Xerces-C++ DLL must use the same *DLL* version of the
|
---|
568 | runtime library. If either statically links to the runtime library, the
|
---|
569 | problem will still occur.</P>
|
---|
570 |
|
---|
571 | <P>For example, for a Win32/VC6 build, the runtime library build setting MUST
|
---|
572 | be "Multithreaded DLL" for release builds and "Debug Multithreaded DLL" for
|
---|
573 | debug builds.</P>
|
---|
574 |
|
---|
575 | <P>Or for example for a Win32/BCB6 build, application need to switch to Multithreaded
|
---|
576 | runtime to avoid such memory access violation.</P>
|
---|
577 |
|
---|
578 | <P>To bypass such problem, instead of calling operator delete[] directly, you can use the
|
---|
579 | provided function XMLString::release to delete any string that was allocated by the parser.
|
---|
580 | This will ensure the string is allocated and deleted by the same DLL and such assertion
|
---|
581 | problem should be resolved.</P>
|
---|
582 | </FONT></TD></TR></TABLE><BR><A name="faq-25"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>How do I transcode to/from something besides the local code page?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
583 | <P>XMLString::transcode() will transcode from XMLCh to the local code page, and
|
---|
584 | other APIs which take a char* assume that the source text is in the local
|
---|
585 | code page. If this is not true, you must transcode the text yourself. You
|
---|
586 | can do this using local transcoding support on your OS, such as Iconv on
|
---|
587 | Unix or IBM's ICU package. However, if your transcoding needs are simple,
|
---|
588 | you can achieve some better portability by using the Xerces-C++ parser's
|
---|
589 | transcoder wrappers. You get a transcoder like this:
|
---|
590 | </P>
|
---|
591 | <UL>
|
---|
592 | <LI>
|
---|
593 | Call XMLPlatformUtils::fgTransServer->MakeNewTranscoderFor() and provide
|
---|
594 | the name of the encoding you wish to create a transcoder for. This will
|
---|
595 | return a transcoder to you, which you own and must delete when you are
|
---|
596 | through with it.
|
---|
597 |
|
---|
598 | NOTE: You must provide a maximum block size that you will pass to the transcoder
|
---|
599 | at one time, and you must pass blocks of characters of this count or smaller when
|
---|
600 | you do your transcoding. The reason for this is that this is really an
|
---|
601 | internal API and is used by the parser itself to do transcoding. The parser
|
---|
602 | always does transcoding in known block sizes, and this allows transcoders to
|
---|
603 | be much more efficient for internal use since it knows the max size it will
|
---|
604 | ever have to deal with and can set itself up for that internally. In
|
---|
605 | general, you should stick to block sizes in the 4 to 64K range.
|
---|
606 | </LI>
|
---|
607 | <LI>
|
---|
608 | The returned transcoder is something derived from XMLTranscoder, so they
|
---|
609 | are all returned to you via that interface.
|
---|
610 | </LI>
|
---|
611 | <LI>
|
---|
612 | This object is really just a wrapper around the underlying transcoding
|
---|
613 | system actually in use by your version of Xerces, and does whatever is
|
---|
614 | necessary to handle differences between the XMLCh representation and the
|
---|
615 | representation used by that underlying transcoding system.
|
---|
616 | </LI>
|
---|
617 | <LI>
|
---|
618 | The transcoder object has two primary APIs, transcodeFrom() and
|
---|
619 | transcodeTo(). These transcode between the XMLCh format and the encoding you
|
---|
620 | indicated.
|
---|
621 | </LI>
|
---|
622 | <LI>
|
---|
623 | These APIs will transcode as much of the source data as will fit into the
|
---|
624 | outgoing buffer you provide. They will tell you how much of the source they
|
---|
625 | ate and how much of the target they filled. You can use this information to
|
---|
626 | continue the process until all source is consumed.
|
---|
627 | </LI>
|
---|
628 | <LI>
|
---|
629 | char* data is always dealt with in terms of bytes, and XMLCh data is
|
---|
630 | always dealt with in terms of characters. Don't mix up which you are dealing
|
---|
631 | with or you will not get the correct results, since many encodings don't
|
---|
632 | have a one to one relationship of characters to bytes.
|
---|
633 | </LI>
|
---|
634 | <LI>
|
---|
635 | When transcoding from XMLCh to the target encoding, the transcodeTo()
|
---|
636 | method provides an 'unrepresentable flag' parameter, which tells the
|
---|
637 | transcoder how to deal with an XMLCh code point that cannot be converted
|
---|
638 | legally to the target encoding, which can easily happen since XMLCh is
|
---|
639 | Unicode and can represent thousands of code points. The options are to use a
|
---|
640 | default replacement character (which the underlying transcoding service will
|
---|
641 | choose, and which is guaranteed to be legal for the target encoding), or to
|
---|
642 | throw an exception.
|
---|
643 | </LI>
|
---|
644 | </UL>
|
---|
645 | <P>Here is an example:</P>
|
---|
646 | <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="4" width="464"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff" width="462"><FONT size="-1"><PRE>
|
---|
647 | // create an XMLTranscoder that is able to transcode between Unicode and Big5
|
---|
648 | // ASSUMPTION: assumes your underlying transcoding utility supports this encoding Big5
|
---|
649 | XMLTranscoder* t =
|
---|
650 | XMLPlatformUtils::fgTransService->makeNewTranscoderFor("Big5", failReason, 16*1024, MemoryManager);
|
---|
651 |
|
---|
652 | // source string is in Unicode, wanna to transcode to Big5
|
---|
653 | t->transcodeTo(source_unicode, length, result_Big5, length, charsEaten, XMLTranscoder::UnRep_Throw );
|
---|
654 |
|
---|
655 | // source string in Big5, wanna to transcode to Unicode
|
---|
656 | t->transcodeFrom(source_Big5, length, result_unicode, length, bytesEaten, (unsigned char*)charSz);
|
---|
657 | </PRE></FONT></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
|
---|
658 |
|
---|
659 | </FONT></TD></TR></TABLE><BR><A name="faq-26"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why does setProperty not work?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
660 |
|
---|
661 | <P>The function <CODE><FONT face="courier, monospaced">SAX2XMLReader::setProperty(const XMLCh* const name, void* value)</FONT></CODE>
|
---|
662 | and <CODE><FONT face="courier, monospaced">DOMBuilder::setProperty(const XMLCh* const name, void* value)</FONT></CODE>
|
---|
663 | takes a void pointer for the property value. Application is required to initialize this void pointer
|
---|
664 | to a correct type. See <A href="program-sax2.html#SAX2Properties">SAX2 Programming Guide</A>
|
---|
665 | and <A href="program-dom.html#DOMBuilderProperties">DOM Programming Guide</A>
|
---|
666 | to learn exactly what type of property value that each property expects for processing.
|
---|
667 | Passing a void pointer that was initialized with a wrong type will lead to unexpected result.
|
---|
668 | </P>
|
---|
669 |
|
---|
670 | </FONT></TD></TR></TABLE><BR><A name="faq-27"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why does getProperty not work?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
671 |
|
---|
672 | <P>The function <CODE><FONT face="courier, monospaced">void* SAX2XMLReader::getProperty(const XMLCh* const name)</FONT></CODE>
|
---|
673 | and <CODE><FONT face="courier, monospaced">void* DOMBuilder::getProperty(const XMLCh* const name)</FONT></CODE>
|
---|
674 | returns a void pointer for the property value. See
|
---|
675 | <A href="program-sax2.html#SAX2Properties">SAX2 Programming Guide</A> and
|
---|
676 | exactly what type of object each property returns.
|
---|
677 | </P>
|
---|
678 | <P>The parser owns the returned pointer. The memory allocated for
|
---|
679 | the returned pointer will be destroyed when the parser is deleted.
|
---|
680 | To ensure accessibility of the returned information after the parser
|
---|
681 | is deleted, callers need to copy and store the returned information
|
---|
682 | somewhere else; otherwise you may get unexpected result. Since the returned
|
---|
683 | pointer is a generic void pointer, see
|
---|
684 | <A href="program-sax2.html#SAX2Properties">SAX2 Programming Guide</A> and
|
---|
685 | <A href="program-dom.html#DOMBuilderProperties">DOM Programming Guide</A> to learn
|
---|
686 | exactly what type of property value each property returns for replication.
|
---|
687 | </P>
|
---|
688 |
|
---|
689 | </FONT></TD></TR></TABLE><BR><A name="faq-28"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why does the parser still try to locate the DTD even validation is turned off
|
---|
690 | and how to ignore external DTD reference?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
691 |
|
---|
692 | <P>When DTD is referenced, the parser will try to read it, because DTDs can
|
---|
693 | provide a lot more information than just validation. It defines entities and
|
---|
694 | notations, external unparsed entities, default attributes, character
|
---|
695 | entities, etc... So it will always try to read it if present, even if
|
---|
696 | validation is turned off.
|
---|
697 | </P>
|
---|
698 |
|
---|
699 | <P>To ignore the DTD, with Xerces-C++ 2.6.0 or up, you can call
|
---|
700 | <CODE><FONT face="courier, monospaced">setLoadExternalDTD(false)</FONT></CODE> (or
|
---|
701 | <CODE><FONT face="courier, monospaced">setFeature(XMLUni::fgXercesLoadExternalDTD, false)</FONT></CODE>
|
---|
702 | to disable the loading of external DTD. The parser will then ignore
|
---|
703 | any external DTD completely if the validationScheme is set to Val_Never.
|
---|
704 | </P>
|
---|
705 |
|
---|
706 | <P>Note: This flag is ignored if the validationScheme is set to Val_Always or Val_Auto.
|
---|
707 | </P>
|
---|
708 |
|
---|
709 | <P>To ignore the DTD in earlier version of Xerces-C++, the
|
---|
710 | only way to get around this is to install an EntityResolver
|
---|
711 | (see the Redirect sample for an example of how this is done), and reset the
|
---|
712 | DTD file to "".
|
---|
713 | </P>
|
---|
714 |
|
---|
715 | </FONT></TD></TR></TABLE><BR><A name="faq-29"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why do I get segmentation fault when running on Redhat Linux?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
716 |
|
---|
717 | <P>There were some problems with Redhat Linux 7.x with C++ exception handling across shared
|
---|
718 | libraries. More details can be found
|
---|
719 | <A href="http://rhn.redhat.com/errata/RHBA-2002-055.html">here</A>.
|
---|
720 | Please try to upgrade your Redhat Linux gcc to the latest patch level and see if it helps.
|
---|
721 | </P>
|
---|
722 |
|
---|
723 | </FONT></TD></TR></TABLE><BR><A name="faq-30"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why does the XML data generated by the DOMWriter does not match my original XML input?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
724 |
|
---|
725 | <P>If you parse an xml document using XercesDOMParser or DOMBuilder and pass such DOMNode
|
---|
726 | to DOMWriter for serialization, you may not get something that is exactly the same
|
---|
727 | as the original XML data. The parser may have done normalization, end of line conversion,
|
---|
728 | or has expanded the entity reference as per the XML 1.0 spec, 4.4 XML Processor Treatment of
|
---|
729 | Entities and References. From DOMWriter perspective, it does not know what the original
|
---|
730 | string was, all it sees is a processed DOMNode generated by the parser.
|
---|
731 | But since the DOMWriter is supposed to generate something that is parsable if sent
|
---|
732 | back to the parser, it will not print the DOMNode node value as is. The DOMWriter
|
---|
733 | may do some "touch up" to the output data for it to be parsable.</P>
|
---|
734 |
|
---|
735 | <P>See <A href="program-dom.html#DOMWriterEntityRef">How does DOMWriter handle built-in entity
|
---|
736 | Reference in node value?</A> to understand further how DOMWriter touches up the entity reference.
|
---|
737 | </P>
|
---|
738 | </FONT></TD></TR></TABLE><BR><A name="faq-31"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why does my application crash when deleting the parser after releasing a document?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
739 |
|
---|
740 | <P>In most cases, the parser handles deleting documents when the parser gets deleted. However, if an application
|
---|
741 | needs to release a document, it shall adopt the document before releasing it, so that the parser
|
---|
742 | knows that the ownership of this particular document is transfered to the application and will not
|
---|
743 | try to delete it once the parser gets deleted.
|
---|
744 | </P>
|
---|
745 |
|
---|
746 | <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="4" width="464"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff" width="462"><FONT size="-1"><PRE>
|
---|
747 | XercesDOMParser *parser = new XercesDOMParser;
|
---|
748 | ...
|
---|
749 | try
|
---|
750 | {
|
---|
751 | parser->parse(gXmlFile);
|
---|
752 | }
|
---|
753 | catch ()
|
---|
754 | {
|
---|
755 | ...
|
---|
756 | }
|
---|
757 | DOMNode *doc = parser->getDocument();
|
---|
758 | ...
|
---|
759 | parser->adoptDocument();
|
---|
760 | doc->release();
|
---|
761 | ...
|
---|
762 | delete parser;
|
---|
763 | </PRE></FONT></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
|
---|
764 |
|
---|
765 | <P>The alternative to release document is to call parser's resetDocumentPool(), which releases
|
---|
766 | all the documents parsed.
|
---|
767 | </P>
|
---|
768 |
|
---|
769 | </FONT></TD></TR></TABLE><BR><A name="faq-32"><!--anchor--></A><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Why do we have two versions of some XMLString methods (one with memory manager and one without)?</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
---|
770 |
|
---|
771 | <P>With the introduction of the configurable memory manager, we didn't want to break users by
|
---|
772 | changing the signature of the existing methods (for example, transcode and replicate). Also,
|
---|
773 | we did not want to provide a default memory
|
---|
774 | manager as it would introduce a side effect with users experiencing some strange core dumps.
|
---|
775 | The latter will occur when the scope of the string allocated is beyond that of
|
---|
776 | XMLPlatformUtils::Terminate (i.e. a string is allocated using the default memory manager
|
---|
777 | which is deleted when XMLPlatformUtils::Terminate is called, but the allocated string is
|
---|
778 | deleted later). We plan to deprecate the methods without a memory manager in a later release.
|
---|
779 | </P>
|
---|
780 |
|
---|
781 | </FONT></TD></TR></TABLE><BR></TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0" cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1" src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT color="#0086b2" size="-1"><I>
|
---|
782 | Copyright © 1999-2004 The Apache Software Foundation.
|
---|
783 | All Rights Reserved.
|
---|
784 | </I></FONT></TD></TR></TABLE></BODY></HTML> |
---|