source: NonGTP/Xerces/xerces/doc/html/program-others.html @ 358

Revision 358, 101.4 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
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 Guide</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/program-others-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>
82    <A name="Macro"><!--anchor--></A>
83    <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>Version Macro</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
84        <P>Xerces-C++ has defined a numeric preprocessor macro, _XERCES_VERSION, for users to
85           introduce into their code to perform conditional compilation where the
86           version of Xerces is detected in order to enable or disable version
87          specific capabilities. For example,
88         </P>
89<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>
90#if _XERCES_VERSION &gt;= 20304
91  // code specific to Xerces-C++ version 2.3.4
92#else
93  // old code here...
94#endif
95</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>
96        <P>The minor and revision (patch level) numbers have two digits of resolution
97           which means that '3' becomes '03' and '4' becomes '04' in this example.
98        </P>
99        <P>There are also other string macro, or constants to represent the Xerces-C++ version.
100           Please refer to the header xercesc/util/XercesVersion.hpp for further details.
101        </P>
102    </FONT></TD></TR></TABLE><BR>
103
104
105    <A name="Schema"><!--anchor--></A>
106    <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>Schema Support</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
107        <P>Xerces-C++ contains an implementation of the W3C XML Schema
108           Language.  See <A href="schema.html">the Schema page</A> for details.
109         </P>
110    </FONT></TD></TR></TABLE><BR>
111
112    <A name="Progressive"><!--anchor--></A>
113    <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>Progressive Parsing</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
114
115        <P>In addition to using the <I>parse()</I> method to parse an XML File.
116        You can use the other two parsing methods, <I>parseFirst()</I> and <I>parseNext()</I>
117        to do 'progressive parsing', so that you don't
118        have to depend upon throwing an exception to terminate the
119        parsing operation.
120         </P>
121         <P>
122        Calling parseFirst() will cause the DTD (both internal and
123        external subsets), and any pre-content, i.e. everything up to
124        but not including the root element, to be parsed. Subsequent calls to
125        parseNext() will cause one more pieces of markup to be parsed,
126        and spit out from the core scanning code to the parser (and
127        hence either on to you if using SAX or into the DOM tree if
128        using DOM).
129         </P>
130         <P>
131        You can quit the parse any time by just not
132        calling parseNext() anymore and breaking out of the loop. When
133        you call parseNext() and the end of the root element is the
134        next piece of markup, the parser will continue on to the end
135        of the file and return false, to let you know that the parse
136        is done. So a typical progressive parse loop will look like
137        this:</P>
138
139<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>// Create a progressive scan token
140XMLPScanToken token;
141
142if (!parser.parseFirst(xmlFile, token))
143{
144  cerr &lt;&lt; &quot;scanFirst() failed\n&quot; &lt;&lt; endl;
145  return 1;
146}
147
148//
149// We started ok, so lets call scanNext()
150// until we find what we want or hit the end.
151//
152bool gotMore = true;
153while (gotMore &amp;&amp; !handler.getDone())
154  gotMore = parser.parseNext(token);</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>
155
156        <P>In this case, our event handler object (named 'handler'
157        surprisingly enough) is watching for some criteria and will
158        return a status from its getDone() method. Since the handler
159        sees the SAX events coming out of the SAXParser, it can tell
160        when it finds what it wants. So we loop until we get no more
161        data or our handler indicates that it saw what it wanted to
162        see.</P>
163
164        <P>When doing non-progressive parses, the parser can easily
165        know when the parse is complete and insure that any used
166        resources are cleaned up. Even in the case of a fatal parsing
167        error, it can clean up all per-parse resources. However, when
168        progressive parsing is done, the client code doing the parse
169        loop might choose to stop the parse before the end of the
170        primary file is reached. In such cases, the parser will not
171        know that the parse has ended, so any resources will not be
172        reclaimed until the parser is destroyed or another parse is started.</P>
173
174        <P>This might not seem like such a bad thing; however, in this case,
175        the files and sockets which were opened in order to parse the
176        referenced XML entities will remain open. This could cause
177        serious problems. Therefore, you should destroy the parser instance
178        in such cases, or restart another parse immediately. In a future
179        release, a reset method will be provided to do this more cleanly.</P>
180
181        <P>Also note that you must create a scan token and pass it
182        back in on each call. This insures that things don't get done
183        out of sequence. When you call parseFirst() or parse(), any
184        previous scan tokens are invalidated and will cause an error
185        if used again. This prevents incorrect mixed use of the two
186        different parsing schemes or incorrect calls to
187        parseNext().</P>
188
189    </FONT></TD></TR></TABLE><BR>
190
191    <A name="GrammarCache"><!--anchor--></A>
192    <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>Preparsing Grammar and Grammar Caching</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
193        <P>Xerces-C++ 2.6.0 provides a new function to pre-parse the grammar so that users
194           can check for any syntax or error before using the grammar.  Users can also optionally
195           cache these pre-parsed grammars for later use during actual parsing.
196        </P>
197        <P>Here is an example:</P>
198<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>
199XercesDOMParser parser;
200
201// enbale schema processing
202parser.setDoSchema(true);
203parser.setDONamespaces(true);
204
205// Let's preparse the schema grammar (.xsd) and cache it.
206Grammar* grammar = parser.loadGrammar(xmlFile, Grammar::SchemaGrammarType, true);
207</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>
208        <P>Besides caching pre-parsed schema grammars, users can also cache any
209           grammars encountered during an xml document parse.
210        </P>
211        <P>Here is an example:</P>
212<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>
213SAXParser parser;
214
215// Enable grammar caching by setting cacheGrammarFromParse to true.
216// The parser will cache any encountered grammars if it does not
217// exist in the pool.
218// If the grammar is DTD, no internal subset is allowed.
219parser.cacheGrammarFromParse(true);
220
221// Let's parse our xml file (DTD grammar)
222parser.parse(xmlFile);
223
224// We can get the grammar where the root element was declared
225// by calling the parser's method getRootGrammar;
226// Note: The parser owns the grammar, and the user should not delete it.
227Grammar* grammar = parser.getRootGrammar();
228</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>
229        <P>We can use any previously cached grammars when parsing new xml
230        documents. Here are some examples on how to use those cached grammars:
231        </P>
232<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>
233/**
234  * Caching and reusing XML Schema (.xsd) grammar
235  * Parse an XML document and cache its grammar set. Then,  use the cached
236  * grammar set in subsequent parses.
237  */
238
239XercesDOMParser parser;
240
241// Enable schema processing
242parser.setDoSchema(true);
243parser.setDoNamespaces(true);
244
245// Enable grammar caching
246parser.cacheGrammarFromParse(true);
247
248// Let's parse the XML document. The parser will cache any grammars encounterd.
249parser.parse(xmlFile);
250
251// No need to enable re-use by setting useCachedGrammarInParse to true. It is
252// automatically enabled with grammar caching.
253for (int i=0; i&lt; 3; i++)
254    parser.parse(xmlFile);
255
256// This will flush the grammar pool
257parser.resetCachedGrammarPool();
258</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>
259
260<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>
261/**
262  * Caching and reusing DTD grammar
263  * Preparse a grammar and cache it in the pool. Then, we use the cached grammar
264  * when parsing XML documents.
265  */
266
267SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
268
269// Load grammar and cache it
270parser-&gt;loadGrammar(dtdFile, Grammar::DTDGrammarType, true);
271
272// enable grammar reuse
273parser-&gt;setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true);
274
275// Parse xml files
276parser-&gt;parse(xmlFile1);
277parser-&gt;parse(xmlFile2);
278</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>
279        <P>There are some limitations about caching and using cached grammars:</P>
280           <UL>
281              <LI>When caching/reusing DTD grammars, no internal subset is allowed.</LI>
282              <LI>When preparsing grammars with caching option enabled, if a grammar, in the
283              result set, already exists in the pool (same NS for schema or same system
284              id for DTD), the entire set will not be cached.</LI>
285              <LI>When parsing an XML document with the grammar caching option enabled, the
286              reuse option is also automatically enabled. We will only parse a grammar if it
287              does not exist in the pool.</LI>
288           </UL>
289    </FONT></TD></TR></TABLE><BR>
290
291    <A name="LoadableMessageText"><!--anchor--></A>
292    <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>Loadable Message Text</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
293
294        <P>The Xerces-C++ supports loadable message text.   Although
295        the current drop just supports English, it is capable to support other
296        languages. Anyone interested in contributing any translations
297        should contact us. This would be an extremely useful
298        service.</P>
299
300        <P>In order to support the local message loading services, all the error messages
301        are captured in an XML file in the src/xercesc/NLS/ directory.
302        There is a simple program, in the tools/NLS/Xlat/ directory,
303        which can spit out that text in various formats. It currently
304        supports a simple 'in memory' format (i.e. an array of
305        strings), the Win32 resource format, and the message catalog
306        format.  The 'in memory' format is intended for very simple
307        installations or for use when porting to a new platform (since
308        you can use it until you can get your own local message
309        loading support done.)</P>
310
311        <P>In the src/xercesc/util/ directory, there is an XMLMsgLoader
312        class.  This is an abstraction from which any number of
313        message loading services can be derived. Your platform driver
314        file can create whichever type of message loader it wants to
315        use on that platform.  Xerces-C++ currently has versions for the in
316        memory format, the Win32 resource format, the message
317        catalog format, and ICU message loader.
318        Some of the platforms can support multiple message
319        loaders, in which case a #define token is used to control
320        which one is used. You can set this in your build projects to
321        control the message loader type used.</P>
322
323    </FONT></TD></TR></TABLE><BR>
324
325    <A name="PluggableTranscoders"><!--anchor--></A>
326    <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>Pluggable Transcoders</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
327
328        <P>Xerces-C++ also supports pluggable transcoding services. The
329        XMLTransService class is an abstract API that can be derived
330        from, to support any desired transcoding
331        service. XMLTranscoder is the abstract API for a particular
332        instance of a transcoder for a particular encoding. The
333        platform driver file decides what specific type of transcoder
334        to use, which allows each platform to use its native
335        transcoding services, or the ICU service if desired.</P>
336
337        <P>Implementations are provided for Win32 native services, ICU
338        services, and the <I>iconv</I> services available on many
339        Unix platforms. The Win32 version only provides native code
340        page services, so it can only handle XML code in the intrinsic
341        encodings ASCII, UTF-8, UTF-16 (Big/Small Endian), UCS4
342        (Big/Small Endian), EBCDIC code pages IBM037, IBM1047 and
343        IBM1140 encodings, ISO-8859-1 (aka Latin1) and Windows-1252. The ICU version
344        provides all of the encodings that ICU supports. The
345        <I>iconv</I> version will support the encodings supported
346        by the local system. You can use transcoders we provide or
347        create your own if you feel ours are insufficient in some way,
348        or if your platform requires an implementation that Xerces-C++ does not
349        provide.</P>
350
351    </FONT></TD></TR></TABLE><BR>
352
353    <A name="PortingGuidelines"><!--anchor--></A>
354    <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>Porting Guidelines</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
355
356      <P>All platform dependent code in Xerces has been
357      isolated to a couple of files, which should ease the porting
358      effort.  Here are the basic steps that should be followed to
359      port Xerces.</P>
360
361      <OL>
362
363        <LI>The directory <CODE><FONT face="courier, monospaced">src/xercesc/util/Platforms</FONT></CODE> contains the
364        platform sensitive files while <CODE><FONT face="courier, monospaced">src/xercesc/util/Compilers</FONT></CODE> contains
365        all development environment sensitive files. Each operating
366        system has a file of its own and each development environment
367        has another one of its own too.
368
369        <BR>
370
371        As an example, the Win32 platform as a <CODE><FONT face="courier, monospaced">Win32Defs.hpp</FONT></CODE> file
372        and the Visual C++ environment has a <CODE><FONT face="courier, monospaced">VCPPDefs.hpp</FONT></CODE> file.
373        These files set up certain define tokens, typedefs,
374        constants, etc... that will drive the rest of the code to
375        do the right thing for that platform and development
376        environment. AIX/CSet have their own <CODE><FONT face="courier, monospaced">AIXDefs.hpp</FONT></CODE> and
377        <CODE><FONT face="courier, monospaced">CSetDefs.hpp</FONT></CODE> files, and so on. You should create new
378        versions of these files for your platform and environment
379        and follow the comments in them to set up your own.
380        Probably the comments in the Win32 and Visual C++ will be
381        the best to follow, since that is where the main
382        development is done.</LI>
383
384        <LI>Next, edit the file <CODE><FONT face="courier, monospaced">XercesDefs.hpp</FONT></CODE>, which is where all
385            of the fundamental stuff comes into the system. You will
386            see conditional sections in there where the above
387            per-platform and per-environment headers are brought in.
388            Add the new ones for your platform under the appropriate
389            conditionals.</LI>
390
391        <LI>Now edit <CODE><FONT face="courier, monospaced">AutoSense.hpp</FONT></CODE>. Here we set canonical Xerces
392            internal <CODE><FONT face="courier, monospaced">#define</FONT></CODE> tokens which indicate the platform and
393            compiler. These definitions are based on known platform
394            and compiler defines.
395            <BR>
396            <CODE><FONT face="courier, monospaced">AutoSense.hpp</FONT></CODE> is included in <CODE><FONT face="courier, monospaced">XercesDefs.hpp</FONT></CODE> and the
397            canonical platform and compiler settings thus defined will
398            make the particular platform and compiler headers to be
399            the included at compilation.
400            <BR>
401            It might be a little tricky to decipher this file so be
402            careful. If you are using say another compiler on Win32,
403            probably it will use similar tokens so that the platform
404            will get picked up already using what is already there.</LI>
405
406        <LI>Once this is done, you will then need to implement a
407            version of the <I>platform utilities</I> for your platform.
408            Each operating system has a file which implements some
409            methods of the XMLPlatformUtils class, specific to that
410            operating system. These are not terribly complex, so it
411            should not be a lot of work. The Win32 version is called
412            <CODE><FONT face="courier, monospaced">Win32PlatformUtils.cpp</FONT></CODE>, the AIX version is
413            <CODE><FONT face="courier, monospaced">AIXPlatformUtils.cpp</FONT></CODE> and so on. Create one for your
414            platform, with the correct name, and empty out all of the
415            implementation so that just the empty shells of the
416            methods are there (with dummy returns where needed to make
417            the compiler happy.) Once you've done that, you can start
418            to get it to build without any real implementation.</LI>
419
420        <LI>Once you have the system building, then start
421            implementing your own platform utilities methods. Follow
422            the comments in the Win32 version as to what they do, the
423            comments will be improved in subsequent versions, but they
424            should be fairly obvious now. Once you have these
425            implementations done, you should be able to start
426            debugging the system using the demo programs.</LI>
427      </OL>
428
429      <P>Other concerns are:</P>
430
431      <UL>
432        <LI>Does ICU compile on your platform? If not, then you'll need to
433            create a transcoder implementation that uses your local transcoding
434            services. The iconv transcoder should work for you, though perhaps
435            with some modifications.</LI>
436        <LI>What message loader will you use? To get started, you can use the
437            &quot;in memory&quot; one, which is very simple and easy. Then, once you get
438            going, you may want to adapt the message catalog message loader, or
439            write one of your own that uses local services.</LI>
440        <LI>What should I define XMLCh to be? Please refer to <A href="build-misc.html#XMLChInfo">What should I define XMLCh to be?</A> for
441            further details.</LI>
442      </UL>
443
444      <P>That is the work required in a nutshell!</P>
445    </FONT></TD></TR></TABLE><BR>
446
447    <A name="CPPNamespace"><!--anchor--></A>
448    <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>Using C++ Namespace</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
449
450        <P>Xerces-C++ 2.6.0 supports C++ Namespace as of Version 2.2.0.</P>
451
452        <P>The macro <CODE><FONT face="courier, monospaced">XERCES_HAS_CPP_NAMESPACE</FONT></CODE> is defined in each Compiler
453           Definition file if C++ Namespace is supported.</P>
454        <P>For example in header <CODE><FONT face="courier, monospaced">xercesc/util/Compilers/GCCDefs.hpp</FONT></CODE>,
455           the C++ Namespace is enabled:</P>
456
457<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>
458// -------------------------------------------------------------------------
459// Indicate that we support C++ namespace
460// Do not define it if the compile cannot handle C++ namespace
461// -------------------------------------------------------------------------
462#define XERCES_HAS_CPP_NAMESPACE
463</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>
464
465        <P>If C++ Namespace support is ENABLED (all the binary
466           distributions of Xerces-C++ 2.6.0 are built
467           with C++ Namespace enabled), users' applications must
468           namespace qualify all the Xerces-C++ classes, data and
469           variables with <CODE><FONT face="courier, monospaced">XERCES_CPP_NAMESPACE_QUALIFIER </FONT></CODE>
470           or add the <CODE><FONT face="courier, monospaced">XERCES_CPP_NAMESPACE_USE</FONT></CODE>
471           statement. Users also need to ensure all forward
472           declarations are properly qualified or scoped.</P>
473
474        <P>Note: If If C++ Namespace support is ENABLED,
475           <CODE><FONT face="courier, monospaced">XERCES_CPP_NAMESPACE_QUALIFIER</FONT></CODE> expands to the
476           Xerces-C++ namespace name followed by two colons, and
477           <CODE><FONT face="courier, monospaced">XERCES_CPP_NAMESPACE_USE</FONT></CODE> expands to the full
478           <CODE><FONT face="courier, monospaced">using namespace</FONT></CODE> statement, including the
479           semicolon. Do NOT add colons or semicolons following these
480           macros in your source.</P>
481
482        <P>If C++ Namespace support is not enabled, both macros expand
483           to an empty string. The same holds for macros
484           <CODE><FONT face="courier, monospaced">XERCES_CPP_NAMESPACE_BEGIN</FONT></CODE> and
485           <CODE><FONT face="courier, monospaced">XERCES_CPP_NAMESPACE_END</FONT></CODE>, introduced in the
486           example below. You will also see all of these macros used
487           throughout the Xerces-C++ source code.</P>
488
489                <P>For example:</P>
490
491<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>
492#include &lt;stdio.h&gt;
493#include &lt;stdlib.h&gt;
494#include &lt;xercesc/sax/HandlerBase.hpp&gt;
495
496// indicate using Xerces-C++ namespace in general
497XERCES_CPP_NAMESPACE_USE
498
499// need to properly scope any forward declarations
500XERCES_CPP_NAMESPACE_BEGIN
501  class AttributeList;
502XERCES_CPP_NAMESPACE_END
503
504
505// or namespace qualifier the forward declarations
506class XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler;
507
508class MySAXHandlers : public HandlerBase
509{
510public:
511    // -----------------------------------------------------------------------
512    //  Handlers for the SAX DocumentHandler interface
513    // -----------------------------------------------------------------------
514    void startElement(const XMLCh* const name, AttributeList&amp; attributes);
515    void characters(const XMLCh* const chars, const unsigned int length);
516:
517:
518};
519</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>
520
521        <P>All macros used above are defined in header file <CODE><FONT face="courier, monospaced">xercesc/util/XercesDefs.hpp</FONT></CODE>:</P>
522
523<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>
524#if defined(XERCES_HAS_CPP_NAMESPACE)
525    #define XERCES_CPP_NAMESPACE_BEGIN    namespace xercesc_2_6 {
526    #define XERCES_CPP_NAMESPACE_END    }
527    #define XERCES_CPP_NAMESPACE_USE    using namespace xercesc_2_6;
528    #define XERCES_CPP_NAMESPACE_QUALIFIER    xercesc_2_6::
529
530    namespace xercesc_2_6 { }
531    namespace xercesc = xercesc_2_6;
532#else
533    #define XERCES_CPP_NAMESPACE_BEGIN
534    #define XERCES_CPP_NAMESPACE_END
535    #define XERCES_CPP_NAMESPACE_USE
536    #define XERCES_CPP_NAMESPACE_QUALIFIER
537#endif
538</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>
539
540        <P>Users should make use of these pre-defined macro in their applications.  For example:</P>
541<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>
542#include &lt;stdio.h&gt;
543#include &lt;stdlib.h&gt;
544#include &lt;xercesc/sax/HandlerBase.hpp&gt;
545
546// indicate using Xerces-C++ namespace in general
547XERCES_CPP_NAMESPACE_USE
548
549// need to properly scope any forward declarations
550XERCES_CPP_NAMESPACE_BEGIN
551class AttributeList;
552XERCES_CPP_NAMESPACE_END
553
554// or namespace qualify the forward declarations
555class XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler;
556
557class MySAXHandlers : public HandlerBase
558{
559public:
560    // -----------------------------------------------------------------------
561    //  Handlers for the SAX DocumentHandler interface
562    // -----------------------------------------------------------------------
563    void startElement(const XMLCh* const name, AttributeList&amp; attributes);
564    void characters(const XMLCh* const chars, const unsigned int length);
565:
566:
567};
568</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>
569
570         <P>For those users who want to selectively pick which version of API to use, they can do
571            something like the code below (Note that this is not the best of examples, as the
572            API is the same in all versions):</P>
573
574<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>
575#if _XERCES_VERSION == 20300
576  // code specific to Xerces-C++ version 2.3.0
577  new xercesc_2_3::SAXParser();
578#elif _XERCES_VERSION == 20200
579  // code specific to Xerces-C++ version 2.2.0
580  new xercesc_2_2::SAXParser();
581#else
582  // old code here...
583  new SAXParser();
584#endif
585</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>
586
587        <P>But for those who just want to call the latest API, then they should use
588           the macro <CODE><FONT face="courier, monospaced">XERCES_CPP_NAMESPACE_QUALIFIER</FONT></CODE>
589           for source compatibility:</P>
590
591<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>
592new XERCES_CPP_NAMESPACE_QUALIFIER SAXParser();
593</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>
594           
595        <P>Header file <CODE><FONT face="courier, monospaced">xercesc/util/XercesDefs.hpp</FONT></CODE> also
596           declares <CODE><FONT face="courier, monospaced">namespace xercesc</FONT></CODE> as a
597           generic namespace name which will be assigned to
598           <CODE><FONT face="courier, monospaced">xercesc_YY_ZZ</FONT></CODE> in each specific release, where
599           &quot;YY&quot; is the Major Release Number and &quot;ZZ&quot; is the Minor
600           Version Number. However, when you use
601           <CODE><FONT face="courier, monospaced">xercesc::</FONT></CODE> instead of
602           <CODE><FONT face="courier, monospaced">XERCES_CPP_NAMESPACE_QUALIFIER </FONT></CODE> when your
603           compiler does not support namespaces, your code will not
604           work.</P>
605 
606           
607
608    </FONT></TD></TR></TABLE><BR>
609
610
611    <A name="SpecifyLocaleForMessageLoader"><!--anchor--></A>
612    <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>Specify Locale for Message Loader</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
613
614        <P>The Xerces-C++ has implemented mechanism to support NLS, though
615        the current drop has only English version message file, it is capable
616        to support other languages once the translated version of the target
617        language is available.</P>
618
619        <P>Application can specify the locale for the message loader in their
620        very first invocation to XMLPlatformUtils::Initialize() by supplying
621        a parameter for the target locale intended. The defaul locale is &quot;en_US&quot;.
622        </P>
623
624<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>
625
626...
627    // Initialize the parser system
628    try
629    {
630         XMLPlatformUtils::Initialize(&quot;fr_FR&quot;);
631    }
632
633    catch ()
634    {
635    }
636..
637</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>
638    </FONT></TD></TR></TABLE><BR>
639
640
641    <A name="SpecifyLocationForMessageLoader"><!--anchor--></A>
642    <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>Specify Location for Message Loader</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
643
644        <P>The Xerces-C++ searches for message files at the default message directory, $XERCESCROOT/msg.
645        </P>
646
647        <P>Application can specify an alternative location for the message files in their
648        very first invocation to XMLPlatformUtils::Initialize() by supplying
649        a parameter for the alternative location intended.
650        </P>
651
652<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>
653
654...
655    // Initialize the parser system
656    try
657    {
658         XMLPlatformUtils::Initialize(&quot;en_US&quot;, &quot;/usr/application_root/msg_home&quot;);
659    }
660
661    catch ()
662    {
663    }
664..
665</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>
666    </FONT></TD></TR></TABLE><BR>
667
668    <A name="PluggablePanicHandler"><!--anchor--></A>
669    <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>Pluggable Panic Handler</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
670
671        <P>The Xerces-C++ reports, through the method panic(), any panic encountered,
672           to the panic handler installed, which in turn takes whatever action appropriate,
673           to handle the panic.                   
674        </P>
675        <P>The Xerces-C++ allows application plugging a customized panic handler
676           (class implementing the interface PanicHandler), in its very first invocation to
677           XMLPlatformUtils::Initialize() by supplying a parameter for the panic handler
678           intended.
679        </P>
680        <P>In the absence of such a plugged panic handler, Xerces-C++ default
681           panic handler is installed and used, which aborts program whenever a panic
682           is seen.
683        </P>
684
685<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>
686
687...
688    // Initialize the parser system
689    try
690    {
691         PanicHandler* ph = new MyPanicHandler();
692
693         XMLPlatformUtils::Initialize(&quot;en_US&quot;
694                                    , &quot;/usr/application_root/msg_home&quot;
695                                    , ph);
696    }
697
698    catch ()
699    {
700    }
701..
702</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>
703    </FONT></TD></TR></TABLE><BR>
704
705    <A name="PluggableMemoryManager"><!--anchor--></A>
706    <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>Pluggable Memory Manager</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
707        <P>Certain applications wish to maintain precise control over
708        memory allocation.  This enables them to recover more easily
709        from crashes of individual components, as well as to allocate
710        memory more efficiently than a general-purpose OS-level
711        procedure with no knowledge of the characteristics of the
712        program making the requests for memory.  As of Xerces-C 2.3.0 this
713        is supported via the Pluggable Memory Handler.
714        </P>
715        <P>Users that have no particular memory management
716        requirements (beyond that components don't leak memory or
717        attempt to read from or write to areas of memory they haven't
718        been assigned), should notice no behavioural changes in the
719        parser, so long as their code conforms to Xerces-C best
720        practices (e.g., avoids implicit destruction of objects
721        related to the parser after XMLPlatformUtils::Terminate() has
722        been called; see <A href="faq-parse.html#faq-7">the FAQ
723        entry describing a reason why applications may suddenly start
724        segfaulting with Xerces-C 2.3.0</A> for details.).  Such users can ignore this subsection and
725        continue using the parser as they always had.
726        </P>
727        <P>Users who wish to implement their own MemoryManager,
728        an interface found in xercesc/framework/MemoryManager.hpp, need
729        implement only two methods:</P>
730<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>
731// This method allocates requested memory.
732// the parameter is the requested memory size
733// A pointer to the allocated memory is returned.
734virtual void* allocate(size_t size) = 0;
735
736// This method deallocates memory
737// The parameter is a pointer to the allocated memory to be deleted
738virtual void deallocate(void* p) = 0;
739</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>
740        <P>To maximize the amount of flexibility that applications
741        have in terms of controlling memory allocation, a
742        MemoryManager instance may be set as part of the call to
743        XMLPlatformUtils::Initialize() to allow for static
744        initialization to be done with the given MemoryHandler; a
745        (possibly different) MemoryManager may be passed in to the
746        constructors of all Xerces parser objects as well, and all
747        dynamic allocations within the parsers will make use of this
748        object.  Assuming that MyMemoryHandler is a class that
749        implements the MemoryManager interface, here is a bit of
750        pseudocode which illustrates these ideas:
751        </P>
752<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>
753MyMemoryHandler *mm_for_statics = new MyMemoryHandler();
754MyMemoryHandler *mm_for_particular_parser = new MyMemoryManager();
755
756// initialize the parser information; try/catch
757// removed for brevity
758XMLPlatformUtils::Initialize(XMLUni::fgXercescDefaultLocale, 0,0,
759        mm_for_statics);
760
761// create a parser object
762XercesDOMParser *parser = new
763        XercesDomParser(mm_for_particular_parser);
764
765// ...
766delete parser;
767XMLPlatformUtils::Terminate();
768</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>
769      <P>
770        Notice that, to maintain backward compatibility, the
771        MemoryManager parameter is positioned last in the list of
772        parameters to XMLPlatformUtils::Initialize(); this means that
773        all other parameters must be specified with their defaults as
774        found in Xerces code if all other aspects of standard
775        behaviour are to be preserved. 
776      </P>
777      <P>
778        If a user provides a MemoryManager object to the parser, then
779        the user owns that object.  It is also important to note that
780        Xerces default implementation simply uses the global new and
781        delete.
782      </P>
783      <P>
784        Finally, there are two platform/compiler-related
785        limitations of our memory handling facilities that
786        certain users will need to be aware of:
787      </P>
788      <UL>
789        <LI>The compiler shipped with HPUX 11 does not understand
790        &quot;placement&quot; delete operators.  These versions of delete
791        have the same signature as our &quot;placement&quot; new operators
792        but will only be invoked when an exception is thrown
793        during the construction of an object.  Since the HP
794        compiler does not permit delete to be overridden twice
795        within a class, we cannot provide a placement delete;
796        hence, in the few cases in which an exception may be
797        thrown during object construction by Xerces, destructors of objects
798        created during that construction will not be called.</LI>
799        <LI>There is a bug in versions of GCC older than 2.96
800        which makes it impossible to have the pluggable memory
801        manager create elements in the
802        <CODE><FONT face="courier, monospaced">RefHash3KeysIdPool</FONT></CODE> template hashtable.
803        Therefore, on this compiler, we must use global new for
804        this purpose.  These elements will be properly destroyed
805        under this compiler; the limitation is that, since the
806        pluggable memory manager cannot be used, these particular
807        elements will not be destroyed if the user destroys their
808        memory manager directly.  Note that this hashtable is not
809        used that often in Xerces.</LI>
810      </UL>
811    </FONT></TD></TR></TABLE><BR>
812
813    <A name="SecurityManager"><!--anchor--></A>
814    <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>Managing Security Vulnerabilities</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
815      <P>
816        The purpose of the SecurityManager class is to permit applications a
817        means to have the parser reject documents whose processing would
818        otherwise consume large amounts of system resources.  Malicious
819        use of such documents could be used to launch a denial-of-service
820        attack against a system running the parser.  Initially, the
821        SecurityManager only knows about attacks that can result from
822        exponential entity expansion; this is the only known attack that
823        involves processing a single XML document.  Other, simlar attacks
824        can be launched if arbitrary schemas may be parsed; there already
825        exist means (via use of the EntityResolver interface) by which
826        applications can deny processing of untrusted schemas.  In future,
827        the SecurityManager will be expanded to take these other exploits
828        into account.
829      </P>
830      <P>
831        The SecurityManager class is very simple:  It will contain
832        getters and setters corresponding to each known variety of
833        exploit.  These will reflect limits that the application may
834        impose on the parser with respect to the processing of various
835        XML constructs.  When an instance of SecurityManager is
836        instantiated, default values for these limits will be provided
837        that should suit most applications.
838      </P>
839      <P>
840        By default, Xerces-C is a wholly conformant XML parser; that
841        is, no security-related considerations will be observed by
842        default.  An application must set an instance of the
843        SecurityManager class on a Xerces parser in order to make that
844        parser behave in a security-conscious manner.  i.e.:
845      </P>
846<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>
847SAXParser *myParser = new SAXParser();
848SecurityManager *myManager = new SecurityManager();
849myManager-&gt;setEntityExpansionLimit(100000); // larger than default
850myParser-&gt;setSecurityManager(myManager);
851// ... use the parser
852</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>
853      <P>
854        Note that SecurityManager instances may be set on all kinds of
855        Xerces parsers; please see the documentation for the
856        individual parsers for details.
857      </P>
858      <P>
859        Note also that the application always owns the SecurityManager
860        instance.  The default SecurityManager that Xerces provides is
861        not thread-safe; although it only uses primitive operations at
862        the moment, users may need to extend the class with a
863        thread-safe implementation on some platforms.
864      </P>
865    </FONT></TD></TR></TABLE><BR>
866<A name="UseSpecificScanner"><!--anchor--></A>
867    <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>Use Specific Scanner</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">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
868
869        <P>For performance and modularity, the Xerces-C++ has implemented a mechanism
870        to allow users to specify the scanner to use when scanning an XML document.
871        Such mechanism will enable the creation of special purpose scanners that can be easily
872        plugged in.</P>
873
874        <P>Xerces-C++ supports the following scanners:</P>
875
876        <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="ffffff" colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><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="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></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="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>WFXMLScanner</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="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></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">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
877
878            <P>
879            The WFXMLScanner is a non-validating scanner which performs well-formedness check only.
880            It does not do any DTD/XMLSchema processing. If the XML document contains a DOCTYPE, it
881            will be silently ignored (i.e. no warning message is issued). Similiarly, any schema
882            specific attributes (e.g. schemaLocation), will be treated as normal element attributes.
883            Setting grammar specific features/properties will have no effect on its behavior
884            (e.g. setLoadExternalDTD(true) is ignored).
885            </P>
886
887<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>
888// Create a DOM parser
889XercesDOMParser parser;
890
891// Specify scanner name
892parser.useScanner(XMLUni::fgWFXMLScanner);
893
894// Specify other parser features, e.g.
895parser.setDoNamespaces(true);
896</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>
897
898
899        </FONT></TD></TR></TABLE><BR>
900
901        <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="ffffff" colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><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="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></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="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>DGXMLScanner</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="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></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">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
902
903            <P>
904            The DGXMLScanner handles XML documents with DOCTYPE information. It does not do any
905            XMLSchema processing, which means that any schema specific attributes (e.g. schemaLocation),
906            will be treated as normal element attributes. Setting schema grammar specific features/properties
907            will have no effect on its behavior (e.g. setDoSchema(true) is ignored).
908            </P>
909
910<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>
911// Create a SAX parser
912SAXParser parser;
913
914// Specify scanner name
915parser.useScanner(XMLUni::fgDGXMLScanner);
916
917// Specify other parser features, e.g.
918parser.setLoadExternalDTD(true);
919</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>
920
921        </FONT></TD></TR></TABLE><BR>
922
923        <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="ffffff" colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><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="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></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="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>SGXMLScanner</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="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></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">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
924
925            <P>
926            The SGXMLScanner handles XML documents with XML schema grammar information.
927            If the XML document contains a DOCTYPE, it will be ignored. Namespace and
928            schema processing features are on by default, and setting them to off has
929            not effect.
930            </P>
931
932<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>
933// Create a SAX2 parser
934SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
935
936// Specify scanner name
937parser-&gt;setProperty(XMLUni::fgXercesScannerName, (void *)XMLUni::fgSGXMLScanner);
938
939// Specify other parser features, e.g.
940parser-&gt;setFeature(XMLUni::fgXercesSchemaFullChecking, false);
941</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>
942
943        </FONT></TD></TR></TABLE><BR>
944
945        <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="ffffff" colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><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="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></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="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>IGXMLScanner</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="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></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">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
946
947            <P>
948            The IGXMLScanner is an integrated scanner and handles XML documents with DTD and/or
949            XML schema grammar. This is the default scanner used by the various parsers if no
950            scanner is specified.
951            </P>
952
953<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>
954// Create a DOMBuilder parser
955DOMBuilder *parser = ((DOMImplementationLS*)impl)-&gt;createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
956
957// Specify scanner name - This is optional as IGXMLScanner is the default
958parser-&gt;setProperty(XMLUni::fgXercesScannerName, (void *)XMLUni::fgIGXMLScanner);
959
960// Specify other parser features, e.g.
961parser-&gt;setFeature(XMLUni::fgDOMNamespaces, doNamespaces);
962parser-&gt;setFeature(XMLUni::fgXercesSchema, doSchema);
963</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>
964
965        </FONT></TD></TR></TABLE><BR>
966
967    </FONT></TD></TR></TABLE><BR>
968
969</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>
970              Copyright &copy; 1999-2004 The Apache Software Foundation.
971              All Rights Reserved.
972            </I></FONT></TD></TR></TABLE></BODY></HTML>
Note: See TracBrowser for help on using the repository browser.