gareth 2003/08/20 13:49:31 Modified: c/doc program-dom.xml c/src/xercesc/parsers AbstractDOMParser.cpp AbstractDOMParser.hpp DOMBuilderImpl.cpp c/src/xercesc/util XMLUni.cpp XMLUni.hpp Log: Added a method for use in XercesDOMParser (and others derived from AbstractDOMParser) and a feature in DOMBuilder that allows the creation of the document during parse to be from an DOMImplementation other than the default. Updated documentation. Revision Changes Path 1.36 +21 -0 xml-xerces/c/doc/program-dom.xml Index: program-dom.xml =================================================================== RCS file: /home/cvs/xml-xerces/c/doc/program-dom.xml,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- program-dom.xml 14 May 2003 17:11:55 -0000 1.35 +++ program-dom.xml 20 Aug 2003 20:49:30 -0000 1.36 @@ -624,6 +624,18 @@ for more programming details. </td></tr> </table> + + <p/> + <table> + <tr><th colspan="2"><em>void useImplementation(const XMLCh* const)</em></th></tr> + <tr><th><em>Description</em></th><td>This property allows the user to specify a set of features + which the parser will then use to acquire an implementation from which it will create + the DOMDocument to use when reading in an XML file. + <tr><th><em>Value Type</em></th><td> XMLCh* </td></tr> + </table> + + <p/> + <p/> <table> <tr><th @@ -1268,6 +1280,15 @@ <tr><th><em>Value Type</em></th><td> XMLCh* </td></tr> <tr><th><em>note: </em></th><td> See <jump href="program-others.html#UseSpecificScanner">Use Specific Scanner</jump> for more programming details. </td></tr> + </table> + <p/> + <table> + <tr><th colspan="2"><em>http://apache.org/xml/properties/parser-use-DOMDocument-from-Implemenation</em></th></tr> + <tr><th><em>Description</em></th><td>This property allows the user to specify a set of features + which the parser will then use to acquire an implementation from which it will create + the DOMDocument to use when reading in an XML file. + <tr><th><em>Value Type</em></th><td> XMLCh* </td></tr> + </table> <p/> <table> 1.48 +10 -3 xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp Index: AbstractDOMParser.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- AbstractDOMParser.cpp 13 Aug 2003 22:46:20 -0000 1.47 +++ AbstractDOMParser.cpp 20 Aug 2003 20:49:30 -0000 1.48 @@ -77,6 +77,7 @@ #include <xercesc/framework/XMLValidator.hpp> #include <xercesc/util/IOException.hpp> #include <xercesc/dom/DOMImplementation.hpp> +#include <xercesc/dom/DOMImplementationRegistry.hpp> #include <xercesc/dom/DOMElement.hpp> #include <xercesc/dom/impl/DOMAttrImpl.hpp> #include <xercesc/dom/DOMCDATASection.hpp> @@ -113,6 +114,7 @@ , fCreateCommentNodes(true) , fDocumentAdoptedByUser(false) , fScanner(0) +, fImplementationFeatures(0) , fCurrentParent(0) , fCurrentNode(0) , fCurrentEntity(0) @@ -178,6 +180,8 @@ delete fGrammarResolver; delete fURIStringPool; + delete[] fImplementationFeatures; + if (fValidator) delete fValidator; } @@ -198,7 +202,6 @@ fDocument = 0; resetDocType(); - fCurrentParent = 0; fCurrentNode = 0; fCurrentEntity = 0; @@ -753,7 +756,11 @@ void AbstractDOMParser::startDocument() { - fDocument = (DOMDocumentImpl *)DOMImplementation::getImplementation()->createDocument(fMemoryManager); + if(fImplementationFeatures == 0) + fDocument = (DOMDocumentImpl *)DOMImplementation::getImplementation()->createDocument(fMemoryManager); + else + fDocument = (DOMDocumentImpl *)DOMImplementationRegistry::getDOMImplementation(fImplementationFeatures)->createDocument(fMemoryManager); + // Just set the document as the current parent and current node fCurrentParent = fDocument; fCurrentNode = fDocument; 1.21 +22 -3 xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.hpp Index: AbstractDOMParser.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.hpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- AbstractDOMParser.hpp 20 Jun 2003 18:55:54 -0000 1.20 +++ AbstractDOMParser.hpp 20 Aug 2003 20:49:30 -0000 1.21 @@ -72,7 +72,6 @@ #include <xercesc/validators/DTD/DTDElementDecl.hpp> #include <xercesc/framework/XMLBufferMgr.hpp> - XERCES_CPP_NAMESPACE_BEGIN class XMLPScanToken; @@ -700,13 +699,22 @@ /** Set the scanner to use when scanning the XML document * - * This method allows users to set the the scanner to use + * This method allows users to set the scanner to use * when scanning a given XML document. * * @param scannerName The name of the desired scanner */ void useScanner(const XMLCh* const scannerName); + /** Set the implementation to use when creating the document + * + * This method allows users to set the implementation to use + * to create the document when parseing. + * + * @param implementationFeatures The names of the desired features the implementation should have. + */ + void useImplementation(const XMLCh* const implementationFeatures); + //@} @@ -1442,6 +1450,11 @@ // The scanner used for this parser. This is created during the // constructor. // + // fImplementationFeatures + // The implementation features that we use to get an implementation + // for use in creating the DOMDocument used during parse. If this is + // null then the default DOMImplementation is used + // // fNodeStack // Used to track previous parent nodes during nested element events. // @@ -1486,6 +1499,7 @@ bool fCreateCommentNodes; bool fDocumentAdoptedByUser; XMLScanner* fScanner; + XMLCh* fImplementationFeatures; DOMNode* fCurrentParent; DOMNode* fCurrentNode; DOMEntity* fCurrentEntity; @@ -1564,6 +1578,11 @@ fCreateCommentNodes = create; } +inline void AbstractDOMParser::useImplementation(const XMLCh* const implementationFeatures) +{ + delete[] fImplementationFeatures; + fImplementationFeatures = XMLString::replicate(implementationFeatures); +} // --------------------------------------------------------------------------- // AbstractDOMParser: Protected getter methods 1.29 +6 -1 xml-xerces/c/src/xercesc/parsers/DOMBuilderImpl.cpp Index: DOMBuilderImpl.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/DOMBuilderImpl.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- DOMBuilderImpl.cpp 19 Aug 2003 14:15:18 -0000 1.28 +++ DOMBuilderImpl.cpp 20 Aug 2003 20:49:31 -0000 1.29 @@ -402,6 +402,11 @@ { AbstractDOMParser::useScanner((const XMLCh*) value); } + else if (XMLString::equals(name, XMLUni::fgXercesParserUseDocumentFromImplementation)) + { + useImplementation((const XMLCh*) value); + } + else throw DOMException(DOMException::NOT_FOUND_ERR, 0); } 1.32 +20 -1 xml-xerces/c/src/xercesc/util/XMLUni.cpp Index: XMLUni.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- XMLUni.cpp 20 Aug 2003 13:41:47 -0000 1.31 +++ XMLUni.cpp 20 Aug 2003 20:49:31 -0000 1.32 @@ -1129,6 +1129,25 @@ , chLatin_m, chLatin_e, chNull }; +//Property +//Xerces: http://apache.org/xml/properties/parser-use-DOMDocument-from-Implemenation +const XMLCh XMLUni::fgXercesParserUseDocumentFromImplementation[] = +{ + chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash + , chForwardSlash, chLatin_a, chLatin_p, chLatin_a, chLatin_c, chLatin_h + , chLatin_e, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash + , chLatin_x, chLatin_m, chLatin_l, chForwardSlash, chLatin_p, chLatin_r + , chLatin_o, chLatin_p, chLatin_e, chLatin_r, chLatin_t, chLatin_i + , chLatin_e, chLatin_s, chForwardSlash, chLatin_f, chLatin_g, chLatin_X + , chLatin_e, chLatin_r, chLatin_c, chLatin_e, chLatin_s, chLatin_P, chLatin_a + , chLatin_r, chLatin_s, chLatin_e, chLatin_r, chLatin_U, chLatin_s, chLatin_e + , chLatin_D, chLatin_o, chLatin_c, chLatin_u, chLatin_m, chLatin_e, chLatin_n + , chLatin_t, chLatin_F, chLatin_r, chLatin_o, chLatin_m, chLatin_I, chLatin_m + , chLatin_p, chLatin_l, chLatin_e, chLatin_m, chLatin_e, chLatin_n, chLatin_t + , chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull +}; + + //Xerces: http://apache.org/xml/features/dom/user-adopts-DOMDocument const XMLCh XMLUni::fgXercesUserAdoptsDOMDocument[] = { 1.28 +2 -1 xml-xerces/c/src/xercesc/util/XMLUni.hpp Index: XMLUni.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.hpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- XMLUni.hpp 17 Apr 2003 21:58:50 -0000 1.27 +++ XMLUni.hpp 20 Aug 2003 20:49:31 -0000 1.28 @@ -250,6 +250,7 @@ static const XMLCh fgXercesCacheGrammarFromParse[]; static const XMLCh fgXercesUseCachedGrammarInParse[]; static const XMLCh fgXercesScannerName[]; + static const XMLCh fgXercesParserUseDocumentFromImplementation[]; static const XMLCh fgXercesCalculateSrcOfs[]; static const XMLCh fgXercesStandardUriConformant[];
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]