diff --git a/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp b/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp index a9e0b78487e5fdf961bb968c016b4d0f5c281c6f..5b0f56bca8461d774d7e7384b70eb4a69843a429 100644 --- a/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp +++ b/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp @@ -7,19 +7,19 @@ CFG=XercesLib - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "XercesLib.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "XercesLib.mak" CFG="XercesLib - Win32 Debug" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE !MESSAGE "XercesLib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "XercesLib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE +!MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 @@ -84,7 +84,7 @@ LINK32=link.exe # ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib /nologo /base:"0x12000000" /subsystem:windows /dll /debug /machine:I386 /out:"..\..\..\..\..\Build\Win32\VC6\Debug/xerces-c_2_0_0D.dll" /implib:"..\..\..\..\..\Build\Win32\VC6\Debug/xerces-c_2D.lib" /pdbtype:sept /version:2.0.0 # SUBTRACT LINK32 /pdb:none -!ENDIF +!ENDIF # Begin Target @@ -2107,6 +2107,10 @@ SOURCE=..\..\..\..\..\src\xercesc\dom\impl\DOMImplementationimpl.hpp # End Source File # Begin Source File +SOURCE=..\..\..\..\..\src\xercesc\dom\impl\DOMImplementationRegistry.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\..\..\src\xercesc\dom\impl\DOMLocatorImpl.cpp # End Source File # Begin Source File @@ -2804,6 +2808,14 @@ SOURCE=..\..\..\..\..\src\xercesc\dom\DOMImplementationLS.hpp # End Source File # Begin Source File +SOURCE=..\..\..\..\..\src\xercesc\dom\DOMImplementationRegistry.hpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\xercesc\dom\DOMImplementationSource.hpp +# End Source File +# Begin Source File + SOURCE=..\..\..\..\..\src\xercesc\dom\DOMInputSource.hpp # End Source File # Begin Source File diff --git a/doc/program-dom.xml b/doc/program-dom.xml index 03539a00ab6458a130c1f8c7b30d011fea5d18d5..f18c5f53a912b3602c6ceac94bd8ee2b20b640e5 100644 --- a/doc/program-dom.xml +++ b/doc/program-dom.xml @@ -120,7 +120,8 @@ int main (int argc, char* args[]) { <source> DOMNode* aNode; DOMNode* docRootNode; - aNode = someDocument->createElement(L"ElementName"); + + aNode = someDocument->createElement(anElementName); docRootNode = someDocument->getDocumentElement(); docRootNode->appendChild(aNode); </source> @@ -141,33 +142,42 @@ int main (int argc, char* args[]) { // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(L"", L"root", 0); + XMLCh* tempStr[100]; + + XMLString::transcode("Range", tempStr, 99); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(tempStr, 0); + + XMLString::transcode("root", tempStr, 99); + DOMDocument* doc = impl->createDocument(0, tempStr, 0); + DOMElement* root = doc->getDocumentElement(); + + XMLString::transcode("FirstElement", tempStr, 99); + DOMElement* e1 = doc->createElement(tempStr); + root->appendChild(e1); - DOMElement* root = doc->getDocumentElement(); - - DOMElement* e1 = doc->createElement(L"FirstElement"); - root->appendChild(e1); - - DOMElement* e2 = doc->createElement(L"SecondElement"); - root->appendChild(e2); + XMLString::transcode("SecondElement", tempStr, 99); + DOMElement* e2 = doc->createElement(tempStr); + root->appendChild(e2); - DOMText* textNode = doc->createTextNode(L"aTextNode"); + XMLString::transcode("aTextNode", tempStr, 99); + DOMText* textNode = doc->createTextNode(tempStr); e1->appendChild(textNode); - + // call release() to release the resource associated with the range after done DOMRange* range = doc->createRange(); range->release(); - + // removedElement is an orphaned node, call release() to release associated resource - DOMElement* removedElement = root->removeChild(e2); + DOMElement* removedElement = root->removeChild(e2); removedElement->release(); // no need to release this returned object which is owned by implementation - DOMNodeList* nodeList = doc->getElementsByTagName(L"*"); - + XMLString::transcode("*", tempStr, 99); + DOMNodeList* nodeList = doc->getElementsByTagName(tempStr); + // done with the document, call release() to release the entire document resources doc->release(); - }; + }; </source> </s3> diff --git a/doc/releases.xml b/doc/releases.xml index 0a882fa911a6d3f203080b74f4800bf3182d5f06..38f2a1b95927d46b81225fa96e3f7444c0f4dd10 100644 --- a/doc/releases.xml +++ b/doc/releases.xml @@ -11,6 +11,56 @@ <td>Description</td> </tr> + <tr> + <td>2002-06-03</td> + <td>Tinny Ng</td> + <td>DOM L3: Add DOMImplementationRegistry and DOMImplementationSource. + </td> + </tr> + + <tr> + <td>2002-05-30</td> + <td>Tinny Ng</td> + <td>Add feature http://apache.org/xml/features/nonvalidating/load-external-dtd to + optionally ignore external DTD. + </td> + </tr> + + <tr> + <td>2002-05-29</td> + <td>Khaled Noaman</td> + <td>DOM L3: Add DOMInputSource, DOMEntityResolver, DOMImplementationLS and DOMBuilder. + </td> + </tr> + + <tr> + <td>2002-05-29</td> + <td>Gereon Steffens</td> + <td>[Bug 9489] Malformed HTTP GET Requests in UnixHTTPUrlInputStream. + </td> + </tr> + + <tr> + <td>2002-05-28</td> + <td>PeiYong Zhang</td> + <td>DOM L3: Modify DOMPrint to use DOMWriter. + </td> + </tr> + + <tr> + <td>2002-05-28</td> + <td>PeiYong Zhang</td> + <td>DOM L3: Add DOMWriter, DOMWriterFilter, StdOutFormatTarget, and MemBufFormatTarget.hpp. + </td> + </tr> + + <tr> + <td>2002-05-28</td> + <td>Tinny Ng</td> + <td>[Bug 9104] prefixes dissapearing when schema validation turned on. + </td> + </tr> + <tr> <td>2002-05-27</td> <td>Tinny Ng</td> diff --git a/doc/releases_plan.xml b/doc/releases_plan.xml index d977cb10ee223f5dc4c21541bfce6d9f88d07934..ceb104fc19052806d850c7548330da0a81403db2 100644 --- a/doc/releases_plan.xml +++ b/doc/releases_plan.xml @@ -98,7 +98,7 @@ Those features that have 'Complete' status will be included in the 'Next Target optionally ignore external DTD</td> <td>Tinny Ng</td> <td>May</td> - <td></td> + <td>Complete</td> </tr> <tr> @@ -109,10 +109,10 @@ Those features that have 'Complete' status will be included in the 'Next Target </tr> <tr> - <td>DOM L3 Core: DOMImplementationSource</td> + <td>DOM L3 Core: DOMImplementationRegistry and DOMImplementationSource</td> <td>Tinny Ng</td> <td>June</td> - <td></td> + <td>Complete</td> </tr> <tr> @@ -152,16 +152,16 @@ Those features that have 'Complete' status will be included in the 'Next Target </tr> <tr> - <td>DOM L3 Load: DOMInputSource, DOMEntityResolver, DOMBuilder</td> + <td>DOM L3 Load: DOMInputSource, DOMEntityResolver, DOMBuilder, DOMImplementationLS</td> <td>Khaled Noaman</td> <td>May</td> <td>Complete</td> </tr> <tr> - <td>DOM L3 Save: DOMWriter</td> + <td>DOM L3 Save: DOMWriter, DOMWriterFilter, DOMOutputSource(or similar class)</td> <td>PeiYong Zhang</td> - <td>June</td> - <td></td> + <td>May</td> + <td>Complete</td> </tr> <tr> @@ -185,6 +185,13 @@ Those features that have 'Complete' status will be included in the 'Next Target <td></td> </tr> + <tr> + <td>Schema 1.1</td> + <td></td> + <td></td> + <td></td> + </tr> + <tr> <td>PSVI</td> <td></td> diff --git a/samples/CreateDOMDocument/CreateDOMDocument.cpp b/samples/CreateDOMDocument/CreateDOMDocument.cpp index ad2f0bbf6110720e440c272f8e42028f599059ba..9fa4f4532e1c0599ff3838ef7c3b3a7030366cd0 100644 --- a/samples/CreateDOMDocument/CreateDOMDocument.cpp +++ b/samples/CreateDOMDocument/CreateDOMDocument.cpp @@ -151,8 +151,6 @@ int main(int argC, char* argV[]) { // Nest entire test in an inner block. - // Reference counting should recover all document - // storage when this block exits. // The tree we create below is the same that the XercesDOMParser would // have created, except that no whitespace text nodes would be created. @@ -162,7 +160,7 @@ int main(int argC, char* argV[]) // <developedBy>Apache Software Foundation</developedBy> // </company> - DOMImplementation* impl = DOMImplementation::getImplementation(); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); DOMDocument* doc = impl->createDocument( 0, // root element namespace URI. diff --git a/samples/DOMPrint/DOMPrint.cpp b/samples/DOMPrint/DOMPrint.cpp index 4a5aa711fe3ac79491bd1d195d9855231da809dd..d1d8ccbb4b243d9326870784b9a80a1779c3357d 100644 --- a/samples/DOMPrint/DOMPrint.cpp +++ b/samples/DOMPrint/DOMPrint.cpp @@ -60,22 +60,22 @@ // --------------------------------------------------------------------------- // This sample program invokes the XercesDOMParser to build a DOM tree for -// the specified input file. It then invokes DOMWriter::writeNode() to -// serialize the resultant DOM tree into StdOutmyFormTarget, if no error -// occurs during the parsing. +// the specified input file. It then invokes DOMWriter::writeNode() to +// serialize the resultant DOM tree into StdOutmyFormTarget, if no error +// occurs during the parsing. // // // Note: Application needs to provide its own implementation of DOMErrorHandler -// (in this sample, the DOMPrintErrorHandler), if it would receive +// (in this sample, the DOMPrintErrorHandler), if it would receive // notification from the serializer in case any error occurs during // the serialization. // // Note: And application needs to provide its own implementation of DOMWriterFilter // as well (in this sample, the DOMPrintFilter), if it would like to -// filtering out certain part of the DOM representation. but must be aware +// filtering out certain part of the DOM representation. but must be aware // that thus may render the resultant XML stream invalid. // -// Note: Application may choose any combination of characters as the end of line +// Note: Application may choose any combination of characters as the end of line // sequence to be used in the resultant XML stream, but must be aware that // thus may render the serialized XML stream ill formed. // @@ -85,7 +85,7 @@ // to terminate serialization prematurely, and thus no complete serialization // be done. // -// Note: Application shall query the serializer first, before set any +// Note: Application shall query the serializer first, before set any // feature/mode(true, false), or be ready to catch exception if this // feature/mode is not supported by the serializer. // @@ -145,7 +145,7 @@ // then it is defaults to the encoding of the input XML file. // // gMyEOLSequence -// The end of line sequence we are to output. +// The end of line sequence we are to output. // // gValScheme // Indicates what validation scheme to use. It defaults to 'auto', but @@ -412,17 +412,19 @@ int main(int argC, char* argV[]) try { // get a serializer, an instance of DOMWriter - DOMImplementation *impl = DOMImplementation::getImplementation(); + XMLCh tempStr[100]; + XMLString::transcode("Core", tempStr, 99); + DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr); DOMWriter *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter(); // set user specified end of line sequence and output encoding theSerializer->setNewLine(gMyEOLSequence); theSerializer->setEncoding(gOutputEncoding); - // plug in user's own filter + // plug in user's own filter if (gUseFilter) { - myFilter = new DOMPrintFilter; + myFilter = new DOMPrintFilter; theSerializer->setFilter(myFilter); } @@ -456,12 +458,12 @@ int main(int argC, char* argV[]) delete theSerializer; - // - // Filter, formatTarget and error handler + // + // Filter, formatTarget and error handler // are NOT owned by the serializer. // - delete myFormTarget; - delete myErrorHandler; + delete myFormTarget; + delete myErrorHandler; if (gUseFilter) delete myFilter; diff --git a/src/xercesc/dom/DOM.hpp b/src/xercesc/dom/DOM.hpp index 5598bcf682862431fd58af3be8cbd689b4c03f75..0a5763423745f04fd940b0a6538c2890639ea5d4 100644 --- a/src/xercesc/dom/DOM.hpp +++ b/src/xercesc/dom/DOM.hpp @@ -71,28 +71,43 @@ #include <xercesc/dom/DOMCharacterData.hpp> #include <xercesc/dom/DOMComment.hpp> #include <xercesc/dom/DOMDocument.hpp> -#include <xercesc/dom/DOMDocumentRange.hpp> -#include <xercesc/dom/DOMDocumentTraversal.hpp> #include <xercesc/dom/DOMDocumentFragment.hpp> #include <xercesc/dom/DOMDocumentType.hpp> -#include <xercesc/dom/DOMException.hpp> -#include <xercesc/dom/DOMImplementation.hpp> -#include <xercesc/dom/DOMImplementationLS.hpp> #include <xercesc/dom/DOMElement.hpp> #include <xercesc/dom/DOMEntity.hpp> #include <xercesc/dom/DOMEntityReference.hpp> +#include <xercesc/dom/DOMEntityResolver.hpp> +#include <xercesc/dom/DOMError.hpp> +#include <xercesc/dom/DOMErrorHandler.hpp> +#include <xercesc/dom/DOMException.hpp> +#include <xercesc/dom/DOMImplementation.hpp> #include <xercesc/dom/DOMNamedNodeMap.hpp> #include <xercesc/dom/DOMNode.hpp> #include <xercesc/dom/DOMNodeList.hpp> #include <xercesc/dom/DOMNotation.hpp> #include <xercesc/dom/DOMProcessingInstruction.hpp> #include <xercesc/dom/DOMText.hpp> -#include <xercesc/dom/DOMRange.hpp> -#include <xercesc/dom/DOMRangeException.hpp> + +// Introduced in DOM Level 2 +#include <xercesc/dom/DOMDocumentRange.hpp> +#include <xercesc/dom/DOMDocumentTraversal.hpp> #include <xercesc/dom/DOMNodeFilter.hpp> #include <xercesc/dom/DOMNodeIterator.hpp> +#include <xercesc/dom/DOMRange.hpp> +#include <xercesc/dom/DOMRangeException.hpp> #include <xercesc/dom/DOMTreeWalker.hpp> + +// Introduced in DOM Level 3 +// Experimental - subject to change +#include <xercesc/dom/DOMBuilder.hpp> +#include <xercesc/dom/DOMImplementationLS.hpp> +#include <xercesc/dom/DOMImplementationRegistry.hpp> +#include <xercesc/dom/DOMImplementationSource.hpp> +#include <xercesc/dom/DOMInputSource.hpp> +#include <xercesc/dom/DOMLocator.hpp> #include <xercesc/dom/DOMWriter.hpp> #include <xercesc/dom/DOMWriterFilter.hpp> + + #endif diff --git a/src/xercesc/dom/DOMImplementationRegistry.hpp b/src/xercesc/dom/DOMImplementationRegistry.hpp new file mode 100644 index 0000000000000000000000000000000000000000..fd09361426aeccf7d6a7ef8687b7120b5e4700e6 --- /dev/null +++ b/src/xercesc/dom/DOMImplementationRegistry.hpp @@ -0,0 +1,116 @@ +#ifndef DOMImplementationRegistry_HEADER_GUARD_ +#define DOMImplementationRegistry_HEADER_GUARD_ + +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2002, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + */ + +/** + * Introduced in DOM Level 3 + * + * This class holds the list of registered DOMImplementations. Implementation + * or application can register DOMImplementationSource to the registry, and + * then can query DOMImplementation based on a list of requested features. + * + * <p>This provides an application with an implementation independent starting + * point. + * + * @see DOMImplementation + * @see DOMImplementationSource + */ + +class DOMImplementation; +class DOMImplementationSource; + +class CDOM_EXPORT DOMImplementationRegistry +{ +public: + // ----------------------------------------------------------------------- + // Static DOMImplementationRegistry interface */ + // ----------------------------------------------------------------------- + /** @name Static DOMImplementationRegistry interface */ + //@{ + /** + * <p><b>"Experimental - subject to change"</b></p> + * + * Return the first registered implementation that has the desired features, + * or null if none is found. + * + * @param features A string that specifies which features are required. + * This is a space separated list in which each feature is + * specified by its name optionally followed by a space + * and a version number. + * This is something like: "XML 1.0 Traversal Events 2.0" + * @return An implementation that has the desired features, or + * <code>null</code> if this source has none. + */ + static DOMImplementation* getDOMImplementation(const XMLCh* features); + + /** + * <p><b>"Experimental - subject to change"</b></p> + * + * Register an implementation. + * + * @param source A DOMImplementation Source object to be added to the registry. + * The registry does NOT adopt the source object. Users still own it. + */ + static void addSource(DOMImplementationSource* source); +}; + +#endif diff --git a/src/xercesc/dom/DOMImplementationSource.hpp b/src/xercesc/dom/DOMImplementationSource.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ac12ed9cd0709ef6031ee9f7ac4979b95bf41bd8 --- /dev/null +++ b/src/xercesc/dom/DOMImplementationSource.hpp @@ -0,0 +1,126 @@ +#ifndef DOMImplementationSource_HEADER_GUARD_ +#define DOMImplementationSource_HEADER_GUARD_ + +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2002, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + */ + +/** + * Introduced in DOM Level 3 + * + * This interface permits a DOM implementer to supply one or more + * implementations, based upon requested features. Each implemented + * <code>DOMImplementationSource</code> object is listed in the + * binding-specific list of available sources so that its + * <code>DOMImplementation</code> objects are made available. + * <p>See also the <a href='http://www.w3.org/2001/10/WD-DOM-Level-3-Core-20011017'>Document Object Model (DOM) Level 3 Core Specification</a>. + */ + +class DOMImplementation; + +class CDOM_EXPORT DOMImplementationSource +{ +protected : + // ----------------------------------------------------------------------- + // Hidden constructors + // ----------------------------------------------------------------------- + /** @name Constructors */ + //@{ + + /** Default constructor */ + DOMImplementationSource() {}; + + //@} + + +public: + // ----------------------------------------------------------------------- + // All constructors are hidden, just the destructor is available + // ----------------------------------------------------------------------- + /** @name Destructor */ + //@{ + /** + * Destructor + * + */ + virtual ~DOMImplementationSource() {}; + //@} + + // ----------------------------------------------------------------------- + // Virtual DOMImplementationSource interface */ + // ----------------------------------------------------------------------- + /** @name Virtual DOMImplementationSource interface */ + //@{ + /** + * <p><b>"Experimental - subject to change"</b></p> + * + * A method to request a DOM implementation. + * @param features A string that specifies which features are required. + * This is a space separated list in which each feature is specified + * by its name optionally followed by a space and a version number. + * This is something like: "XML 1.0 Traversal Events 2.0" + * @return An implementation that has the desired features, or + * <code>null</code> if this source has none. + */ + virtual DOMImplementation* getDOMImplementation(const XMLCh* features) const = 0; + //@} + +}; + +#endif diff --git a/src/xercesc/dom/Makefile.in b/src/xercesc/dom/Makefile.in index a1f4475a29453a567b80627bfb3f9cac71938ba6..6a198d63dc9dab34d29a80949ad65848766a9df6 100644 --- a/src/xercesc/dom/Makefile.in +++ b/src/xercesc/dom/Makefile.in @@ -97,6 +97,8 @@ DOM_CPP_PUBHEADERS = \ DOMException.hpp \ DOMImplementation.hpp \ DOMImplementationLS.hpp \ + DOMImplementationRegistry.hpp \ + DOMImplementationSource.hpp \ DOMInputSource.hpp \ DOMLocator.hpp \ DOMNamedNodeMap.hpp \ diff --git a/src/xercesc/dom/impl/DOMImplementationImpl.cpp b/src/xercesc/dom/impl/DOMImplementationImpl.cpp index 23b9167f3171cb29b7399135d98d69375e8b0999..3f02c9c443c741d6a110bb3f64e985645c79617c 100644 --- a/src/xercesc/dom/impl/DOMImplementationImpl.cpp +++ b/src/xercesc/dom/impl/DOMImplementationImpl.cpp @@ -69,12 +69,15 @@ #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLRegisterCleanup.hpp> +#include <xercesc/util/XMLStringTokenizer.hpp> #include <xercesc/parsers/DOMBuilderImpl.hpp> +// ------------------------------------------------------------ // // Static constants. These are lazily initialized on first usage. // (Static constructors can not be safely used because // of order of initialization dependencies.) +// ------------------------------------------------------------ static DOMImplementationImpl *gDomimp; // Points to the singleton instance @@ -82,40 +85,23 @@ static DOMImplementationImpl *gDomimp; // Points to the singleton instance // by any call to getImplementation(). static const XMLCh gXML[] = // Points to "XML" - {chLatin_X, chLatin_M, chLatin_L, 0}; + {chLatin_X, chLatin_M, chLatin_L, chNull}; static const XMLCh g1_0[] = // Points to "1.0" - {chDigit_1, chPeriod, chDigit_0, 0}; + {chDigit_1, chPeriod, chDigit_0, chNull}; static const XMLCh g2_0[] = // Points to "2.0" - {chDigit_2, chPeriod, chDigit_0, 0}; + {chDigit_2, chPeriod, chDigit_0, chNull}; +static const XMLCh g3_0[] = // Points to "3.0" + {chDigit_3, chPeriod, chDigit_0, chNull}; static const XMLCh gTrav[] = // Points to "Traversal" {chLatin_T, chLatin_r, chLatin_a, chLatin_v, chLatin_e, chLatin_r, - chLatin_s, chLatin_a, chLatin_l, 0}; + chLatin_s, chLatin_a, chLatin_l, chNull}; static const XMLCh gCore[] = // Points to "Core" - {chLatin_C, chLatin_o, chLatin_r, chLatin_e, 0}; + {chLatin_C, chLatin_o, chLatin_r, chLatin_e, chNull}; static const XMLCh gRange[] = // Points to "Range" {chLatin_R, chLatin_a, chLatin_n, chLatin_g, chLatin_e, 0}; - - -DOMImplementationImpl::DOMImplementationImpl() { -}; - - - -DOMImplementationImpl::DOMImplementationImpl(const DOMImplementationImpl & other) -{ -}; - - -DOMImplementationImpl::~DOMImplementationImpl() -{ -}; - - -DOMImplementationImpl & DOMImplementationImpl::operator = (const DOMImplementationImpl & other) -{ - return *this; -}; +static const XMLCh gLS[] = // Points to "LS" + {chLatin_L, chLatin_S, chNull}; // ----------------------------------------------------------------------- @@ -135,7 +121,7 @@ static void reinitImplementation() // promise that different documents can safely be // used concurrently by different threads. // -DOMImplementation *DOMImplementationImpl::getImplementation() { +DOMImplementationImpl *DOMImplementationImpl::getDOMImplementationImpl() { static XMLRegisterCleanup implementationCleanup; if (gDomimp == 0) @@ -154,22 +140,15 @@ DOMImplementation *DOMImplementationImpl::getImplementation() { return gDomimp; }; -// -// DOMImplementation::getImplementation. DOMImplementation is supposed to -// be a pure interface class. This one static -// function is the hook that lets things get started. -DOMImplementation *DOMImplementation::getImplementation() -{ - return DOMImplementationImpl::getImplementation(); -} - - - +// ------------------------------------------------------------ +// DOMImplementation Virtual interface +// ------------------------------------------------------------ bool DOMImplementationImpl::hasFeature(const XMLCh * feature, const XMLCh * version) { bool anyVersion = (version == 0 || XMLString::stringLen(version) == 0); bool version1_0 = (XMLString::compareString(version, g1_0) == 0); bool version2_0 = (XMLString::compareString(version, g2_0) == 0); + bool version3_0 = (XMLString::compareString(version, g3_0) == 0); // Currently, we support only XML Level 1 version 1.0 if (XMLString::compareIString(feature, gXML) == 0 @@ -177,7 +156,7 @@ bool DOMImplementationImpl::hasFeature(const XMLCh * feature, const XMLCh * return true; if (XMLString::compareIString(feature, gCore) == 0 - && (anyVersion || version1_0 || version2_0)) + && (anyVersion || version1_0 || version2_0 || version3_0)) return true; if (XMLString::compareIString(feature, gTrav) == 0 @@ -188,6 +167,10 @@ bool DOMImplementationImpl::hasFeature(const XMLCh * feature, const XMLCh * && (anyVersion || version2_0)) return true; + if (XMLString::compareIString(feature, gLS) == 0 + && (anyVersion || version3_0)) + return true; + return false; } @@ -209,13 +192,25 @@ DOMDocument *DOMImplementationImpl::createDocument(const XMLCh *namespaceURI, } - +// Non-standard extension DOMDocument *DOMImplementationImpl::createDocument() { return new DOMDocumentImpl(); } +// +// DOMImplementation::getImplementation. DOMImplementation is supposed to +// be a pure interface class. This one static +// function is the hook that lets things get started. +DOMImplementation *DOMImplementation::getImplementation() +{ + return (DOMImplementation*) DOMImplementationImpl::getDOMImplementationImpl(); +} + +// ------------------------------------------------------------ +// DOMImplementationLS Virtual interface +// ------------------------------------------------------------ //Introduced in DOM Level 3 DOMBuilder* DOMImplementationImpl::createDOMBuilder(const short mode, const XMLCh* const schemaType) @@ -235,5 +230,38 @@ DOMWriter* DOMImplementationImpl::createDOMWriter() DOMInputSource* DOMImplementationImpl::createDOMInputSource() { throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0); + return 0; } + +// ------------------------------------------------------------ +// DOMImplementationSource Virtual interface +// ------------------------------------------------------------ +DOMImplementation* DOMImplementationImpl::getDOMImplementation(const XMLCh* features) const +{ + DOMImplementation* impl = DOMImplementation::getImplementation(); + + XMLStringTokenizer tokenizer(features); + const XMLCh* feature = 0; + + while (feature || tokenizer.hasMoreTokens()) { + + if (!feature) + feature = tokenizer.nextToken(); + + const XMLCh* version = 0; + const XMLCh* token = tokenizer.nextToken(); + + if (token && XMLString::isDigit(token[0])) + version = token; + + if (!impl->hasFeature(feature, version)) + return 0; + + if (!version) + feature = token; + } + return impl; +} + + diff --git a/src/xercesc/dom/impl/DOMImplementationImpl.hpp b/src/xercesc/dom/impl/DOMImplementationImpl.hpp index c92514dcda8b5721bca97b3ac889f83669fef5ec..17cdee614d605d6431c6fc06b77f46f430b10fea 100644 --- a/src/xercesc/dom/impl/DOMImplementationImpl.hpp +++ b/src/xercesc/dom/impl/DOMImplementationImpl.hpp @@ -71,29 +71,50 @@ #include <xercesc/util/XercesDefs.hpp> #include <xercesc/dom/DOMImplementation.hpp> +#include <xercesc/dom/DOMImplementationSource.hpp> -class DOMImplementationImpl: public DOMImplementation +class DOMImplementationImpl: public DOMImplementation, + public DOMImplementationSource { private: - DOMImplementationImpl(); - DOMImplementationImpl(const DOMImplementationImpl & other); - DOMImplementationImpl & operator = (const DOMImplementationImpl & other); + DOMImplementationImpl() {}; + DOMImplementationImpl(const DOMImplementationImpl & other) {}; + DOMImplementationImpl & operator = (const DOMImplementationImpl & other) {return *this;}; public: - virtual ~DOMImplementationImpl(); - static DOMImplementation *getImplementation(); - virtual bool hasFeature(const XMLCh * feature, const XMLCh * version); - virtual DOMDocumentType *createDocumentType(const XMLCh *qualifiedName, - const XMLCh * publicId, const XMLCh *systemId); - virtual DOMDocument *createDocument(const XMLCh *namespaceURI, - const XMLCh *qualifiedName, DOMDocumentType *doctype); - virtual DOMDocument *createDocument(); + virtual ~DOMImplementationImpl() {}; + static DOMImplementationImpl* getDOMImplementationImpl(); + // ------------------------------------------------------------ + // DOMImplementation Virtual interface + // ------------------------------------------------------------ + virtual bool hasFeature(const XMLCh * feature, const XMLCh * version); + + // Introduced in DOM Level 2 + virtual DOMDocumentType* createDocumentType(const XMLCh *qualifiedName, + const XMLCh * publicId, + const XMLCh *systemId); + virtual DOMDocument* createDocument(const XMLCh *namespaceURI, + const XMLCh *qualifiedName, + DOMDocumentType *doctype); + + // Non-standard extension + virtual DOMDocument* createDocument(); + + // ------------------------------------------------------------ + // DOMImplementationLS Virtual interface + // ------------------------------------------------------------ // Introduced in DOM Level 3 // Experimental - subject to change - virtual DOMBuilder* createDOMBuilder(const short mode, - const XMLCh* const schemaType); - virtual DOMWriter* createDOMWriter(); - virtual DOMInputSource* createDOMInputSource(); + virtual DOMBuilder* createDOMBuilder(const short mode, + const XMLCh* const schemaType); + virtual DOMWriter* createDOMWriter(); + virtual DOMInputSource* createDOMInputSource(); + + // ------------------------------------------------------------ + // DOMImplementationSource Virtual interface + // ------------------------------------------------------------ + virtual DOMImplementation* getDOMImplementation(const XMLCh* features) const; + }; diff --git a/src/xercesc/dom/impl/DOMImplementationRegistry.cpp b/src/xercesc/dom/impl/DOMImplementationRegistry.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2cd12555dea4077594d8bdbf49f058993a206cd --- /dev/null +++ b/src/xercesc/dom/impl/DOMImplementationRegistry.cpp @@ -0,0 +1,167 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2002, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + */ + +#include <xercesc/util/PlatformUtils.hpp> +#include <xercesc/util/RefVectorOf.hpp> +#include <xercesc/util/XMLRegisterCleanup.hpp> +#include <xercesc/dom/DOMImplementationRegistry.hpp> +#include <xercesc/dom/DOMImplementationSource.hpp> +#include <xercesc/dom/DOMImplementation.hpp> +#include "DOMImplementationImpl.hpp" + +// ----------------------------------------------------------------------- +// Static constants. These are lazily initialized on first usage. +// (Static constructors can not be safely used because +// of order of initialization dependencies.) +// ----------------------------------------------------------------------- +// Points to the singleton instance of a registry of DOMImplementationSource +static RefVectorOf<DOMImplementationSource>* gDOMImplSrcVector; + +// Global mutex that is used to synchronize access to the vector +static XMLMutex* gDOMImplSrcVectorMutex = 0; + +// ----------------------------------------------------------------------- +// Reset the static data +// ----------------------------------------------------------------------- +static void reinitDOMImplSrcVector() +{ + delete gDOMImplSrcVector; + gDOMImplSrcVector = 0; +} + +static void reinitDOMImplSrcVectorMutex() +{ + delete gDOMImplSrcVectorMutex; + gDOMImplSrcVectorMutex = 0; +}; + +// ----------------------------------------------------------------------- +// Get the static data +// ----------------------------------------------------------------------- +RefVectorOf<DOMImplementationSource>* getDOMImplSrcVector() +{ + static XMLRegisterCleanup cleanupDOMImplSrcVector; + + if (gDOMImplSrcVector == 0) + { + RefVectorOf<DOMImplementationSource> *t = new RefVectorOf<DOMImplementationSource>(3, false); + if (XMLPlatformUtils::compareAndSwap((void **)&gDOMImplSrcVector, t, 0) != 0) + { + delete t; + } + else + { + cleanupDOMImplSrcVector.registerCleanup(reinitDOMImplSrcVector); + } + } + return gDOMImplSrcVector; +} + +XMLMutex& getDOMImplSrcVectorMutex() +{ + static XMLRegisterCleanup cleanupDOMImplSrcVectorMutex; + if (!gDOMImplSrcVectorMutex) + { + XMLMutex* tmpMutex = new XMLMutex; + if (XMLPlatformUtils::compareAndSwap((void**)&gDOMImplSrcVectorMutex, tmpMutex, 0)) + { + // Someone beat us to it, so let's clean up ours + delete tmpMutex; + } + else + cleanupDOMImplSrcVectorMutex.registerCleanup(reinitDOMImplSrcVectorMutex); + + } + + return *gDOMImplSrcVectorMutex; +} + + +// ----------------------------------------------------------------------- +// DOMImplementationRegistry Functions +// ----------------------------------------------------------------------- +DOMImplementation *DOMImplementationRegistry::getDOMImplementation(const XMLCh* features) { + + XMLMutexLock lock(&getDOMImplSrcVectorMutex()); + + unsigned int len = getDOMImplSrcVector()->size(); + + // Put our defined source there + if (len == 0) + getDOMImplSrcVector()->addElement((DOMImplementationSource*)DOMImplementationImpl::getDOMImplementationImpl()); + + len = getDOMImplSrcVector()->size(); + + for (unsigned int i = len; i > 0; i--) { + DOMImplementationSource* source = getDOMImplSrcVector()->elementAt(i-1); + DOMImplementation* impl = source->getDOMImplementation(features); + if (impl) + return impl; + } + + return 0; +} + +void DOMImplementationRegistry::addSource (DOMImplementationSource* source) { + XMLMutexLock lock(&getDOMImplSrcVectorMutex()); + getDOMImplSrcVector()->addElement(source); +} + + diff --git a/src/xercesc/dom/impl/Makefile.in b/src/xercesc/dom/impl/Makefile.in index d4b585336833340321b57046cb39182bb02393d7..e6557e1fe64f3e140bceb0d54c1030d0fe4c5a9c 100644 --- a/src/xercesc/dom/impl/Makefile.in +++ b/src/xercesc/dom/impl/Makefile.in @@ -133,6 +133,7 @@ DOM_IMPL_CPP_OBJECTS = \ DOMDocumentImpl.$(TO) \ DOMDocumentTypeImpl.$(TO) \ DOMImplementationImpl.$(TO) \ + DOMImplementationRegistry.$(TO) \ DOMElementImpl.$(TO) \ DOMElementNSImpl.$(TO) \ DOMEntityImpl.$(TO) \ diff --git a/tests/DOM/DOMMemTest/DOMMemTest.cpp b/tests/DOM/DOMMemTest/DOMMemTest.cpp index e7bd449fad814b26b177602e3746e9c35ef258e6..1e7955baec070da3bb76a36285b597dba148dcce 100644 --- a/tests/DOM/DOMMemTest/DOMMemTest.cpp +++ b/tests/DOM/DOMMemTest/DOMMemTest.cpp @@ -96,13 +96,47 @@ void tassert(bool c, const char *file, int line) } \ } +// --------------------------------------------------------------------------- +// This is a simple class that lets us do easy (though not terribly efficient) +// trancoding of char* data to XMLCh data. +// --------------------------------------------------------------------------- +class XStr +{ +public : + // ----------------------------------------------------------------------- + // Constructors and Destructor + // ----------------------------------------------------------------------- + XStr(const char* const toTranscode) + { + // Call the private transcoding method + fUnicodeForm = XMLString::transcode(toTranscode); + } + + ~XStr() + { + delete [] fUnicodeForm; + } -//temp XMLCh String Buffer -XMLCh tempStr[4000]; -XMLCh tempStr2[4000]; -XMLCh tempStr3[4000]; -XMLCh tempStr4[4000]; -XMLCh tempStr5[4000]; + + // ----------------------------------------------------------------------- + // Getter methods + // ----------------------------------------------------------------------- + const XMLCh* unicodeForm() const + { + return fUnicodeForm; + } + +private : + // ----------------------------------------------------------------------- + // Private data members + // + // fUnicodeForm + // This is the Unicode XMLCh format of the string. + // ----------------------------------------------------------------------- + XMLCh* fUnicodeForm; +}; + +#define X(str) XStr(str).unicodeForm() //--------------------------------------------------------------------------------------- // @@ -118,7 +152,7 @@ void DOMBasicTests() // First precondition, so that lazily created strings do not appear // as memory leaks. DOMDocument* doc; - doc = DOMImplementation::getImplementation()->createDocument(); + doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); delete doc; } @@ -131,34 +165,25 @@ void DOMBasicTests() // Do all operations in a preconditioning step, to force the // creation of implementation objects that are set up on first use. // Don't watch for leaks in this block (no / ) - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("Doc02Element", tempStr, 3999); - DOMElement* el = doc->createElement(tempStr); + DOMElement* el = doc->createElement(X("Doc02Element")); DOMDocumentFragment* frag = doc->createDocumentFragment (); - XMLString::transcode("Doc02TextNode", tempStr, 3999); - DOMText* text = doc->createTextNode(tempStr); + DOMText* text = doc->createTextNode(X("Doc02TextNode")); - XMLString::transcode("Doc02Comment", tempStr, 3999); - DOMComment* comment = doc->createComment(tempStr); + DOMComment* comment = doc->createComment(X("Doc02Comment")); - XMLString::transcode("Doc02CDataSection", tempStr, 3999); - DOMCDATASection* cdataSec = doc->createCDATASection(tempStr); + DOMCDATASection* cdataSec = doc->createCDATASection(X("Doc02CDataSection")); - XMLString::transcode("Doc02DocumentType", tempStr, 3999); - DOMDocumentType* docType = doc->createDocumentType(tempStr); + DOMDocumentType* docType = doc->createDocumentType(X("Doc02DocumentType")); - XMLString::transcode("Doc02Notation", tempStr, 3999); - DOMNotation* notation = doc->createNotation(tempStr); + DOMNotation* notation = doc->createNotation(X("Doc02Notation")); - XMLString::transcode("Doc02PITarget", tempStr, 3999); - XMLString::transcode("Doc02PIData", tempStr2, 3999); - DOMProcessingInstruction* pi = doc->createProcessingInstruction(tempStr, tempStr2); + DOMProcessingInstruction* pi = doc->createProcessingInstruction(X("Doc02PITarget"), X("Doc02PIData")); - XMLString::transcode("*", tempStr, 3999); - DOMNodeList* nodeList = doc->getElementsByTagName(tempStr); + DOMNodeList* nodeList = doc->getElementsByTagName(X("*")); delete doc; } @@ -170,20 +195,17 @@ void DOMBasicTests() // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("Doc03RootElement", tempStr, 3999); - DOMElement* rootEl = doc->createElement(tempStr); + DOMElement* rootEl = doc->createElement(X("Doc03RootElement")); doc->appendChild(rootEl); - XMLString::transcode("Doc03 text stuff", tempStr, 3999); - DOMText* textNode = doc->createTextNode(tempStr); + DOMText* textNode = doc->createTextNode(X("Doc03 text stuff")); rootEl->appendChild(textNode); - XMLString::transcode("*", tempStr, 3999); - DOMNodeList* nodeList = doc->getElementsByTagName(tempStr); + DOMNodeList* nodeList = doc->getElementsByTagName(X("*")); delete doc; }; @@ -193,22 +215,19 @@ void DOMBasicTests() // Attr01 // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("RootElement", tempStr, 3999); - DOMElement* rootEl = doc->createElement(tempStr); + DOMElement* rootEl = doc->createElement(X("RootElement")); doc->appendChild(rootEl); { - XMLString::transcode("Attr01", tempStr, 3999); - DOMAttr* attr01 = doc->createAttribute(tempStr); + DOMAttr* attr01 = doc->createAttribute(X("Attr01")); rootEl->setAttributeNode(attr01); } { - XMLString::transcode("Attr01", tempStr, 3999); - DOMAttr* attr02 = doc->createAttribute(tempStr); + DOMAttr* attr02 = doc->createAttribute(X("Attr01")); rootEl->setAttributeNode(attr02); } delete doc; @@ -220,19 +239,17 @@ void DOMBasicTests() // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("RootElement", tempStr, 3999); - DOMElement* rootEl = doc->createElement(tempStr); + DOMElement* rootEl = doc->createElement(X("RootElement")); doc->appendChild(rootEl); - XMLString::transcode("Attr02", tempStr, 3999); - DOMAttr* attr01 = doc->createAttribute(tempStr); + DOMAttr* attr01 = doc->createAttribute(X("Attr02")); rootEl->setAttributeNode(attr01); - DOMAttr* attr02 = doc->createAttribute(tempStr); + DOMAttr* attr02 = doc->createAttribute(X("Attr02")); rootEl->setAttributeNode(attr02); delete doc; @@ -245,23 +262,19 @@ void DOMBasicTests() // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("RootElement", tempStr, 3999); - DOMElement* rootEl = doc->createElement(tempStr); + DOMElement* rootEl = doc->createElement(X("RootElement")); doc->appendChild(rootEl); - XMLString::transcode("Attr03", tempStr, 3999); - DOMAttr* attr01 = doc->createAttribute(tempStr); + DOMAttr* attr01 = doc->createAttribute(X("Attr03")); rootEl->setAttributeNode(attr01); - XMLString::transcode("Attr03Value1", tempStr, 3999); - attr01->setValue(tempStr); + attr01->setValue(X("Attr03Value1")); - XMLString::transcode("Attr03Value2", tempStr, 3999); - attr01->setValue(tempStr); + attr01->setValue(X("Attr03Value2")); delete doc; } @@ -272,20 +285,17 @@ void DOMBasicTests() // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("RootElement", tempStr, 3999); - DOMElement* rootEl = doc->createElement(tempStr); + DOMElement* rootEl = doc->createElement(X("RootElement")); doc->appendChild(rootEl); - XMLString::transcode("Attr04", tempStr, 3999); - DOMAttr* attr01 = doc->createAttribute(tempStr); + DOMAttr* attr01 = doc->createAttribute(X("Attr04")); rootEl->setAttributeNode(attr01); - XMLString::transcode("Attr04Value1", tempStr, 3999); - attr01->setValue(tempStr); + attr01->setValue(X("Attr04Value1")); DOMNode* value = attr01->getFirstChild(); delete doc; @@ -299,15 +309,13 @@ void DOMBasicTests() // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("RootElement", tempStr, 3999); - DOMElement* rootEl = doc->createElement(tempStr); + DOMElement* rootEl = doc->createElement(X("RootElement")); doc->appendChild(rootEl); - XMLString::transcode("Hello Goodbye", tempStr, 3999); - DOMText* txt1 = doc->createTextNode(tempStr); + DOMText* txt1 = doc->createTextNode(X("Hello Goodbye")); rootEl->appendChild(txt1); txt1->splitText(6); @@ -323,29 +331,27 @@ void DOMBasicTests() // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("DocType_for_Notation01", tempStr, 3999); - DOMDocumentType* dt = doc->createDocumentType(tempStr); + DOMDocumentType* dt = doc->createDocumentType(X("DocType_for_Notation01")); doc->appendChild(dt); DOMNamedNodeMap* notationMap = dt->getNotations(); - XMLString::transcode("Notation01", tempStr, 3999); - DOMNotation* nt1 = doc->createNotation(tempStr); + DOMNotation* nt1 = doc->createNotation(X("Notation01")); notationMap->setNamedItem (nt1); - DOMNode* abc1 = notationMap->getNamedItem(tempStr); + DOMNode* abc1 = notationMap->getNamedItem(X("Notation01")); DOMNotation* nt2 = (DOMNotation*) abc1; TASSERT(nt1==nt2); nt2 = 0; nt1 = 0; - DOMNode* abc6 = notationMap->getNamedItem(tempStr); + DOMNode* abc6 = notationMap->getNamedItem(X("Notation01")); nt2 = (DOMNotation*) abc6; delete doc; @@ -361,14 +367,13 @@ void DOMBasicTests() DOMNamedNodeMap* nnm = 0; TASSERT(nnm == 0); - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); nnm = doc->getAttributes(); // Should be null, because node type // is not Element. TASSERT(nnm == 0); TASSERT(!(nnm != 0)); - XMLString::transcode("NamedNodeMap01", tempStr, 3999); - DOMElement* el = doc->createElement(tempStr); + DOMElement* el = doc->createElement(X("NamedNodeMap01")); DOMNamedNodeMap* nnm2 = el->getAttributes(); // Should be an empty, but non-null map. TASSERT(nnm2 != 0); @@ -385,11 +390,10 @@ void DOMBasicTests() // { - DOMDocument* doc1 = DOMImplementation::getImplementation()->createDocument(); - DOMDocument* doc2 = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc1 = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); + DOMDocument* doc2 = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("abc", tempStr, 3999); - DOMElement* el1 = doc1->createElement(tempStr); + DOMElement* el1 = doc1->createElement(X("abc")); doc1->appendChild(el1); TASSERT(el1->getParentNode() != 0); @@ -397,7 +401,7 @@ void DOMBasicTests() TASSERT(el2->getParentNode() == 0); const XMLCh* tagName = el2->getNodeName(); - TASSERT(!XMLString::compareString(tagName, tempStr)); + TASSERT(!XMLString::compareString(tagName, X("abc"))); TASSERT(el2->getOwnerDocument() == doc2); TASSERT(doc1 != doc2); @@ -416,13 +420,11 @@ void DOMBasicTests() // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("Hello", tempStr, 3999); - DOMText* tx = doc->createTextNode(tempStr); + DOMText* tx = doc->createTextNode(X("Hello")); - XMLString::transcode("abc", tempStr, 3999); - DOMElement* el = doc->createElement(tempStr); + DOMElement* el = doc->createElement(X("abc")); el->appendChild(tx); @@ -451,15 +453,14 @@ void DOMBasicTests() TASSERT(!(nl != 0)); TASSERT(nl == nl2); - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); nl = doc->getChildNodes(); // Should be non-null, but empty TASSERT(nl != 0); int len = nl->getLength(); TASSERT(len == 0); - XMLString::transcode("NodeList01", tempStr, 3999); - DOMElement* el = doc->createElement(tempStr); + DOMElement* el = doc->createElement(X("NodeList01")); doc->appendChild(el); len = nl->getLength(); @@ -478,11 +479,10 @@ void DOMBasicTests() // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); try { - XMLString::transcode("!@@ bad element name", tempStr, 3999); - DOMElement* el = doc->createElement(tempStr); + DOMElement* el = doc->createElement(X("!@@ bad element name")); TASSERT(false); // Exception above should prevent us reaching here. } catch ( DOMException e) @@ -503,10 +503,9 @@ void DOMBasicTests() // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("NodeList01", tempStr, 3999); - DOMElement* el = doc->createElement(tempStr); + DOMElement* el = doc->createElement(X("NodeList01")); doc->appendChild(el); @@ -531,30 +530,27 @@ void DOMBasicTests() // { - DOMDocument* doc = DOMImplementation::getImplementation()->createDocument(); + DOMDocument* doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("CTestRoot", tempStr, 3999); - DOMElement* root = doc->createElement(tempStr); + DOMElement* root = doc->createElement(X("CTestRoot")); - XMLString::transcode("CTestAttr", tempStr, 3999); - XMLString::transcode("CTestAttrValue", tempStr2, 3999); - root->setAttribute(tempStr, tempStr2); + root->setAttribute(X("CTestAttr"), X("CTestAttrValue")); - const XMLCh* s = root->getAttribute(tempStr); - TASSERT(!XMLString::compareString(s, tempStr2)); + const XMLCh* s = root->getAttribute(X("CTestAttr")); + TASSERT(!XMLString::compareString(s, X("CTestAttrValue"))); DOMNode* abc2 = root->cloneNode(true); DOMElement* cloned = (DOMElement*) abc2; - DOMAttr* a = cloned->getAttributeNode(tempStr); + DOMAttr* a = cloned->getAttributeNode(X("CTestAttr")); TASSERT(a != 0); s = a->getValue(); - TASSERT(!XMLString::compareString(s, tempStr2)); + TASSERT(!XMLString::compareString(s, X("CTestAttrValue"))); a = 0; - a = cloned->getAttributeNode(tempStr); + a = cloned->getAttributeNode(X("CTestAttr")); TASSERT(a != 0); s = a->getValue(); - TASSERT(!XMLString::compareString(s, tempStr2)); + TASSERT(!XMLString::compareString(s, X("CTestAttrValue"))); delete doc; } @@ -568,26 +564,22 @@ void DOMBasicTests() { DOMDocument* doc; - doc = DOMImplementation::getImplementation()->createDocument(); + doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); DOMText* tn, *tn1, *tn2; - XMLString::transcode("0123456789", tempStr, 3999); - tn = doc->createTextNode (tempStr); + tn = doc->createTextNode (X("0123456789")); tn1 = tn->splitText(5); - XMLString::transcode("01234", tempStr, 3999); - TASSERT(!XMLString::compareString(tn->getNodeValue(), tempStr)); + TASSERT(!XMLString::compareString(tn->getNodeValue(), X("01234"))); - XMLString::transcode("56789", tempStr2, 3999); - TASSERT(!XMLString::compareString(tn1->getNodeValue(), tempStr2)); + TASSERT(!XMLString::compareString(tn1->getNodeValue(), X("56789"))); tn2 = tn->splitText(5); - TASSERT(!XMLString::compareString(tn->getNodeValue(), tempStr)); + TASSERT(!XMLString::compareString(tn->getNodeValue(), X("01234"))); - XMLString::transcode("", tempStr2, 3999); - TASSERT(!XMLString::compareString(tn2->getNodeValue(), tempStr2)); + TASSERT(!XMLString::compareString(tn2->getNodeValue(), XMLUni::fgZeroLenString)); EXCEPTION_TEST(tn->splitText(6), DOMException::INDEX_SIZE_ERR); delete doc; @@ -622,103 +614,72 @@ void DOMNSTests() // { - DOMImplementation* impl = DOMImplementation::getImplementation(); - XMLString::transcode("1.0", tempStr, 3999); - XMLString::transcode("2.0", tempStr2, 3999); - XMLString::transcode("3.0", tempStr3, 3999); - XMLString::transcode("", tempStr4, 3999); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); - XMLString::transcode("XmL", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr2) == true); + TASSERT(impl->hasFeature(X("XmL"), X("2.0")) == true); - XMLString::transcode("xML", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == true); + TASSERT(impl->hasFeature(X("xML"), 0) == true); + TASSERT(impl->hasFeature(X("xML"), XMLUni::fgZeroLenString) == true); - XMLString::transcode("XMl", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr) == true); + TASSERT(impl->hasFeature(X("XMl"), X("1.0")) == true); - XMLString::transcode("xMl", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr3) == false); + TASSERT(impl->hasFeature(X("xMl"), X("3.0")) == false); - XMLString::transcode("TrAveRsal", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == true); + TASSERT(impl->hasFeature(X("TrAveRsal"), 0) == true); + TASSERT(impl->hasFeature(X("TrAveRsal"), XMLUni::fgZeroLenString) == true); } { - DOMImplementation* impl = DOMImplementation::getImplementation(); - XMLString::transcode("1.0", tempStr, 3999); - XMLString::transcode("2.0", tempStr2, 3999); - XMLString::transcode("3.0", tempStr3, 3999); - XMLString::transcode("", tempStr4, 3999); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); - XMLString::transcode("XmL", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == true); - TASSERT(impl->hasFeature(tempStr5, tempStr) == true); - TASSERT(impl->hasFeature(tempStr5, tempStr2) == true); - TASSERT(impl->hasFeature(tempStr5, tempStr3) == false); + TASSERT(impl->hasFeature(X("XmL"), 0) == true); + TASSERT(impl->hasFeature(X("XmL"), X("1.0")) == true); + TASSERT(impl->hasFeature(X("XmL"), X("2.0")) == true); + TASSERT(impl->hasFeature(X("XmL"), X("3.0")) == false); - XMLString::transcode("Core", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == true); + TASSERT(impl->hasFeature(X("Core"), 0) == true); - XMLString::transcode("coRe", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr) == true); + TASSERT(impl->hasFeature(X("coRe"), X("1.0")) == true); - XMLString::transcode("core", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr2) == true); + TASSERT(impl->hasFeature(X("core"), X("2.0")) == true); - XMLString::transcode("cORe", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr3) == false); + TASSERT(impl->hasFeature(X("cORe"), X("3.0")) == true); + TASSERT(impl->hasFeature(X("cORe"), X("4.0")) == false); - XMLString::transcode("Traversal", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == true); + TASSERT(impl->hasFeature(X("Traversal"), XMLUni::fgZeroLenString) == true); - XMLString::transcode("traversal", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr) == false); + TASSERT(impl->hasFeature(X("traversal"), X("1.0")) == false); - XMLString::transcode("TraVersal", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr2) == true); + TASSERT(impl->hasFeature(X("TraVersal"), X("2.0")) == true); - XMLString::transcode("Range", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == true); + TASSERT(impl->hasFeature(X("Range"), 0) == true); - XMLString::transcode("raNge", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr) == false); + TASSERT(impl->hasFeature(X("raNge"), X("1.0")) == false); - XMLString::transcode("RaNge", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr2) == true); + TASSERT(impl->hasFeature(X("RaNge"), X("2.0")) == true); - XMLString::transcode("HTML", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == false); + TASSERT(impl->hasFeature(X("HTML"), 0) == false); - XMLString::transcode("Views", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == false); + TASSERT(impl->hasFeature(X("Views"), XMLUni::fgZeroLenString) == false); - XMLString::transcode("StyleSheets", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == false); + TASSERT(impl->hasFeature(X("StyleSheets"), 0) == false); - XMLString::transcode("CSS", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == false); + TASSERT(impl->hasFeature(X("CSS"), XMLUni::fgZeroLenString) == false); - XMLString::transcode("CSS2", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == false); + TASSERT(impl->hasFeature(X("CSS2"), 0) == false); - XMLString::transcode("Events", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == false); + TASSERT(impl->hasFeature(X("Events"), 0) == false); - XMLString::transcode("UIEvents", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == false); + TASSERT(impl->hasFeature(X("UIEvents"), 0) == false); - XMLString::transcode("MouseEvents", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == false); + TASSERT(impl->hasFeature(X("MouseEvents"), 0) == false); - XMLString::transcode("MutationEvents", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == false); + TASSERT(impl->hasFeature(X("MutationEvents"), 0) == false); - XMLString::transcode("HTMLEvents", tempStr5, 3999); - TASSERT(impl->hasFeature(tempStr5, tempStr4) == false); + TASSERT(impl->hasFeature(X("HTMLEvents"), 0) == false); } @@ -729,79 +690,54 @@ void DOMNSTests() { DOMDocument* doc; - doc = DOMImplementation::getImplementation()->createDocument(); - - XMLString::transcode("1.0", tempStr, 3999); - XMLString::transcode("2.0", tempStr2, 3999); - XMLString::transcode("3.0", tempStr3, 3999); - XMLString::transcode("", tempStr4, 3999); - - XMLString::transcode("XmL", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == true); - TASSERT(doc->isSupported(tempStr5, tempStr) == true); - TASSERT(doc->isSupported(tempStr5, tempStr2) == true); - TASSERT(doc->isSupported(tempStr5, tempStr3) == false); + doc = DOMImplementationRegistry::getDOMImplementation(X("Core"))->createDocument(); - XMLString::transcode("Core", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == true); - XMLString::transcode("coRe", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr) == true); + TASSERT(doc->isSupported(X("XmL"), 0) == true); + TASSERT(doc->isSupported(X("XmL"), X("1.0")) == true); + TASSERT(doc->isSupported(X("XmL"), X("2.0")) == true); + TASSERT(doc->isSupported(X("XmL"), X("3.0")) == false); - XMLString::transcode("core", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr2) == true); + TASSERT(doc->isSupported(X("Core"), 0) == true); + TASSERT(doc->isSupported(X("Core"), XMLUni::fgZeroLenString) == true); - XMLString::transcode("cORe", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr3) == false); + TASSERT(doc->isSupported(X("coRe"), X("1.0")) == true); - XMLString::transcode("Traversal", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == true); + TASSERT(doc->isSupported(X("core"), X("2.0")) == true); - XMLString::transcode("traversal", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr) == false); + TASSERT(doc->isSupported(X("cORe"), X("3.0")) == true); + TASSERT(doc->isSupported(X("cORe"), X("4.0")) == false); - XMLString::transcode("TraVersal", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr2) == true); + TASSERT(doc->isSupported(X("Traversal"), 0) == true); - XMLString::transcode("Range", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == true); + TASSERT(doc->isSupported(X("traversal"), X("1.0")) == false); - XMLString::transcode("raNge", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr) == false); + TASSERT(doc->isSupported(X("TraVersal"), X("2.0")) == true); - XMLString::transcode("RaNge", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr2) == true); + TASSERT(doc->isSupported(X("Range"), XMLUni::fgZeroLenString) == true); + TASSERT(doc->isSupported(X("raNge"), X("1.0")) == false); - XMLString::transcode("HTML", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == false); + TASSERT(doc->isSupported(X("RaNge"), X("2.0")) == true); - XMLString::transcode("Views", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == false); + TASSERT(doc->isSupported(X("HTML"), 0) == false); - XMLString::transcode("StyleSheets", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == false); + TASSERT(doc->isSupported(X("Views"), 0) == false); - XMLString::transcode("CSS", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == false); + TASSERT(doc->isSupported(X("StyleSheets"), 0) == false); - XMLString::transcode("CSS2", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == false); + TASSERT(doc->isSupported(X("CSS"), 0) == false); - XMLString::transcode("Events", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == false); + TASSERT(doc->isSupported(X("CSS2"), XMLUni::fgZeroLenString) == false); + TASSERT(doc->isSupported(X("Events"), 0) == false); - XMLString::transcode("UIEvents", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == false); + TASSERT(doc->isSupported(X("UIEvents"), 0) == false); - XMLString::transcode("MouseEvents", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == false); + TASSERT(doc->isSupported(X("MouseEvents"), 0) == false); - XMLString::transcode("MutationEvents", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == false); + TASSERT(doc->isSupported(X("MutationEvents"), XMLUni::fgZeroLenString) == false); - XMLString::transcode("HTMLEvents", tempStr5, 3999); - TASSERT(doc->isSupported(tempStr5, tempStr4) == false); + TASSERT(doc->isSupported(X("HTMLEvents"), 0) == false); delete doc; } @@ -811,22 +747,19 @@ void DOMNSTests() // { - DOMImplementation* impl = DOMImplementation::getImplementation(); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); - XMLString::transcode("foo:docName", tempStr, 3999); - XMLString::transcode("pubId", tempStr2, 3999); - XMLString::transcode( "http://sysId", tempStr3, 3999); - DOMDocumentType* dt = impl->createDocumentType(tempStr, tempStr2, tempStr3); + DOMDocumentType* dt = impl->createDocumentType(X("foo:docName"), X("pubId"), X("http://sysId")); TASSERT(dt != 0); TASSERT(dt->getNodeType() == DOMNode::DOCUMENT_TYPE_NODE); - TASSERT(!XMLString::compareString(dt->getNodeName(), tempStr)); + TASSERT(!XMLString::compareString(dt->getNodeName(), X("foo:docName"))); TASSERT(dt->getNamespaceURI() == 0); TASSERT(dt->getPrefix() == 0); TASSERT(dt->getLocalName() == 0); - TASSERT(!XMLString::compareString(dt->getPublicId(), tempStr2)); - TASSERT(!XMLString::compareString(dt->getSystemId(), tempStr3)); + TASSERT(!XMLString::compareString(dt->getPublicId(), X("pubId"))); + TASSERT(!XMLString::compareString(dt->getSystemId(), X("http://sysId"))); TASSERT(dt->getInternalSubset() == 0); TASSERT(dt->getOwnerDocument() == 0); @@ -839,35 +772,29 @@ void DOMNSTests() // // Qualified name without prefix should also work. // - XMLString::transcode("docName", tempStr, 3999); - dt = impl->createDocumentType(tempStr, tempStr2, tempStr3); + dt = impl->createDocumentType(X("docName"), X("pubId"), X("http://sysId")); TASSERT(dt != 0); TASSERT(dt->getNodeType() == DOMNode::DOCUMENT_TYPE_NODE); - TASSERT(!XMLString::compareString(dt->getNodeName(), tempStr)); + TASSERT(!XMLString::compareString(dt->getNodeName(), X("docName"))); TASSERT(dt->getNamespaceURI() == 0); TASSERT(dt->getPrefix() == 0); TASSERT(dt->getLocalName() == 0); - TASSERT(!XMLString::compareString(dt->getPublicId(), tempStr2)); - TASSERT(!XMLString::compareString(dt->getSystemId(), tempStr3)); + TASSERT(!XMLString::compareString(dt->getPublicId(), X("pubId"))); + TASSERT(!XMLString::compareString(dt->getSystemId(), X("http://sysId"))); TASSERT(dt->getInternalSubset() == 0); TASSERT(dt->getOwnerDocument() == 0); // Creating a DocumentType with invalid or malformed qName should fail. - XMLString::transcode("<docName", tempStr, 3999); - EXCEPTION_TEST(impl->createDocumentType(tempStr, tempStr2, tempStr3), DOMException::INVALID_CHARACTER_ERR); + EXCEPTION_TEST(impl->createDocumentType(X("<docName"), X("pubId"), X("http://sysId")), DOMException::INVALID_CHARACTER_ERR); - XMLString::transcode(":docName", tempStr, 3999); - EXCEPTION_TEST(impl->createDocumentType(tempStr, tempStr2, tempStr3), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(impl->createDocumentType(X(":docName"), X("pubId"), X("http://sysId")), DOMException::NAMESPACE_ERR); - XMLString::transcode("docName:", tempStr, 3999); - EXCEPTION_TEST(impl->createDocumentType(tempStr, tempStr2, tempStr3), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(impl->createDocumentType(X("docName:"), X("pubId"), X("http://sysId")), DOMException::NAMESPACE_ERR); - XMLString::transcode("doc::Name", tempStr, 3999); - EXCEPTION_TEST(impl->createDocumentType(tempStr, tempStr2, tempStr3), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(impl->createDocumentType(X("doc::Name"), X("pubId"), X("http://sysId")), DOMException::NAMESPACE_ERR); - XMLString::transcode("doc:N:ame", tempStr, 3999); - EXCEPTION_TEST(impl->createDocumentType(tempStr, tempStr2, tempStr3), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(impl->createDocumentType(X("doc:N:ame"), X("pubId"), X("http://sysId")), DOMException::NAMESPACE_ERR); delete dt; } @@ -878,12 +805,10 @@ void DOMNSTests() // DOMImplementation::CreateDocument { - DOMImplementation* impl = DOMImplementation::getImplementation(); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); DOMDocumentType* dt = 0; - XMLString::transcode("", tempStr2, 3999); - XMLString::transcode("a", tempStr, 3999); - DOMDocument* doc = impl->createDocument(tempStr2, tempStr, dt); + DOMDocument* doc = impl->createDocument(XMLUni::fgZeroLenString, X("a"), dt); doc->getNodeName(); delete doc; @@ -893,18 +818,13 @@ void DOMNSTests() { - DOMImplementation* impl = DOMImplementation::getImplementation(); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); - XMLString::transcode("foo:docName", tempStr3, 3999); - XMLString::transcode("pubId", tempStr2, 3999); - XMLString::transcode( "http://sysId", tempStr, 3999); - DOMDocumentType* dt = impl->createDocumentType(tempStr3, tempStr2, tempStr); + DOMDocumentType* dt = impl->createDocumentType(X("foo:docName"), X("pubId"), X("http://sysId")); - XMLString::transcode("http://document.namespace", tempStr2, 3999); - - DOMDocument* doc = impl->createDocument(tempStr2, tempStr3, dt); + DOMDocument* doc = impl->createDocument(X("http://document.namespace"), X("foo:docName"), dt); TASSERT(dt->getOwnerDocument() == doc); TASSERT(doc->getOwnerDocument() == 0); @@ -912,8 +832,7 @@ void DOMNSTests() TASSERT(doc->getNodeType() == DOMNode::DOCUMENT_NODE); TASSERT(doc->getDoctype() == dt); - XMLString::transcode("#document", tempStr, 3999); - TASSERT(!XMLString::compareString(doc->getNodeName(), tempStr)); + TASSERT(!XMLString::compareString(doc->getNodeName(), X("#document"))); TASSERT(doc->getNodeValue() == 0); TASSERT(doc->getNamespaceURI() == 0); @@ -922,18 +841,16 @@ void DOMNSTests() DOMElement* el = doc->getDocumentElement(); - XMLString::transcode("docName", tempStr, 3999); - TASSERT(!XMLString::compareString(el->getLocalName(), tempStr)); + TASSERT(!XMLString::compareString(el->getLocalName(), X("docName"))); - TASSERT(!XMLString::compareString(el->getNamespaceURI(), tempStr2)); - TASSERT(!XMLString::compareString(el->getNodeName(), tempStr3)); + TASSERT(!XMLString::compareString(el->getNamespaceURI(), X("http://document.namespace"))); + TASSERT(!XMLString::compareString(el->getNodeName(), X("foo:docName"))); TASSERT(el->getOwnerDocument() == doc); TASSERT(el->getParentNode() == doc); - XMLString::transcode("foo", tempStr, 3999); - TASSERT(!XMLString::compareString(el->getPrefix(), tempStr)); + TASSERT(!XMLString::compareString(el->getPrefix(), X("foo"))); - TASSERT(!XMLString::compareString(el->getTagName(), tempStr3)); + TASSERT(!XMLString::compareString(el->getTagName(), X("foo:docName"))); TASSERT(el->hasChildNodes() == false); @@ -942,7 +859,7 @@ void DOMNSTests() // try { - DOMDocument* doc2 = impl->createDocument(tempStr2, tempStr3, dt); + DOMDocument* doc2 = impl->createDocument(X("pubId"), X("foo:docName"), dt); TASSERT(false); // should not reach here. } catch ( DOMException &e) @@ -956,7 +873,7 @@ void DOMNSTests() delete doc; // Creating a document with null NamespaceURI and DocumentType - doc = impl->createDocument(tempStr2, tempStr3, 0); + doc = impl->createDocument(X("pubId"), X("foo:docName"), 0); // Namespace tests of createDocument are covered by createElementNS below delete doc; @@ -975,149 +892,115 @@ void DOMNSTests() // Set up an initial (root element only) document. // - DOMImplementation* impl = DOMImplementation::getImplementation(); - - XMLString::transcode("foo:docName", tempStr3, 3999); - XMLString::transcode("pubId", tempStr2, 3999); - XMLString::transcode( "http://sysId", tempStr, 3999); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); - DOMDocumentType* dt = impl->createDocumentType(tempStr3, tempStr2, tempStr); + DOMDocumentType* dt = impl->createDocumentType(X("foo:docName"), X("pubId"), X("http://sysId")); - XMLString::transcode("http://document.namespace", tempStr2, 3999); - DOMDocument* doc = impl->createDocument(tempStr2, tempStr3, dt); + DOMDocument* doc = impl->createDocument(X("http://document.namespace"), X("foo:docName"), dt); DOMElement* rootEl = doc->getDocumentElement(); // // CreateElementNS // - XMLString::transcode("http://nsa", tempStr5, 3999); - XMLString::transcode("a:ela", tempStr, 3999); - DOMElement* ela = doc->createElementNS(tempStr5, tempStr); // prefix and URI - - TASSERT(!XMLString::compareString(ela->getNodeName(), tempStr)); - TASSERT(!XMLString::compareString(ela->getNamespaceURI(), tempStr5)); - XMLString::transcode("a", tempStr3, 3999); - TASSERT(!XMLString::compareString(ela->getPrefix(), tempStr3)); - XMLString::transcode("ela", tempStr3, 3999); - TASSERT(!XMLString::compareString(ela->getLocalName(), tempStr3)); - TASSERT(!XMLString::compareString(ela->getTagName(), tempStr)); + DOMElement* ela = doc->createElementNS(X("http://nsa"), X("a:ela")); // prefix and URI + TASSERT(!XMLString::compareString(ela->getNodeName(), X("a:ela"))); + TASSERT(!XMLString::compareString(ela->getNamespaceURI(), X("http://nsa"))); + TASSERT(!XMLString::compareString(ela->getPrefix(), X("a"))); + TASSERT(!XMLString::compareString(ela->getLocalName(), X("ela"))); + TASSERT(!XMLString::compareString(ela->getTagName(), X("a:ela"))); - XMLString::transcode("", tempStr3, 3999); - XMLString::transcode("http://nsb", tempStr2, 3999); - XMLString::transcode("elb", tempStr, 3999); - DOMElement* elb = doc->createElementNS(tempStr2, tempStr); // URI, no prefix. + DOMElement* elb = doc->createElementNS(X("http://nsb"), X("elb")); // URI, no prefix. - TASSERT(!XMLString::compareString(elb->getNodeName(), tempStr)); - TASSERT(!XMLString::compareString(elb->getNamespaceURI(), tempStr2)); - TASSERT(!XMLString::compareString(elb->getPrefix(), tempStr3)); - TASSERT(!XMLString::compareString(elb->getLocalName(), tempStr)); - TASSERT(!XMLString::compareString(elb->getTagName(), tempStr)); + TASSERT(!XMLString::compareString(elb->getNodeName(), X("elb"))); + TASSERT(!XMLString::compareString(elb->getNamespaceURI(), X("http://nsb"))); + TASSERT(!XMLString::compareString(elb->getPrefix(), XMLUni::fgZeroLenString)); + TASSERT(!XMLString::compareString(elb->getLocalName(), X("elb"))); + TASSERT(!XMLString::compareString(elb->getTagName(), X("elb"))); + DOMElement* elc = doc->createElementNS(XMLUni::fgZeroLenString, X("elc")); // No URI, no prefix. - XMLString::transcode("elc", tempStr, 3999); - DOMElement* elc = doc->createElementNS(tempStr3, tempStr); // No URI, no prefix. - - TASSERT(!XMLString::compareString(elc->getNodeName(), tempStr)); - TASSERT(!XMLString::compareString(elc->getNamespaceURI(), tempStr3)); - TASSERT(!XMLString::compareString(elc->getPrefix(), tempStr3)); - TASSERT(!XMLString::compareString(elc->getLocalName(), tempStr)); - TASSERT(!XMLString::compareString(elc->getTagName(), tempStr)); + TASSERT(!XMLString::compareString(elc->getNodeName(), X("elc"))); + TASSERT(!XMLString::compareString(elc->getNamespaceURI(), XMLUni::fgZeroLenString)); + TASSERT(!XMLString::compareString(elc->getPrefix(), XMLUni::fgZeroLenString)); + TASSERT(!XMLString::compareString(elc->getLocalName(), X("elc"))); + TASSERT(!XMLString::compareString(elc->getTagName(), X("elc"))); rootEl->appendChild(ela); rootEl->appendChild(elb); rootEl->appendChild(elc); // Badly formed qualified name - XMLString::transcode("<a", tempStr4, 3999); - EXCEPTION_TEST(doc->createElementNS(tempStr5, tempStr4), DOMException::INVALID_CHARACTER_ERR); + EXCEPTION_TEST(doc->createElementNS(X("http://nsa"), X("<a")), DOMException::INVALID_CHARACTER_ERR); - XMLString::transcode(":a", tempStr4, 3999); - EXCEPTION_TEST(doc->createElementNS(tempStr5, tempStr4), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createElementNS(X("http://nsa"), X(":a")), DOMException::NAMESPACE_ERR); - XMLString::transcode("a:", tempStr4, 3999); - EXCEPTION_TEST(doc->createElementNS(tempStr5, tempStr4), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createElementNS(X("http://nsa"), X("a:")), DOMException::NAMESPACE_ERR); - XMLString::transcode("a::a", tempStr4, 3999); - EXCEPTION_TEST(doc->createElementNS(tempStr5, tempStr4), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createElementNS(X("http://nsa"), X("a::a")), DOMException::NAMESPACE_ERR); - XMLString::transcode("a:a:a", tempStr4, 3999); - EXCEPTION_TEST(doc->createElementNS(tempStr5, tempStr4), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createElementNS(X("http://nsa"), X("a:a:a")), DOMException::NAMESPACE_ERR); // xml:a must have namespaceURI == "http://www.w3.org/XML/1998/namespace" - XMLString::transcode("http://www.w3.org/XML/1998/namespace", tempStr4, 3999); - XMLString::transcode("xml:a",tempStr2, 3999); - TASSERT(!XMLString::compareString(doc->createElementNS(tempStr4, tempStr2)->getNamespaceURI(), tempStr4)); - EXCEPTION_TEST(doc->createElementNS(tempStr5, tempStr2), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createElementNS(tempStr3, tempStr2), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createElementNS(0, tempStr2), DOMException::NAMESPACE_ERR); + TASSERT(!XMLString::compareString(doc->createElementNS(X("http://www.w3.org/XML/1998/namespace"), X("xml:a"))->getNamespaceURI(), X("http://www.w3.org/XML/1998/namespace"))); + EXCEPTION_TEST(doc->createElementNS(X("http://nsa"), X("xml:a")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createElementNS(XMLUni::fgZeroLenString, X("xml:a")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createElementNS(0, X("xml:a")), DOMException::NAMESPACE_ERR); //unlike Attribute, xmlns (no different from foo) can have any namespaceURI for Element - XMLString::transcode("xmlns", tempStr2, 3999); - TASSERT(!XMLString::compareString(doc->createElementNS(tempStr5, tempStr2)->getNamespaceURI(), tempStr5)); + TASSERT(!XMLString::compareString(doc->createElementNS(X("http://nsa"), X("xmlns"))->getNamespaceURI(), X("http://nsa"))); - TASSERT(!XMLString::compareString(doc->createElementNS(tempStr4, tempStr2)->getNamespaceURI(), tempStr4)); - TASSERT(!XMLString::compareString(doc->createElementNS(tempStr3, tempStr2)->getNamespaceURI(), tempStr3)); - TASSERT(!XMLString::compareString(doc->createElementNS(0, tempStr2)->getNamespaceURI(), tempStr3)); + TASSERT(!XMLString::compareString(doc->createElementNS(X("http://www.w3.org/XML/1998/namespace"), X("xmlns"))->getNamespaceURI(), X("http://www.w3.org/XML/1998/namespace"))); + TASSERT(!XMLString::compareString(doc->createElementNS(XMLUni::fgZeroLenString, X("xmlns"))->getNamespaceURI(), XMLUni::fgZeroLenString)); + TASSERT(!XMLString::compareString(doc->createElementNS(0, X("xmlns"))->getNamespaceURI(), XMLUni::fgZeroLenString)); //unlike Attribute, xmlns:a (no different from foo:a) can have any namespaceURI for Element //except "" and null - XMLString::transcode("xmlns:a", tempStr2, 3999); - TASSERT(!XMLString::compareString(doc->createElementNS(tempStr5, tempStr2)->getNamespaceURI(), tempStr5)); - TASSERT(!XMLString::compareString(doc->createElementNS(tempStr4, tempStr2)->getNamespaceURI(), tempStr4)); - EXCEPTION_TEST(doc->createElementNS(tempStr3, tempStr2), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createElementNS(0, tempStr2), DOMException::NAMESPACE_ERR); + TASSERT(!XMLString::compareString(doc->createElementNS(X("http://nsa"), X("xmlns:a"))->getNamespaceURI(), X("http://nsa"))); + TASSERT(!XMLString::compareString(doc->createElementNS(X("http://www.w3.org/XML/1998/namespace"), X("xmlns:a"))->getNamespaceURI(), X("http://www.w3.org/XML/1998/namespace"))); + EXCEPTION_TEST(doc->createElementNS(XMLUni::fgZeroLenString, X("xmlns:a")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createElementNS(0, X("xmlns:a")), DOMException::NAMESPACE_ERR); //In fact, any prefix != null should have a namespaceURI != 0 or != "" - XMLString::transcode("foo:a", tempStr2, 3999); - TASSERT(!XMLString::compareString(doc->createElementNS(tempStr5, tempStr2)->getNamespaceURI(), tempStr5)); - EXCEPTION_TEST(doc->createElementNS(tempStr3, tempStr2), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createElementNS(0, tempStr2), DOMException::NAMESPACE_ERR); + TASSERT(!XMLString::compareString(doc->createElementNS(X("http://nsa"), X("foo:a"))->getNamespaceURI(), X("http://nsa"))); + EXCEPTION_TEST(doc->createElementNS(XMLUni::fgZeroLenString, X("foo:a")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createElementNS(0, X("foo:a")), DOMException::NAMESPACE_ERR); //Change prefix - DOMElement* elem = doc->createElementNS(tempStr5, tempStr2); - XMLString::transcode("bar", tempStr2, 3999); - elem->setPrefix(tempStr2); - XMLString::transcode("bar:a", tempStr4, 3999); - TASSERT(!XMLString::compareString(elem->getNodeName(), tempStr4)); - TASSERT(!XMLString::compareString(elem->getNamespaceURI(), tempStr5)); - TASSERT(!XMLString::compareString(elem->getPrefix(), tempStr2)); - XMLString::transcode("a", tempStr, 3999); - TASSERT(!XMLString::compareString(elem->getLocalName(), tempStr)); - TASSERT(!XMLString::compareString(elem->getTagName(), tempStr4)); + DOMElement* elem = doc->createElementNS(X("http://nsa"), X("foo:a")); + elem->setPrefix(X("bar")); + TASSERT(!XMLString::compareString(elem->getNodeName(), X("bar:a"))); + TASSERT(!XMLString::compareString(elem->getNamespaceURI(), X("http://nsa"))); + TASSERT(!XMLString::compareString(elem->getPrefix(), X("bar"))); + TASSERT(!XMLString::compareString(elem->getLocalName(), X("a"))); + TASSERT(!XMLString::compareString(elem->getTagName(), X("bar:a"))); //The spec does not prevent us from setting prefix to a node without prefix - elem = doc->createElementNS(tempStr5, tempStr); - TASSERT(!XMLString::compareString(elem->getPrefix(), tempStr3)); - elem->setPrefix(tempStr2); - TASSERT(!XMLString::compareString(elem->getNodeName(), tempStr4)); - TASSERT(!XMLString::compareString(elem->getNamespaceURI(), tempStr5)); - TASSERT(!XMLString::compareString(elem->getPrefix(), tempStr2)); - TASSERT(!XMLString::compareString(elem->getLocalName(), tempStr)); - TASSERT(!XMLString::compareString(elem->getTagName(), tempStr4)); + elem = doc->createElementNS(X("http://nsa"), X("a")); + TASSERT(!XMLString::compareString(elem->getPrefix(), XMLUni::fgZeroLenString)); + elem->setPrefix(X("bar")); + TASSERT(!XMLString::compareString(elem->getNodeName(), X("bar:a"))); + TASSERT(!XMLString::compareString(elem->getNamespaceURI(), X("http://nsa"))); + TASSERT(!XMLString::compareString(elem->getPrefix(), X("bar"))); + TASSERT(!XMLString::compareString(elem->getLocalName(), X("a"))); + TASSERT(!XMLString::compareString(elem->getTagName(), X("bar:a"))); //Special case for xml:a where namespaceURI must be xmlURI - XMLString::transcode("foo:a", tempStr, 3999); - XMLString::transcode("http://www.w3.org/XML/1998/namespace", tempStr4, 3999); - elem = doc->createElementNS(tempStr4, tempStr); - XMLString::transcode("xml", tempStr2, 3999); - elem->setPrefix(tempStr2); - elem = doc->createElementNS(tempStr5, tempStr); - EXCEPTION_TEST(elem->setPrefix(tempStr2), DOMException::NAMESPACE_ERR); + elem = doc->createElementNS(X("http://www.w3.org/XML/1998/namespace"), X("foo:a")); + elem->setPrefix(X("xml")); + elem = doc->createElementNS(X("http://nsa"), X("foo:a")); + EXCEPTION_TEST(elem->setPrefix(X("xml")), DOMException::NAMESPACE_ERR); //However, there is no restriction on prefix xmlns - XMLString::transcode("xmlns", tempStr4, 3999); - elem->setPrefix(tempStr4); + elem->setPrefix(X("xmlns")); //Also an element can not have a prefix with namespaceURI == null or "" - XMLString::transcode("a", tempStr, 3999); - XMLString::transcode("foo", tempStr2, 3999); - elem = doc->createElementNS(0, tempStr); - EXCEPTION_TEST(elem->setPrefix(tempStr2), DOMException::NAMESPACE_ERR); - elem = doc->createElementNS(tempStr3, tempStr); - EXCEPTION_TEST(elem->setPrefix(tempStr2), DOMException::NAMESPACE_ERR); + elem = doc->createElementNS(0, X("a")); + EXCEPTION_TEST(elem->setPrefix(X("foo")), DOMException::NAMESPACE_ERR); + elem = doc->createElementNS(XMLUni::fgZeroLenString, X("a")); + EXCEPTION_TEST(elem->setPrefix(X("foo")), DOMException::NAMESPACE_ERR); //Only prefix of Element and Attribute can be changed - EXCEPTION_TEST(doc->setPrefix(tempStr2), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->setPrefix(X("foo")), DOMException::NAMESPACE_ERR); //Prefix of readonly Element can not be changed. //However, there is no way to create such DOMElement* for testing yet. @@ -1136,162 +1019,128 @@ void DOMNSTests() // Set up an initial (root element only) document. // - DOMImplementation* impl = DOMImplementation::getImplementation(); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); - XMLString::transcode("foo:docName", tempStr3, 3999); - XMLString::transcode("pubId", tempStr2, 3999); - XMLString::transcode( "http://sysId", tempStr, 3999); - DOMDocumentType* dt = impl->createDocumentType(tempStr3, tempStr2, tempStr); + DOMDocumentType* dt = impl->createDocumentType(X("foo:docName"), X("pubId"), X("http://sysId")); - XMLString::transcode("http://document.namespace", tempStr2, 3999); - DOMDocument* doc = impl->createDocument(tempStr2, tempStr3, dt); + DOMDocument* doc = impl->createDocument(X("http://document.namespace"), X("foo:docName"), dt); DOMElement* rootEl = doc->getDocumentElement(); // // CreateAttributeNS // - XMLString::transcode("http://nsa", tempStr5, 3999); - XMLString::transcode("http://nsb", tempStr4, 3999); - XMLString::transcode("", tempStr3, 3999); - XMLString::transcode("a:attra", tempStr, 3999); - DOMAttr* attra = doc->createAttributeNS(tempStr5, tempStr); // prefix and URI - TASSERT(!XMLString::compareString(attra->getNodeName(), tempStr)); - TASSERT(!XMLString::compareString(attra->getNamespaceURI(), tempStr5)); + DOMAttr* attra = doc->createAttributeNS(X("http://nsa"), X("a:attra")); // prefix and URI + TASSERT(!XMLString::compareString(attra->getNodeName(), X("a:attra"))); + TASSERT(!XMLString::compareString(attra->getNamespaceURI(), X("http://nsa"))); - XMLString::transcode("a", tempStr2, 3999); - TASSERT(!XMLString::compareString(attra->getPrefix(), tempStr2)); + TASSERT(!XMLString::compareString(attra->getPrefix(), X("a"))); - XMLString::transcode("attra", tempStr2, 3999); - TASSERT(!XMLString::compareString(attra->getLocalName(), tempStr2)); - TASSERT(!XMLString::compareString(attra->getName(), tempStr)); + TASSERT(!XMLString::compareString(attra->getLocalName(), X("attra"))); + TASSERT(!XMLString::compareString(attra->getName(), X("a:attra"))); TASSERT(attra->getOwnerElement() == 0); - XMLString::transcode("attrb", tempStr2, 3999); - DOMAttr* attrb = doc->createAttributeNS(tempStr4, tempStr2); // URI, no prefix. - TASSERT(!XMLString::compareString(attrb->getNodeName(), tempStr2)); - TASSERT(!XMLString::compareString(attrb->getNamespaceURI(), tempStr4)); - TASSERT(!XMLString::compareString(attrb->getPrefix(), tempStr3)); - TASSERT(!XMLString::compareString(attrb->getLocalName(), tempStr2)); - TASSERT(!XMLString::compareString(attrb->getName(), tempStr2)); + DOMAttr* attrb = doc->createAttributeNS(X("http://nsb"), X("attrb")); // URI, no prefix. + TASSERT(!XMLString::compareString(attrb->getNodeName(), X("attrb"))); + TASSERT(!XMLString::compareString(attrb->getNamespaceURI(), X("http://nsb"))); + TASSERT(!XMLString::compareString(attrb->getPrefix(), XMLUni::fgZeroLenString)); + TASSERT(!XMLString::compareString(attrb->getLocalName(), X("attrb"))); + TASSERT(!XMLString::compareString(attrb->getName(), X("attrb"))); TASSERT(attrb->getOwnerElement() == 0); - XMLString::transcode("attrc", tempStr2, 3999); - DOMAttr* attrc = doc->createAttributeNS(tempStr3, tempStr2); - TASSERT(!XMLString::compareString(attrc->getNodeName(), tempStr2)); - TASSERT(!XMLString::compareString(attrc->getNamespaceURI(), tempStr3)); - TASSERT(!XMLString::compareString(attrc->getPrefix(), tempStr3)); - TASSERT(!XMLString::compareString(attrc->getLocalName(), tempStr2)); - TASSERT(!XMLString::compareString(attrc->getName(), tempStr2)); + DOMAttr* attrc = doc->createAttributeNS(XMLUni::fgZeroLenString, X("attrc")); + TASSERT(!XMLString::compareString(attrc->getNodeName(), X("attrc"))); + TASSERT(!XMLString::compareString(attrc->getNamespaceURI(), XMLUni::fgZeroLenString)); + TASSERT(!XMLString::compareString(attrc->getPrefix(), XMLUni::fgZeroLenString)); + TASSERT(!XMLString::compareString(attrc->getLocalName(), X("attrc"))); + TASSERT(!XMLString::compareString(attrc->getName(), X("attrc"))); TASSERT(attrc->getOwnerElement() == 0); // Badly formed qualified name - XMLString::transcode("<a", tempStr, 3999); - EXCEPTION_TEST(doc->createAttributeNS(tempStr5, tempStr), DOMException::INVALID_CHARACTER_ERR); + EXCEPTION_TEST(doc->createAttributeNS(X("http://nsa"), X("<a")), DOMException::INVALID_CHARACTER_ERR); - XMLString::transcode(":a", tempStr, 3999); - EXCEPTION_TEST(doc->createAttributeNS(tempStr5, tempStr), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(X("http://nsa"), X(":a")), DOMException::NAMESPACE_ERR); - XMLString::transcode("a:", tempStr, 3999); - EXCEPTION_TEST(doc->createAttributeNS(tempStr5, tempStr), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(X("http://nsa"), X("a:")), DOMException::NAMESPACE_ERR); - XMLString::transcode("a::a", tempStr, 3999); - EXCEPTION_TEST(doc->createAttributeNS(tempStr5, tempStr), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(X("http://nsa"), X("a::a")), DOMException::NAMESPACE_ERR); - XMLString::transcode("a:a:a", tempStr, 3999); - EXCEPTION_TEST(doc->createAttributeNS(tempStr5, tempStr), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(X("http://nsa"), X("a:a:a")), DOMException::NAMESPACE_ERR); // xml:a must have namespaceURI == "http://www.w3.org/XML/1998/namespace" - XMLString::transcode("http://www.w3.org/XML/1998/namespace", tempStr2, 3999); - XMLString::transcode("xml:a", tempStr, 3999); - TASSERT(!XMLString::compareString(doc->createAttributeNS(tempStr2, tempStr)->getNamespaceURI(), tempStr2)); - EXCEPTION_TEST(doc->createAttributeNS(tempStr5, tempStr), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createAttributeNS(tempStr3, tempStr), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createAttributeNS(0, tempStr), DOMException::NAMESPACE_ERR); + TASSERT(!XMLString::compareString(doc->createAttributeNS(X("http://www.w3.org/XML/1998/namespace"), X("xml:a"))->getNamespaceURI(), X("http://www.w3.org/XML/1998/namespace"))); + EXCEPTION_TEST(doc->createAttributeNS(X("http://nsa"), X("xml:a")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(XMLUni::fgZeroLenString, X("xml:a")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(0, X("xml:a")), DOMException::NAMESPACE_ERR); //unlike Element, xmlns must have namespaceURI == "http://www.w3.org/2000/xmlns/" - XMLString::transcode("http://www.w3.org/2000/xmlns/", tempStr4, 3999); - XMLString::transcode("xmlns", tempStr, 3999); - TASSERT(!XMLString::compareString(doc->createAttributeNS(tempStr4, tempStr)->getNamespaceURI(), tempStr4)); - EXCEPTION_TEST(doc->createAttributeNS(tempStr5, tempStr), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createAttributeNS(tempStr2, tempStr), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createAttributeNS(tempStr3, tempStr), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createAttributeNS(0, tempStr), DOMException::NAMESPACE_ERR); + TASSERT(!XMLString::compareString(doc->createAttributeNS(X("http://www.w3.org/2000/xmlns/"), X("xmlns"))->getNamespaceURI(), X("http://www.w3.org/2000/xmlns/"))); + EXCEPTION_TEST(doc->createAttributeNS(X("http://nsa"), X("xmlns")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(X("http://www.w3.org/XML/1998/namespace"), X("xmlns")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(XMLUni::fgZeroLenString, X("xmlns")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(0, X("xmlns")), DOMException::NAMESPACE_ERR); //unlike Element, xmlns:a must have namespaceURI == "http://www.w3.org/2000/xmlns/" - XMLString::transcode("xmlns:a", tempStr, 3999); - TASSERT(!XMLString::compareString(doc->createAttributeNS(tempStr4, tempStr)->getNamespaceURI(), tempStr4)); - EXCEPTION_TEST(doc->createAttributeNS(tempStr5, tempStr), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createAttributeNS(tempStr2, tempStr), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createAttributeNS(tempStr3, tempStr), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createAttributeNS(0, tempStr), DOMException::NAMESPACE_ERR); + TASSERT(!XMLString::compareString(doc->createAttributeNS(X("http://www.w3.org/2000/xmlns/"), X("xmlns:a"))->getNamespaceURI(), X("http://www.w3.org/2000/xmlns/"))); + EXCEPTION_TEST(doc->createAttributeNS(X("http://nsa"), X("xmlns:a")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(X("http://www.w3.org/XML/1998/namespace"), X("xmlns:a")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(XMLUni::fgZeroLenString, X("xmlns:a")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(0, X("xmlns:a")), DOMException::NAMESPACE_ERR); //In fact, any prefix != null should have a namespaceURI != 0 or != "" - XMLString::transcode("foo:a", tempStr, 3999); - TASSERT(!XMLString::compareString(doc->createAttributeNS(tempStr5, tempStr)->getNamespaceURI(), tempStr5)); - EXCEPTION_TEST(doc->createAttributeNS(tempStr3, tempStr), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(doc->createAttributeNS(0, tempStr), DOMException::NAMESPACE_ERR); + TASSERT(!XMLString::compareString(doc->createAttributeNS(X("http://nsa"), X("foo:a"))->getNamespaceURI(), X("http://nsa"))); + EXCEPTION_TEST(doc->createAttributeNS(XMLUni::fgZeroLenString, X("foo:a")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->createAttributeNS(0, X("foo:a")), DOMException::NAMESPACE_ERR); //Change prefix - DOMAttr* attr = doc->createAttributeNS(tempStr5, tempStr); - XMLString::transcode("bar", tempStr4, 3999); - XMLString::transcode("bar:a", tempStr, 3999); - XMLString::transcode("a", tempStr2, 3999); - attr->setPrefix(tempStr4); - - TASSERT(!XMLString::compareString(attr->getNodeName(), tempStr)); - TASSERT(!XMLString::compareString(attr->getNamespaceURI(), tempStr5)); - TASSERT(!XMLString::compareString(attr->getPrefix(), tempStr4)); - TASSERT(!XMLString::compareString(attr->getName(), tempStr)); + DOMAttr* attr = doc->createAttributeNS(X("http://nsa"), X("foo:a")); + attr->setPrefix(X("bar")); + + TASSERT(!XMLString::compareString(attr->getNodeName(), X("bar:a"))); + TASSERT(!XMLString::compareString(attr->getNamespaceURI(), X("http://nsa"))); + TASSERT(!XMLString::compareString(attr->getPrefix(), X("bar"))); + TASSERT(!XMLString::compareString(attr->getName(), X("bar:a"))); //The spec does not prevent us from setting prefix to a node without prefix - TASSERT(!XMLString::compareString(attr->getLocalName(), tempStr2)); - attr = doc->createAttributeNS(tempStr5, tempStr2); - TASSERT(!XMLString::compareString(attr->getPrefix(), tempStr3)); - attr->setPrefix(tempStr4); - TASSERT(!XMLString::compareString(attr->getNodeName(), tempStr)); - TASSERT(!XMLString::compareString(attr->getNamespaceURI(), tempStr5)); - TASSERT(!XMLString::compareString(attr->getPrefix(), tempStr4)); - TASSERT(!XMLString::compareString(attr->getLocalName(), tempStr2)); - TASSERT(!XMLString::compareString(attr->getName(), tempStr)); + TASSERT(!XMLString::compareString(attr->getLocalName(), X("a"))); + attr = doc->createAttributeNS(X("http://nsa"), X("a")); + TASSERT(!XMLString::compareString(attr->getPrefix(), XMLUni::fgZeroLenString)); + attr->setPrefix(X("bar")); + TASSERT(!XMLString::compareString(attr->getNodeName(), X("bar:a"))); + TASSERT(!XMLString::compareString(attr->getNamespaceURI(), X("http://nsa"))); + TASSERT(!XMLString::compareString(attr->getPrefix(), X("bar"))); + TASSERT(!XMLString::compareString(attr->getLocalName(), X("a"))); + TASSERT(!XMLString::compareString(attr->getName(), X("bar:a"))); //Special case for xml:a where namespaceURI must be xmlURI - XMLString::transcode("foo:a", tempStr, 3999); - XMLString::transcode("xml", tempStr4, 3999); - XMLString::transcode("http://www.w3.org/XML/1998/namespace", tempStr2, 3999); - - attr = doc->createAttributeNS(tempStr2, tempStr); - attr->setPrefix(tempStr4); - attr = doc->createAttributeNS(tempStr5, tempStr); - EXCEPTION_TEST(attr->setPrefix(tempStr4), DOMException::NAMESPACE_ERR); + attr = doc->createAttributeNS(X("http://www.w3.org/XML/1998/namespace"), X("foo:a")); + attr->setPrefix(X("xml")); + attr = doc->createAttributeNS(X("http://nsa"), X("foo:a")); + EXCEPTION_TEST(attr->setPrefix(X("xml")), DOMException::NAMESPACE_ERR); //Special case for xmlns:a where namespaceURI must be xmlURI - XMLString::transcode("http://www.w3.org/2000/xmlns/", tempStr2, 3999); - attr = doc->createAttributeNS(tempStr2, tempStr); + attr = doc->createAttributeNS(X("http://www.w3.org/2000/xmlns/"), X("foo:a")); - XMLString::transcode("xmlns", tempStr4, 3999); - attr->setPrefix(tempStr4); - attr = doc->createAttributeNS(tempStr5, tempStr); - EXCEPTION_TEST(attr->setPrefix(tempStr4), DOMException::NAMESPACE_ERR); + attr->setPrefix(X("xmlns")); + attr = doc->createAttributeNS(X("http://nsa"), X("foo:a")); + EXCEPTION_TEST(attr->setPrefix(X("xmlns")), DOMException::NAMESPACE_ERR); //Special case for xmlns where no prefix can be set - attr = doc->createAttributeNS(tempStr2, tempStr4); + attr = doc->createAttributeNS(X("http://www.w3.org/2000/xmlns/"), X("xmlns")); - XMLString::transcode("foo", tempStr, 3999); - EXCEPTION_TEST(attr->setPrefix(tempStr), DOMException::NAMESPACE_ERR); - EXCEPTION_TEST(attr->setPrefix(tempStr4), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(attr->setPrefix(X("foo")), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(attr->setPrefix(X("xmlns")), DOMException::NAMESPACE_ERR); //Also an attribute can not have a prefix with namespaceURI == null or "" - XMLString::transcode("a", tempStr4, 3999); - attr = doc->createAttributeNS(0, tempStr4); - EXCEPTION_TEST(attr->setPrefix(tempStr), DOMException::NAMESPACE_ERR); - attr = doc->createAttributeNS(tempStr3, tempStr4); - EXCEPTION_TEST(attr->setPrefix(tempStr), DOMException::NAMESPACE_ERR); + attr = doc->createAttributeNS(XMLUni::fgZeroLenString, X("a")); + EXCEPTION_TEST(attr->setPrefix(X("foo")), DOMException::NAMESPACE_ERR); + attr = doc->createAttributeNS(0, X("a")); + EXCEPTION_TEST(attr->setPrefix(X("foo")), DOMException::NAMESPACE_ERR); //Only prefix of Element and Attribute can be changed - EXCEPTION_TEST(doc->setPrefix(tempStr), DOMException::NAMESPACE_ERR); + EXCEPTION_TEST(doc->setPrefix(X("foo")), DOMException::NAMESPACE_ERR); //Prefix of readonly Attribute can not be changed. //However, there is no way to create such DOMAttribute for testing yet. @@ -1309,45 +1158,30 @@ void DOMNSTests() // Set up an initial (root element only) document. // - DOMImplementation* impl = DOMImplementation::getImplementation(); - - XMLString::transcode("foo:docName", tempStr3, 3999); - XMLString::transcode("pubId", tempStr2, 3999); - XMLString::transcode( "http://sysId", tempStr, 3999); - - - DOMDocumentType* dt = impl->createDocumentType(tempStr3, tempStr2, tempStr); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); + DOMDocumentType* dt = impl->createDocumentType(X("foo:docName"), X("pubId"), X("http://sysId")); - XMLString::transcode("http://document.namespace", tempStr2, 3999); - DOMDocument* doc = impl->createDocument(tempStr2, tempStr3, dt); + DOMDocument* doc = impl->createDocument(X("http://document.namespace"), X("foo:docName"), dt); DOMElement* rootEl = doc->getDocumentElement(); // // Populate the document // - XMLString::transcode("http://nsa", tempStr5, 3999); - XMLString::transcode("http://nsb", tempStr4, 3999); - XMLString::transcode("", tempStr3, 3999); - XMLString::transcode("a:ela", tempStr, 3999); - DOMElement* ela = doc->createElementNS(tempStr5, tempStr); + DOMElement* ela = doc->createElementNS(X("http://nsa"), X("a:ela")); rootEl->appendChild(ela); - XMLString::transcode("elb", tempStr2, 3999); - DOMElement* elb = doc->createElementNS(tempStr4, tempStr2); + DOMElement* elb = doc->createElementNS(X("http://nsb"), X("elb")); rootEl->appendChild(elb); - XMLString::transcode("elc", tempStr, 3999); - DOMElement* elc = doc->createElementNS(tempStr3, tempStr); + DOMElement* elc = doc->createElementNS(XMLUni::fgZeroLenString, X("elc")); rootEl->appendChild(elc); - XMLString::transcode("d:ela", tempStr, 3999); - DOMElement* eld = doc->createElementNS(tempStr5, tempStr); + DOMElement* eld = doc->createElementNS(X("http://nsa"), X("d:ela")); rootEl->appendChild(eld); - XMLString::transcode("http://nse", tempStr, 3999); - DOMElement* ele = doc->createElementNS(tempStr, tempStr2); + DOMElement* ele = doc->createElementNS(X("http://nse"), X("elb")); rootEl->appendChild(ele); @@ -1357,18 +1191,16 @@ void DOMNSTests() DOMNodeList* nl; - XMLString::transcode("a:ela", tempStr, 3999); - nl = doc->getElementsByTagName(tempStr); + nl = doc->getElementsByTagName(X("a:ela")); TASSERT(nl->getLength() == 1); TASSERT(nl->item(0) == ela); - nl = doc->getElementsByTagName(tempStr2); + nl = doc->getElementsByTagName(X("elb")); TASSERT(nl->getLength() == 2); TASSERT(nl->item(0) == elb); TASSERT(nl->item(1) == ele); - XMLString::transcode("d:ela", tempStr, 3999); - nl = doc->getElementsByTagName(tempStr); + nl = doc->getElementsByTagName(X("d:ela")); TASSERT(nl->getLength() == 1); TASSERT(nl->item(0) == eld); @@ -1376,51 +1208,47 @@ void DOMNSTests() // Access with DOM Level 2 getElementsByTagNameNS // - XMLString::transcode("elc", tempStr, 3999); - nl = doc->getElementsByTagNameNS(tempStr3, tempStr); + nl = doc->getElementsByTagNameNS(XMLUni::fgZeroLenString, X("elc")); TASSERT(nl->getLength() == 1); TASSERT(nl->item(0) == elc); - nl = doc->getElementsByTagNameNS(0, tempStr); + nl = doc->getElementsByTagNameNS(0, X("elc")); TASSERT(nl->getLength() == 1); TASSERT(nl->item(0) == elc); - XMLString::transcode("ela", tempStr, 3999); - nl = doc->getElementsByTagNameNS(tempStr5, tempStr); + nl = doc->getElementsByTagNameNS(X("http://nsa"), X("ela")); TASSERT(nl->getLength() == 2); TASSERT(nl->item(0) == ela); TASSERT(nl->item(1) == eld); - nl = doc->getElementsByTagNameNS(tempStr3, tempStr2); + nl = doc->getElementsByTagNameNS(XMLUni::fgZeroLenString, X("elb")); TASSERT(nl->getLength() == 0); - nl = doc->getElementsByTagNameNS(tempStr4, tempStr2); + nl = doc->getElementsByTagNameNS(X("http://nsb"), X("elb")); TASSERT(nl->getLength() == 1); TASSERT(nl->item(0) == elb); - XMLString::transcode("*", tempStr, 3999); - nl = doc->getElementsByTagNameNS(tempStr, tempStr2); + nl = doc->getElementsByTagNameNS(X("*"), X("elb")); TASSERT(nl->getLength() == 2); TASSERT(nl->item(0) == elb); TASSERT(nl->item(1) == ele); - nl = doc->getElementsByTagNameNS(tempStr5, tempStr); + nl = doc->getElementsByTagNameNS(X("http://nsa"), X("*")); TASSERT(nl->getLength() == 2); TASSERT(nl->item(0) == ela); TASSERT(nl->item(1) == eld); - nl = doc->getElementsByTagNameNS(tempStr, tempStr); + nl = doc->getElementsByTagNameNS(X("*"), X("*")); TASSERT(nl->getLength() == 6); // Gets the document root element, plus 5 more TASSERT(nl->item(6) == 0); // TASSERT(nl->item(-1) == 0); - nl = rootEl->getElementsByTagNameNS(tempStr, tempStr); + nl = rootEl->getElementsByTagNameNS(X("*"), X("*")); TASSERT(nl->getLength() == 5); - XMLString::transcode("d:ela", tempStr2, 3999); - nl = doc->getElementsByTagNameNS(tempStr5, tempStr2); + nl = doc->getElementsByTagNameNS(X("http://nsa"), X("d:ela")); TASSERT(nl->getLength() == 0); @@ -1428,8 +1256,8 @@ void DOMNSTests() // Node lists are Live // - nl = doc->getElementsByTagNameNS(tempStr, tempStr); - DOMNodeList* nla = ela->getElementsByTagNameNS(tempStr, tempStr); + nl = doc->getElementsByTagNameNS(X("*"), X("*")); + DOMNodeList* nla = ela->getElementsByTagNameNS(X("*"), X("*")); TASSERT(nl->getLength() == 6); TASSERT(nla->getLength() == 0); @@ -1455,94 +1283,72 @@ void DOMNSTests() // Set up an initial (root element only) document. // - DOMImplementation* impl = DOMImplementation::getImplementation(); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); - XMLString::transcode("foo:docName", tempStr, 3999); - XMLString::transcode("pubId", tempStr2, 3999); - XMLString::transcode("http://sysId", tempStr3, 3999); - DOMDocumentType* dt = impl->createDocumentType(tempStr, tempStr2, tempStr3); + DOMDocumentType* dt = impl->createDocumentType(X("foo:docName"), X("pubId"), X("http://sysId")); - XMLString::transcode("http://document.namespace", tempStr2, 3999); - DOMDocument* doc = impl->createDocument(tempStr2, tempStr, dt); + DOMDocument* doc = impl->createDocument(X("http://document.namespace"), X("foo:docName"), dt); DOMElement* rootEl = doc->getDocumentElement(); // // Create a set of attributes and hang them on the root element. // - XMLString::transcode("http://nsa", tempStr5, 3999); - XMLString::transcode("http://nsb", tempStr4, 3999); - XMLString::transcode("", tempStr3, 3999); - XMLString::transcode("a:attra", tempStr2, 3999); - DOMAttr* attra = doc->createAttributeNS(tempStr5, tempStr2); + DOMAttr* attra = doc->createAttributeNS(X("http://nsa"), X("a:attra")); rootEl->setAttributeNodeNS(attra); - XMLString::transcode("attrb", tempStr, 3999); - DOMAttr* attrb = doc->createAttributeNS(tempStr4, tempStr); + DOMAttr* attrb = doc->createAttributeNS(X("http://nsb"), X("attrb")); rootEl->setAttributeNodeNS(attrb); - XMLString::transcode("attrc", tempStr, 3999); - DOMAttr* attrc = doc->createAttributeNS(tempStr3, tempStr); + DOMAttr* attrc = doc->createAttributeNS(XMLUni::fgZeroLenString, X("attrc")); rootEl->setAttributeNodeNS(attrc); - XMLString::transcode("d:attra", tempStr, 3999); - DOMAttr* attrd = doc->createAttributeNS(tempStr5, tempStr); + DOMAttr* attrd = doc->createAttributeNS(X("http://nsa"), X("d:attra")); rootEl->setAttributeNodeNS(attrd); - XMLString::transcode("http://nse", tempStr2, 3999); - XMLString::transcode("attrb", tempStr, 3999); - DOMAttr* attre = doc->createAttributeNS(tempStr2, tempStr); + DOMAttr* attre = doc->createAttributeNS(X("http://nse"), X("attrb")); rootEl->setAttributeNodeNS(attre); // // Check that the attribute nodes were created with the correct properties. // - XMLString::transcode("a:attra", tempStr2, 3999); - TASSERT(!XMLString::compareString(attra->getNodeName(), tempStr2)); - TASSERT(!XMLString::compareString(attra->getNamespaceURI(), tempStr5)); + TASSERT(!XMLString::compareString(attra->getNodeName(), X("a:attra"))); + TASSERT(!XMLString::compareString(attra->getNamespaceURI(), X("http://nsa"))); - XMLString::transcode("attra", tempStr, 3999); - TASSERT(!XMLString::compareString(attra->getLocalName(), tempStr)); - TASSERT(!XMLString::compareString(attra->getName(), tempStr2)); + TASSERT(!XMLString::compareString(attra->getLocalName(), X("attra"))); + TASSERT(!XMLString::compareString(attra->getName(), X("a:attra"))); TASSERT(attra->getNodeType() == DOMNode::ATTRIBUTE_NODE); - TASSERT(!XMLString::compareString(attra->getNodeValue(), tempStr3)); + TASSERT(!XMLString::compareString(attra->getNodeValue(), XMLUni::fgZeroLenString)); - XMLString::transcode("a", tempStr, 3999); - TASSERT(!XMLString::compareString(attra->getPrefix(), tempStr)); + TASSERT(!XMLString::compareString(attra->getPrefix(), X("a"))); TASSERT(attra->getSpecified() == true); - TASSERT(!XMLString::compareString(attra->getValue(), tempStr3)); + TASSERT(!XMLString::compareString(attra->getValue(), XMLUni::fgZeroLenString)); TASSERT(attra->getOwnerElement() == 0); // Test methods of NamedNodeMap DOMNamedNodeMap* nnm = rootEl->getAttributes(); TASSERT(nnm->getLength() == 4); - XMLString::transcode("attra", tempStr2, 3999); - XMLString::transcode("attrb", tempStr, 3999); - TASSERT(nnm->getNamedItemNS(tempStr5, tempStr2) == attrd); - TASSERT(nnm->getNamedItemNS(tempStr4, tempStr) == attrb); - TASSERT(nnm->getNamedItemNS(tempStr3, tempStr2) == 0); - TASSERT(nnm->getNamedItemNS(tempStr5, tempStr) == 0); + TASSERT(nnm->getNamedItemNS(X("http://nsa"), X("attra")) == attrd); + TASSERT(nnm->getNamedItemNS(X("http://nsb"), X("attrb")) == attrb); + TASSERT(nnm->getNamedItemNS(XMLUni::fgZeroLenString, X("attra")) == 0); + TASSERT(nnm->getNamedItemNS(X("http://nsa"), X("attrb")) == 0); - XMLString::transcode("http://nse", tempStr2, 3999); - TASSERT(nnm->getNamedItemNS(tempStr2, tempStr) == attre); + TASSERT(nnm->getNamedItemNS(X("http://nse"), X("attrb")) == attre); - XMLString::transcode("attrc", tempStr2, 3999); - TASSERT(nnm->getNamedItemNS(tempStr3, tempStr2) == attrc); + TASSERT(nnm->getNamedItemNS(XMLUni::fgZeroLenString, X("attrc")) == attrc); // Test hasAttributes, hasAttribute, hasAttributeNS TASSERT(doc->hasAttributes() == false); TASSERT(attrc->hasAttributes() == false); TASSERT(rootEl->hasAttributes() == true); - TASSERT(rootEl->hasAttribute(tempStr2) == true); + TASSERT(rootEl->hasAttribute(X("attrc")) == true); - XMLString::transcode("wrong", tempStr, 3999); - TASSERT(rootEl->hasAttribute(tempStr) == false); + TASSERT(rootEl->hasAttribute(X("wrong")) == false); - XMLString::transcode("attra", tempStr2, 3999); - TASSERT(rootEl->hasAttributeNS(tempStr5, tempStr2) == true); - TASSERT(rootEl->hasAttributeNS(tempStr5, tempStr) == false); + TASSERT(rootEl->hasAttributeNS(X("http://nsa"), X("attra")) == true); + TASSERT(rootEl->hasAttributeNS(X("http://nsa"), X("wrong")) == false); delete doc; delete dt; } diff --git a/tests/DOM/DOMTest/DTest.cpp b/tests/DOM/DOMTest/DTest.cpp index 5df0d357f27228bad587fb9079d5b00b90b57b5a..12fe3c6c0e4ae256c798565040e73c74fec4d878 100644 --- a/tests/DOM/DOMTest/DTest.cpp +++ b/tests/DOM/DOMTest/DTest.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.20 2002/06/03 20:51:21 tng + * DOM L3: Add DOMImplementationRegistry and DOMImplementationSource + * * Revision 1.19 2002/05/21 18:50:16 tng * Test case update: modify to use the latest DOM interface * @@ -151,7 +154,10 @@ DOMTest::DOMTest() * */ DOMDocument* DOMTest::createDocument() { - DOMImplementation* impl = DOMImplementation::getImplementation(); + XMLCh coreStr[100]; + XMLString::transcode("Core",coreStr,99); + + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(coreStr); return impl->createDocument(); }; diff --git a/tests/DOM/RangeTest/RangeTest.cpp b/tests/DOM/RangeTest/RangeTest.cpp index 3ded642345c76a688a1890a221ae9ea0e5f5a87e..349ca03369d3c473b327d116773b548a9c1aa76f 100644 --- a/tests/DOM/RangeTest/RangeTest.cpp +++ b/tests/DOM/RangeTest/RangeTest.cpp @@ -212,8 +212,10 @@ int main() */ { + XMLCh tempStr[100]; + XMLString::transcode("Core",tempStr,99); { - DOMImplementation* impl = DOMImplementation::getImplementation(); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(tempStr); DOMDocument* doc = impl->createDocument(); //Creating a root element @@ -247,7 +249,7 @@ int main() { //DOM Tree and some usable node creation - DOMImplementation* impl = DOMImplementation::getImplementation(); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(tempStr); DOMDocument* doc = impl->createDocument(); //Creating a root element @@ -586,7 +588,7 @@ int main() //another set of test //TEST createRange, setStart and setEnd, insertnode //*************************************************************** - DOMImplementation* impl2 = DOMImplementation::getImplementation(); + DOMImplementation* impl2 = DOMImplementationRegistry::getDOMImplementation(tempStr); DOMDocument* doc2 = impl2->createDocument(); DOMElement* root2 = doc2->createElement(xroot2); @@ -842,7 +844,7 @@ int main() // | | | // b "Hello cd" "ef" // - DOMImplementation* impl3 = DOMImplementation::getImplementation(); + DOMImplementation* impl3 = DOMImplementationRegistry::getDOMImplementation(tempStr); DOMDocument* doc3 = impl3->createDocument(); DOMElement* root3 = doc3->createElement(xroot); diff --git a/tests/DOM/Traversal/Traversal.cpp b/tests/DOM/Traversal/Traversal.cpp index 87bbc23e26c95d3a50f3f20e66aff96a969b6796..fda922194a637bb12249031e3bb3d38acf6ae01c 100644 --- a/tests/DOM/Traversal/Traversal.cpp +++ b/tests/DOM/Traversal/Traversal.cpp @@ -66,6 +66,9 @@ /** * $Log$ + * Revision 1.10 2002/06/03 20:51:46 tng + * DOM L3: Add DOMImplementationRegistry and DOMImplementationSource + * * Revision 1.9 2002/05/27 21:11:26 tng * Add DOMDocumentRange and DOMDocumentTraversal. * @@ -184,6 +187,9 @@ int main() // Create a XMLCh buffer for string manipulation XMLCh tempStr[4000]; + XMLCh coreStr[100]; + XMLString::transcode("Core",coreStr,99); + // @@ -205,7 +211,7 @@ int main() - comment */ - DOMImplementation* impl = DOMImplementation::getImplementation(); + DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(coreStr); DOMDocument* doc = impl->createDocument(); //Creating a root element