diff --git a/doc/migration_archive.xml b/doc/migration_archive.xml index 1cf84ac538e1d1d9fb0bddfc8c865856ab4d22b2..768c6df44fe4735107a22a63540549266f1a0de3 100644 --- a/doc/migration_archive.xml +++ b/doc/migration_archive.xml @@ -121,7 +121,7 @@ <s3 title="Experiemental IDOM"> <p>The experimental IDOM API is a new design of the C++ DOM API. If you would like to migrate from DOM to the experimental IDOM, please refer to - <jump href="program.html#IDOMProgGuide"> + <jump href="program-idom.html"> IDOM programming guide.</jump> Please note that this experimental IDOM API is only a prototype and is subject to change. </p> diff --git a/doc/program-dom.xml b/doc/program-dom.xml new file mode 100644 index 0000000000000000000000000000000000000000..e11bf9cdbe077b6868b8539d538693a142467d10 --- /dev/null +++ b/doc/program-dom.xml @@ -0,0 +1,265 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE s1 SYSTEM "./dtd/document.dtd"> + +<s1 title="DOM Programming Guide"> + + <anchor name="DOMProgGuide"/> + <anchor name="JAVAandCPP"/> + <s2 title="Java and C++ DOM comparisons"> + <p>The C++ DOM API is very similar in design and use, to the + Java DOM API bindings. As a consequence, conversion of + existing Java code that makes use of the DOM to C++ is a + straight forward process. + </p> + <p> + This section outlines the differences between Java and C++ bindings. + </p> + </s2> + + <anchor name="AccessAPI"/> + <s2 title="Accessing the API from application code"> + +<source> +// C++ +#include <dom/DOM.hpp></source> + +<source>// Java +import org.w3c.dom.*</source> + + <p>The header file <dom/DOM.hpp> includes all the + individual headers for the DOM API classes. </p> + + </s2> + + <anchor name="ClassNames"/> + <s2 title="Class Names"> + <p>The C++ class names are prefixed with "DOM_". The intent is + to prevent conflicts between DOM class names and other names + that may already be in use by an application or other + libraries that a DOM based application must link with.</p> + + <p>The use of C++ namespaces would also have solved this + conflict problem, but for the fact that many compilers do not + yet support them.</p> + +<source>DOM_Document myDocument; // C++ +DOM_Node aNode; +DOM_Text someText;</source> + +<source>Document myDocument; // Java +Node aNode; +Text someText;</source> + + <p>If you wish to use the Java class names in C++, then you need + to typedef them in C++. This is not advisable for the general + case - conflicts really do occur - but can be very useful when + converting a body of existing Java code to C++.</p> + +<source>typedef DOM_Document Document; +typedef DOM_Node Node; + +Document myDocument; // Now C++ usage is + // indistinguishable from Java +Node aNode;</source> + </s2> + + + <anchor name="ObjMemMgmt"/> + <s2 title="Objects and Memory Management"> + <p>The C++ DOM implementation uses automatic memory management, + implemented using reference counting. As a result, the C++ + code for most DOM operations is very similar to the equivalent + Java code, right down to the use of factory methods in the DOM + document class for nearly all object creation, and the lack of + any explicit object deletion.</p> + + <p>Consider the following code snippets </p> + +<source>// This is C++ +DOM_Node aNode; +aNode = someDocument.createElement("ElementName"); +DOM_Node docRootNode = someDoc.getDocumentElement(); +docRootNode.AppendChild(aNode);</source> + +<source>// This is Java +Node aNode; +aNode = someDocument.createElement("ElementName"); +Node docRootNode = someDoc.getDocumentElement(); +docRootNode.AppendChild(aNode);</source> + + <p>The Java and the C++ are identical on the surface, except for + the class names, and this similarity remains true for most DOM + code. </p> + + <p>However, Java and C++ handle objects in somewhat different + ways, making it important to understand a little bit of what + is going on beneath the surface.</p> + + <p>In Java, the variable <code>aNode</code> is an object reference , + essentially a pointer. It is initially == null, and references + an object only after the assignment statement in the second + line of the code.</p> + + <p>In C++ the variable <code>aNode</code> is, from the C++ language's + perspective, an actual live object. It is constructed when the + first line of the code executes, and DOM_Node::operator = () + executes at the second line. The C++ class DOM_Node + essentially a form of a smart-pointer; it implements much of + the behavior of a Java Object Reference variable, and + delegates the DOM behaviors to an implementation class that + lives behind the scenes. </p> + + <p>Key points to remember when using the C++ DOM classes:</p> + + <ul> + <li>Create them as local variables, or as member variables of + some other class. Never "new" a DOM object into the heap or + make an ordinary C pointer variable to one, as this will + greatly confuse the automatic memory management. </li> + + <li>The "real" DOM objects - nodes, attributes, CData + sections, whatever, do live on the heap, are created with the + create... methods on class DOM_Document. DOM_Node and the + other DOM classes serve as reference variables to the + underlying heap objects.</li> + + <li>The visible DOM classes may be freely copied (assigned), + passed as parameters to functions, or returned by value from + functions.</li> + + <li>Memory management of the underlying DOM heap objects is + automatic, implemented by means of reference counting. So long + as some part of a document can be reached, directly or + indirectly, via reference variables that are still alive in + the application program, the corresponding document data will + stay alive in the heap. When all possible paths of access have + been closed off (all of the application's DOM objects have + gone out of scope) the heap data itself will be automatically + deleted. </li> + + <li>There are restrictions on the ability to subclass the DOM + classes. </li> + + </ul> + + </s2> + + <anchor name="DOMString"/> + <s2 title="DOMString"> + <p>Class DOMString provides the mechanism for passing string + data to and from the DOM API. DOMString is not intended to be + a completely general string class, but rather to meet the + specific needs of the DOM API.</p> + + <p>The design derives from two primary sources: from the DOM's + CharacterData interface and from class <code>java.lang.string</code>.</p> + + <p>Main features are:</p> + + <ul> + <li>It stores Unicode text.</li> + + <li>Automatic memory management, using reference counting.</li> + + <li>DOMStrings are mutable - characters can be inserted, + deleted or appended.</li> + + </ul> + <p></p> + + <p>When a string is passed into a method of the DOM, when + setting the value of a Node, for example, the string is cloned + so that any subsequent alteration or reuse of the string by + the application will not alter the document contents. + Similarly, when strings from the document are returned to an + application via the DOM API, the string is cloned so that the + document can not be inadvertently altered by subsequent edits + to the string.</p> + + <note>The ICU classes are a more general solution to UNICODE + character handling for C++ applications. ICU is an Open + Source Unicode library, available at the <jump + href="http://oss.software.ibm.com/icu/">IBM + DeveloperWorks website</jump>.</note> + + </s2> + + <anchor name="EqualityTesting"/> + <s2 title="Equality Testing"> + <p>The DOMString equality operators (and all of the rest of the + DOM class conventions) are modeled after the Java + equivalents. The equals() method compares the content of the + string, while the == operator checks whether the string + reference variables (the application program variables) refer + to the same underlying string in memory. This is also true of + DOM_Node, DOM_Element, etc., in that operator == tells whether + the variables in the application are referring to the same + actual node or not. It's all very Java-like </p> + + <ul> + <li>bool operator == () is true if the DOMString variables + refer to the same underlying storage. </li> + + <li>bool equals() is true if the strings contain the same + characters. </li> + + </ul> + <p>Here is an example of how the equality operators work: </p> +<source>DOMString a = "Hello"; +DOMString b = a; +DOMString c = a.clone(); +if (b == a) // This is true +if (a == c) // This is false +if (a.equals(c)) // This is true +b = b + " World"; +if (b == a) // Still true, and the string's + // value is "Hello World" +if (a.equals(c)) // false. a is "Hello World"; + // c is still "Hello".</source> + </s2> + + <anchor name="Downcasting"/> + <s2 title="Downcasting"> + <p>Application code sometimes must cast an object reference from + DOM_Node to one of the classes deriving from DOM_Node, + DOM_Element, for example. The syntax for doing this in C++ is + different from that in Java.</p> + +<source>// This is C++ +DOM_Node aNode = someFunctionReturningNode(); +DOM_Element el = (DOM_Element &) aNode;</source> + +<source>// This is Java +Node aNode = someFunctionReturningNode(); +Element el = (Element) aNode;</source> + + <p>The C++ cast is not type-safe; the Java cast is checked for + compatible types at runtime. If necessary, a type-check can + be made in C++ using the node type information: </p> + +<source>// This is C++ + +DOM_Node aNode = someFunctionReturningNode(); +DOM_Element el; // by default, el will == null. + +if (anode.getNodeType() == DOM_Node::ELEMENT_NODE) + el = (DOM_Element &) aNode; +else + // aNode does not refer to an element. + // Do something to recover here.</source> + + </s2> + + <anchor name="Subclassing"/> + <s2 title="Subclassing"> + <p>The C++ DOM classes, DOM_Node, DOM_Attr, DOM_Document, etc., + are not designed to be subclassed by an application + program. </p> + + <p>As an alternative, the DOM_Node class provides a User Data + field for use by applications as a hook for extending nodes by + referencing additional data or objects. See the API + description for DOM_Node for details.</p> + </s2> + +</s1> diff --git a/doc/program-idom.xml b/doc/program-idom.xml new file mode 100644 index 0000000000000000000000000000000000000000..346a6128ec5ef9ac7d8d48a26095f2e7af9e670d --- /dev/null +++ b/doc/program-idom.xml @@ -0,0 +1,389 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE s1 SYSTEM "./dtd/document.dtd"> + +<s1 title="Experimental IDOM Programming Guide"> + <anchor name="IDOMProgGuide"/> + <p>The experimental IDOM API is a new design of the C++ DOM API. + Please note that this experimental IDOM API is only a prototype + and is subject to change.</p> + + <anchor name="ConstructIDOMParser"/> + <s2 title="Constructing a parser"> + <p>In order to use &XercesCName; to parse XML files using IDOM, you + will need to create an instance of the IDOMParser class. The example + below shows the code you need in order to create an instance of the + IDOMParser.</p> + + <source> +int main (int argc, char* args[]) { + + try { + XMLPlatformUtils::Initialize(); + } + catch (const XMLException& toCatch) { + cout << "Error during initialization! :\n" + << DOMString(toCatch.getMessage()) << "\n"; + return 1; + } + + char* xmlFile = "x1.xml"; + IDOMParser* parser = new IDOMParser(); + parser->setValidationScheme(IDOMParser::Val_Always); // optional. + parser->setDoNamespaces(true); // optional + + ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase(); + parser->setErrorHandler(errHandler); + + try { + parser->parse(xmlFile); + } + catch (const XMLException& toCatch) { + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (const SAXParseException& toCatch) { + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (...) { + cout << "Unexpected Exception \n" ; + return -1; + } + + return 0; +} + </source> + </s2> + + <anchor name="DOMandIDOM"/> + <s2 title="Comparision of C++ DOM and IDOM"> + <p> + This section outlines the differences between the C++ DOM and IDOM APIs. + </p> + </s2> + + <anchor name="Motivation"/> + <s2 title="Motivation behind new design"> + <p> + The performance of the C++ DOM has not been as good as it + might be, especially for use in server style applications. + The DOM's reference counted automatic memory management has + been the biggest time consumer. The situation becomes worse + when running multi-threaded applications. + </p> + <p> + The experimental C++ IDOM is a new alternative to the C++ DOM, and aims at + meeting the following requirements: + </p> + <ul> + <li>Reduced memory footprint.</li> + <li>Fast.</li> + <li>Good scalability on multiprocessor systems.</li> + <li>More C++ like and less Java like.</li> + </ul> + </s2> + + <anchor name="IDOMClassNames"/> + <s2 title="Class Names"> + <p> + The IDOM class names are prefixed with "IDOM_". The intent is + to prevent conflicts between IDOM class names and DOM class names + that may already be in use by an application or other + libraries that a DOM based application must link with. + </p> + + + <source> +IDOM_Document* myDocument; // IDOM +IDOM_Node* aNode; +IDOM_Text* someText; + </source> + + <source> +DOM_Document myDocument; // DOM +DOM_Node aNode; +DOM_Text someText; + </source> + </s2> + + <anchor name="IDOMObjMgmt"/> + <s2 title="Objects Management"> + <p>Applications would use normal C++ pointers to directly access the + implementation objects for Nodes in IDOM C++, while they would use + object references in DOM C++. + </p> + + <p>Consider the following code snippets</p> + + + <source> +// IDOM C++ +IDOM_Node* aNode; +IDOM_Node* docRootNode; +aNode = someDocument->createElement("ElementName"); +docRootNode = someDocument->getDocumentElement(); +docRootNode->appendChild(aNode); + </source> + + <source> +// DOM C++ +DOM_Node aNode; +DOM_Node docRootNode; +aNode = someDocument.createElement("ElementName"); +docRootNode = someDocument.getDocumentElement(); +docRootNode.appendChild(aNode); + </source> + </s2> + + + <anchor name="IDOMMemMgmt"/> + <s2 title="Memory Management"> + <p>The C++ IDOM implementation no longer uses reference counting for + automatic memory management. The C++ IDOM uses an independent storage + allocator per document. The storage for a DOM document is + associated with the document node object. + The advantage here is that allocation would require no synchronization + in most cases (based on the the same threading model that we + have now - one thread active per document, but any number of + documents running in parallel with separate threads). + </p> + + <p>The allocator does not support a delete operation at all - all + allocated memory would persist for the life of the document, and + then the larger blocks would be returned to the system without separately + deleting all of the individual nodes and strings within the document. + </p> + + <p>The C++ DOM and IDOM are similar in the use of factory methods in the + document class for all object creation. They differ in the object deletion + mechanism. + </p> + + <p>In C++ DOM, there is no explicit object deletion. The deallocation of + memory is automatically taken care of by the reference counting. + </p> + + <p>In C++ IDOM, there is an implict and explict object deletion. + </p> + </s2> + + <anchor name="IDOMMemImplicit"/> + <s2 title="Implicit Object Deletion"> + <p>When parsing a document using an IDOMParser, all memory allocated + for a DOM tree is associated to the DOM document. And this storage + will be automatically deleted when the parser instance is deleted (implicit). + </p> + <p>If you do multiple parse using the same IDOMParser instance, then + multiple DOM documents will be generated and saved in a vector pool. + All these documents (and thus all the allocated memory) won't be deleted + until the parser instance is destroyed. If you want to release the memory + back to the system but don't want to destroy the IDOMParser instance at this moment, + then you can call the method IDOMParser::resetDocumentPool to reset the document + vector pool, provided that you do not need access to these documents anymore. + </p> + + <p>Consider the following code snippets: </p> + + <source> + // C++ IDOM - implicit deletion + IDOMParser* parser = new IDOMParser(); + parser->parse(xmlFile) + IDOM_Document *doc = parser->getDocument(); + + unsigned int i = 1000; + while (i > 0) { + parser->parse(xmlFile) + IDOM_Document* myDoc = parser->getDocument(); + i--; + } + + // all allocated memory associated with these 1001 DOM documents + // will be deleted implicitly when the parser instance is destroyed + delete parser; + </source> + + <source> + // C++ IDOM - implicit deletion + // optionally release the memory + IDOMParser* parser = new IDOMParser(); + unsigned int i = 1000; + while (i > 0) { + parser->parse(xmlFile) + IDOM_Document *doc = parser->getDocument(); + i--; + } + + // instead of waiting until the parser instance is destroyed, + // user can optionally choose to release the memory back to the system + // if does not need access to these 1000 parsed documents anymore. + parser->resetDocumentPool(); + + // now the parser has some fresh memory to work on for the following + // big loop + i = 1000; + while (i > 0) { + parser->parse(xmlFile) + IDOM_Document *doc = parser->getDocument(); + i--; + } + delete parser; + + </source> + </s2> + + <anchor name="IDOMMemExplicit"/> + <s2 title="Explicit Object Deletion"> + <p>If user is manually building a DOM tree in memory using the document factory methods, + then the user needs to explicilty delete the document object to free all the allocated memory. + It normally falls under the following 3 scenarios: + </p> + <ul> + <li>If a user is manually creating a DOM document using the document implementation + factory methods, IDOM_DOMImplementation::getImplementation()->createDocument, + then the user needs to explicilty delete the document object to free all + allocated memory. </li> + <li>If a user is creating a DocumentType object using the document implementation factory + method, IDOM_DOMImplementation::getImplementation()->createDocumentType, then + the user also needs to explicilty delete the document type object to free the + allocated memory.</li> + <li>Special case: If a user is creating a DocumentType using the document + implementation factory method, and clone the node WITHOUT assigning a document + owner to that documentType object, then the cloned node also needs to be explicitly + deleted.</li> + </ul> + + <p>Consider the following code snippets: </p> + + <source> +// C++ IDOM - explicit deletion +// use the document implementation factory method to create a document type and a document +IDOM_DocumentType* myDocType; +IDOM_Document* myDocument; +IDOM_Node* root; +IDOM_Node* aNode; + +myDocType = IDOM_DOMImplementation::getImplementation()->createDocumentType(name, 0, 0); +myDocument = IDOM_DOMImplementation::getImplementation()->createDocument(0, name, myDocType); +root = myDocument->getDocumentElement(); +aNode = myDocument->createElement(anElementname); + +root->appendChild(aNode); + +// need to delete both myDocType and myDocument which are created through DOM Implementation +delete myDocType; +delete myDocument; + </source> + + <source> +// C++ IDOM - explicit deletion +// use the document implementation factory method to create a document +IDOM_DocumentType* myDocType; +IDOM_Document* myDocument; +IDOM_Node* root; +IDOM_Node* aNode; + +myDocument = IDOM_DOMImplementation::getImplementation()->createDocument(); +myDocType = myDocument->createDocumentType(name); +root = myDocument->createElement(name); +aNode = myDocument->createElement(anElementname); + +myDocument->appendChild(myDocType); +myDocument->appendChild(root); +root->appendChild(aNode); + +// the myDocType is created through myDocument, not through Document Implementation +// thus no need to delete myDocType +delete myDocument; + </source> + + <source> +// C++ IDOM - explicit deletion +// manually build a DOM document +// clone the document type object which does not have an owner yet +IDOM_DocumentType* myDocType1; +IDOM_DocumentType* myDocType; +IDOM_Document* myDocument; +IDOM_Node* root; +IDOM_Node* aNode; + +myDocType = IDOM_DOMImplementation::getImplementation()->createDocumentType(name, 0, 0); +myDocType1 = (IDOM_DocumentType*) myDocType->cloneNode(false); +myDocument = IDOM_DOMImplementation::getImplementation()->createDocument(0, name, myDocType); + +root = myDocument->getDocumentElement(); +aNode = myDocument->createElement(anElementname); + +root->appendChild(aNode); + +// myDocType does not have an owner yet when myDocType1 was cloned. +// thus need to explicitly delete myDocType1 +delete myDocType1; +delete myDocType; +delete myDocument; + </source> + + <source> +// C++ IDOM - explicit deletion +// manually build a DOM document +// clone the document type object that has an owner already +// thus no need to delete the cloned object +IDOM_DocumentType* myDocType1; +IDOM_DocumentType* myDocType; +IDOM_Document* myDocument; +IDOM_Node* root; +IDOM_Node* aNode; + +myDocType = IDOM_DOMImplementation::getImplementation()->createDocumentType(name, 0, 0); +myDocument = IDOM_DOMImplementation::getImplementation()->createDocument(0, name, myDocType); +myDocType1 = (IDOM_DocumentType*) myDocType->cloneNode(false); + +root = myDocument->getDocumentElement(); +aNode = myDocument->createElement(anElementname); + +root->appendChild(aNode); + +// myDocType already has myDocument as the owner when myDocType1 was cloned +// thus NO need to explicitly delete myDocType1 +delete myDocType; +delete myDocument; + </source> + </s2> + + <p>Key points to remember when using the C++ IDOM classes:</p> + + <ul> + <li>The DOM objects are accessed via C++ pointers.</li> + + <li>The DOM objects - nodes, attributes, CData + sections, etc., are created with the factory methods + (create...) in the document class.</li> + + <li>If you are manually building a DOM tree in memory, you + need to explicitly delete the document object. + Memory management will be automatically taken care of by + the IDOM parser when parsing an instance document.</li> + + </ul> + + <anchor name="DOMStringXMCh"/> + <s2 title="DOMString vs. XMLCh"> + <p>The IDOM C++ no longer uses DOMString to pass string data to + and from the DOM API. Instead, the IDOM C++ uses plain, null-terminated + (XMLCh *) utf-16 strings. The (XMLCh*) utf-16 type string is much + simpler with lower overhead. All the string data would remain in + memory until the document object is deleted.</p> + + <source> +//C++ IDOM +const XMLCh* nodeValue = aNode->getNodeValue(); + </source> + + <source> +//C++ DOM +DOMString nodeValue = aNode.getNodeValue(); + </source> + </s2> + +</s1> diff --git a/doc/program-sax.xml b/doc/program-sax.xml new file mode 100644 index 0000000000000000000000000000000000000000..b522044f0ca92dca8770ff17ae45b9c4fa4009b6 --- /dev/null +++ b/doc/program-sax.xml @@ -0,0 +1,128 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE s1 SYSTEM "./dtd/document.dtd"> + +<s1 title="SAX1 Programming Guide"> + + <anchor name="SAX1ProgGuide"/> + <anchor name="ConstructParser"/> + <s2 title="Constructing a parser"> + <p>In order to use &XercesCName; to parse XML files, you will + need to create an instance of the SAXParser class. The example + below shows the code you need in order to create an instance + of SAXParser. The DocumentHandler and ErrorHandler instances + required by the SAX API are provided using the HandlerBase + class supplied with &XercesCName;.</p> + +<source>int main (int argc, char* args[]) { + + try { + XMLPlatformUtils::Initialize(); + } + catch (const XMLException& toCatch) { + cout << "Error during initialization! :\n" + << DOMString(toCatch.getMessage()) << "\n"; + return 1; + } + + char* xmlFile = "x1.xml"; + SAXParser* parser = new SAXParser(); + parser->setDoValidation(true); // optional. + parser->setDoNamespaces(true); // optional + + DocumentHandler* docHandler = new HandlerBase(); + ErrorHandler* errHandler = (ErrorHandler*) docHandler; + parser->setDocumentHandler(docHandler); + parser->setErrorHandler(errHandler); + + try { + parser->parse(xmlFile); + } + catch (const XMLException& toCatch) { + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (const SAXParseException& toCatch) { + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (...) { + cout << "Unexpected Exception \n" ; + return -1; + } +}</source> + </s2> + + <anchor name="UsingSAX1API"/> + <s2 title="Using the SAX API"> + <p>The SAX API for XML parsers was originally developed for + Java. Please be aware that there is no standard SAX API for + C++, and that use of the &XercesCName; SAX API does not + guarantee client code compatibility with other C++ XML + parsers.</p> + + <p>The SAX API presents a callback based API to the parser. An + application that uses SAX provides an instance of a handler + class to the parser. When the parser detects XML constructs, + it calls the methods of the handler class, passing them + information about the construct that was detected. The most + commonly used handler classes are DocumentHandler which is + called when XML constructs are recognized, and ErrorHandler + which is called when an error occurs. The header files for the + various SAX handler classes are in + '<&XercesCInstallDir;>/include/sax'</p> + + <p>As a convenience, &XercesCName; provides the class + HandlerBase, which is a single class which is publicly derived + from all the Handler classes. HandlerBase's default + implementation of the handler callback methods is to do + nothing. A convenient way to get started with &XercesCName; is + to derive your own handler class from HandlerBase and override + just those methods in HandlerBase which you are interested in + customizing. This simple example shows how to create a handler + which will print element names, and print fatal error + messages. The source code for the sample applications show + additional examples of how to write handler classes.</p> + + <p>This is the header file MySAXHandler.hpp:</p> +<source>#include <sax/HandlerBase.hpp> + +class MySAXHandler : public HandlerBase { +public: + void startElement(const XMLCh* const, AttributeList&); + void fatalError(const SAXParseException&); +};</source> + + <p>This is the implementation file MySAXHandler.cpp:</p> + +<source>#include "MySAXHandler.hpp" +#include <iostream.h> + +MySAXHandler::MySAXHandler() +{ +} + +MySAXHandler::startElement(const XMLCh* const name, + AttributeList& attributes) +{ + // transcode() is an user application defined function which + // converts unicode strings to usual 'char *'. Look at + // the sample program SAXCount for an example implementation. + cout << "I saw element: " << transcode(name) << endl; +} + +MySAXHandler::fatalError(const SAXParseException& exception) +{ + cout << "Fatal Error: " << transcode(exception.getMessage()) + << " at line: " << exception.getLineNumber() + << endl; +}</source> + + <p>The XMLCh and AttributeList types are supplied by + &XercesCName; and are documented in the include + files. Examples of their usage appear in the source code to + the sample applications.</p> + </s2> + +</s1> diff --git a/doc/program-sax2.xml b/doc/program-sax2.xml new file mode 100644 index 0000000000000000000000000000000000000000..d773174b4b41ae7557bbee8c5fa2f4c66d59a254 --- /dev/null +++ b/doc/program-sax2.xml @@ -0,0 +1,269 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE s1 SYSTEM "./dtd/document.dtd"> + +<s1 title="SAX2 Programming Guide"> + + <anchor name="SAX2ProgGuide"/> + <anchor name="ConstructParser2"/> + <s2 title="Constructing an XML Reader"> + <p>In order to use &XercesCName; to parse XML files, you will + need to create an instance of the SAX2XMLReader class. The example + below shows the code you need in order to create an instance + of SAX2XMLReader. The ContentHandler and ErrorHandler instances + required by the SAX API are provided using the DefaultHandler + class supplied with &XercesCName;.</p> + +<source>int main (int argc, char* args[]) { + + try { + XMLPlatformUtils::Initialize(); + } + catch (const XMLException& toCatch) { + cout << "Error during initialization! :\n" + << DOMString(toCatch.getMessage()) << "\n"; + return 1; + } + + char* xmlFile = "x1.xml"; + SAX2XMLReader* parser = XMLReaderFactory::createXMLReader(); + parser->setFeature(XMLString::transcode("http://xml.org/sax/features/validation", true) // optional + parser->setFeature(XMLString::transcode("http://xml.org/sax/features/namespaces", true) // optional + + ContentHandler* contentHandler = new DefaultHandler(); + ErrorHandler* errHandler = (ErrorHandler*) contentHandler; + parser->setContentHandler(contentHandler); + parser->setErrorHandler(errHandler); + + try { + parser->parse(xmlFile); + } + catch (const XMLException& toCatch) { + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (const SAXParseException& toCatch) { + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (...) { + cout << "Unexpected Exception \n" ; + return -1; + } +}</source> + </s2> + + <anchor name="UsingSAX2API"/> + <s2 title="Using the SAX2 API"> + <p>The SAX2 API for XML parsers was originally developed for + Java. Please be aware that there is no standard SAX2 API for + C++, and that use of the &XercesCName; SAX2 API does not + guarantee client code compatibility with other C++ XML + parsers.</p> + + <p>The SAX2 API presents a callback based API to the parser. An + application that uses SAX2 provides an instance of a handler + class to the parser. When the parser detects XML constructs, + it calls the methods of the handler class, passing them + information about the construct that was detected. The most + commonly used handler classes are ContentHandler which is + called when XML constructs are recognized, and ErrorHandler + which is called when an error occurs. The header files for the + various SAX2 handler classes are in + '<&XercesCInstallDir;>/include/sax2'</p> + + <p>As a convenience, &XercesCName; provides the class + DefaultHandler, which is a single class which is publicly derived + from all the Handler classes. DefaultHandler's default + implementation of the handler callback methods is to do + nothing. A convenient way to get started with &XercesCName; is + to derive your own handler class from DefaultHandler and override + just those methods in HandlerBase which you are interested in + customizing. This simple example shows how to create a handler + which will print element names, and print fatal error + messages. The source code for the sample applications show + additional examples of how to write handler classes.</p> + + <p>This is the header file MySAX2Handler.hpp:</p> +<source>#include <sax2/DefaultHandler.hpp> + +class MySAX2Handler : public DefaultHandler { +public: + void startElement( + const XMLCh* const uri, + const XMLCh* const localname, + const XMLCh* const qname, + const Attributes& attrs + ); + void fatalError(const SAXParseException&); +};</source> + + <p>This is the implementation file MySAX2Handler.cpp:</p> + +<source>#include "MySAX2Handler.hpp" +#include <iostream.h> + +MySAX2Handler::MySAX2Handler() +{ +} + +MySAX2Handler::startElement(const XMLCh* const uri, + const XMLCh* const localname, + const XMLCh* const qname, + const Attributes& attrs) +{ + // transcode() is an user application defined function which + // converts unicode strings to usual 'char *'. Look at + // the sample program SAX2Count for an example implementation. + cout << "I saw element: " << transcode(qname) << endl; +} + +MySAX2Handler::fatalError(const SAXParseException& exception) +{ + cout << "Fatal Error: " << transcode(exception.getMessage()) + << " at line: " << exception.getLineNumber() + << endl; +}</source> + + <p>The XMLCh and Attributes types are supplied by + &XercesCName; and are documented in the include + files. Examples of their usage appear in the source code to + the sample applications.</p> + </s2> + + <anchor name="SAX2Features"/> + <s2 title="Xerces SAX2 Supported Features"> + + <p>The behavior of the SAX2XMLReader is dependant on the values of the following features. + All of the features below can be set using the function <code>SAX2XMLReader::setFeature(cons XMLCh* const, const bool)</code>. + And can be queried using the function <code>bool SAX2XMLReader::getFeature(const XMLCh* const)</code>. + </p> + <p>None of these features can be modified in the middle of a parse, or an exception will be thrown.</p> + + <table> + <tr><td colspan="2"><em>http://xml.org/sax/features/namespaces</em></td></tr> + <tr><td><em>true:</em></td><td> Perform Namespace processing (default)</td></tr> + <tr><td><em>false:</em></td><td> Optionally do not perform Namespace processing</td></tr> + </table> + + <p/> + + <table> + <tr><td colspan="2"><em>http://xml.org/sax/features/namespace-prefixes</em></td></tr> + <tr><td><em>true:</em></td><td> Report the orignal prefixed names and attributes used for Namespace declarations (default)</td></tr> + <tr><td><em>false:</em></td><td> Do not report attributes used for Namespace declarations, and optionally do not report original prefixed names. </td></tr> + </table> + + <p/> + + <table> + <tr><td colspan="2"><em>http://xml.org/sax/features/validation</em></td></tr> + <tr><td><em>true:</em></td><td> Report all validation errors. (default)</td></tr> + <tr><td><em>false:</em></td><td> Do not report validation errors. </td></tr> + </table> + + <p/> + + <table> + <tr><td colspan="2"><em>http://apache.org/xml/features/validation/dynamic</em></td></tr> + <tr><td><em>true:</em></td><td> The parser will validate the document only if a grammar is specified. (http://xml.org/sax/features/validation must be true)</td></tr> + <tr><td><em>false:</em></td><td> Validation is determined by the state of the http://xml.org/sax/features/validation feature (default)</td></tr> + </table> + + <p/> + + <table> + <tr><td colspan="2"><em>http://apache.org/xml/features/validation/schema</em></td></tr> + <tr><td><em>true:</em></td><td> Enable the parser's schema support. (default) </td></tr> + <tr><td><em>false:</em></td><td> Disable the parser's schema support. </td></tr> + </table> + + <p/> + + <table> + <tr><td colspan="2"><em>http://apache.org/xml/features/validation/schema-full-checking</em></td></tr> + <tr><td><em>true:</em></td><td> Enable full schema constraint checking, including checking + which may be time-consuming or memory intensive. Currently, particle unique + attribution constraint checking and particle derivation resriction checking + are controlled by this option. </td></tr> + <tr><td><em>false:</em></td><td> Disable full schema constraint checking (default). </td></tr> + </table> + + <p/> + + <table> + <tr><td colspan="2"><em>http://apache.org/xml/features/validation/reuse-grammar</em></td></tr> + <tr><td><em>true:</em></td><td> The parser will reuse grammar information from previous parses in subsequent parses. </td></tr> + <tr><td><em>false:</em></td><td> The parser will not reuse any grammar information. (default)</td></tr> + </table> + + <p/> + + <table> + <tr><td colspan="2"><em>http://apache.org/xml/features/validation/reuse-validator</em> (deprecated) <br/> + Please use <em>http://apache.org/xml/features/validation/reuse-grammar</em> + </td></tr> + <tr><td><em>true:</em></td><td> The parser will reuse grammar information from previous parses in subsequent parses. </td></tr> + <tr><td><em>false:</em></td><td> The parser will not reuse any grammar information. (default)</td></tr> + </table> + + </s2> + + <anchor name="SAX2Properties"/> + <s2 title="Xerces SAX2 Supported Properties"> + + <p>The behavior of the SAX2XMLReader is dependant on the values of the following properties. + All of the properties below can be set using the function <code>SAX2XMLReader::setProperty(const XMLCh* const, void*)</code>. + It takes a void pointer as the property value. Application is required to initialize this void + pointer to a correct type. Please check the column "Value Type" below + to learn exactly what type of property value each property expects for processing. + Passing a void pointer that was initialized with a wrong type will lead to unexpected result. + If the same property is set more than once, the last one takes effect.</p> + + <p>Property values can be queried using the function <code>void* SAX2XMLReader::getFeature(const XMLCh* const)</code>. + The parser owns the returned pointer, and the memory allocated for the returned pointer will + be destroyed when the parser is deleted. To ensure assessiblity of the returned information after + the parser is deleted, callers need to copy and store the returned information somewhere else. + Since the returned pointer is a generic void pointer, check the column "Value Type" below to learn + exactly what type of object each property returns for replication.</p> + + <p>None of these properties can be modified in the middle of a parse, or an exception will be thrown.</p> + + <table> + <tr><td colspan="2"><em>http://apache.org/xml/properties/schema/external-schemaLocation</em></td></tr> + <tr><td><em>Description</em></td><td> The XML Schema Recommendation explicitly states that + the inclusion of schemaLocation/ noNamespaceSchemaLocation attributes in the + instance document is only a hint; it does not mandate that these attributes + must be used to locate schemas. Similar situation happens to <import> + element in schema documents. This property allows the user to specify a list + of schemas to use. If the targetNamespace of a schema specified using this + method matches the targetNamespace of a schema occurring in the instance + document in schemaLocation attribute, or + if the targetNamespace matches the namespace attribute of <import> + element, the schema specified by the user using this property will + be used (i.e., the schemaLocation attribute in the instance document + or on the <import> element will be effectively ignored).</td></tr> + <tr><td><em>Value</em></td><td> The syntax is the same as for schemaLocation attributes + in instance documents: e.g, "http://www.example.com file_name.xsd". + The user can specify more than one XML Schema in the list.</td></tr> + <tr><td><em>Value Type</em></td><td> XMLCh* </td></tr> + </table> + + <p/> + <table> + <tr><td colspan="2"><em>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation</em></td></tr> + <tr><td><em>Description</em></td><td> The XML Schema Recommendation explicitly states that + the inclusion of schemaLocation/ noNamespaceSchemaLocation attributes in the + instance document is only a hint; it does not mandate that these attributes + must be used to locate schemas. This property allows the user to specify the + no target namespace XML Schema Location externally. If specified, the instance + document's noNamespaceSchemaLocation attribute will be effectively ignored.</td></tr> + <tr><td><em>Value</em></td><td> The syntax is the same as for the noNamespaceSchemaLocation + attribute that may occur in an instance document: e.g."file_name.xsd".</td></tr> + <tr><td><em>Value Type</em></td><td> XMLCh* </td></tr> + </table> + + </s2> + +</s1> diff --git a/doc/program.xml b/doc/program.xml index 512c0d0303d9b81f9b58168491158d8b7e60b28d..ceadeea6d310eaf24afa6c3de5c6c703d1f8b328 100644 --- a/doc/program.xml +++ b/doc/program.xml @@ -3,1093 +3,52 @@ <s1 title="Programming Guide"> - <p>This page has sections on the following topics:</p> + <p>The Programming Guide has the following topics:</p> <ul> - <li><link anchor="SAX1ProgGuide">SAX Programming Guide</link></li> + <li><jump href="program-sax.html">SAX Programming Guide</jump></li> <ul> - <li><link anchor="ConstructParser">Constructing a parser</link></li> - <li><link anchor="UsingSAX1API">Using the SAX API</link></li> + <li><jump href="program-sax.html#ConstructParser">Constructing a parser</jump></li> + <li><jump href="program-sax.html#UsingSAX1API">Using the SAX API</jump></li> </ul> - <li><link anchor="SAX2ProgGuide">SAX2 Programming Guide</link></li> + <li><jump href="program-sax2.html">SAX2 Programming Guide</jump></li> <ul> - <li><link anchor="ConstructParser2">Constructing an XML Reader</link></li> - <li><link anchor="UsingSAX2API">Using the SAX2 API</link></li> - <li><link anchor="SAX2Features">Supported Features</link></li> - <li><link anchor="SAX2Properties">Supported Properties</link></li> + <li><jump href="program-sax2.html#ConstructParser2">Constructing an XML Reader</jump></li> + <li><jump href="program-sax2.html#UsingSAX2API">Using the SAX2 API</jump></li> + <li><jump href="program-sax2.html#SAX2Features">Supported Features</jump></li> + <li><jump href="program-sax2.html#SAX2Properties">Supported Properties</jump></li> </ul> - <li><link anchor="DOMProgGuide">DOM Programming Guide</link></li> + <li><jump href="program-dom.html">DOM Programming Guide</jump></li> <ul> - <li><link anchor="JAVAandCPP">Comparision of Java and C++ DOM's</link></li> + <li><jump href="program-dom.html#JAVAandCPP">Comparision of Java and C++ DOM's</jump></li> <ul> - <li><link anchor="AccessAPI">Accessing the API from application code</link></li> - <li><link anchor="ClassNames">Class Names</link></li> - <li><link anchor="ObjMemMgmt">Objects and Memory Management</link></li> + <li><jump href="program-dom.html#AccessAPI">Accessing the API from application code</jump></li> + <li><jump href="program-dom.html#ClassNames">Class Names</jump></li> + <li><jump href="program-dom.html#ObjMemMgmt">Objects and Memory Management</jump></li> </ul> - <li><link anchor="DOMString">DOMString</link></li> + <li><jump href="program-dom.html#DOMString">DOMString</jump></li> <ul> - <li><link anchor="EqualityTesting">Equality Testing</link></li> + <li><jump href="program-dom.html#EqualityTesting">Equality Testing</jump></li> </ul> - <li><link anchor="Downcasting">Downcasting</link></li> - <li><link anchor="Subclassing">Subclassing</link></li> + <li><jump href="program-dom.html#Downcasting">Downcasting</jump></li> + <li><jump href="program-dom.html#Subclassing">Subclassing</jump></li> </ul> - <li><link anchor="IDOMProgGuide">Experimental IDOM Programming Guide</link></li> + <li><jump href="program-idom.html">Experimental IDOM Programming Guide</jump></li> <ul> - <li><link anchor="ConstructIDOMParser">Constructing a parser</link></li> - <li><link anchor="DOMandIDOM">Comparision of C++ DOM and IDOM</link></li> + <li><jump href="program-idom.html#ConstructIDOMParser">Constructing a parser</jump></li> + <li><jump href="program-idom.html#DOMandIDOM">Comparision of C++ DOM and IDOM</jump></li> <ul> - <li><link anchor="Motivation">Motivation behind new design</link></li> - <li><link anchor="IDOMClassNames">Class Names</link></li> - <li><link anchor="IDOMObjMgmt">Objects Management</link></li> - <li><link anchor="IDOMMemMgmt">Memory Management</link></li> + <li><jump href="program-idom.html#Motivation">Motivation behind new design</jump></li> + <li><jump href="program-idom.html#IDOMClassNames">Class Names</jump></li> + <li><jump href="program-idom.html#IDOMObjMgmt">Objects Management</jump></li> + <li><jump href="program-idom.html#IDOMMemMgmt">Memory Management</jump></li> <ul> - <li><link anchor="IDOMMemImplicit">Implicit Object Deletion</link></li> - <li><link anchor="IDOMMemExplicit">Explicit Object Deletion</link></li> + <li><jump href="program-idom.html#IDOMMemImplicit">Implicit Object Deletion</jump></li> + <li><jump href="program-idom.html#IDOMMemExplicit">Explicit Object Deletion</jump></li> </ul> - <li><link anchor="DOMStringXMCh">DOMString vs. XMLCh</link></li> + <li><jump href="program-idom.html#DOMStringXMCh">DOMString vs. XMLCh</jump></li> </ul> </ul> </ul> - <anchor name="SAX1ProgGuide"/> - <s2 title="SAX1 Programming Guide"> - - <anchor name="ConstructParser"/> - <s3 title="Constructing a parser"> - <p>In order to use &XercesCName; to parse XML files, you will - need to create an instance of the SAXParser class. The example - below shows the code you need in order to create an instance - of SAXParser. The DocumentHandler and ErrorHandler instances - required by the SAX API are provided using the HandlerBase - class supplied with &XercesCName;.</p> - -<source>int main (int argc, char* args[]) { - - try { - XMLPlatformUtils::Initialize(); - } - catch (const XMLException& toCatch) { - cout << "Error during initialization! :\n" - << DOMString(toCatch.getMessage()) << "\n"; - return 1; - } - - char* xmlFile = "x1.xml"; - SAXParser* parser = new SAXParser(); - parser->setDoValidation(true); // optional. - parser->setDoNamespaces(true); // optional - - DocumentHandler* docHandler = new HandlerBase(); - ErrorHandler* errHandler = (ErrorHandler*) docHandler; - parser->setDocumentHandler(docHandler); - parser->setErrorHandler(errHandler); - - try { - parser->parse(xmlFile); - } - catch (const XMLException& toCatch) { - cout << "Exception message is: \n" - << DOMString(toCatch.getMessage()) << "\n" ; - return -1; - } - catch (const SAXParseException& toCatch) { - cout << "Exception message is: \n" - << DOMString(toCatch.getMessage()) << "\n" ; - return -1; - } - catch (...) { - cout << "Unexpected Exception \n" ; - return -1; - } -}</source> - </s3> - - <anchor name="UsingSAX1API"/> - <s3 title="Using the SAX API"> - <p>The SAX API for XML parsers was originally developed for - Java. Please be aware that there is no standard SAX API for - C++, and that use of the &XercesCName; SAX API does not - guarantee client code compatibility with other C++ XML - parsers.</p> - - <p>The SAX API presents a callback based API to the parser. An - application that uses SAX provides an instance of a handler - class to the parser. When the parser detects XML constructs, - it calls the methods of the handler class, passing them - information about the construct that was detected. The most - commonly used handler classes are DocumentHandler which is - called when XML constructs are recognized, and ErrorHandler - which is called when an error occurs. The header files for the - various SAX handler classes are in - '<&XercesCInstallDir;>/include/sax'</p> - - <p>As a convenience, &XercesCName; provides the class - HandlerBase, which is a single class which is publicly derived - from all the Handler classes. HandlerBase's default - implementation of the handler callback methods is to do - nothing. A convenient way to get started with &XercesCName; is - to derive your own handler class from HandlerBase and override - just those methods in HandlerBase which you are interested in - customizing. This simple example shows how to create a handler - which will print element names, and print fatal error - messages. The source code for the sample applications show - additional examples of how to write handler classes.</p> - - <p>This is the header file MySAXHandler.hpp:</p> -<source>#include <sax/HandlerBase.hpp> - -class MySAXHandler : public HandlerBase { -public: - void startElement(const XMLCh* const, AttributeList&); - void fatalError(const SAXParseException&); -};</source> - - <p>This is the implementation file MySAXHandler.cpp:</p> - -<source>#include "MySAXHandler.hpp" -#include <iostream.h> - -MySAXHandler::MySAXHandler() -{ -} - -MySAXHandler::startElement(const XMLCh* const name, - AttributeList& attributes) -{ - // transcode() is an user application defined function which - // converts unicode strings to usual 'char *'. Look at - // the sample program SAXCount for an example implementation. - cout << "I saw element: " << transcode(name) << endl; -} - -MySAXHandler::fatalError(const SAXParseException& exception) -{ - cout << "Fatal Error: " << transcode(exception.getMessage()) - << " at line: " << exception.getLineNumber() - << endl; -}</source> - - <p>The XMLCh and AttributeList types are supplied by - &XercesCName; and are documented in the include - files. Examples of their usage appear in the source code to - the sample applications.</p> - </s3> - </s2> - - <anchor name="SAX2ProgGuide"/> - <s2 title="SAX2 Programming Guide"> - - <anchor name="ConstructParser2"/> - <s3 title="Constructing an XML Reader"> - <p>In order to use &XercesCName; to parse XML files, you will - need to create an instance of the SAX2XMLReader class. The example - below shows the code you need in order to create an instance - of SAX2XMLReader. The ContentHandler and ErrorHandler instances - required by the SAX API are provided using the DefaultHandler - class supplied with &XercesCName;.</p> - -<source>int main (int argc, char* args[]) { - - try { - XMLPlatformUtils::Initialize(); - } - catch (const XMLException& toCatch) { - cout << "Error during initialization! :\n" - << DOMString(toCatch.getMessage()) << "\n"; - return 1; - } - - char* xmlFile = "x1.xml"; - SAX2XMLReader* parser = XMLReaderFactory::createXMLReader(); - parser->setFeature(XMLString::transcode("http://xml.org/sax/features/validation", true) // optional - parser->setFeature(XMLString::transcode("http://xml.org/sax/features/namespaces", true) // optional - - ContentHandler* contentHandler = new DefaultHandler(); - ErrorHandler* errHandler = (ErrorHandler*) contentHandler; - parser->setContentHandler(contentHandler); - parser->setErrorHandler(errHandler); - - try { - parser->parse(xmlFile); - } - catch (const XMLException& toCatch) { - cout << "Exception message is: \n" - << DOMString(toCatch.getMessage()) << "\n" ; - return -1; - } - catch (const SAXParseException& toCatch) { - cout << "Exception message is: \n" - << DOMString(toCatch.getMessage()) << "\n" ; - return -1; - } - catch (...) { - cout << "Unexpected Exception \n" ; - return -1; - } -}</source> - </s3> - - <anchor name="UsingSAX2API"/> - <s3 title="Using the SAX2 API"> - <p>The SAX2 API for XML parsers was originally developed for - Java. Please be aware that there is no standard SAX2 API for - C++, and that use of the &XercesCName; SAX2 API does not - guarantee client code compatibility with other C++ XML - parsers.</p> - - <p>The SAX2 API presents a callback based API to the parser. An - application that uses SAX2 provides an instance of a handler - class to the parser. When the parser detects XML constructs, - it calls the methods of the handler class, passing them - information about the construct that was detected. The most - commonly used handler classes are ContentHandler which is - called when XML constructs are recognized, and ErrorHandler - which is called when an error occurs. The header files for the - various SAX2 handler classes are in - '<&XercesCInstallDir;>/include/sax2'</p> - - <p>As a convenience, &XercesCName; provides the class - DefaultHandler, which is a single class which is publicly derived - from all the Handler classes. DefaultHandler's default - implementation of the handler callback methods is to do - nothing. A convenient way to get started with &XercesCName; is - to derive your own handler class from DefaultHandler and override - just those methods in HandlerBase which you are interested in - customizing. This simple example shows how to create a handler - which will print element names, and print fatal error - messages. The source code for the sample applications show - additional examples of how to write handler classes.</p> - - <p>This is the header file MySAX2Handler.hpp:</p> -<source>#include <sax2/DefaultHandler.hpp> - -class MySAX2Handler : public DefaultHandler { -public: - void startElement( - const XMLCh* const uri, - const XMLCh* const localname, - const XMLCh* const qname, - const Attributes& attrs - ); - void fatalError(const SAXParseException&); -};</source> - - <p>This is the implementation file MySAX2Handler.cpp:</p> - -<source>#include "MySAX2Handler.hpp" -#include <iostream.h> - -MySAX2Handler::MySAX2Handler() -{ -} - -MySAX2Handler::startElement(const XMLCh* const uri, - const XMLCh* const localname, - const XMLCh* const qname, - const Attributes& attrs) -{ - // transcode() is an user application defined function which - // converts unicode strings to usual 'char *'. Look at - // the sample program SAX2Count for an example implementation. - cout << "I saw element: " << transcode(qname) << endl; -} - -MySAX2Handler::fatalError(const SAXParseException& exception) -{ - cout << "Fatal Error: " << transcode(exception.getMessage()) - << " at line: " << exception.getLineNumber() - << endl; -}</source> - - <p>The XMLCh and Attributes types are supplied by - &XercesCName; and are documented in the include - files. Examples of their usage appear in the source code to - the sample applications.</p> - </s3> - - <anchor name="SAX2Features"/> - <s3 title="Xerces SAX2 Supported Features"> - - <p>The behavior of the SAX2XMLReader is dependant on the values of the following features. - All of the features below can be set using the function <code>SAX2XMLReader::setFeature(cons XMLCh* const, const bool)</code>. - And can be queried using the function <code>bool SAX2XMLReader::getFeature(const XMLCh* const)</code>. - </p> - <p>None of these features can be modified in the middle of a parse, or an exception will be thrown.</p> - - <table> - <tr><td colspan="2"><em>http://xml.org/sax/features/namespaces</em></td></tr> - <tr><td><em>true:</em></td><td> Perform Namespace processing (default)</td></tr> - <tr><td><em>false:</em></td><td> Optionally do not perform Namespace processing</td></tr> - </table> - - <p/> - - <table> - <tr><td colspan="2"><em>http://xml.org/sax/features/namespace-prefixes</em></td></tr> - <tr><td><em>true:</em></td><td> Report the orignal prefixed names and attributes used for Namespace declarations (default)</td></tr> - <tr><td><em>false:</em></td><td> Do not report attributes used for Namespace declarations, and optionally do not report original prefixed names. </td></tr> - </table> - - <p/> - - <table> - <tr><td colspan="2"><em>http://xml.org/sax/features/validation</em></td></tr> - <tr><td><em>true:</em></td><td> Report all validation errors. (default)</td></tr> - <tr><td><em>false:</em></td><td> Do not report validation errors. </td></tr> - </table> - - <p/> - - <table> - <tr><td colspan="2"><em>http://apache.org/xml/features/validation/dynamic</em></td></tr> - <tr><td><em>true:</em></td><td> The parser will validate the document only if a grammar is specified. (http://xml.org/sax/features/validation must be true)</td></tr> - <tr><td><em>false:</em></td><td> Validation is determined by the state of the http://xml.org/sax/features/validation feature (default)</td></tr> - </table> - - <p/> - - <table> - <tr><td colspan="2"><em>http://apache.org/xml/features/validation/schema</em></td></tr> - <tr><td><em>true:</em></td><td> Enable the parser's schema support. (default) </td></tr> - <tr><td><em>false:</em></td><td> Disable the parser's schema support. </td></tr> - </table> - - <p/> - - <table> - <tr><td colspan="2"><em>http://apache.org/xml/features/validation/schema-full-checking</em></td></tr> - <tr><td><em>true:</em></td><td> Enable full schema constraint checking, including checking - which may be time-consuming or memory intensive. Currently, particle unique - attribution constraint checking and particle derivation resriction checking - are controlled by this option. </td></tr> - <tr><td><em>false:</em></td><td> Disable full schema constraint checking (default). </td></tr> - </table> - - <p/> - - <table> - <tr><td colspan="2"><em>http://apache.org/xml/features/validation/reuse-grammar</em></td></tr> - <tr><td><em>true:</em></td><td> The parser will reuse grammar information from previous parses in subsequent parses. </td></tr> - <tr><td><em>false:</em></td><td> The parser will not reuse any grammar information. (default)</td></tr> - </table> - - <p/> - - <table> - <tr><td colspan="2"><em>http://apache.org/xml/features/validation/reuse-validator</em> (deprecated) <br/> - Please use <em>http://apache.org/xml/features/validation/reuse-grammar</em> - </td></tr> - <tr><td><em>true:</em></td><td> The parser will reuse grammar information from previous parses in subsequent parses. </td></tr> - <tr><td><em>false:</em></td><td> The parser will not reuse any grammar information. (default)</td></tr> - </table> - - </s3> - - <anchor name="SAX2Properties"/> - <s3 title="Xerces SAX2 Supported Properties"> - - <p>The behavior of the SAX2XMLReader is dependant on the values of the following properties. - All of the properties below can be set using the function <code>SAX2XMLReader::setProperty(const XMLCh* const, void*)</code>. - It takes a void pointer as the property value. Application is required to initialize this void - pointer to a correct type. Please check the column "Value Type" below - to learn exactly what type of property value each property expects for processing. - Passing a void pointer that was initialized with a wrong type will lead to unexpected result. - If the same property is set more than once, the last one takes effect.</p> - - <p>Property values can be queried using the function <code>void* SAX2XMLReader::getFeature(const XMLCh* const)</code>. - The parser owns the returned pointer, and the memory allocated for the returned pointer will - be destroyed when the parser is deleted. To ensure assessiblity of the returned information after - the parser is deleted, callers need to copy and store the returned information somewhere else. - Since the returned pointer is a generic void pointer, check the column "Value Type" below to learn - exactly what type of object each property returns for replication.</p> - - <p>None of these properties can be modified in the middle of a parse, or an exception will be thrown.</p> - - <table> - <tr><td colspan="2"><em>http://apache.org/xml/properties/schema/external-schemaLocation</em></td></tr> - <tr><td><em>Description</em></td><td> The XML Schema Recommendation explicitly states that - the inclusion of schemaLocation/ noNamespaceSchemaLocation attributes in the - instance document is only a hint; it does not mandate that these attributes - must be used to locate schemas. Similar situation happens to <import> - element in schema documents. This property allows the user to specify a list - of schemas to use. If the targetNamespace of a schema specified using this - method matches the targetNamespace of a schema occurring in the instance - document in schemaLocation attribute, or - if the targetNamespace matches the namespace attribute of <import> - element, the schema specified by the user using this property will - be used (i.e., the schemaLocation attribute in the instance document - or on the <import> element will be effectively ignored).</td></tr> - <tr><td><em>Value</em></td><td> The syntax is the same as for schemaLocation attributes - in instance documents: e.g, "http://www.example.com file_name.xsd". - The user can specify more than one XML Schema in the list.</td></tr> - <tr><td><em>Value Type</em></td><td> XMLCh* </td></tr> - </table> - - <p/> - <table> - <tr><td colspan="2"><em>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation</em></td></tr> - <tr><td><em>Description</em></td><td> The XML Schema Recommendation explicitly states that - the inclusion of schemaLocation/ noNamespaceSchemaLocation attributes in the - instance document is only a hint; it does not mandate that these attributes - must be used to locate schemas. This property allows the user to specify the - no target namespace XML Schema Location externally. If specified, the instance - document's noNamespaceSchemaLocation attribute will be effectively ignored.</td></tr> - <tr><td><em>Value</em></td><td> The syntax is the same as for the noNamespaceSchemaLocation - attribute that may occur in an instance document: e.g."file_name.xsd".</td></tr> - <tr><td><em>Value Type</em></td><td> XMLCh* </td></tr> - </table> - - </s3> - </s2> - - <anchor name="DOMProgGuide"/> - <s2 title="DOM Programming Guide"> - - <anchor name="JAVAandCPP"/> - <s3 title="Java and C++ DOM comparisons"> - <p>The C++ DOM API is very similar in design and use, to the - Java DOM API bindings. As a consequence, conversion of - existing Java code that makes use of the DOM to C++ is a - straight forward process. - </p> - <p> - This section outlines the differences between Java and C++ bindings. - </p> - </s3> - - <anchor name="AccessAPI"/> - <s3 title="Accessing the API from application code"> - -<source> -// C++ -#include <dom/DOM.hpp></source> - -<source>// Java -import org.w3c.dom.*</source> - - <p>The header file <dom/DOM.hpp> includes all the - individual headers for the DOM API classes. </p> - - </s3> - - <anchor name="ClassNames"/> - <s3 title="Class Names"> - <p>The C++ class names are prefixed with "DOM_". The intent is - to prevent conflicts between DOM class names and other names - that may already be in use by an application or other - libraries that a DOM based application must link with.</p> - - <p>The use of C++ namespaces would also have solved this - conflict problem, but for the fact that many compilers do not - yet support them.</p> - -<source>DOM_Document myDocument; // C++ -DOM_Node aNode; -DOM_Text someText;</source> - -<source>Document myDocument; // Java -Node aNode; -Text someText;</source> - - <p>If you wish to use the Java class names in C++, then you need - to typedef them in C++. This is not advisable for the general - case - conflicts really do occur - but can be very useful when - converting a body of existing Java code to C++.</p> - -<source>typedef DOM_Document Document; -typedef DOM_Node Node; - -Document myDocument; // Now C++ usage is - // indistinguishable from Java -Node aNode;</source> - </s3> - - - <anchor name="ObjMemMgmt"/> - <s3 title="Objects and Memory Management"> - <p>The C++ DOM implementation uses automatic memory management, - implemented using reference counting. As a result, the C++ - code for most DOM operations is very similar to the equivalent - Java code, right down to the use of factory methods in the DOM - document class for nearly all object creation, and the lack of - any explicit object deletion.</p> - - <p>Consider the following code snippets </p> - -<source>// This is C++ -DOM_Node aNode; -aNode = someDocument.createElement("ElementName"); -DOM_Node docRootNode = someDoc.getDocumentElement(); -docRootNode.AppendChild(aNode);</source> - -<source>// This is Java -Node aNode; -aNode = someDocument.createElement("ElementName"); -Node docRootNode = someDoc.getDocumentElement(); -docRootNode.AppendChild(aNode);</source> - - <p>The Java and the C++ are identical on the surface, except for - the class names, and this similarity remains true for most DOM - code. </p> - - <p>However, Java and C++ handle objects in somewhat different - ways, making it important to understand a little bit of what - is going on beneath the surface.</p> - - <p>In Java, the variable <code>aNode</code> is an object reference , - essentially a pointer. It is initially == null, and references - an object only after the assignment statement in the second - line of the code.</p> - - <p>In C++ the variable <code>aNode</code> is, from the C++ language's - perspective, an actual live object. It is constructed when the - first line of the code executes, and DOM_Node::operator = () - executes at the second line. The C++ class DOM_Node - essentially a form of a smart-pointer; it implements much of - the behavior of a Java Object Reference variable, and - delegates the DOM behaviors to an implementation class that - lives behind the scenes. </p> - - <p>Key points to remember when using the C++ DOM classes:</p> - - <ul> - <li>Create them as local variables, or as member variables of - some other class. Never "new" a DOM object into the heap or - make an ordinary C pointer variable to one, as this will - greatly confuse the automatic memory management. </li> - - <li>The "real" DOM objects - nodes, attributes, CData - sections, whatever, do live on the heap, are created with the - create... methods on class DOM_Document. DOM_Node and the - other DOM classes serve as reference variables to the - underlying heap objects.</li> - - <li>The visible DOM classes may be freely copied (assigned), - passed as parameters to functions, or returned by value from - functions.</li> - - <li>Memory management of the underlying DOM heap objects is - automatic, implemented by means of reference counting. So long - as some part of a document can be reached, directly or - indirectly, via reference variables that are still alive in - the application program, the corresponding document data will - stay alive in the heap. When all possible paths of access have - been closed off (all of the application's DOM objects have - gone out of scope) the heap data itself will be automatically - deleted. </li> - - <li>There are restrictions on the ability to subclass the DOM - classes. </li> - - </ul> - - </s3> - - <anchor name="DOMString"/> - <s3 title="DOMString"> - <p>Class DOMString provides the mechanism for passing string - data to and from the DOM API. DOMString is not intended to be - a completely general string class, but rather to meet the - specific needs of the DOM API.</p> - - <p>The design derives from two primary sources: from the DOM's - CharacterData interface and from class <code>java.lang.string</code>.</p> - - <p>Main features are:</p> - - <ul> - <li>It stores Unicode text.</li> - - <li>Automatic memory management, using reference counting.</li> - - <li>DOMStrings are mutable - characters can be inserted, - deleted or appended.</li> - - </ul> - <p></p> - - <p>When a string is passed into a method of the DOM, when - setting the value of a Node, for example, the string is cloned - so that any subsequent alteration or reuse of the string by - the application will not alter the document contents. - Similarly, when strings from the document are returned to an - application via the DOM API, the string is cloned so that the - document can not be inadvertently altered by subsequent edits - to the string.</p> - - <note>The ICU classes are a more general solution to UNICODE - character handling for C++ applications. ICU is an Open - Source Unicode library, available at the <jump - href="http://oss.software.ibm.com/icu/">IBM - DeveloperWorks website</jump>.</note> - - </s3> - - <anchor name="EqualityTesting"/> - <s3 title="Equality Testing"> - <p>The DOMString equality operators (and all of the rest of the - DOM class conventions) are modeled after the Java - equivalents. The equals() method compares the content of the - string, while the == operator checks whether the string - reference variables (the application program variables) refer - to the same underlying string in memory. This is also true of - DOM_Node, DOM_Element, etc., in that operator == tells whether - the variables in the application are referring to the same - actual node or not. It's all very Java-like </p> - - <ul> - <li>bool operator == () is true if the DOMString variables - refer to the same underlying storage. </li> - - <li>bool equals() is true if the strings contain the same - characters. </li> - - </ul> - <p>Here is an example of how the equality operators work: </p> -<source>DOMString a = "Hello"; -DOMString b = a; -DOMString c = a.clone(); -if (b == a) // This is true -if (a == c) // This is false -if (a.equals(c)) // This is true -b = b + " World"; -if (b == a) // Still true, and the string's - // value is "Hello World" -if (a.equals(c)) // false. a is "Hello World"; - // c is still "Hello".</source> - </s3> - - <anchor name="Downcasting"/> - <s3 title="Downcasting"> - <p>Application code sometimes must cast an object reference from - DOM_Node to one of the classes deriving from DOM_Node, - DOM_Element, for example. The syntax for doing this in C++ is - different from that in Java.</p> - -<source>// This is C++ -DOM_Node aNode = someFunctionReturningNode(); -DOM_Element el = (DOM_Element &) aNode;</source> - -<source>// This is Java -Node aNode = someFunctionReturningNode(); -Element el = (Element) aNode;</source> - - <p>The C++ cast is not type-safe; the Java cast is checked for - compatible types at runtime. If necessary, a type-check can - be made in C++ using the node type information: </p> - -<source>// This is C++ - -DOM_Node aNode = someFunctionReturningNode(); -DOM_Element el; // by default, el will == null. - -if (anode.getNodeType() == DOM_Node::ELEMENT_NODE) - el = (DOM_Element &) aNode; -else - // aNode does not refer to an element. - // Do something to recover here.</source> - - </s3> - - <anchor name="Subclassing"/> - <s3 title="Subclassing"> - <p>The C++ DOM classes, DOM_Node, DOM_Attr, DOM_Document, etc., - are not designed to be subclassed by an application - program. </p> - - <p>As an alternative, the DOM_Node class provides a User Data - field for use by applications as a hook for extending nodes by - referencing additional data or objects. See the API - description for DOM_Node for details.</p> - </s3> - - </s2> - - <anchor name="IDOMProgGuide"/> - <s2 title="Experimental IDOM Programming Guide"> - <p>The experimental IDOM API is a new design of the C++ DOM API. - Please note that this experimental IDOM API is only a prototype - and is subject to change.</p> - - <anchor name="ConstructIDOMParser"/> - <s3 title="Constructing a parser"> - <p>In order to use &XercesCName; to parse XML files using IDOM, you - will need to create an instance of the IDOMParser class. The example - below shows the code you need in order to create an instance of the - IDOMParser.</p> - - <source> -int main (int argc, char* args[]) { - - try { - XMLPlatformUtils::Initialize(); - } - catch (const XMLException& toCatch) { - cout << "Error during initialization! :\n" - << DOMString(toCatch.getMessage()) << "\n"; - return 1; - } - - char* xmlFile = "x1.xml"; - IDOMParser* parser = new IDOMParser(); - parser->setValidationScheme(IDOMParser::Val_Always); // optional. - parser->setDoNamespaces(true); // optional - - ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase(); - parser->setErrorHandler(errHandler); - - try { - parser->parse(xmlFile); - } - catch (const XMLException& toCatch) { - cout << "Exception message is: \n" - << DOMString(toCatch.getMessage()) << "\n" ; - return -1; - } - catch (const SAXParseException& toCatch) { - cout << "Exception message is: \n" - << DOMString(toCatch.getMessage()) << "\n" ; - return -1; - } - catch (...) { - cout << "Unexpected Exception \n" ; - return -1; - } - - return 0; -} - </source> - </s3> - - <anchor name="DOMandIDOM"/> - <s3 title="Comparision of C++ DOM and IDOM"> - <p> - This section outlines the differences between the C++ DOM and IDOM APIs. - </p> - </s3> - - <anchor name="Motivation"/> - <s3 title="Motivation behind new design"> - <p> - The performance of the C++ DOM has not been as good as it - might be, especially for use in server style applications. - The DOM's reference counted automatic memory management has - been the biggest time consumer. The situation becomes worse - when running multi-threaded applications. - </p> - <p> - The experimental C++ IDOM is a new alternative to the C++ DOM, and aims at - meeting the following requirements: - </p> - <ul> - <li>Reduced memory footprint.</li> - <li>Fast.</li> - <li>Good scalability on multiprocessor systems.</li> - <li>More C++ like and less Java like.</li> - </ul> - </s3> - - <anchor name="IDOMClassNames"/> - <s3 title="Class Names"> - <p> - The IDOM class names are prefixed with "IDOM_". The intent is - to prevent conflicts between IDOM class names and DOM class names - that may already be in use by an application or other - libraries that a DOM based application must link with. - </p> - - - <source> -IDOM_Document* myDocument; // IDOM -IDOM_Node* aNode; -IDOM_Text* someText; - </source> - - <source> -DOM_Document myDocument; // DOM -DOM_Node aNode; -DOM_Text someText; - </source> - </s3> - - <anchor name="IDOMObjMgmt"/> - <s3 title="Objects Management"> - <p>Applications would use normal C++ pointers to directly access the - implementation objects for Nodes in IDOM C++, while they would use - object references in DOM C++. - </p> - - <p>Consider the following code snippets</p> - - - <source> -// IDOM C++ -IDOM_Node* aNode; -IDOM_Node* docRootNode; -aNode = someDocument->createElement("ElementName"); -docRootNode = someDocument->getDocumentElement(); -docRootNode->appendChild(aNode); - </source> - - <source> -// DOM C++ -DOM_Node aNode; -DOM_Node docRootNode; -aNode = someDocument.createElement("ElementName"); -docRootNode = someDocument.getDocumentElement(); -docRootNode.appendChild(aNode); - </source> - </s3> - - - <anchor name="IDOMMemMgmt"/> - <s3 title="Memory Management"> - <p>The C++ IDOM implementation no longer uses reference counting for - automatic memory management. The C++ IDOM uses an independent storage - allocator per document. The storage for a DOM document is - associated with the document node object. - The advantage here is that allocation would require no synchronization - in most cases (based on the the same threading model that we - have now - one thread active per document, but any number of - documents running in parallel with separate threads). - </p> - - <p>The allocator does not support a delete operation at all - all - allocated memory would persist for the life of the document, and - then the larger blocks would be returned to the system without separately - deleting all of the individual nodes and strings within the document. - </p> - - <p>The C++ DOM and IDOM are similar in the use of factory methods in the - document class for all object creation. They differ in the object deletion - mechanism. - </p> - - <p>In C++ DOM, there is no explicit object deletion. The deallocation of - memory is automatically taken care of by the reference counting. - </p> - - <p>In C++ IDOM, there is an implict and explict object deletion. - </p> - </s3> - - <anchor name="IDOMMemImplicit"/> - <s3 title="Implicit Object Deletion"> - <p>When parsing a document using an IDOMParser, all memory allocated - for a DOM tree is associated to the DOM document. And this storage - will be automatically deleted when the parser instance is deleted (implicit). - </p> - <p>If you do multiple parse using the same IDOMParser instance, then - multiple DOM documents will be generated and saved in a vector pool. - All these documents (and thus all the allocated memory) won't be deleted - until the parser instance is destroyed. If you want to release the memory - back to the system but don't want to destroy the IDOMParser instance at this moment, - then you can call the method IDOMParser::resetDocumentPool to reset the document - vector pool, provided that you do not need access to these documents anymore. - </p> - - <p>Consider the following code snippets: </p> - - <source> - // C++ IDOM - implicit deletion - IDOMParser* parser = new IDOMParser(); - parser->parse(xmlFile) - IDOM_Document *doc = parser->getDocument(); - - unsigned int i = 1000; - while (i > 0) { - parser->parse(xmlFile) - IDOM_Document* myDoc = parser->getDocument(); - i--; - } - - // all allocated memory associated with these 1001 DOM documents - // will be deleted implicitly when the parser instance is destroyed - delete parser; - </source> - - <source> - // C++ IDOM - implicit deletion - // optionally release the memory - IDOMParser* parser = new IDOMParser(); - unsigned int i = 1000; - while (i > 0) { - parser->parse(xmlFile) - IDOM_Document *doc = parser->getDocument(); - i--; - } - - // instead of waiting until the parser instance is destroyed, - // user can optionally choose to release the memory back to the system - // if does not need access to these 1000 parsed documents anymore. - parser->resetDocumentPool(); - - // now the parser has some fresh memory to work on for the following - // big loop - i = 1000; - while (i > 0) { - parser->parse(xmlFile) - IDOM_Document *doc = parser->getDocument(); - i--; - } - delete parser; - - </source> - </s3> - - <anchor name="IDOMMemExplicit"/> - <s3 title="Explicit Object Deletion"> - <p>If user is manually building a DOM tree in memory using the document factory methods, - then the user needs to explicilty delete the document object to free all the allocated memory. - It normally falls under the following 3 scenarios: - </p> - <ul> - <li>If a user is manually creating a DOM document using the document implementation - factory methods, IDOM_DOMImplementation::getImplementation()->createDocument, - then the user needs to explicilty delete the document object to free all - allocated memory. </li> - <li>If a user is creating a DocumentType object using the document implementation factory - method, IDOM_DOMImplementation::getImplementation()->createDocumentType, then - the user also needs to explicilty delete the document type object to free the - allocated memory.</li> - <li>Special case: If a user is creating a DocumentType using the document - implementation factory method, and clone the node WITHOUT assigning a document - owner to that documentType object, then the cloned node also needs to be explicitly - deleted.</li> - </ul> - - <p>Consider the following code snippets: </p> - - <source> -// C++ IDOM - explicit deletion -// use the document implementation factory method to create a document type and a document -IDOM_DocumentType* myDocType; -IDOM_Document* myDocument; -IDOM_Node* root; -IDOM_Node* aNode; - -myDocType = IDOM_DOMImplementation::getImplementation()->createDocumentType(name, 0, 0); -myDocument = IDOM_DOMImplementation::getImplementation()->createDocument(0, name, myDocType); -root = myDocument->getDocumentElement(); -aNode = myDocument->createElement(anElementname); - -root->appendChild(aNode); - -// need to delete both myDocType and myDocument which are created through DOM Implementation -delete myDocType; -delete myDocument; - </source> - - <source> -// C++ IDOM - explicit deletion -// use the document implementation factory method to create a document -IDOM_DocumentType* myDocType; -IDOM_Document* myDocument; -IDOM_Node* root; -IDOM_Node* aNode; - -myDocument = IDOM_DOMImplementation::getImplementation()->createDocument(); -myDocType = myDocument->createDocumentType(name); -root = myDocument->createElement(name); -aNode = myDocument->createElement(anElementname); - -myDocument->appendChild(myDocType); -myDocument->appendChild(root); -root->appendChild(aNode); - -// the myDocType is created through myDocument, not through Document Implementation -// thus no need to delete myDocType -delete myDocument; - </source> - - <source> -// C++ IDOM - explicit deletion -// manually build a DOM document -// clone the document type object which does not have an owner yet -IDOM_DocumentType* myDocType1; -IDOM_DocumentType* myDocType; -IDOM_Document* myDocument; -IDOM_Node* root; -IDOM_Node* aNode; - -myDocType = IDOM_DOMImplementation::getImplementation()->createDocumentType(name, 0, 0); -myDocType1 = (IDOM_DocumentType*) myDocType->cloneNode(false); -myDocument = IDOM_DOMImplementation::getImplementation()->createDocument(0, name, myDocType); - -root = myDocument->getDocumentElement(); -aNode = myDocument->createElement(anElementname); - -root->appendChild(aNode); - -// myDocType does not have an owner yet when myDocType1 was cloned. -// thus need to explicitly delete myDocType1 -delete myDocType1; -delete myDocType; -delete myDocument; - </source> - - <source> -// C++ IDOM - explicit deletion -// manually build a DOM document -// clone the document type object that has an owner already -// thus no need to delete the cloned object -IDOM_DocumentType* myDocType1; -IDOM_DocumentType* myDocType; -IDOM_Document* myDocument; -IDOM_Node* root; -IDOM_Node* aNode; - -myDocType = IDOM_DOMImplementation::getImplementation()->createDocumentType(name, 0, 0); -myDocument = IDOM_DOMImplementation::getImplementation()->createDocument(0, name, myDocType); -myDocType1 = (IDOM_DocumentType*) myDocType->cloneNode(false); - -root = myDocument->getDocumentElement(); -aNode = myDocument->createElement(anElementname); - -root->appendChild(aNode); - -// myDocType already has myDocument as the owner when myDocType1 was cloned -// thus NO need to explicitly delete myDocType1 -delete myDocType; -delete myDocument; - </source> - </s3> - - <p>Key points to remember when using the C++ IDOM classes:</p> - - <ul> - <li>The DOM objects are accessed via C++ pointers.</li> - - <li>The DOM objects - nodes, attributes, CData - sections, etc., are created with the factory methods - (create...) in the document class.</li> - - <li>If you are manually building a DOM tree in memory, you - need to explicitly delete the document object. - Memory management will be automatically taken care of by - the IDOM parser when parsing an instance document.</li> - - </ul> - - <anchor name="DOMStringXMCh"/> - <s3 title="DOMString vs. XMLCh"> - <p>The IDOM C++ no longer uses DOMString to pass string data to - and from the DOM API. Instead, the IDOM C++ uses plain, null-terminated - (XMLCh *) utf-16 strings. The (XMLCh*) utf-16 type string is much - simpler with lower overhead. All the string data would remain in - memory until the document object is deleted.</p> - - <source> -//C++ IDOM -const XMLCh* nodeValue = aNode->getNodeValue(); - </source> - - <source> -//C++ DOM -DOMString nodeValue = aNode.getNodeValue(); - </source> - </s3> - - </s2> - </s1> diff --git a/doc/releases.xml b/doc/releases.xml index 227111fc3f1b479624f9889307390ecdb32b1a1e..28aab3536717bc86c3d3d805b9bb924d0cde1294 100644 --- a/doc/releases.xml +++ b/doc/releases.xml @@ -11,6 +11,114 @@ <td>Description</td> </tr> + <tr> + <td>2002-01-18</td> + <td>Tinny Ng</td> + <td>Break program.xml which takes too long to load, into program-sax.xml, program-sax2.xml + program-dom.xml, program-idom.xml. + </td> + </tr> + + <tr> + <td>2002-01-18</td> + <td>Tinny Ng</td> + <td>Break faq-parse.xml which becomes longer and longer into faq-parse.xml and faq-build.xml + to better categorize the FAQ. + </td> + </tr> + + <tr> + <td>2002-01-18</td> + <td>Tinny Ng</td> + <td>Create symbolic link to those duplicate ICU libraries, instead of physical duplicate copies. + </td> + </tr> + + <tr> + <td>2002-01-15</td> + <td>Khaled Noaman</td> + <td>[Bug 5807] Parser produces unexpected errors from 'Good' document. + </td> + </tr> + + <tr> + <td>2002-01-14</td> + <td>PeiYong Zhang</td> + <td>XMLURi bug fix: related to Authority and wellformedAddress + </td> + </tr> + + <tr> + <td>2002-01-14</td> + <td>Max Gotlib</td> + <td>[Bug 5570] DOM_Range lacks the copy constructor. + </td> + </tr> + + <tr> + <td>2002-01-14</td> + <td>Max Gotlib</td> + <td>Support IconvFBSD in multi-threading environment with all the possible + combinations of threading and transcoding options. + </td> + </tr> + + <tr> + <td>2002-01-10</td> + <td>Khaled Noaman</td> + <td>[Bug 5786] Unexpected Schema errors. + </td> + </tr> + + <tr> + <td>2002-01-03</td> + <td>Khaled Noaman</td> + <td>Fix for identity constraints - union operation. + </td> + </tr> + + <tr> + <td>2002-01-03</td> + <td>Khaled Noaman</td> + <td>Resolve namespace first before resolving the schema location in <import>. + </td> + </tr> + + <tr> + <td>2002-01-03</td> + <td>Khaled Noaman</td> + <td>[Bug 5675] Use of setExternalSchemaLocation() yields inconsistent behavior. + </td> + </tr> + + <tr> + <td>2002-01-02</td> + <td>Khaled Noaman</td> + <td>Fix for validity constraint check for standalone documents. + </td> + </tr> + + <tr> + <td>2002-01-02</td> + <td>Khaled Noaman</td> + <td>Fix for regular expression patterns that begin with ".". + </td> + </tr> + + <tr> + <td>2002-01-02</td> + <td>Khaled Noaman</td> + <td>Fix for error message when checking for attributes with a namespace prefix. + </td> + </tr> + + <tr> + <td>2002-01-02</td> + <td>Khaled Noaman</td> + <td>[Bug 5569] <extension> does not work -- ancestor elements not recognized. + </td> + </tr> + <tr> <td>2002-01-02</td> <td>Tinny Ng</td> diff --git a/src/parsers/SAX2XMLReaderImpl.hpp b/src/parsers/SAX2XMLReaderImpl.hpp index c15504981a1819a7d54c7a27a69311f02dd5643a..16e2a7c019edc64ba2e2572bf4e4dc0d6b1c5248 100644 --- a/src/parsers/SAX2XMLReaderImpl.hpp +++ b/src/parsers/SAX2XMLReaderImpl.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.18 2002/01/18 16:31:38 tng + * Break program.xml which takes too long to load, into program-sax.xml, program-sax2.xml, program-dom.xml, program-idom.xml. + * * Revision 1.17 2002/01/02 15:36:41 tng * Some documentation update. * @@ -642,7 +645,7 @@ public : /** * Set the state of any feature in a SAX2 XMLReader. * Supported features in SAX2 for xerces-c are: - * <br>(See http://xml.apache.org/xerces-c/program.html#SAX2Features for detail description). + * <br>(See http://xml.apache.org/xerces-c/program-sax2.html#SAX2Features for detail description). * * <br>http://xml.org/sax/features/validation (default: true) * <br>http://xml.org/sax/features/namespaces (default: true) @@ -673,20 +676,20 @@ public : /** * Set the value of any property in a SAX2 XMLReader. * Supported properties in SAX2 for xerces-c are: - * <br>(See http://xml.apache.org/xerces-c/program.html#SAX2Properties for detail description). + * <br>(See http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties for detail description). * * <br>http://apache.org/xml/properties/schema/external-schemaLocation * <br>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation. * * It takes a void pointer as the property value. Application is required to initialize this void - * pointer to a correct type. See http://xml.apache.org/xerces-c/program.html#SAX2Properties + * pointer to a correct type. See http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties * to learn exactly what type of property value each property expects for processing. * Passing a void pointer that was initialized with a wrong type will lead to unexpected result. * If the same property is set more than once, the last one takes effect. * * @param name The unique identifier (URI) of the property being set. * @param value The requested value for the property. See - * http://xml.apache.org/xerces-c/program.html#SAX2Properties to learn + * http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties to learn * exactly what type of property value each property expects for processing. * Passing a void pointer that was initialized with a wrong type will lead * to unexpected result. @@ -705,7 +708,7 @@ public : * is deleted, callers need to copy and store the returned information * somewhere else; otherwise you may get unexpected result. Since the returned * pointer is a generic void pointer, see - * http://xml.apache.org/xerces-c/program.html#SAX2Properties to learn + * http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties to learn * exactly what type of property value each property returns for replication. * * @param name The unique identifier (URI) of the property being set. diff --git a/src/sax2/SAX2XMLReader.hpp b/src/sax2/SAX2XMLReader.hpp index aeddb3e82098ef4424b445969f33aae755464be4..95a503484829d6b8f3267d24596fd3751ea6934d 100644 --- a/src/sax2/SAX2XMLReader.hpp +++ b/src/sax2/SAX2XMLReader.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.16 2002/01/18 16:31:26 tng + * Break program.xml which takes too long to load, into program-sax.xml, program-sax2.xml, program-dom.xml, program-idom.xml. + * * Revision 1.15 2002/01/02 15:36:54 tng * Some documentation update. * @@ -232,7 +235,7 @@ public: * is deleted, callers need to copy and store the returned information * somewhere else; otherwise you may get unexpected result. Since the returned * pointer is a generic void pointer, see - * http://xml.apache.org/xerces-c/program.html#SAX2Properties to learn + * http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties to learn * exactly what type of property value each property returns for replication. * * @param name The unique identifier (URI) of the property being set. @@ -472,7 +475,7 @@ public: /** * Set the state of any feature in a SAX2 XMLReader. * Supported features in SAX2 for xerces-c are: - * <br>(See http://xml.apache.org/xerces-c/program.html#SAX2Features for detail description). + * <br>(See http://xml.apache.org/xerces-c/program-sax2.html#SAX2Features for detail description). * * <br>http://xml.org/sax/features/validation (default: true) * <br>http://xml.org/sax/features/namespaces (default: true) @@ -494,20 +497,20 @@ public: /** * Set the value of any property in a SAX2 XMLReader. * Supported properties in SAX2 for xerces-c are: - * <br>(See http://xml.apache.org/xerces-c/program.html#SAX2Properties for detail description). + * <br>(See http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties for detail description). * * <br>http://apache.org/xml/properties/schema/external-schemaLocation * <br>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation. * * It takes a void pointer as the property value. Application is required to initialize this void - * pointer to a correct type. See http://xml.apache.org/xerces-c/program.html#SAX2Properties + * pointer to a correct type. See http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties * to learn exactly what type of property value each property expects for processing. * Passing a void pointer that was initialized with a wrong type will lead to unexpected result. * If the same property is set more than once, the last one takes effect. * * @param name The unique identifier (URI) of the property being set. * @param value The requested value for the property. See - * http://xml.apache.org/xerces-c/program.html#SAX2Properties to learn + * http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties to learn * exactly what type of property value each property expects for processing. * Passing a void pointer that was initialized with a wrong type will lead * to unexpected result.