diff --git a/Projects/Win32/BCB6/Xerces-all/XercesLib/XercesLib.bpr b/Projects/Win32/BCB6/Xerces-all/XercesLib/XercesLib.bpr index 57236c80605ec7f19ebd031c0a7dec6786ded844..b1b2a2499a00cfad0072fe30e7ecaf5b2719e7e8 100644 --- a/Projects/Win32/BCB6/Xerces-all/XercesLib/XercesLib.bpr +++ b/Projects/Win32/BCB6/Xerces-all/XercesLib/XercesLib.bpr @@ -255,6 +255,8 @@ ..\..\..\..\..\Build\Win32\BCB6\obj\DOMImplementationListImpl.obj ..\..\..\..\..\Build\Win32\BCB6\obj\DOMImplementationRegistry.obj ..\..\..\..\..\Build\Win32\BCB6\obj\DOMLocatorImpl.obj + ..\..\..\..\..\Build\Win32\BCB6\obj\DOMLSInputImpl.obj + ..\..\..\..\..\Build\Win32\BCB6\obj\DOMLSOutputImpl.obj ..\..\..\..\..\Build\Win32\BCB6\obj\DOMLSSerializerImpl.obj ..\..\..\..\..\Build\Win32\BCB6\obj\DOMNamedNodeMapImpl.obj ..\..\..\..\..\Build\Win32\BCB6\obj\DOMNodeIDMap.obj diff --git a/Projects/Win32/BCC.551/Xerces-all/XercesLib/XercesLib.mak b/Projects/Win32/BCC.551/Xerces-all/XercesLib/XercesLib.mak index 6048280adca9db8550d990688c5c4f39bc993ed7..649970c62d7a87701f3cb2e2c0ef7d63bf1bb363 100644 --- a/Projects/Win32/BCC.551/Xerces-all/XercesLib/XercesLib.mak +++ b/Projects/Win32/BCC.551/Xerces-all/XercesLib/XercesLib.mak @@ -291,6 +291,8 @@ OBJFILES = $(TARGETPATH)\obj\XercesLib.obj \ $(TARGETPATH)\obj\DOMStringListImpl.obj \ $(TARGETPATH)\obj\DOMLSParserImpl.obj \ $(TARGETPATH)\obj\DOMLSSerializerImpl.obj \ + $(TARGETPATH)\obj\DOMLSInputImpl.obj \ + $(TARGETPATH)\obj\DOMLSOutputImpl.obj \ $(TARGETPATH)\obj\DOMLSException.obj \ $(TARGETPATH)\obj\Wrapper4InputSource.obj \ $(TARGETPATH)\obj\Wrapper4DOMLSInput.obj \ diff --git a/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp b/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp index c75a22ca07173de6f9629bf136687b002dbec4f9..6dc8601f938463e02ffaf94269b702998524ac90 100644 --- a/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp +++ b/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp @@ -2983,6 +2983,22 @@ SOURCE=..\..\..\..\..\src\xercesc\dom\impl\DOMLocatorImpl.hpp # End Source File # Begin Source File +SOURCE=..\..\..\..\..\src\xercesc\dom\impl\DOMLSInputImpl.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\xercesc\dom\impl\DOMLSInputImpl.hpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\xercesc\dom\impl\DOMLSOutputImpl.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\xercesc\dom\impl\DOMLSOutputImpl.hpp +# End Source File +# Begin Source File + SOURCE=..\..\..\..\..\src\xercesc\dom\impl\DOMLSSerializerImpl.cpp # End Source File # Begin Source File diff --git a/Projects/Win32/VC7.1/xerces-all/XercesLib/XercesLib.vcproj b/Projects/Win32/VC7.1/xerces-all/XercesLib/XercesLib.vcproj index e0ddd8781ffed36c99e5f57fa7171ac9f7fc3227..cde3cc199b25ac9de7f995aacc1c6d25cdf3bd59 100644 --- a/Projects/Win32/VC7.1/xerces-all/XercesLib/XercesLib.vcproj +++ b/Projects/Win32/VC7.1/xerces-all/XercesLib/XercesLib.vcproj @@ -2607,6 +2607,18 @@ copy $(InputDir)\$(InputName).msvc.hpp $(InputPath) <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLocatorImpl.hpp"> </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSInputImpl.cpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSInputImpl.hpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSOutputImpl.cpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSOutputImpl.hpp"> + </File> <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSSerializerImpl.cpp"> </File> diff --git a/Projects/Win32/VC7/xerces-all/XercesLib/XercesLib.vcproj b/Projects/Win32/VC7/xerces-all/XercesLib/XercesLib.vcproj index bbb2916bc102f01bf686d416acc85cfdab2b8fbc..ee2a5119f5c2e1cd63b5fd654caac1e7b3daa446 100644 --- a/Projects/Win32/VC7/xerces-all/XercesLib/XercesLib.vcproj +++ b/Projects/Win32/VC7/xerces-all/XercesLib/XercesLib.vcproj @@ -1924,6 +1924,12 @@ <File RelativePath="..\..\..\..\..\src\xercesc\validators\schema\identity\IdentityConstraint.hpp"> </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\validators\schema\identity\IdentityConstraintHandler.cpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\validators\schema\identity\IdentityConstraintHandler.hpp"> + </File> <File RelativePath="..\..\..\..\..\src\xercesc\validators\schema\identity\ValueStore.cpp"> </File> @@ -2160,13 +2166,13 @@ RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMAttrNSImpl.hpp"> </File> <File - RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMCDATASectionImpl.cpp"> + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMCasts.hpp"> </File> <File - RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMCDATASectionImpl.hpp"> + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMCDATASectionImpl.cpp"> </File> <File - RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMCasts.hpp"> + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMCDATASectionImpl.hpp"> </File> <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMCharacterDataImpl.cpp"> @@ -2253,10 +2259,16 @@ RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMImplementationImpl.cpp"> </File> <File - RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMImplementationRegistry.cpp"> + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMImplementationImpl.hpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMImplementationListImpl.cpp"> </File> <File - RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMImplementationimpl.hpp"> + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMImplementationListImpl.hpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMImplementationRegistry.cpp"> </File> <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLocatorImpl.cpp"> @@ -2264,6 +2276,24 @@ <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLocatorImpl.hpp"> </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSInputImpl.cpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSInputImpl.hpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSOutputImpl.cpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSOutputImpl.hpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSSerializerImpl.cpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSSerializerImpl.hpp"> + </File> <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMNamedNodeMapImpl.cpp"> </File> @@ -2330,6 +2360,12 @@ <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMRangeImpl.hpp"> </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMStringListImpl.cpp"> + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMStringListImpl.hpp"> + </File> <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMStringPool.cpp"> </File> @@ -2354,12 +2390,6 @@ <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMTypeInfoImpl.hpp"> </File> - <File - RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMWriterImpl.cpp"> - </File> - <File - RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMWriterImpl.hpp"> - </File> <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\XSDElementNSImpl.cpp"> </File> @@ -2368,12 +2398,6 @@ </File> </Filter> </Filter> - <File - RelativePath="..\..\..\..\..\src\xercesc\validators\schema\identity\IdentityConstraintHandler.cpp"> - </File> - <File - RelativePath="..\..\..\..\..\src\xercesc\validators\schema\identity\IdentityConstraintHandler.hpp"> - </File> <File RelativePath="..\..\..\..\..\src\xercesc\util\MsgLoaders\Win32\Version.rc"> <FileConfiguration diff --git a/Projects/Win32/VC8/xerces-all/XercesLib/XercesLib.vcproj b/Projects/Win32/VC8/xerces-all/XercesLib/XercesLib.vcproj index 7f6de502cd1ea37ac62b012cfce0e59133ee7d76..1651c449ec50a02938919dd9ac8ac371ff7bcaa6 100644 --- a/Projects/Win32/VC8/xerces-all/XercesLib/XercesLib.vcproj +++ b/Projects/Win32/VC8/xerces-all/XercesLib/XercesLib.vcproj @@ -3476,6 +3476,22 @@ RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLocatorImpl.hpp" > </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSInputImpl.cpp" + > + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSInputImpl.hpp" + > + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSOutputImpl.cpp" + > + </File> + <File + RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSOutputImpl.hpp" + > + </File> <File RelativePath="..\..\..\..\..\src\xercesc\dom\impl\DOMLSSerializerImpl.cpp" > diff --git a/samples/src/DOMPrint/DOMPrint.cpp b/samples/src/DOMPrint/DOMPrint.cpp index 5230ab701d462ea1b20f7332b8b09a30e3ceca39..a6d6ed749026e731508a6a78676a3a6bd61d6e6d 100644 --- a/samples/src/DOMPrint/DOMPrint.cpp +++ b/samples/src/DOMPrint/DOMPrint.cpp @@ -68,9 +68,6 @@ #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/dom/DOM.hpp> -#include <xercesc/dom/DOMImplementation.hpp> -#include <xercesc/dom/DOMImplementationLS.hpp> -#include <xercesc/dom/DOMLSSerializer.hpp> #include <xercesc/framework/StdOutFormatTarget.hpp> #include <xercesc/framework/LocalFileFormatTarget.hpp> @@ -434,9 +431,10 @@ int main(int argC, char* argV[]) XMLCh tempStr[3] = {chLatin_L, chLatin_S, chNull}; DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr); DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer(); + DOMLSOutput *theOutputDesc = ((DOMImplementationLS*)impl)->createLSOutput(); // set user specified output encoding - theSerializer->setEncoding(gOutputEncoding); + theOutputDesc->setEncoding(gOutputEncoding); // plug in user's own filter if (gUseFilter) @@ -482,9 +480,10 @@ int main(int argC, char* argV[]) // XMLFormatTarget *myFormTarget; if (goutputfile) - myFormTarget = new LocalFileFormatTarget(goutputfile); + myFormTarget=new LocalFileFormatTarget(goutputfile); else - myFormTarget = new StdOutFormatTarget(); + myFormTarget=new StdOutFormatTarget(); + theOutputDesc->setByteStream(myFormTarget); // get the DOM representation DOMNode *doc = parser->getDocument(); @@ -492,9 +491,10 @@ int main(int argC, char* argV[]) // // do the serialization through DOMLSSerializer::write(); // - theSerializer->write(doc, myFormTarget); + theSerializer->write(doc, theOutputDesc); - delete theSerializer; + theOutputDesc->release(); + theSerializer->release(); // // Filter, formatTarget and error handler diff --git a/src/Makefile.am b/src/Makefile.am index 85398b9ff1677a4fc0dda9b99541090b20ed44b5..d53a50df107906d9d21487c04b099dc2224772fa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -355,6 +355,8 @@ domimpl_headers = \ xercesc/dom/impl/DOMTreeWalkerImpl.hpp \ xercesc/dom/impl/DOMTypeInfoImpl.hpp \ xercesc/dom/impl/DOMLSSerializerImpl.hpp \ + xercesc/dom/impl/DOMLSInputImpl.hpp \ + xercesc/dom/impl/DOMLSOutputImpl.hpp \ xercesc/dom/impl/XSDElementNSImpl.hpp domimpl_sources = \ @@ -396,6 +398,8 @@ domimpl_sources = \ xercesc/dom/impl/DOMTreeWalkerImpl.cpp \ xercesc/dom/impl/DOMTypeInfoImpl.cpp \ xercesc/dom/impl/DOMLSSerializerImpl.cpp \ + xercesc/dom/impl/DOMLSInputImpl.cpp \ + xercesc/dom/impl/DOMLSOutputImpl.cpp \ xercesc/dom/impl/XSDElementNSImpl.cpp diff --git a/src/Makefile.in b/src/Makefile.in index 4510381f082974045d7db259a9635d44b06e9766..f745c46ffa027cfd8c1ffac74f37331a15b303d7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -223,6 +223,8 @@ am__objects_4 = xercesc/dom/impl/DOMAttrImpl.lo \ xercesc/dom/impl/DOMTreeWalkerImpl.lo \ xercesc/dom/impl/DOMTypeInfoImpl.lo \ xercesc/dom/impl/DOMLSSerializerImpl.lo \ + xercesc/dom/impl/DOMLSInputImpl.lo \ + xercesc/dom/impl/DOMLSOutputImpl.lo \ xercesc/dom/impl/XSDElementNSImpl.lo am_libdomimpl_la_OBJECTS = $(am__objects_4) libdomimpl_la_OBJECTS = $(am_libdomimpl_la_OBJECTS) @@ -1208,6 +1210,8 @@ domimpl_headers = \ xercesc/dom/impl/DOMTreeWalkerImpl.hpp \ xercesc/dom/impl/DOMTypeInfoImpl.hpp \ xercesc/dom/impl/DOMLSSerializerImpl.hpp \ + xercesc/dom/impl/DOMLSInputImpl.hpp \ + xercesc/dom/impl/DOMLSOutputImpl.hpp \ xercesc/dom/impl/XSDElementNSImpl.hpp domimpl_sources = \ @@ -1249,6 +1253,8 @@ domimpl_sources = \ xercesc/dom/impl/DOMTreeWalkerImpl.cpp \ xercesc/dom/impl/DOMTypeInfoImpl.cpp \ xercesc/dom/impl/DOMLSSerializerImpl.cpp \ + xercesc/dom/impl/DOMLSInputImpl.cpp \ + xercesc/dom/impl/DOMLSOutputImpl.cpp \ xercesc/dom/impl/XSDElementNSImpl.cpp framework_headers = \ @@ -2223,6 +2229,10 @@ xercesc/dom/impl/DOMTypeInfoImpl.lo: xercesc/dom/impl/$(am__dirstamp) \ xercesc/dom/impl/DOMLSSerializerImpl.lo: \ xercesc/dom/impl/$(am__dirstamp) \ xercesc/dom/impl/$(DEPDIR)/$(am__dirstamp) +xercesc/dom/impl/DOMLSInputImpl.lo: xercesc/dom/impl/$(am__dirstamp) \ + xercesc/dom/impl/$(DEPDIR)/$(am__dirstamp) +xercesc/dom/impl/DOMLSOutputImpl.lo: xercesc/dom/impl/$(am__dirstamp) \ + xercesc/dom/impl/$(DEPDIR)/$(am__dirstamp) xercesc/dom/impl/XSDElementNSImpl.lo: \ xercesc/dom/impl/$(am__dirstamp) \ xercesc/dom/impl/$(DEPDIR)/$(am__dirstamp) @@ -3170,6 +3180,10 @@ mostlyclean-compile: -rm -f xercesc/dom/impl/DOMImplementationListImpl.lo -rm -f xercesc/dom/impl/DOMImplementationRegistry.$(OBJEXT) -rm -f xercesc/dom/impl/DOMImplementationRegistry.lo + -rm -f xercesc/dom/impl/DOMLSInputImpl.$(OBJEXT) + -rm -f xercesc/dom/impl/DOMLSInputImpl.lo + -rm -f xercesc/dom/impl/DOMLSOutputImpl.$(OBJEXT) + -rm -f xercesc/dom/impl/DOMLSOutputImpl.lo -rm -f xercesc/dom/impl/DOMLSSerializerImpl.$(OBJEXT) -rm -f xercesc/dom/impl/DOMLSSerializerImpl.lo -rm -f xercesc/dom/impl/DOMLocatorImpl.$(OBJEXT) @@ -3776,6 +3790,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@xercesc/dom/impl/$(DEPDIR)/DOMImplementationImpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@xercesc/dom/impl/$(DEPDIR)/DOMImplementationListImpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@xercesc/dom/impl/$(DEPDIR)/DOMImplementationRegistry.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@xercesc/dom/impl/$(DEPDIR)/DOMLSInputImpl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@xercesc/dom/impl/$(DEPDIR)/DOMLSOutputImpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@xercesc/dom/impl/$(DEPDIR)/DOMLSSerializerImpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@xercesc/dom/impl/$(DEPDIR)/DOMLocatorImpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@xercesc/dom/impl/$(DEPDIR)/DOMNamedNodeMapImpl.Plo@am__quote@ diff --git a/src/xercesc/dom/DOM.hpp b/src/xercesc/dom/DOM.hpp index 836aaaad1dda694497d76e5e419c5d238d3c434f..91239e900bf8c5d6d9b6d67d86cf2f2e0390f9b4 100644 --- a/src/xercesc/dom/DOM.hpp +++ b/src/xercesc/dom/DOM.hpp @@ -64,6 +64,7 @@ #include <xercesc/dom/DOMImplementationRegistry.hpp> #include <xercesc/dom/DOMImplementationSource.hpp> #include <xercesc/dom/DOMLSInput.hpp> +#include <xercesc/dom/DOMLSOutput.hpp> #include <xercesc/dom/DOMLocator.hpp> #include <xercesc/dom/DOMTypeInfo.hpp> #include <xercesc/dom/DOMUserDataHandler.hpp> diff --git a/src/xercesc/dom/DOMImplementationLS.hpp b/src/xercesc/dom/DOMImplementationLS.hpp index 5da22427deda5c1d16a54a70f078b06356826a1d..abaa21db665da8035bd8d58a281797bdb8a99bd6 100644 --- a/src/xercesc/dom/DOMImplementationLS.hpp +++ b/src/xercesc/dom/DOMImplementationLS.hpp @@ -163,7 +163,7 @@ public: * @see DOMLSInput * @since DOM Level 3 */ - virtual DOMLSInput* createLSInput() = 0; + virtual DOMLSInput* createLSInput(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0; /** * Create a new "empty" LSOutput. @@ -173,7 +173,7 @@ public: * @see LSOutput * @since DOM Level 3 */ - virtual DOMLSOutput* createLSOutput() = 0; + virtual DOMLSOutput* createLSOutput(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0; //@} }; diff --git a/src/xercesc/dom/DOMLSInput.hpp b/src/xercesc/dom/DOMLSInput.hpp index ffe9bad3c9dfc7ef9e8d600db75562db63207a3b..a05800ea7078052bd272775ab44930e98e86b191 100644 --- a/src/xercesc/dom/DOMLSInput.hpp +++ b/src/xercesc/dom/DOMLSInput.hpp @@ -27,7 +27,7 @@ XERCES_CPP_NAMESPACE_BEGIN -class BinInputStream; +class InputSource; /** @@ -99,16 +99,19 @@ public: // Getter methods // ----------------------------------------------------------------------- /** - * Makes the byte stream for this input source. + * String data to parse. If provided, this will always be treated as a sequence of 16-bit units (UTF-16 encoded characters). + * It is not a requirement to have an XML declaration when using stringData. If an XML declaration is present, the value of + * the encoding attribute will be ignored. * - * <p>The derived class must create and return a binary input stream of an - * appropriate type for its kind of data source. The returned stream must - * be dynamically allocated and becomes the parser's property. - * </p> + */ + virtual const XMLCh* getStringData() const = 0; + + /** + * Returns the byte stream for this input source. * - * @see BinInputStream + * @see InputSource */ - virtual BinInputStream* getByteStream() const = 0; + virtual InputSource* getByteStream() const = 0; /** * An input source can be set to force the parser to assume a particular @@ -159,6 +162,20 @@ public: // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- + /** + * Sets the UTF-16 string for this input source. + * + */ + virtual void setStringData(const XMLCh* data) = 0; + + /** + * Sets the byte stream for this input source. + * + * @see BinInputStream + */ + virtual void setByteStream(InputSource* stream) = 0; + /** * Set the encoding which will be required for use with the XML text read * via a stream opened by this input source. @@ -228,7 +245,7 @@ public: * * @see #getIssueFatalErrorIfNotFound */ - virtual void setIssueFatalErrorIfNotFound(const bool flag) = 0; + virtual void setIssueFatalErrorIfNotFound(bool flag) = 0; /** @@ -247,7 +264,7 @@ public: * * Access to a released object will lead to unexpected result. */ - virtual void release() = 0; + virtual void release() = 0; //@} }; diff --git a/src/xercesc/dom/DOMLSOutput.hpp b/src/xercesc/dom/DOMLSOutput.hpp index 7cade6bee415aee12f946766be4f836db9c18acc..2bc189db427b92d0fd3e0c6400c47a2a98b10a80 100644 --- a/src/xercesc/dom/DOMLSOutput.hpp +++ b/src/xercesc/dom/DOMLSOutput.hpp @@ -1,5 +1,5 @@ -#ifndef DOMLSInput_HEADER_GUARD_ -#define DOMLSInput_HEADER_GUARD_ +#ifndef DOMLSOutput_HEADER_GUARD_ +#define DOMLSOutput_HEADER_GUARD_ /* * Copyright 2002,2004 The Apache Software Foundation. @@ -27,14 +27,12 @@ XERCES_CPP_NAMESPACE_BEGIN -class BinInputStream; +class XMLFormatTarget; /** * This interface represents an output destination for data. * - * Xerces currently doesn't use <code>DOMLSOutput</code> objects - * * @see XMLFormatTarget * @since DOM Level 3 */ @@ -80,14 +78,19 @@ public: // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- + /** + * Returns the byte stream for this input source. + * + * @see InputSource + */ + virtual XMLFormatTarget* getByteStream() const = 0; + /** * An input source can be set to force the parser to assume a particular * encoding for the data that input source reprsents, via the setEncoding() * method. This method returns name of the encoding that is to be forced. * If the encoding has never been forced, it returns a null pointer. * - * <p><b>"Experimental - subject to change"</b></p> - * * @return The forced encoding, or null if none was supplied. * @see #setEncoding * @since DOM Level 3 @@ -97,8 +100,6 @@ public: /** * Get the system identifier for this input source. * - * <p><b>"Experimental - subject to change"</b></p> - * * <p>If the system ID is a URL, it will be fully resolved.</p> * * @return The system identifier. @@ -110,6 +111,13 @@ public: // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- + /** + * Sets the byte stream for this input source. + * + * @see BinInputStream + */ + virtual void setByteStream(XMLFormatTarget* stream) = 0; + /** * Set the encoding which will be required for use with the XML text read * via a stream opened by this input source. @@ -119,8 +127,6 @@ public: * to be incorrect because of intermediate transcoding, for instance * encapsulation within a MIME document. * - * <p><b>"Experimental - subject to change"</b></p> - * * @param encodingStr The name of the encoding to force. * @since DOM Level 3 */ @@ -135,8 +141,6 @@ public: * * <p>If the system ID is a URL, it must be fully resolved.</p> * - * <p><b>"Experimental - subject to change"</b></p> - * * @param systemId The system identifier as a string. * @see #getSystemId * @since DOM Level 3 @@ -149,21 +153,6 @@ public: // ----------------------------------------------------------------------- /** @name Non-standard Extension */ //@{ - - /** - * Makes the byte stream for this input source. - * - * <p>The derived class must create and return a binary input stream of an - * appropriate type for its kind of data source. The returned stream must - * be dynamically allocated and becomes the parser's property. - * </p> - * - * <p><b>"Experimental - subject to change"</b></p> - * - * @see BinInputStream - */ - virtual BinInputStream* makeStream() const = 0; - /** * Called to indicate that this DOMLSOutput is no longer in use * and that the implementation may relinquish any resources associated with it. diff --git a/src/xercesc/dom/DOMLSParser.hpp b/src/xercesc/dom/DOMLSParser.hpp index 337ecd764a194bac0ad5c61b4ab142428260d536..ce625ec59f0e8eea6e769c28dff31e234a1073ba 100644 --- a/src/xercesc/dom/DOMLSParser.hpp +++ b/src/xercesc/dom/DOMLSParser.hpp @@ -451,7 +451,7 @@ public: * @see resetDocumentPool * @since DOM Level 3 */ - virtual DOMDocument* parse(const DOMLSInput& source) = 0; + virtual DOMDocument* parse(const DOMLSInput* source) = 0; /** * Parse an XML document from a location identified by a URI reference [IETF RFC 2396]. @@ -578,7 +578,7 @@ public: */ virtual void parseWithContext ( - const DOMLSInput& source + const DOMLSInput* source , DOMNode* contextNode , const unsigned short action ) = 0; @@ -641,8 +641,6 @@ public: * is enabled, the parser will cache the grammars for re-use. If a grammar * key is found in the pool, no caching of any grammar will take place. * - * <p><b>"Experimental - subject to change"</b></p> - * * @param source A const reference to the DOMLSInput object which * points to the schema grammar file to be preparsed. * @param grammarType The grammar type (Schema or DTD). @@ -659,7 +657,7 @@ public: * * @see DOMLSInput#DOMLSInput */ - virtual Grammar* loadGrammar(const DOMLSInput& source, + virtual Grammar* loadGrammar(const DOMLSInput* source, const short grammarType, const bool toCache = false) = 0; @@ -671,8 +669,6 @@ public: * enabled, the parser will cache the grammars for re-use. If a grammar * key is found in the pool, no caching of any grammar will take place. * - * <p><b>"Experimental - subject to change"</b></p> - * * @param systemId A const XMLCh pointer to the Unicode string which * contains the path to the XML grammar file to be * preparsed. @@ -700,8 +696,6 @@ public: * enabled, the parser will cache the grammars for re-use. If a grammar * key is found in the pool, no caching of any grammar will take place. * - * <p><b>"Experimental - subject to change"</b></p> - * * @param systemId A const char pointer to a native string which contains * the path to the XML grammar file to be preparsed. * @param grammarType The grammar type (Schema or DTD). diff --git a/src/xercesc/dom/DOMLSResourceResolver.hpp b/src/xercesc/dom/DOMLSResourceResolver.hpp index 177286b897f41238e219fcfd0942c653fb8ee45d..74738063f833cf5eb550e1c4bdad66175736abfe 100644 --- a/src/xercesc/dom/DOMLSResourceResolver.hpp +++ b/src/xercesc/dom/DOMLSResourceResolver.hpp @@ -128,14 +128,11 @@ public: * @see DOMLSInput#DOMLSInput * @since DOM Level 3 */ - virtual DOMLSInput* resolveResource - ( - const XMLCh* const resourceType - , const XMLCh* const namespaceUri - , const XMLCh* const publicId - , const XMLCh* const systemId - , const XMLCh* const baseURI - ) = 0; + virtual DOMLSInput* resolveResource( const XMLCh* const resourceType + , const XMLCh* const namespaceUri + , const XMLCh* const publicId + , const XMLCh* const systemId + , const XMLCh* const baseURI) = 0; //@} diff --git a/src/xercesc/dom/DOMLSSerializer.hpp b/src/xercesc/dom/DOMLSSerializer.hpp index 325a7c7733ec6dc251e20612c96edfad87ae1845..2f4088afd278b6b8cded779c516cc8ec55fe5283 100644 --- a/src/xercesc/dom/DOMLSSerializer.hpp +++ b/src/xercesc/dom/DOMLSSerializer.hpp @@ -245,11 +245,13 @@ #include <xercesc/dom/DOMLSSerializerFilter.hpp> #include <xercesc/dom/DOMErrorHandler.hpp> #include <xercesc/dom/DOMConfiguration.hpp> -#include <xercesc/framework/XMLFormatter.hpp> XERCES_CPP_NAMESPACE_BEGIN -class CDOM_EXPORT DOMLSSerializer { +class DOMLSOutput; + +class CDOM_EXPORT DOMLSSerializer +{ protected : // ----------------------------------------------------------------------- // Hidden constructors @@ -369,24 +371,6 @@ public: // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- - /** - * The character encoding in which the output will be written. - * <br> The encoding to use when writing is determined as follows: If the - * encoding attribute has been set, that value will be used.If the - * encoding attribute is <code>null</code> or empty, but the item to be - * written includes an encoding declaration, that value will be used.If - * neither of the above provides an encoding name, a default encoding of - * "UTF-8" will be used. - * <br>The default value is <code>null</code>. - * - * <p><b>"Experimental - subject to change"</b></p> - * - * @param encoding The character encoding in which the output will be written. - * @see getEncoding - * @since DOM Level 3 - */ - virtual void setEncoding(const XMLCh* const encoding) = 0; - /** * The end-of-line sequence of characters to be used in the XML being * written out. The only permitted values are these: @@ -430,23 +414,10 @@ public: // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- - /** - * Return the character encoding in which the output will be written. - * - * <p><b>"Experimental - subject to change"</b></p> - * - * @return The character encoding used. - * @see setEncoding - * @since DOM Level 3 - */ - virtual const XMLCh* getEncoding() const = 0; - /** * Return the end-of-line sequence of characters to be used in the XML being * written out. * - * <p><b>"Experimental - subject to change"</b></p> - * * @return The end-of-line sequence of characters to be used. * @see setNewLine * @since DOM Level 3 @@ -483,7 +454,7 @@ public: * @since DOM Level 3 */ virtual bool write(const DOMNode* nodeToWrite, - XMLFormatTarget* const destination) = 0; + DOMLSOutput* const destination) = 0; /** * Write out the specified node as described above in the description of diff --git a/src/xercesc/dom/impl/DOMImplementationImpl.cpp b/src/xercesc/dom/impl/DOMImplementationImpl.cpp index 254aba28674495c218ca9a03a47396bcfe548b9e..c9a27df3ff4c50cc9430fb71e6678d40195b78b9 100644 --- a/src/xercesc/dom/impl/DOMImplementationImpl.cpp +++ b/src/xercesc/dom/impl/DOMImplementationImpl.cpp @@ -22,6 +22,8 @@ #include "DOMDocumentImpl.hpp" #include "DOMDocumentTypeImpl.hpp" #include "DOMLSSerializerImpl.hpp" +#include "DOMLSInputImpl.hpp" +#include "DOMLSOutputImpl.hpp" #include "DOMImplementationListImpl.hpp" #include <xercesc/dom/DOMDocument.hpp> @@ -310,18 +312,14 @@ DOMLSSerializer* DOMImplementationImpl::createLSSerializer(MemoryManager* const return new (manager) DOMLSSerializerImpl(manager); } -DOMLSInput* DOMImplementationImpl::createLSInput() +DOMLSInput* DOMImplementationImpl::createLSInput(MemoryManager* const manager) { - throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0); - - return 0; + return new (manager) DOMLSInputImpl(manager); } -DOMLSOutput* DOMImplementationImpl::createLSOutput() +DOMLSOutput* DOMImplementationImpl::createLSOutput(MemoryManager* const manager) { - throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0); - - return 0; + return new (manager) DOMLSOutputImpl(manager); } // ------------------------------------------------------------ diff --git a/src/xercesc/dom/impl/DOMImplementationImpl.hpp b/src/xercesc/dom/impl/DOMImplementationImpl.hpp index a00229aac906d0ce8fccadc2ef968595b5741470..d75ed30d65542ac85b23829fd90fdbcec7bc89f7 100644 --- a/src/xercesc/dom/impl/DOMImplementationImpl.hpp +++ b/src/xercesc/dom/impl/DOMImplementationImpl.hpp @@ -81,8 +81,8 @@ public: MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager, XMLGrammarPool* const gramPool = 0); virtual DOMLSSerializer* createLSSerializer(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); - virtual DOMLSInput* createLSInput(); - virtual DOMLSOutput* createLSOutput(); + virtual DOMLSInput* createLSInput(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); + virtual DOMLSOutput* createLSOutput(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); // ------------------------------------------------------------ // DOMImplementationSource Virtual interface diff --git a/src/xercesc/dom/impl/DOMLSInputImpl.cpp b/src/xercesc/dom/impl/DOMLSInputImpl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e86b53950630468208bee693ca0b187dcf972475 --- /dev/null +++ b/src/xercesc/dom/impl/DOMLSInputImpl.cpp @@ -0,0 +1,93 @@ +/* + * Copyright 2002-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * $Id$ + */ + +#include "DOMLSInputImpl.hpp" + +#include <xercesc/util/XMLString.hpp> + +XERCES_CPP_NAMESPACE_BEGIN + +DOMLSInputImpl::DOMLSInputImpl(MemoryManager* const manager /*= XMLPlatformUtils::fgMemoryManager*/) +:fStringData(0) +,fByteStream(0) +,fEncoding(0) +,fPublicId(0) +,fSystemId(0) +,fBaseURI(0) +,fIssueFatalErrorIfNotFound(true) +,fMemoryManager(manager) +{ +} + +DOMLSInputImpl::~DOMLSInputImpl() +{ + fMemoryManager->deallocate(fEncoding); + fMemoryManager->deallocate(fPublicId); + fMemoryManager->deallocate(fSystemId); + fMemoryManager->deallocate(fBaseURI); +} + +void DOMLSInputImpl::setStringData(const XMLCh* data) +{ + fStringData=data; +} + +void DOMLSInputImpl::setByteStream(InputSource* stream) +{ + fByteStream=stream; +} + +void DOMLSInputImpl::setEncoding(const XMLCh* const encodingStr) +{ + fMemoryManager->deallocate(fEncoding); + fEncoding = XMLString::replicate(encodingStr, fMemoryManager); +} + +void DOMLSInputImpl::setPublicId(const XMLCh* const publicId) +{ + fMemoryManager->deallocate(fPublicId); + fPublicId = XMLString::replicate(publicId, fMemoryManager); +} + +void DOMLSInputImpl::setSystemId(const XMLCh* const systemId) +{ + fMemoryManager->deallocate(fSystemId); + fSystemId = XMLString::replicate(systemId, fMemoryManager); +} + +void DOMLSInputImpl::setBaseURI(const XMLCh* const baseURI) +{ + fMemoryManager->deallocate(fBaseURI); + fBaseURI = XMLString::replicate(baseURI, fMemoryManager); +} + +void DOMLSInputImpl::setIssueFatalErrorIfNotFound(bool flag) +{ + fIssueFatalErrorIfNotFound=flag; +} + +void DOMLSInputImpl::release() +{ + delete this; +} + + +XERCES_CPP_NAMESPACE_END + diff --git a/src/xercesc/dom/impl/DOMLSInputImpl.hpp b/src/xercesc/dom/impl/DOMLSInputImpl.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f31c1375be3d214833d5cb34031e1222c2aa7bde --- /dev/null +++ b/src/xercesc/dom/impl/DOMLSInputImpl.hpp @@ -0,0 +1,133 @@ +/* + * Copyright 2002,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * $Id$ + */ + + +#ifndef DOMLSInputImpl_HEADER_GUARD_ +#define DOMLSInputImpl_HEADER_GUARD_ + +#include <xercesc/dom/DOM.hpp> +#include <xercesc/dom/DOMLSInput.hpp> + +XERCES_CPP_NAMESPACE_BEGIN + +class CDOM_EXPORT DOMLSInputImpl : public XMemory, public DOMLSInput +{ + +public: + + DOMLSInputImpl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); + ~DOMLSInputImpl(); + + virtual const XMLCh* getStringData() const; + virtual InputSource* getByteStream() const; + virtual const XMLCh* getEncoding() const; + virtual const XMLCh* getPublicId() const; + virtual const XMLCh* getSystemId() const; + virtual const XMLCh* getBaseURI() const; + + virtual void setStringData(const XMLCh* data); + virtual void setByteStream(InputSource* stream); + virtual void setEncoding(const XMLCh* const encodingStr); + virtual void setPublicId(const XMLCh* const publicId); + virtual void setSystemId(const XMLCh* const systemId); + virtual void setBaseURI(const XMLCh* const baseURI); + + virtual void setIssueFatalErrorIfNotFound(bool flag); + virtual bool getIssueFatalErrorIfNotFound() const; + virtual void release(); + +private: + + /** unimplemented copy ctor and assignment operator */ + DOMLSInputImpl(const DOMLSInputImpl&); + DOMLSInputImpl & operator = (const DOMLSInputImpl&); + + // ----------------------------------------------------------------------- + // Private data members + // + // fStringData + // We don't own it + // + // fByteStream + // We don't own it + // + // fEncoding + // We own it + // + // fPublicId + // We own it + // + // fSystemId + // We own it + // + // fBaseURI + // We own it + // + // ----------------------------------------------------------------------- + + const XMLCh *fStringData; + InputSource *fByteStream; + XMLCh *fEncoding; + XMLCh *fPublicId; + XMLCh *fSystemId; + XMLCh *fBaseURI; + bool fIssueFatalErrorIfNotFound; + MemoryManager* fMemoryManager; +}; + +inline const XMLCh* DOMLSInputImpl::getStringData() const +{ + return fStringData; +} + +inline InputSource* DOMLSInputImpl::getByteStream() const +{ + return fByteStream; +} + +inline const XMLCh* DOMLSInputImpl::getEncoding() const +{ + return fEncoding; +} + +inline const XMLCh* DOMLSInputImpl::getPublicId() const +{ + return fPublicId; +} + +inline const XMLCh* DOMLSInputImpl::getSystemId() const +{ + return fSystemId; +} + +inline const XMLCh* DOMLSInputImpl::getBaseURI() const +{ + return fBaseURI; +} + +inline bool DOMLSInputImpl::getIssueFatalErrorIfNotFound() const +{ + return fIssueFatalErrorIfNotFound; +} + + +XERCES_CPP_NAMESPACE_END + +#endif diff --git a/src/xercesc/dom/impl/DOMLSOutputImpl.cpp b/src/xercesc/dom/impl/DOMLSOutputImpl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9f91d9a485284e604c5452d02a0546cbc806ad31 --- /dev/null +++ b/src/xercesc/dom/impl/DOMLSOutputImpl.cpp @@ -0,0 +1,65 @@ +/* + * Copyright 2002-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * $Id$ + */ + +#include "DOMLSOutputImpl.hpp" + +#include <xercesc/util/XMLString.hpp> + +XERCES_CPP_NAMESPACE_BEGIN + +DOMLSOutputImpl::DOMLSOutputImpl(MemoryManager* const manager /*= XMLPlatformUtils::fgMemoryManager*/) +:fByteStream(0) +,fEncoding(0) +,fSystemId(0) +,fMemoryManager(manager) +{ +} + +DOMLSOutputImpl::~DOMLSOutputImpl() +{ + fMemoryManager->deallocate(fEncoding); + fMemoryManager->deallocate(fSystemId); +} + +void DOMLSOutputImpl::setByteStream(XMLFormatTarget* stream) +{ + fByteStream=stream; +} + +void DOMLSOutputImpl::setEncoding(const XMLCh* const encodingStr) +{ + fMemoryManager->deallocate(fEncoding); + fEncoding = XMLString::replicate(encodingStr, fMemoryManager); +} + +void DOMLSOutputImpl::setSystemId(const XMLCh* const systemId) +{ + fMemoryManager->deallocate(fSystemId); + fSystemId = XMLString::replicate(systemId, fMemoryManager); +} + +void DOMLSOutputImpl::release() +{ + delete this; +} + + +XERCES_CPP_NAMESPACE_END + diff --git a/src/xercesc/dom/impl/DOMLSOutputImpl.hpp b/src/xercesc/dom/impl/DOMLSOutputImpl.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b6eb0f19a760823043bd4bee2ed025b3b41e887d --- /dev/null +++ b/src/xercesc/dom/impl/DOMLSOutputImpl.hpp @@ -0,0 +1,91 @@ +/* + * Copyright 2002,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * $Id$ + */ + + +#ifndef DOMLSOutputImpl_HEADER_GUARD_ +#define DOMLSOutputImpl_HEADER_GUARD_ + +#include <xercesc/dom/DOM.hpp> +#include <xercesc/dom/DOMLSOutput.hpp> + +XERCES_CPP_NAMESPACE_BEGIN + +class CDOM_EXPORT DOMLSOutputImpl : public XMemory, public DOMLSOutput +{ + +public: + + DOMLSOutputImpl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); + ~DOMLSOutputImpl(); + + virtual XMLFormatTarget* getByteStream() const; + virtual const XMLCh* getEncoding() const; + virtual const XMLCh* getSystemId() const; + + virtual void setByteStream(XMLFormatTarget* stream); + virtual void setEncoding(const XMLCh* const encodingStr); + virtual void setSystemId(const XMLCh* const systemId); + + virtual void release(); + +private: + + /** unimplemented copy ctor and assignment operator */ + DOMLSOutputImpl(const DOMLSOutputImpl&); + DOMLSOutputImpl & operator = (const DOMLSOutputImpl&); + + // ----------------------------------------------------------------------- + // Private data members + // + // fByteStream + // We don't own it + // + // fEncoding + // We own it + // + // fSystemId + // We own it + // + // ----------------------------------------------------------------------- + + XMLFormatTarget *fByteStream; + XMLCh *fEncoding; + XMLCh *fSystemId; + MemoryManager* fMemoryManager; +}; + +inline XMLFormatTarget* DOMLSOutputImpl::getByteStream() const +{ + return fByteStream; +} + +inline const XMLCh* DOMLSOutputImpl::getEncoding() const +{ + return fEncoding; +} + +inline const XMLCh* DOMLSOutputImpl::getSystemId() const +{ + return fSystemId; +} + +XERCES_CPP_NAMESPACE_END + +#endif diff --git a/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp b/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp index e58e3995baf9d75063dce13ce2f715e926963a8e..1f2120171b402e505876c7ed5f7e05e26775904e 100644 --- a/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp +++ b/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp @@ -19,6 +19,7 @@ */ #include "DOMLSSerializerImpl.hpp" +#include "DOMLSOutputImpl.hpp" #include "DOMErrorImpl.hpp" #include "DOMLocatorImpl.hpp" #include "DOMImplementationImpl.hpp" @@ -286,7 +287,6 @@ catch(TranscodingException const &e) \ DOMLSSerializerImpl::~DOMLSSerializerImpl() { - fMemoryManager->deallocate(fEncoding);//delete [] fEncoding; fMemoryManager->deallocate(fNewLine);//delete [] fNewLine; delete fNamespaceStack; delete fSupportedParameters; @@ -295,7 +295,6 @@ DOMLSSerializerImpl::~DOMLSSerializerImpl() DOMLSSerializerImpl::DOMLSSerializerImpl(MemoryManager* const manager) :fFeatures(0) -,fEncoding(0) ,fNewLine(0) ,fErrorHandler(0) ,fFilter(0) @@ -429,18 +428,6 @@ const DOMStringList* DOMLSSerializerImpl::getParameterNames() const return fSupportedParameters; } -// we don't check the validity of the encoding set -void DOMLSSerializerImpl::setEncoding(const XMLCh* const encoding) -{ - fMemoryManager->deallocate(fEncoding);//delete [] fEncoding; - fEncoding = XMLString::replicate(encoding, fMemoryManager); -} - -const XMLCh* DOMLSSerializerImpl::getEncoding() const -{ - return fEncoding; -} - void DOMLSSerializerImpl::setNewLine(const XMLCh* const newLine) { fMemoryManager->deallocate(fNewLine);//delete [] fNewLine; @@ -465,20 +452,97 @@ DOMLSSerializerFilter* DOMLSSerializerImpl::getFilter() const // // // -bool DOMLSSerializerImpl::write(const DOMNode* nodeToWrite, - XMLFormatTarget* const destination) +bool DOMLSSerializerImpl::write(const DOMNode* nodeToWrite, + DOMLSOutput* const destination) { - //init session vars - initSession(nodeToWrite); + XMLFormatTarget* pTarget=destination->getByteStream(); + Janitor<XMLFormatTarget> janTarget(0); + if(!pTarget) + { + const XMLCh* szSystemId=destination->getSystemId(); + if(!szSystemId) + { + //TODO: report error "missing target" + return false; + } + pTarget=new LocalFileFormatTarget(szSystemId, fMemoryManager); + janTarget.reset(pTarget); + } + /** + * When writing to a LSOutput, the encoding is found by looking at the encoding information + * that is reachable through the LSOutput and the item to be written (or its owner document) in this order: + * + * 1. LSOutput.encoding, + * 2. Document.inputEncoding, + * 3. Document.xmlEncoding. + * + * If no encoding is reachable through the above properties, a default encoding of "UTF-8" will be used. + * If the specified encoding is not supported an "unsupported-encoding" fatal error is raised. + */ + fEncodingUsed = gUTF8; + + const DOMDocument *docu = (nodeToWrite->getNodeType() == DOMNode::DOCUMENT_NODE)? + (const DOMDocument*)nodeToWrite : nodeToWrite->getOwnerDocument(); + + const XMLCh* lsEncoding=destination->getEncoding(); + if (lsEncoding && *lsEncoding) + { + fEncodingUsed = lsEncoding; + } + else if (docu) + { + const XMLCh* tmpEncoding = docu->getInputEncoding(); + + if ( tmpEncoding && *tmpEncoding) + { + fEncodingUsed = tmpEncoding; + } + else + { + tmpEncoding = docu->getXmlEncoding(); + + if ( tmpEncoding && *tmpEncoding) + { + fEncodingUsed = tmpEncoding; + } + } + } + + + /** + * The end-of-line sequence of characters to be used in the XML being + * written out. The only permitted values are these: + * . null + * + * Use a default end-of-line sequence. DOM implementations should choose + * the default to match the usual convention for text files in the + * environment being used. Implementations must choose a default + * sequence that matches one of those allowed by 2.11 "End-of-Line + * Handling". + * + * CR The carriage-return character (#xD) + * CR-LF The carriage-return and line-feed characters (#xD #xA) + * LF The line-feed character (#xA) + * + * The default value for this attribute is null + */ + fNewLineUsed = (fNewLine && *fNewLine)? fNewLine : gEOLSeq; + + /** + * get Document Version + */ + fDocumentVersion = docu?docu->getXmlVersion():XMLUni::fgVersion1_0; + + fErrorCount = 0; try { - fFormatter = new (fMemoryManager) XMLFormatter(fEncodingUsed - ,fDocumentVersion - ,destination - ,XMLFormatter::NoEscapes - ,XMLFormatter::UnRep_CharRef - ,fMemoryManager); + fFormatter = new (fMemoryManager) XMLFormatter( fEncodingUsed + ,fDocumentVersion + ,pTarget + ,XMLFormatter::NoEscapes + ,XMLFormatter::UnRep_CharRef + ,fMemoryManager); } catch (const TranscodingException& e) { @@ -490,7 +554,7 @@ bool DOMLSSerializerImpl::write(const DOMNode* nodeToWrite, { Janitor<XMLFormatter> janName(fFormatter); processNode(nodeToWrite); - destination->flush(); + pTarget->flush(); } // @@ -502,13 +566,13 @@ bool DOMLSSerializerImpl::write(const DOMNode* nodeToWrite, // catch (const TranscodingException&) { - destination->flush(); + pTarget->flush(); return false; } catch (const XMLDOMMsg::Codes) { - destination->flush(); + pTarget->flush(); return false; } catch(const OutOfMemoryException&) @@ -517,7 +581,7 @@ bool DOMLSSerializerImpl::write(const DOMNode* nodeToWrite, } catch (...) { - destination->flush(); + pTarget->flush(); throw; } @@ -531,8 +595,9 @@ bool DOMLSSerializerImpl::write(const DOMNode* nodeToWrite, bool DOMLSSerializerImpl::writeToURI(const DOMNode* nodeToWrite, const XMLCh* uri) { - LocalFileFormatTarget target(uri); - return write(nodeToWrite, &target); + DOMLSOutputImpl output(fMemoryManager); + output.setSystemId(uri); + return write(nodeToWrite, &output); } // @@ -544,15 +609,14 @@ XMLCh* DOMLSSerializerImpl::writeToString(const DOMNode* nodeToWrite) MemBufFormatTarget destination(1023, fMemoryManager); bool retVal; - // XMLCh is unicode, assume fEncoding as UTF-16 - XMLCh* tempEncoding = fEncoding; - fEncoding = (XMLCh*) XMLUni::fgUTF16EncodingString; - bool bBOMFlag=getFeature(BYTE_ORDER_MARK_ID); setFeature(BYTE_ORDER_MARK_ID, false); try { - retVal = write(nodeToWrite, &destination); + DOMLSOutputImpl output(fMemoryManager); + output.setByteStream(&destination); + output.setEncoding(XMLUni::fgUTF16EncodingString); + retVal = write(nodeToWrite, &output); } catch(const OutOfMemoryException&) { @@ -564,92 +628,14 @@ XMLCh* DOMLSSerializerImpl::writeToString(const DOMNode* nodeToWrite) // there is a possibility that memory allocation // exception thrown in XMLBuffer class // - fEncoding = tempEncoding; setFeature(BYTE_ORDER_MARK_ID, bBOMFlag); return 0; } - fEncoding = tempEncoding; setFeature(BYTE_ORDER_MARK_ID, bBOMFlag); return (retVal ? XMLString::replicate((XMLCh*) destination.getRawBuffer(), fMemoryManager) : 0); } -void DOMLSSerializerImpl::initSession(const DOMNode* const nodeToWrite) -{ - -/** - * When writing to a LSOutput, the encoding is found by looking at the encoding information - * that is reachable through the LSOutput and the item to be written (or its owner document) in this order: - * - * 1. LSOutput.encoding, - * 2. Document.inputEncoding, - * 3. Document.xmlEncoding. - * - * If no encoding is reachable through the above properties, a default encoding of "UTF-8" will be used. - * If the specified encoding is not supported an "unsupported-encoding" fatal error is raised. - */ - fEncodingUsed = gUTF8; - - if (fEncoding && *fEncoding) - { - fEncodingUsed = fEncoding; - } - else - { - const DOMDocument *docu = (nodeToWrite->getNodeType() == DOMNode::DOCUMENT_NODE)? - (const DOMDocument*)nodeToWrite : nodeToWrite->getOwnerDocument(); - if (docu) - { - const XMLCh* tmpEncoding = docu->getInputEncoding(); - - if ( tmpEncoding && *tmpEncoding) - { - fEncodingUsed = tmpEncoding; - } - else - { - tmpEncoding = docu->getXmlEncoding(); - - if ( tmpEncoding && *tmpEncoding) - { - fEncodingUsed = tmpEncoding; - } - } - } - } - - /** - * The end-of-line sequence of characters to be used in the XML being - * written out. The only permitted values are these: - * . null - * - * Use a default end-of-line sequence. DOM implementations should choose - * the default to match the usual convention for text files in the - * environment being used. Implementations must choose a default - * sequence that matches one of those allowed by 2.11 "End-of-Line - * Handling". - * - * CR The carriage-return character (#xD) - * CR-LF The carriage-return and line-feed characters (#xD #xA) - * LF The line-feed character (#xA) - * - * The default value for this attribute is null - */ - fNewLineUsed = (fNewLine && *fNewLine)? fNewLine : gEOLSeq; - - /** - * get Document Version - */ - const DOMDocument *docu = (nodeToWrite->getNodeType() == DOMNode::DOCUMENT_NODE)? - (const DOMDocument*)nodeToWrite : nodeToWrite->getOwnerDocument(); - if (docu) - { - fDocumentVersion = docu->getXmlVersion(); - } - - fErrorCount = 0; -} - // // Characters not representable in output encoding, // @@ -787,7 +773,7 @@ void DOMLSSerializerImpl::processNode(const DOMNode* const nodeToWrite, int leve // if (getFeature(XML_DECLARATION)) { - // use the version and encoding resolved in initSession() + // use the version and encoding resolved *fFormatter << gXMLDecl_VersionInfo << fDocumentVersion << gXMLDecl_separator; *fFormatter << gXMLDecl_EncodingDecl << fEncodingUsed << gXMLDecl_separator; @@ -1704,42 +1690,42 @@ void DOMLSSerializerImpl::processBOM() if (!getFeature(BYTE_ORDER_MARK_ID)) return; - if ((XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16LEncodingString) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16LEncodingString2) == 0) ) + if ((XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16LEncodingString) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16LEncodingString2) == 0) ) { fFormatter->writeBOM(BOM_utf16le, 2); } - else if ((XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16BEncodingString) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16BEncodingString2) == 0) ) + else if ((XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16BEncodingString) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16BEncodingString2) == 0) ) { fFormatter->writeBOM(BOM_utf16be, 2); } - else if ((XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16EncodingString) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16EncodingString2) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16EncodingString3) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16EncodingString4) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16EncodingString5) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16EncodingString6) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16EncodingString7) == 0) ) + else if ((XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16EncodingString) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16EncodingString2) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16EncodingString3) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16EncodingString4) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16EncodingString5) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16EncodingString6) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUTF16EncodingString7) == 0) ) { if (XMLPlatformUtils::fgXMLChBigEndian) fFormatter->writeBOM(BOM_utf16be, 2); else fFormatter->writeBOM(BOM_utf16le, 2); } - else if ((XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4LEncodingString) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4LEncodingString2) == 0) ) + else if ((XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUCS4LEncodingString) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUCS4LEncodingString2) == 0) ) { fFormatter->writeBOM(BOM_ucs4le, 4); } - else if ((XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4BEncodingString) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4BEncodingString2) == 0) ) + else if ((XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUCS4BEncodingString) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUCS4BEncodingString2) == 0) ) { fFormatter->writeBOM(BOM_ucs4be, 4); } - else if ((XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4EncodingString) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4EncodingString2) == 0) || - (XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4EncodingString3) == 0) ) + else if ((XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUCS4EncodingString) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUCS4EncodingString2) == 0) || + (XMLString::compareIStringASCII(fEncodingUsed, XMLUni::fgUCS4EncodingString3) == 0) ) { if (XMLPlatformUtils::fgXMLChBigEndian) fFormatter->writeBOM(BOM_ucs4be, 4); diff --git a/src/xercesc/dom/impl/DOMLSSerializerImpl.hpp b/src/xercesc/dom/impl/DOMLSSerializerImpl.hpp index d0192b76d200823de7a04a18df12725a0ce04354..82745d3aabb73a91d1a1573064b752f0a6ae1429 100644 --- a/src/xercesc/dom/impl/DOMLSSerializerImpl.hpp +++ b/src/xercesc/dom/impl/DOMLSSerializerImpl.hpp @@ -27,6 +27,7 @@ #include <xercesc/util/XMLDOMMsg.hpp> #include <xercesc/util/RefHashTableOf.hpp> #include <xercesc/util/RefVectorOf.hpp> +#include <xercesc/framework/XMLFormatter.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -58,19 +59,16 @@ public: virtual DOMConfiguration* getDomConfig(); - virtual void setEncoding(const XMLCh* const encoding); - virtual const XMLCh* getEncoding() const; - virtual void setNewLine(const XMLCh* const newLine); virtual const XMLCh* getNewLine() const; virtual void setFilter(DOMLSSerializerFilter *filter); virtual DOMLSSerializerFilter* getFilter() const; - virtual bool write(const DOMNode* nodeToWrite, - XMLFormatTarget* const destination); - virtual bool writeToURI(const DOMNode* nodeToWrite, - const XMLCh* uri); + virtual bool write(const DOMNode* nodeToWrite, + DOMLSOutput* const destination); + virtual bool writeToURI(const DOMNode* nodeToWrite, + const XMLCh* uri); /** * The caller is responsible for the release of the returned string */ @@ -96,7 +94,6 @@ private: DOMLSSerializerImpl & operator = (const DOMLSSerializerImpl&); /** helper **/ - void initSession(const DOMNode* const); void processNode(const DOMNode* const); void procCdataSection(const XMLCh* const nodeValue @@ -149,9 +146,6 @@ protected: // // fFeatures // - // fEncoding - // own it - // // fNewLine // own it // @@ -192,7 +186,6 @@ protected: // ----------------------------------------------------------------------- int fFeatures; - XMLCh *fEncoding; XMLCh *fNewLine; DOMErrorHandler *fErrorHandler; DOMLSSerializerFilter *fFilter; diff --git a/src/xercesc/framework/Wrapper4DOMLSInput.cpp b/src/xercesc/framework/Wrapper4DOMLSInput.cpp index 3353ca817242e8b2fa622d8ba4c6536c5d9e0a80..9135a622b157ae7991037bede31fbc95503cd16e 100644 --- a/src/xercesc/framework/Wrapper4DOMLSInput.cpp +++ b/src/xercesc/framework/Wrapper4DOMLSInput.cpp @@ -24,7 +24,12 @@ // --------------------------------------------------------------------------- #include <xercesc/framework/Wrapper4DOMLSInput.hpp> #include <xercesc/dom/DOMLSInput.hpp> +#include <xercesc/dom/DOMLSResourceResolver.hpp> #include <xercesc/util/NullPointerException.hpp> +#include <xercesc/util/XMLString.hpp> +#include <xercesc/framework/MemBufInputSource.hpp> +#include <xercesc/framework/LocalFileInputSource.hpp> +#include <xercesc/framework/URLInputSource.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -32,11 +37,14 @@ XERCES_CPP_NAMESPACE_BEGIN // Wrapper4DOMLSInput: Constructor and Destructor // --------------------------------------------------------------------------- Wrapper4DOMLSInput::Wrapper4DOMLSInput(DOMLSInput* const inputSource, - const bool adoptFlag, - MemoryManager* const manager) : + DOMLSResourceResolver* entityResolver, + const bool adoptFlag, + MemoryManager* const manager) : InputSource(manager) , fAdoptInputSource(adoptFlag) - , fInputSource(inputSource) + , fForceXMLChEncoding(false) + , fInputSource(inputSource) + , fEntityResolver(entityResolver) { if (!inputSource) ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero, getMemoryManager()); @@ -59,6 +67,8 @@ bool Wrapper4DOMLSInput::getIssueFatalErrorIfNotFound() const const XMLCh* Wrapper4DOMLSInput::getEncoding() const { + if(fForceXMLChEncoding) + return XMLUni::fgXMLChEncodingString; return fInputSource->getEncoding(); } @@ -105,7 +115,44 @@ void Wrapper4DOMLSInput::setSystemId(const XMLCh* const systemId) // --------------------------------------------------------------------------- BinInputStream* Wrapper4DOMLSInput::makeStream() const { - return fInputSource->getByteStream(); + // The LSParser will use the LSInput object to determine how to read data. The LSParser will look at the different inputs specified in the + // LSInput in the following order to know which one to read from, the first one that is not null and not an empty string will be used: + // 1. LSInput.characterStream + // 2. LSInput.byteStream + // 3. LSInput.stringData + // 4. LSInput.systemId + // 5. LSInput.publicId + InputSource* binStream=fInputSource->getByteStream(); + if(binStream) + return binStream->makeStream(); + const XMLCh* xmlString=fInputSource->getStringData(); + if(xmlString) + { + MemBufInputSource is((const XMLByte*)xmlString, XMLString::stringLen(xmlString)*sizeof(XMLCh), "", false, getMemoryManager()); + is.setCopyBufToStream(false); + return is.makeStream(); + } + const XMLCh* szSystemId=fInputSource->getSystemId(); + if(szSystemId) + { + XMLURL urlTmp(getMemoryManager()); + if (urlTmp.setURL(szSystemId, fInputSource->getBaseURI(), urlTmp) && !urlTmp.isRelative()) + { + URLInputSource src(urlTmp, getMemoryManager()); + return src.makeStream(); + } + LocalFileInputSource src(szSystemId, getMemoryManager()); + return src.makeStream(); + } + const XMLCh* szPublicId=fInputSource->getPublicId(); + if(szPublicId && fEntityResolver) + { + DOMLSInput* is = fEntityResolver->resolveResource(XMLUni::fgDOMDTDType, 0, szPublicId, 0, fInputSource->getBaseURI()); + if (is) + return Wrapper4DOMLSInput(is, fEntityResolver, true, getMemoryManager()).makeStream(); + } + + return 0; } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/framework/Wrapper4DOMLSInput.hpp b/src/xercesc/framework/Wrapper4DOMLSInput.hpp index 68fc459a25aafdaf51b8215a5480d5c351018e35..cae9f740086d9a7a223c9d0ce103346391981670 100644 --- a/src/xercesc/framework/Wrapper4DOMLSInput.hpp +++ b/src/xercesc/framework/Wrapper4DOMLSInput.hpp @@ -27,7 +27,7 @@ XERCES_CPP_NAMESPACE_BEGIN class DOMLSInput; - +class DOMLSResourceResolver; /** * Wrap a DOMLSInput object to a SAX InputSource. @@ -53,6 +53,7 @@ public: Wrapper4DOMLSInput ( DOMLSInput* const inputSource + , DOMLSResourceResolver* entityResolver = 0 , const bool adoptFlag = true , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); @@ -216,8 +217,10 @@ private: // ----------------------------------------------------------------------- // Private data members // ----------------------------------------------------------------------- - bool fAdoptInputSource; - DOMLSInput* fInputSource; + bool fAdoptInputSource, + fForceXMLChEncoding; + DOMLSInput* fInputSource; + DOMLSResourceResolver* fEntityResolver; }; XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/framework/Wrapper4InputSource.cpp b/src/xercesc/framework/Wrapper4InputSource.cpp index 9a0302aef7bc2da84d7a86d45cd66e6ab015b5a1..ff06e169fa715ec9b82b78732aa90591a57a0995 100644 --- a/src/xercesc/framework/Wrapper4InputSource.cpp +++ b/src/xercesc/framework/Wrapper4InputSource.cpp @@ -75,7 +75,7 @@ const XMLCh* Wrapper4InputSource::getPublicId() const // --------------------------------------------------------------------------- // Wrapper4InputSource: Setter methods // --------------------------------------------------------------------------- -void Wrapper4InputSource::setIssueFatalErrorIfNotFound(const bool flag) +void Wrapper4InputSource::setIssueFatalErrorIfNotFound(bool flag) { fInputSource->setIssueFatalErrorIfNotFound(flag); } @@ -102,9 +102,9 @@ void Wrapper4InputSource::setSystemId(const XMLCh* const systemId) // --------------------------------------------------------------------------- // Wrapper4InputSource: Stream methods // --------------------------------------------------------------------------- -BinInputStream* Wrapper4InputSource::getByteStream() const +InputSource* Wrapper4InputSource::getByteStream() const { - return fInputSource->makeStream(); + return fInputSource; } // --------------------------------------------------------------------------- diff --git a/src/xercesc/framework/Wrapper4InputSource.hpp b/src/xercesc/framework/Wrapper4InputSource.hpp index 7c0498ba8d40ace4dd1eda089f9a8427deeedfce..9cabed65591f8f91dd73b575941e0b75f862e6dc 100644 --- a/src/xercesc/framework/Wrapper4InputSource.hpp +++ b/src/xercesc/framework/Wrapper4InputSource.hpp @@ -42,7 +42,7 @@ public: /** * Constructor * - * Wrap a SAX InputSource and pretend it to be a DOMInputSource. + * Wrap a SAX InputSource and pretend it to be a DOMLSInput. * By default, the wrapper will adopt the SAX InputSource that is wrapped. * * @param inputSource The SAX InputSource to be wrapped @@ -65,24 +65,27 @@ public: // ----------------------------------------------------------------------- /** @name Virtual input source interface */ //@{ + /** + * This wrapper doesn't support character streams + * + */ + virtual const XMLCh* getCharacterStream() const; + /** * Makes the byte stream for this input source. * * <p>The function will call the makeStream of the wrapped input source. * The returned stream becomes the parser's property.</p> * - * @see BinInputStream + * @see InputSource */ - BinInputStream* getByteStream() const; - + virtual InputSource* getByteStream() const; //@} // ----------------------------------------------------------------------- /** @name Getter methods */ //@{ /** - * <p><b>"Experimental - subject to change"</b></p> - * * An input source can be set to force the parser to assume a particular * encoding for the data that input source reprsents, via the setEncoding() * method. This method will delegate to the wrapped input source to return @@ -92,12 +95,10 @@ public: * @return The forced encoding, or null if none was supplied. * @see #setEncoding */ - const XMLCh* getEncoding() const; + virtual const XMLCh* getEncoding() const; /** - * <p><b>"Experimental - subject to change"</b></p> - * * Get the public identifier for this input source. Delegated to the * wrapped input source object. * @@ -108,8 +109,6 @@ public: /** - * <p><b>"Experimental - subject to change"</b></p> - * * Get the system identifier for this input source. Delegated to the * wrapped input source object. * @@ -121,22 +120,18 @@ public: const XMLCh* getSystemId() const; /** - * Get the base URI to be used for resolving relative URIs to absolute - * URIs. If the baseURI is itself a relative URI, the behavior is - * implementation dependent. Delegated to the wrapped intput source - * object. - * - * <p><b>"Experimental - subject to change"</b></p> - * - * @return The base URI. - * @see #setBaseURI - * @since DOM Level 3 - */ + * Get the base URI to be used for resolving relative URIs to absolute + * URIs. If the baseURI is itself a relative URI, the behavior is + * implementation dependent. Delegated to the wrapped intput source + * object. + * + * @return The base URI. + * @see #setBaseURI + * @since DOM Level 3 + */ const XMLCh* getBaseURI() const; - /** - * <p><b>"Experimental - subject to change"</b></p> - * + /** * Get the flag that indicates if the parser should issue fatal error if this input source * is not found. Delegated to the wrapped input source object. * @@ -154,8 +149,6 @@ public: //@{ /** - * <p><b>"Experimental - subject to change"</b></p> - * * Set the encoding which will be required for use with the XML text read * via a stream opened by this input source. This will update the wrapped * input source object. @@ -171,8 +164,6 @@ public: /** - * <p><b>"Experimental - subject to change"</b></p> - * * Set the public identifier for this input source. This will update the * wrapped input source object. * @@ -187,8 +178,6 @@ public: void setPublicId(const XMLCh* const publicId); /** - * <p><b>"Experimental - subject to change"</b></p> - * * Set the system identifier for this input source. This will update the * wrapped input source object. * @@ -211,8 +200,6 @@ public: * implementation dependent. This will update the wrapped input source * object. * - * <p><b>"Experimental - subject to change"</b></p> - * * @param baseURI The base URI. * @see #getBaseURI * @since DOM Level 3 @@ -220,8 +207,6 @@ public: void setBaseURI(const XMLCh* const baseURI); /** - * <p><b>"Experimental - subject to change"</b></p> - * * Indicates if the parser should issue fatal error if this input source * is not found. If set to false, the parser issue warning message * instead. This will update the wrapped input source object. @@ -233,7 +218,7 @@ public: * * @see #getIssueFatalErrorIfNotFound */ - void setIssueFatalErrorIfNotFound(const bool flag); + void setIssueFatalErrorIfNotFound(bool flag); /** * Called to indicate that this DOMInputSource is no longer in use @@ -269,6 +254,11 @@ inline const XMLCh* Wrapper4InputSource::getBaseURI() const return 0; // REVISIT - should we return an empty string? } +inline const XMLCh* Wrapper4InputSource::getCharacterStream() const +{ + return 0; +} + // --------------------------------------------------------------------------- // Wrapper4InputSource: Setter methods // --------------------------------------------------------------------------- diff --git a/src/xercesc/parsers/DOMLSParserImpl.cpp b/src/xercesc/parsers/DOMLSParserImpl.cpp index b5cf9778f2f3948c2d94d9c35aba3677fbf47a9e..5c99df82a0a9126924ce71abe2ffede65f043f97 100644 --- a/src/xercesc/parsers/DOMLSParserImpl.cpp +++ b/src/xercesc/parsers/DOMLSParserImpl.cpp @@ -156,9 +156,9 @@ bool DOMLSParserImpl::getBusy() const // --------------------------------------------------------------------------- // DOMLSParserImpl: Setter methods // --------------------------------------------------------------------------- -void DOMLSParserImpl::setFilter(DOMLSParserFilter* const) +void DOMLSParserImpl::setFilter(DOMLSParserFilter* const filter) { - throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, getMemoryManager()); + fFilter = filter; } // --------------------------------------------------------------------------- @@ -690,13 +690,13 @@ void DOMLSParserImpl::resetDocumentPool() // --------------------------------------------------------------------------- // DOMLSParserImpl: Parsing methods // --------------------------------------------------------------------------- -DOMDocument* DOMLSParserImpl::parse(const DOMLSInput& source) +DOMDocument* DOMLSParserImpl::parse(const DOMLSInput* source) { // remove the abort filter, if present if(fFilter==&g_AbortFilter) fFilter=0; - Wrapper4DOMLSInput isWrapper((DOMLSInput*) &source, false, getMemoryManager()); + Wrapper4DOMLSInput isWrapper((DOMLSInput*)source, fEntityResolver, false, getMemoryManager()); AbstractDOMParser::parse(isWrapper); if (fUserAdoptsDocument) @@ -731,7 +731,7 @@ DOMDocument* DOMLSParserImpl::parseURI(const char* const systemId) return getDocument(); } -void DOMLSParserImpl::parseWithContext(const DOMLSInput&, +void DOMLSParserImpl::parseWithContext(const DOMLSInput*, DOMNode* , const unsigned short) { @@ -805,7 +805,7 @@ DOMLSParserImpl::resolveEntity( XMLResourceIdentifier* resourceIdentifier ) resourceIdentifier->getSystemId(), resourceIdentifier->getBaseURI()); if (is) - return new (getMemoryManager()) Wrapper4DOMLSInput(is, true, getMemoryManager()); + return new (getMemoryManager()) Wrapper4DOMLSInput(is, fEntityResolver, true, getMemoryManager()); } if (fXMLEntityResolver) { return(fXMLEntityResolver->resolveEntity(resourceIdentifier)); @@ -887,7 +887,7 @@ Grammar* DOMLSParserImpl::loadGrammar(const XMLCh* const systemId, return grammar; } -Grammar* DOMLSParserImpl::loadGrammar(const DOMLSInput& source, +Grammar* DOMLSParserImpl::loadGrammar(const DOMLSInput* source, const short grammarType, const bool toCache) { @@ -901,7 +901,7 @@ Grammar* DOMLSParserImpl::loadGrammar(const DOMLSInput& source, try { - Wrapper4DOMLSInput isWrapper((DOMLSInput*) &source, false, getMemoryManager()); + Wrapper4DOMLSInput isWrapper((DOMLSInput*)source, fEntityResolver, false, getMemoryManager()); setParseInProgress(true); if (grammarType == Grammar::DTDGrammarType) diff --git a/src/xercesc/parsers/DOMLSParserImpl.hpp b/src/xercesc/parsers/DOMLSParserImpl.hpp index fde12929d98cbdfe5e3ec515fa81988c3ee2cce2..8dbffebe31edb175bcde6c30071a3b0dfbe6e172 100644 --- a/src/xercesc/parsers/DOMLSParserImpl.hpp +++ b/src/xercesc/parsers/DOMLSParserImpl.hpp @@ -140,7 +140,7 @@ public : /** * @see DOMLSParser#parse */ - virtual DOMDocument* parse(const DOMLSInput& source); + virtual DOMDocument* parse(const DOMLSInput* source); /** * @see DOMLSParser#parseURI @@ -157,7 +157,7 @@ public : */ virtual void parseWithContext ( - const DOMLSInput& source + const DOMLSInput* source , DOMNode* contextNode , const unsigned short action ); @@ -231,7 +231,7 @@ public : * * @see DOMLSInput#DOMLSInput */ - virtual Grammar* loadGrammar(const DOMLSInput& source, + virtual Grammar* loadGrammar(const DOMLSInput* source, const short grammarType, const bool toCache = false); diff --git a/tests/src/DOM/Normalizer/Normalizer.cpp b/tests/src/DOM/Normalizer/Normalizer.cpp index 1aed52dff976b8cc4756f3fa698c9fbfb18957e3..cd6f34a3d9b1b4f50aca4a378d09b8c74346bf01 100644 --- a/tests/src/DOM/Normalizer/Normalizer.cpp +++ b/tests/src/DOM/Normalizer/Normalizer.cpp @@ -206,11 +206,16 @@ void Normalizer::serializeNode(const DOMNode * const node) { XMLString::transcode("LS", tempStr, 99); DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr); DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer(); + DOMLSOutput *theOutput = ((DOMImplementationLS*)impl)->createLSOutput(); theSerializer->getDomConfig()->setParameter(X("format-pretty-print"), true); XMLFormatTarget *myFormTarget; myFormTarget = new StdOutFormatTarget(); - theSerializer->write(node,myFormTarget); + theOutput->setByteStream(myFormTarget); + theSerializer->write(node,theOutput); + delete myFormTarget; + theSerializer->release(); + theOutput->release(); } int main(int argc, char **argv) { diff --git a/tests/src/MemHandlerTest/MemoryMonitor.cpp b/tests/src/MemHandlerTest/MemoryMonitor.cpp index 69c0d546cf46849a54ddc7d17679de990feb5f22..27d49b8e0c4d872a1271abf2ce886af16c56d434 100755 --- a/tests/src/MemHandlerTest/MemoryMonitor.cpp +++ b/tests/src/MemHandlerTest/MemoryMonitor.cpp @@ -259,7 +259,7 @@ int main (int argC, char *argV[]) DOMLSParserHandler domBuilderHandler; domBuilder->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, &domBuilderHandler); - // Instantiate the SAX2 domBuilder with its memory manager. + // Instantiate the SAX2 parser with its memory manager. MemoryMonitor *sax2MemMonitor = new MemoryMonitor(); SAX2XMLReader *sax2parser = XMLReaderFactory::createXMLReader(sax2MemMonitor); SAXErrorHandler saxErrorHandler; diff --git a/tests/src/ThreadTest/ThreadTest.cpp b/tests/src/ThreadTest/ThreadTest.cpp index a962a35e0284d3a86ea517f4e7e15451f4a875de..56ae7e0a90cec527b634ffea028258610ebc7aa6 100644 --- a/tests/src/ThreadTest/ThreadTest.cpp +++ b/tests/src/ThreadTest/ThreadTest.cpp @@ -778,10 +778,14 @@ void ThreadParser::domPrint() XMLString::transcode("LS", tempStr, 99); DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr); DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer(); + DOMLSOutput *theOutput = ((DOMImplementationLS*)impl)->createLSOutput(); XMLFormatTarget *myFormTarget = new StdOutFormatTarget(); + theOutput->setByteStream(myFormTarget); DOMNode *doc = fXercesDOMParser->getDocument(); - theSerializer->write(doc,myFormTarget); - delete theSerializer; + theSerializer->write(doc,theOutput); + delete myFormTarget; + theSerializer->release(); + theOutput->release(); } catch (...) {