You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
772 lines
88 KiB
772 lines
88 KiB
<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-3-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>
|
|
|
|
<A href="../index.html" onMouseOut="rolloverOff('side-ext-2');" onMouseOver="rolloverOn('side-ext-2');"><IMG alt="Xerces Project" 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>
|
|
|
|
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
|
|
|
|
<A href="index.html" onMouseOut="rolloverOff('side-index');" onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" 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>
|
|
<A href="charter.html" onMouseOut="rolloverOff('side-charter');" onMouseOver="rolloverOn('side-charter');"><IMG alt="Charter" border="0" height="12" hspace="0" name="side-charter" onLoad="rolloverLoad('side-charter','graphics/charter-label-2.jpg','graphics/charter-label-3.jpg');" src="graphics/charter-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
<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>
|
|
<A href="secadv.html" onMouseOut="rolloverOff('side-secadv');" onMouseOver="rolloverOn('side-secadv');"><IMG alt="Advisories" border="0" height="12" hspace="0" name="side-secadv" onLoad="rolloverLoad('side-secadv','graphics/secadv-label-2.jpg','graphics/secadv-label-3.jpg');" src="graphics/secadv-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
|
|
|
|
<A href="http://xerces.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>
|
|
|
|
|
|
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
|
|
|
|
<IMG alt="Xerces-C++ 3.1.2" border="0" height="17" hspace="0" name="side-sect-24" src="graphics/sect-24-label.jpg" vspace="0" width="120"><BR>
|
|
|
|
<A href="install-3.html" onMouseOut="rolloverOff('side-install-3');" onMouseOver="rolloverOn('side-install-3');"><IMG alt="Installation" border="0" height="12" hspace="0" name="side-install-3" onLoad="rolloverLoad('side-install-3','graphics/install-3-label-2.jpg','graphics/install-3-label-3.jpg');" src="graphics/install-3-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
<A href="build-3.html" onMouseOut="rolloverOff('side-build-3');" onMouseOver="rolloverOn('side-build-3');"><IMG alt="Build Instructions" border="0" height="12" hspace="0" name="side-build-3" onLoad="rolloverLoad('side-build-3','graphics/build-3-label-2.jpg','graphics/build-3-label-3.jpg');" src="graphics/build-3-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
|
|
<IMG border="0" height="6" hspace="0" src="resources/separator-space.gif" vspace="0" width="120"><BR>
|
|
|
|
<A href="program-3.html" onMouseOut="rolloverOff('side-program-3');" onMouseOver="rolloverOn('side-program-3');"><IMG alt="Programming" border="0" height="12" hspace="0" name="side-program-3" onLoad="rolloverLoad('side-program-3','graphics/program-3-label-2.jpg','graphics/program-3-label-3.jpg');" src="graphics/program-3-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A href="samples-3.html" onMouseOut="rolloverOff('side-samples-3');" onMouseOver="rolloverOn('side-samples-3');"><IMG alt="Samples" border="0" height="12" hspace="0" name="side-samples-3" onLoad="rolloverLoad('side-samples-3','graphics/samples-3-label-2.jpg','graphics/samples-3-label-3.jpg');" src="graphics/samples-3-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A href="faqs-3.html" onMouseOut="rolloverOff('side-faqs-3');" onMouseOver="rolloverOn('side-faqs-3');"><IMG alt="FAQs" border="0" height="12" hspace="0" name="side-faqs-3" onLoad="rolloverLoad('side-faqs-3','graphics/faqs-3-label-2.jpg','graphics/faqs-3-label-3.jpg');" src="graphics/faqs-3-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
|
|
<IMG border="0" height="6" hspace="0" src="resources/separator-space.gif" vspace="0" width="120"><BR>
|
|
|
|
<A href="api-3.html" onMouseOut="rolloverOff('side-api-3');" onMouseOver="rolloverOn('side-api-3');"><IMG alt="API Reference" border="0" height="12" hspace="0" name="side-api-3" onLoad="rolloverLoad('side-api-3','graphics/api-3-label-2.jpg','graphics/api-3-label-3.jpg');" src="graphics/api-3-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
<A href="ApacheDOMC++Binding.html" onMouseOut="rolloverOff('side-ext-84');" onMouseOver="rolloverOn('side-ext-84');"><IMG alt="DOM C++ Binding" border="0" height="12" hspace="0" name="side-ext-84" onLoad="rolloverLoad('side-ext-84','graphics/ext-84-label-2.jpg','graphics/ext-84-label-3.jpg');" src="graphics/ext-84-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
<A href="migrate-3.html" onMouseOut="rolloverOff('side-migrate-3');" onMouseOver="rolloverOn('side-migrate-3');"><IMG alt="Migration Guide" border="0" height="12" hspace="0" name="side-migrate-3" onLoad="rolloverLoad('side-migrate-3','graphics/migrate-3-label-2.jpg','graphics/migrate-3-label-3.jpg');" src="graphics/migrate-3-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
|
|
|
|
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
|
|
|
|
<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>
|
|
<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>
|
|
<A href="mailing-lists.html" onMouseOut="rolloverOff('side-mailing-lists');" onMouseOver="rolloverOn('side-mailing-lists');"><IMG alt="Mailing Lists" border="0" height="12" hspace="0" name="side-mailing-lists" onLoad="rolloverLoad('side-mailing-lists','graphics/mailing-lists-label-2.jpg','graphics/mailing-lists-label-3.jpg');" src="graphics/mailing-lists-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
|
|
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
|
|
|
|
<A href="source-repository.html" onMouseOut="rolloverOff('side-source-repository');" onMouseOver="rolloverOn('side-source-repository');"><IMG alt="Source Repository" border="0" height="12" hspace="0" name="side-source-repository" onLoad="rolloverLoad('side-source-repository','graphics/source-repository-label-2.jpg','graphics/source-repository-label-3.jpg');" src="graphics/source-repository-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
<A href="applications.html" onMouseOut="rolloverOff('side-applications');" onMouseOver="rolloverOn('side-applications');"><IMG alt="Applications" border="0" height="12" hspace="0" name="side-applications" onLoad="rolloverLoad('side-applications','graphics/applications-label-2.jpg','graphics/applications-label-3.jpg');" src="graphics/applications-label-3.jpg" vspace="0" width="120"></A><BR>
|
|
|
|
<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>
|
|
<A name="Macro"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
<P>Xerces-C++ defines a numeric preprocessor macro, _XERCES_VERSION, for users to
|
|
introduce into their code to perform conditional compilation where the
|
|
version of Xerces-C++ is detected in order to enable or disable version
|
|
specific capabilities. For example,
|
|
</P>
|
|
<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>
|
|
#if _XERCES_VERSION >= 30102
|
|
// Code specific to Xerces-C++ version 3.1.2 and later.
|
|
#else
|
|
// Old code.
|
|
#endif
|
|
</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>
|
|
<P>The minor and revision (patch level) numbers have two digits of resolution
|
|
which means that '1' becomes '01' and '2' becomes '02' in this example.
|
|
</P>
|
|
<P>There are also other string macros or constants to represent the Xerces-C++ version.
|
|
Please refer to the <CODE><FONT face="courier, monospaced">xercesc/util/XercesVersion.hpp</FONT></CODE> header for details.
|
|
</P>
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
|
|
<A name="Schema"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
<P>Xerces-C++ contains an implementation of the W3C XML Schema
|
|
Language. See the <A href="schema-3.html">XML Schema Support</A> page for details.
|
|
</P>
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<A name="Progressive"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
|
|
<P>In addition to using the <CODE><FONT face="courier, monospaced">parse()</FONT></CODE> method to parse an XML File.
|
|
You can use the other two parsing methods, <CODE><FONT face="courier, monospaced">parseFirst()</FONT></CODE> and <CODE><FONT face="courier, monospaced">parseNext()</FONT></CODE>
|
|
to do the so called progressive parsing. This way you don't
|
|
have to depend on throwing an exception to terminate the
|
|
parsing operation.
|
|
</P>
|
|
<P>
|
|
Calling <CODE><FONT face="courier, monospaced">parseFirst()</FONT></CODE> will cause the DTD (both internal and
|
|
external subsets), and any pre-content, i.e. everything up to
|
|
but not including the root element, to be parsed. Subsequent calls to
|
|
<CODE><FONT face="courier, monospaced">parseNext()</FONT></CODE> will cause one more pieces of markup to be parsed,
|
|
and propagated from the core scanning code to the parser (and
|
|
hence either on to you if using SAX/SAX2 or into the DOM tree if
|
|
using DOM).
|
|
</P>
|
|
<P>
|
|
You can quit the parse any time by just not
|
|
calling <CODE><FONT face="courier, monospaced">parseNext()</FONT></CODE> anymore and breaking out of the loop. When
|
|
you call <CODE><FONT face="courier, monospaced">parseNext()</FONT></CODE> and the end of the root element is the
|
|
next piece of markup, the parser will continue on to the end
|
|
of the file and return false, to let you know that the parse
|
|
is done. So a typical progressive parse loop will look like
|
|
this:</P>
|
|
|
|
<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
|
|
XMLPScanToken token;
|
|
|
|
if (!parser.parseFirst(xmlFile, token))
|
|
{
|
|
cerr << "scanFirst() failed\n" << endl;
|
|
return 1;
|
|
}
|
|
|
|
//
|
|
// We started ok, so lets call scanNext()
|
|
// until we find what we want or hit the end.
|
|
//
|
|
bool gotMore = true;
|
|
while (gotMore && !handler.getDone())
|
|
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>
|
|
|
|
<P>In this case, our event handler object (named 'handler')
|
|
is watching for some criteria and will
|
|
return a status from its <CODE><FONT face="courier, monospaced">getDone()</FONT></CODE> method. Since
|
|
the handler
|
|
sees the SAX events coming out of the SAXParser, it can tell
|
|
when it finds what it wants. So we loop until we get no more
|
|
data or our handler indicates that it saw what it wanted to
|
|
see.</P>
|
|
|
|
<P>When doing non-progressive parses, the parser can easily
|
|
know when the parse is complete and insure that any used
|
|
resources are cleaned up. Even in the case of a fatal parsing
|
|
error, it can clean up all per-parse resources. However, when
|
|
progressive parsing is done, the client code doing the parse
|
|
loop might choose to stop the parse before the end of the
|
|
primary file is reached. In such cases, the parser will not
|
|
know that the parse has ended, so any resources will not be
|
|
reclaimed until the parser is destroyed or another parse is started.</P>
|
|
|
|
<P>This might not seem like such a bad thing; however, in this case,
|
|
the files and sockets which were opened in order to parse the
|
|
referenced XML entities will remain open. This could cause
|
|
serious problems. Therefore, you should destroy the parser instance
|
|
in such cases, or restart another parse immediately. In a future
|
|
release, a reset method will be provided to do this more cleanly.</P>
|
|
|
|
<P>Also note that you must create a scan token and pass it
|
|
back in on each call. This insures that things don't get done
|
|
out of sequence. When you call <CODE><FONT face="courier, monospaced">parseFirst()</FONT></CODE> or
|
|
<CODE><FONT face="courier, monospaced">parse()</FONT></CODE>, any
|
|
previous scan tokens are invalidated and will cause an error
|
|
if used again. This prevents incorrect mixed use of the two
|
|
different parsing schemes or incorrect calls to
|
|
<CODE><FONT face="courier, monospaced">parseNext()</FONT></CODE>.</P>
|
|
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<A name="GrammarCache"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Pre-parsing 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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
<P>Xerces-C++ provides a function to pre-parse the grammar so that users
|
|
can check for any syntax error before using the grammar. Users can also optionally
|
|
cache these pre-parsed grammars for later use during actual parsing.
|
|
</P>
|
|
<P>Here is an example:</P>
|
|
<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>
|
|
XercesDOMParser parser;
|
|
|
|
// Enable schema processing.
|
|
parser.setDoSchema(true);
|
|
parser.setDONamespaces(true);
|
|
|
|
// Let's preparse the schema grammar (.xsd) and cache it.
|
|
Grammar* grammar = parser.loadGrammar(xmlFile, Grammar::SchemaGrammarType, true);
|
|
</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>
|
|
<P>Besides caching pre-parsed schema grammars, users can also cache any
|
|
grammars encountered during an xml document parse.
|
|
</P>
|
|
<P>Here is an example:</P>
|
|
<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>
|
|
SAXParser parser;
|
|
|
|
// Enable grammar caching by setting cacheGrammarFromParse to true.
|
|
// The parser will cache any encountered grammars if it does not
|
|
// exist in the pool.
|
|
// If the grammar is DTD, no internal subset is allowed.
|
|
parser.cacheGrammarFromParse(true);
|
|
|
|
// Let's parse our xml file (DTD grammar)
|
|
parser.parse(xmlFile);
|
|
|
|
// We can get the grammar where the root element was declared
|
|
// by calling the parser's method getRootGrammar;
|
|
// Note: The parser owns the grammar, and the user should not delete it.
|
|
Grammar* grammar = parser.getRootGrammar();
|
|
</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>
|
|
<P>We can use any previously cached grammars when parsing new xml
|
|
documents. Here are some examples on how to use those cached grammars:
|
|
</P>
|
|
<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>
|
|
/**
|
|
* Caching and reusing XML Schema (.xsd) grammar
|
|
* Parse an XML document and cache its grammar set. Then, use the cached
|
|
* grammar set in subsequent parses.
|
|
*/
|
|
|
|
XercesDOMParser parser;
|
|
|
|
// Enable schema processing
|
|
parser.setDoSchema(true);
|
|
parser.setDoNamespaces(true);
|
|
|
|
// Enable grammar caching
|
|
parser.cacheGrammarFromParse(true);
|
|
|
|
// Let's parse the XML document. The parser will cache any grammars encountered.
|
|
parser.parse(xmlFile);
|
|
|
|
// No need to enable re-use by setting useCachedGrammarInParse to true. It is
|
|
// automatically enabled with grammar caching.
|
|
for (int i=0; i< 3; i++)
|
|
parser.parse(xmlFile);
|
|
|
|
// This will flush the grammar pool
|
|
parser.resetCachedGrammarPool();
|
|
</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>
|
|
|
|
<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>
|
|
/**
|
|
* Caching and reusing DTD grammar
|
|
* Preparse a grammar and cache it in the pool. Then, we use the cached grammar
|
|
* when parsing XML documents.
|
|
*/
|
|
|
|
SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
|
|
|
|
// Load grammar and cache it
|
|
parser->loadGrammar(dtdFile, Grammar::DTDGrammarType, true);
|
|
|
|
// enable grammar reuse
|
|
parser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true);
|
|
|
|
// Parse xml files
|
|
parser->parse(xmlFile1);
|
|
parser->parse(xmlFile2);
|
|
</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>
|
|
<P>There are some limitations about caching and using cached grammars:</P>
|
|
<UL>
|
|
<LI>When caching/reusing DTD grammars, no internal subset is allowed.</LI>
|
|
<LI>When preparsing grammars with caching option enabled, if a grammar, in the
|
|
result set, already exists in the pool (same namespace for schema or same system
|
|
id for DTD), the entire set will not be cached. This behavior is the default but can
|
|
be overridden for XML Schema caching. See the SAX/SAX2/DOM parser features for details.</LI>
|
|
<LI>When parsing an XML document with the grammar caching option enabled, the
|
|
reuse option is also automatically enabled. We will only parse a grammar if it
|
|
does not exist in the pool.</LI>
|
|
</UL>
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<A name="LoadableMessageText"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
|
|
<P>The Xerces-C++ supports loadable message text. Although
|
|
the current distribution only supports English, it is capable of
|
|
supporting other
|
|
languages. Anyone interested in contributing any translations
|
|
should contact us. This would be an extremely useful
|
|
service.</P>
|
|
|
|
<P>In order to support the local message loading services, all the error messages
|
|
are captured in an XML file in the src/xercesc/NLS/ directory.
|
|
There is a simple program, in the tools/NLS/Xlat/ directory,
|
|
which can translate that text in various formats. It currently
|
|
supports a simple 'in memory' format (i.e. an array of
|
|
strings), the Win32 resource format, and the message catalog
|
|
format. The 'in memory' format is intended for very simple
|
|
installations or for use when porting to a new platform (since
|
|
you can use it until you can get your own local message
|
|
loading support done.)</P>
|
|
|
|
<P>In the src/xercesc/util/ directory, there is an XMLMsgLoader
|
|
class. This is an abstraction from which any number of
|
|
message loading services can be derived. Your platform driver
|
|
file can create whichever type of message loader it wants to
|
|
use on that platform. Xerces-C++ currently has versions for the in
|
|
memory format, the Win32 resource format, the message
|
|
catalog format, and ICU message loader.
|
|
Some of the platforms can support multiple message
|
|
loaders, in which case a #define token is used to control
|
|
which one is used. You can set this in your build projects to
|
|
control the message loader type used.</P>
|
|
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<A name="PluggableTranscoders"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
|
|
<P>Xerces-C++ also supports pluggable transcoding services. The
|
|
XMLTransService class is an abstract API that can be derived
|
|
from, to support any desired transcoding
|
|
service. XMLTranscoder is the abstract API for a particular
|
|
instance of a transcoder for a particular encoding. The
|
|
platform driver file decides what specific type of transcoder
|
|
to use, which allows each platform to use its native
|
|
transcoding services, or the ICU service if desired.</P>
|
|
|
|
<P>Implementations are provided for Win32 native services, ICU
|
|
services, and the <I>iconv</I> services available on many
|
|
Unix platforms. The Win32 version only provides native code
|
|
page services, so it can only handle XML code in the intrinsic
|
|
encodings ASCII, UTF-8, UTF-16 (Big/Small Endian), UCS4
|
|
(Big/Small Endian), EBCDIC code pages IBM037, IBM1047 and
|
|
IBM1140 encodings, ISO-8859-1 (aka Latin1) and Windows-1252. The ICU version
|
|
provides all of the encodings that ICU supports. The
|
|
<I>iconv</I> version will support the encodings supported
|
|
by the local system. You can use transcoders we provide or
|
|
create your own if you feel ours are insufficient in some way,
|
|
or if your platform requires an implementation that Xerces-C++ does not
|
|
provide.</P>
|
|
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<A name="PortingGuidelines"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
|
|
<P>All platform dependent code in Xerces-C++ has been
|
|
isolated to a couple of files, which should ease the porting
|
|
effort. The <CODE><FONT face="courier, monospaced">src/xercesc/util</FONT></CODE> directory
|
|
contains all such files. In particular:</P>
|
|
|
|
<UL>
|
|
<LI>The <CODE><FONT face="courier, monospaced">src/xercesc/util/FileManagers</FONT></CODE> directory
|
|
contains implementations of file managers for various
|
|
platforms.</LI>
|
|
|
|
<LI>The <CODE><FONT face="courier, monospaced">src/xercesc/util/MutexManagers</FONT></CODE> directory
|
|
contains implementations of mutex managers for various
|
|
platforms.</LI>
|
|
|
|
<LI>The <CODE><FONT face="courier, monospaced">src/xercesc/util/Xerces_autoconf_const*</FONT></CODE> files
|
|
provide base definitions for various platforms.</LI>
|
|
</UL>
|
|
|
|
<P>Other concerns are:</P>
|
|
|
|
<UL>
|
|
<LI>Does ICU compile on your platform? If not, then you'll need to
|
|
create a transcoder implementation that uses your local transcoding
|
|
services. The iconv transcoder should work for you, though perhaps
|
|
with some modifications.</LI>
|
|
<LI>What message loader will you use? To get started, you can use the
|
|
"in memory" one, which is very simple and easy. Then, once you get
|
|
going, you may want to adapt the message catalog message loader, or
|
|
write one of your own that uses local services.</LI>
|
|
<LI>What should I define XMLCh to be? Please refer to <A href="build-misc-3.html#XMLChInfo">What should I define XMLCh to be?</A> for
|
|
further details.</LI>
|
|
</UL>
|
|
|
|
<P>Finally, you need to decide about how to define XMLCh. Generally,
|
|
XMLCh should be defined to be a type suitable for holding a
|
|
utf-16 encoded (16 bit) value, usually an <CODE><FONT face="courier, monospaced">unsigned short</FONT></CODE>. </P>
|
|
|
|
<P>All XML data is handled within Xerces-C++ as strings of
|
|
XMLCh characters. Regardless of the size of the
|
|
type chosen, the data stored in variables of type XMLCh
|
|
will always be utf-16 encoded values. </P>
|
|
|
|
|
|
|
|
<P>Unlike XMLCh, the encoding
|
|
of wchar_t is platform dependent. Sometimes it is utf-16
|
|
(AIX, Windows), sometimes ucs-4 (Solaris,
|
|
Linux), sometimes it is not based on Unicode at all
|
|
(HP/UX, AS/400, system 390). </P>
|
|
|
|
<P>Some earlier releases of Xerces-C++ defined XMLCh to be the
|
|
same type as wchar_t on most platforms, with the goal of making
|
|
it possible to pass XMLCh strings to library or system functions
|
|
that were expecting wchar_t parameters. This approach has
|
|
been abandoned because of</P>
|
|
|
|
<UL>
|
|
<LI>
|
|
Portability problems with any code that assumes that
|
|
the types of XMLCh and wchar_t are compatible
|
|
</LI>
|
|
|
|
<LI>Excessive memory usage, especially in the DOM, on
|
|
platforms with 32 bit wchar_t.
|
|
</LI>
|
|
|
|
<LI>utf-16 encoded XMLCh is not always compatible with
|
|
ucs-4 encoded wchar_t on Solaris and Linux. The
|
|
problem occurs with Unicode characters with values
|
|
greater than 64k; in ucs-4 the value is stored as
|
|
a single 32 bit quantity. With utf-16, the value
|
|
will be stored as a "surrogate pair" of two 16 bit
|
|
values. Even with XMLCh equated to wchar_t, xerces will
|
|
still create the utf-16 encoded surrogate pairs, which
|
|
are illegal in ucs-4 encoded wchar_t strings.
|
|
</LI>
|
|
</UL>
|
|
|
|
|
|
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<A name="CPPNamespace"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
|
|
<P>Xerces-C++ makes use of C++ namespace to make sure its
|
|
definitions do not conflict with other libraries and
|
|
applications. As a result applications must
|
|
namespace-qualify all Xerces-C++ classes, data and
|
|
variables using the <CODE><FONT face="courier, monospaced">xercesc</FONT></CODE> name. Alternatively,
|
|
applications can use <CODE><FONT face="courier, monospaced">using xercesc::<Name>;</FONT></CODE>
|
|
declarations
|
|
to make individual Xerces-C++ names visible in the
|
|
current scope
|
|
or <CODE><FONT face="courier, monospaced">using namespace xercesc;</FONT></CODE>
|
|
definition to make all Xerces-C++ names visible in the
|
|
current scope.</P>
|
|
|
|
<P>While the above information should be sufficient for the majority
|
|
of applications, for cases where several versions of the Xerces-C++
|
|
library must be used in the same application, namespace versioning is
|
|
provided. The following convenience macros can be used to access the
|
|
Xerces-C++ namespace names with versions embedded
|
|
(see <CODE><FONT face="courier, monospaced">src/xercesc/util/XercesDefs.hpp</FONT></CODE>):</P>
|
|
|
|
<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>
|
|
#define XERCES_CPP_NAMESPACE_BEGIN namespace xercesc_3_1 {
|
|
#define XERCES_CPP_NAMESPACE_END }
|
|
#define XERCES_CPP_NAMESPACE_USE using namespace xercesc_3_1;
|
|
#define XERCES_CPP_NAMESPACE_QUALIFIER xercesc_3_1::
|
|
|
|
namespace xercesc_3_1 { }
|
|
namespace xercesc = xercesc_3_1;
|
|
</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>
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
|
|
<A name="SpecifyLocaleForMessageLoader"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
|
|
<P>Xerces-C++ provides mechanisms for Native Language Support (NLS).
|
|
Even though
|
|
the current distribution has only English message file, it is capable
|
|
of supporting other languages once the translated version of the
|
|
target language is available.</P>
|
|
|
|
<P>An application can specify the locale for the message loader in their
|
|
very first invocation to XMLPlatformUtils::Initialize() by supplying
|
|
a parameter for the target locale intended. The default locale is "en_US".
|
|
</P>
|
|
<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>
|
|
// Initialize the parser system
|
|
try
|
|
{
|
|
XMLPlatformUtils::Initialize("fr_FR");
|
|
}
|
|
catch ()
|
|
{
|
|
}
|
|
</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>
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
|
|
<A name="SpecifyLocationForMessageLoader"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
|
|
<P>Xerces-C++ searches for message files at the location
|
|
specified in the <CODE><FONT face="courier, monospaced">XERCESC_NLS_HOME</FONT></CODE> environment
|
|
variable and, if that is not set, at the default
|
|
message directory, <CODE><FONT face="courier, monospaced">$XERCESCROOT/msg</FONT></CODE>.
|
|
</P>
|
|
|
|
<P>Application can specify an alternative location for the message files in their
|
|
very first invocation to XMLPlatformUtils::Initialize() by supplying
|
|
a parameter for the alternative location.
|
|
</P>
|
|
|
|
<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>
|
|
// Initialize the parser system
|
|
try
|
|
{
|
|
XMLPlatformUtils::Initialize("en_US", "/usr/nls");
|
|
}
|
|
catch ()
|
|
{
|
|
}
|
|
</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>
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<A name="PluggablePanicHandler"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
|
|
<P>Xerces-C++ reports panic conditions encountered to the panic
|
|
handler installed. The panic handler can take whatever action
|
|
appropriate to handle the panic condition.
|
|
</P>
|
|
<P>Xerces-C++ allows application to provide a customized panic handler
|
|
(class implementing the interface PanicHandler), in its very first invocation of
|
|
XMLPlatformUtils::Initialize().
|
|
</P>
|
|
<P>In the absence of an application-specific panic handler, Xerces-C++ default
|
|
panic handler is installed and used, which aborts program whenever a panic
|
|
condition is encountered.
|
|
</P>
|
|
|
|
<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>
|
|
// Initialize the parser system
|
|
try
|
|
{
|
|
PanicHandler* ph = new MyPanicHandler();
|
|
|
|
XMLPlatformUtils::Initialize("en_US",
|
|
"/usr/nls",
|
|
ph);
|
|
}
|
|
catch ()
|
|
{
|
|
}
|
|
</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>
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<A name="PluggableMemoryManager"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
<P>Certain applications wish to maintain precise control over
|
|
memory allocation. This enables them to recover more easily
|
|
from crashes of individual components, as well as to allocate
|
|
memory more efficiently than a general-purpose OS-level
|
|
procedure with no knowledge of the characteristics of the
|
|
program making the requests for memory. In Xerces-C++ this
|
|
is supported via the Pluggable Memory Handler.
|
|
</P>
|
|
|
|
<P>Users who wish to implement their own MemoryManager,
|
|
an interface found in <CODE><FONT face="courier, monospaced">xercesc/framework/MemoryManager.hpp</FONT></CODE>,
|
|
need to implement only two methods:</P>
|
|
<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>
|
|
// This method allocates requested memory.
|
|
// the parameter is the requested memory size
|
|
// A pointer to the allocated memory is returned.
|
|
virtual void* allocate(XMLSize_t size) = 0;
|
|
|
|
// This method deallocates memory
|
|
// The parameter is a pointer to the allocated memory to be deleted
|
|
virtual void deallocate(void* p) = 0;
|
|
</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>
|
|
<P>To maximize the amount of flexibility that applications
|
|
have in terms of controlling memory allocation, a
|
|
MemoryManager instance may be set as part of the call to
|
|
XMLPlatformUtils::Initialize() to allow for static
|
|
initialization to be done with the given MemoryHandler; a
|
|
(possibly different) MemoryManager may be passed in to the
|
|
constructors of all Xerces parser objects as well, and all
|
|
dynamic allocations within the parsers will make use of this
|
|
object. Assuming that MyMemoryHandler is a class that
|
|
implements the MemoryManager interface, here is a bit of
|
|
pseudocode which illustrates these ideas:
|
|
</P>
|
|
<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>
|
|
MyMemoryHandler *mm_for_statics = new MyMemoryHandler();
|
|
MyMemoryHandler *mm_for_particular_parser = new MyMemoryManager();
|
|
|
|
// initialize the parser information; try/catch
|
|
// removed for brevity
|
|
XMLPlatformUtils::Initialize(XMLUni::fgXercescDefaultLocale, 0,0,
|
|
mm_for_statics);
|
|
|
|
// create a parser object
|
|
XercesDOMParser *parser = new
|
|
XercesDomParser(mm_for_particular_parser);
|
|
|
|
// ...
|
|
delete parser;
|
|
XMLPlatformUtils::Terminate();
|
|
</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>
|
|
<P>
|
|
If a user provides a MemoryManager object to the parser, then
|
|
the user owns that object. It is also important to note that
|
|
Xerces-C++ default implementation simply uses the global
|
|
new and delete operators.
|
|
</P>
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<A name="SecurityManager"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
<P>
|
|
The purpose of the SecurityManager class is to permit applications a
|
|
means to have the parser reject documents whose processing would
|
|
otherwise consume large amounts of system resources. Malicious
|
|
use of such documents could be used to launch a denial-of-service
|
|
attack against a system running the parser. Initially, the
|
|
SecurityManager only knows about attacks that can result from
|
|
exponential entity expansion; this is the only known attack that
|
|
involves processing a single XML document. Other, similar attacks
|
|
can be launched if arbitrary schemas may be parsed; there already
|
|
exist means (via use of the EntityResolver interface) by which
|
|
applications can deny processing of untrusted schemas. In future,
|
|
the SecurityManager will be expanded to take these other exploits
|
|
into account.
|
|
</P>
|
|
<P>
|
|
The SecurityManager class is very simple: It will contain
|
|
getters and setters corresponding to each known variety of
|
|
exploit. These will reflect limits that the application may
|
|
impose on the parser with respect to the processing of various
|
|
XML constructs. When an instance of SecurityManager is
|
|
instantiated, default values for these limits will be provided
|
|
that should suit most applications.
|
|
</P>
|
|
<P>
|
|
By default, Xerces-C++ is a wholly conformant XML parser; that
|
|
is, no security-related considerations will be observed by
|
|
default. An application must provide an instance of the
|
|
SecurityManager class to a parser in order to make that
|
|
parser behave in a security-conscious manner. For example:
|
|
</P>
|
|
<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>
|
|
SAXParser *myParser = new SAXParser();
|
|
SecurityManager *myManager = new SecurityManager();
|
|
myManager->setEntityExpansionLimit(100000); // larger than default
|
|
myParser->setSecurityManager(myManager);
|
|
// ... use the parser
|
|
</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>
|
|
<P>
|
|
Note that SecurityManager instances may be set on all kinds of
|
|
Xerces-C++ parsers; please see the documentation for the
|
|
individual parsers for details.
|
|
</P>
|
|
<P>
|
|
Note also that the application always owns the SecurityManager
|
|
instance. The default SecurityManager that Xerces-C++ provides
|
|
is not thread-safe; although it only uses primitive operations at
|
|
the moment, users may need to extend the class with a
|
|
thread-safe implementation on some platforms.
|
|
</P>
|
|
</FONT></TD></TR></TABLE><BR>
|
|
<A name="UseSpecificScanner"><!--anchor--></A>
|
|
<TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="ffffff" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>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"> </TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
|
|
|
|
<P>For performance and modularity Xerces-C++ provides a mechanism
|
|
for specifying the scanner to be used when scanning an XML document.
|
|
Such mechanism will enable the creation of special purpose scanners
|
|
that can be easily plugged in.</P>
|
|
|
|
<P>Xerces-C++ supports the following scanners:</P>
|
|
|
|
<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"> </TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
|
|
|
|
<P>
|
|
The WFXMLScanner is a non-validating scanner which performs well-formedness check only.
|
|
It does not do any DTD/XMLSchema processing. If the XML document contains a DOCTYPE, it
|
|
will be silently ignored (i.e. no warning message is issued). Similarly, any schema
|
|
specific attributes (e.g. schemaLocation), will be treated as normal element attributes.
|
|
Setting grammar specific features/properties will have no effect on its behavior
|
|
(e.g. setLoadExternalDTD(true) is ignored).
|
|
</P>
|
|
|
|
<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 DOM parser
|
|
XercesDOMParser parser;
|
|
|
|
// Specify scanner name
|
|
parser.useScanner(XMLUni::fgWFXMLScanner);
|
|
|
|
// Specify other parser features, e.g.
|
|
parser.setDoNamespaces(true);
|
|
</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>
|
|
|
|
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<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"> </TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
|
|
|
|
<P>
|
|
The DGXMLScanner handles XML documents with DOCTYPE information. It does not do any
|
|
XMLSchema processing, which means that any schema specific attributes (e.g. schemaLocation),
|
|
will be treated as normal element attributes. Setting schema grammar specific features/properties
|
|
will have no effect on its behavior (e.g. setDoSchema(true) and setLoadSchema(true) are ignored).
|
|
</P>
|
|
|
|
<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 SAX parser
|
|
SAXParser parser;
|
|
|
|
// Specify scanner name
|
|
parser.useScanner(XMLUni::fgDGXMLScanner);
|
|
|
|
// Specify other parser features, e.g.
|
|
parser.setLoadExternalDTD(true);
|
|
</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>
|
|
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<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"> </TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
|
|
|
|
<P>
|
|
The SGXMLScanner handles XML documents with XML schema grammar information.
|
|
If the XML document contains a DOCTYPE, it will be ignored. Namespace and
|
|
schema processing features are on by default, and setting them to off has
|
|
not effect.
|
|
</P>
|
|
|
|
<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 SAX2 parser
|
|
SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
|
|
|
|
// Specify scanner name
|
|
parser->setProperty(XMLUni::fgXercesScannerName, (void *)XMLUni::fgSGXMLScanner);
|
|
|
|
// Specify other parser features, e.g.
|
|
parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
|
|
</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>
|
|
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
<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"> </TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
|
|
|
|
<P>
|
|
The IGXMLScanner is an integrated scanner and handles XML documents with DTD and/or
|
|
XML schema grammar. This is the default scanner used by the various parsers if no
|
|
scanner is specified.
|
|
</P>
|
|
|
|
<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 DOMLSParser parser
|
|
DOMLSParser *parser = ((DOMImplementationLS*)impl)->createLSParser(
|
|
DOMImplementationLS::MODE_SYNCHRONOUS, 0);
|
|
|
|
// Specify scanner name - This is optional as IGXMLScanner is the default
|
|
parser->getDomConfig()->setParameter(
|
|
XMLUni::fgXercesScannerName, (void *)XMLUni::fgIGXMLScanner);
|
|
|
|
// Specify other parser features, e.g.
|
|
parser->getDomConfig()->setParameter(XMLUni::fgDOMNamespaces, doNamespaces);
|
|
parser->getDomConfig()->setParameter(XMLUni::fgXercesSchema, doSchema);
|
|
</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>
|
|
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
</FONT></TD></TR></TABLE><BR>
|
|
|
|
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0" cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1" src="resources/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT color="#0086b2" size="-1"><I>
|
|
Copyright © 1999-2015 The Apache Software Foundation.
|
|
All Rights Reserved.
|
|
</I></FONT></TD></TR></TABLE></BODY></HTML>
|