You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sc...@apache.org on 2017/07/29 20:43:21 UTC

svn commit: r1803393 - in /xerces/c/trunk: ./ cmake/ config/ scripts/ src/xercesc/util/MsgLoaders/Win32/ src/xercesc/util/NetAccessors/MacOSURLAccessCF/ src/xercesc/util/Transcoders/Win32/ tests/ tests/scripts/ tests/src/Char16Test/

Author: scantor
Date: Sat Jul 29 20:43:21 2017
New Revision: 1803393

URL: http://svn.apache.org/viewvc?rev=1803393&view=rev
Log:
XERCESC-2101 - Add support for XERCES_XMLCH_T = char16_t

Added:
    xerces/c/trunk/tests/scripts/Char16Test
    xerces/c/trunk/tests/src/Char16Test/   (with props)
    xerces/c/trunk/tests/src/Char16Test/Char16Test.cpp
Modified:
    xerces/c/trunk/cmake/XercesXMLCh.cmake
    xerces/c/trunk/config/   (props changed)
    xerces/c/trunk/config.h.cmake.in
    xerces/c/trunk/configure.ac
    xerces/c/trunk/scripts/   (props changed)
    xerces/c/trunk/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp
    xerces/c/trunk/src/xercesc/util/NetAccessors/MacOSURLAccessCF/URLAccessCFBinInputStream.cpp
    xerces/c/trunk/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp
    xerces/c/trunk/tests/CMakeLists.txt
    xerces/c/trunk/tests/Makefile.am

Modified: xerces/c/trunk/cmake/XercesXMLCh.cmake
URL: http://svn.apache.org/viewvc/xerces/c/trunk/cmake/XercesXMLCh.cmake?rev=1803393&r1=1803392&r2=1803393&view=diff
==============================================================================
--- xerces/c/trunk/cmake/XercesXMLCh.cmake (original)
+++ xerces/c/trunk/cmake/XercesXMLCh.cmake Sat Jul 29 20:43:21 2017
@@ -23,12 +23,37 @@
 # while it is not true on Unix)
 
 include(CheckCXXSourceCompiles)
+include(CheckTypeSize)
 include(XercesIntTypes)
 
 set(XERCES_XMLCH_T ${XERCES_U16BIT_INT})
+set(XERCES_USE_CHAR16_T 0)
 set(XERCES_INCLUDE_WCHAR_H 0)
-if(WIN32)
-  check_cxx_source_compiles("
+
+check_cxx_source_compiles("
+int main() {
+  const char16_t *unicode = u\"Test ünícodè → ©\";
+  return 0;
+}" HAVE_STD_char16_t)
+
+if(HAVE_STD_char16_t)
+  check_type_size("char16_t" SIZEOF_CHAR16_T LANGUAGE CXX)
+  check_type_size("wchar_t" SIZEOF_WCHAR_T LANGUAGE CXX)
+
+  if(NOT SIZEOF_CHAR16_T EQUAL 2)
+    message(FATAL_ERROR "char16_t is not a 16-bit type")
+  endif()
+  if(WIN32)
+    if(NOT SIZEOF_WCHAR_T EQUAL 2)
+      message(FATAL_ERROR "wchar_t is not a 16-bit type, and size differs from char16_t")
+    endif()
+  endif()
+
+  set(XERCES_XMLCH_T char16_t)
+  set(XERCES_USE_CHAR16_T 1)
+else()
+  if(WIN32)
+    check_cxx_source_compiles("
 #include <windows.h>
 
 wchar_t file[] = L\"dummy.file\";
@@ -37,10 +62,11 @@ int main() {
   DeleteFileW(file);
   return 0;
 }"
-    WINDOWS_wchar)
+      WINDOWS_wchar)
 
-  if(WINDOWS_wchar)
-    set(XERCES_XMLCH_T wchar_t)
-    set(XERCES_INCLUDE_WCHAR_H 1)
+    if(WINDOWS_wchar)
+      set(XERCES_XMLCH_T wchar_t)
+      set(XERCES_INCLUDE_WCHAR_H 1)
+    endif()
   endif()
 endif()

Propchange: xerces/c/trunk/config/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sat Jul 29 20:43:21 2017
@@ -5,3 +5,4 @@ depcomp
 install-sh
 ltmain.sh
 missing
+test-driver

Modified: xerces/c/trunk/config.h.cmake.in
URL: http://svn.apache.org/viewvc/xerces/c/trunk/config.h.cmake.in?rev=1803393&r1=1803392&r2=1803393&view=diff
==============================================================================
--- xerces/c/trunk/config.h.cmake.in (original)
+++ xerces/c/trunk/config.h.cmake.in Sat Jul 29 20:43:21 2017
@@ -466,6 +466,9 @@
 /* Define to use the Windows transcoder */
 #cmakedefine XERCES_USE_TRANSCODER_WINDOWS 1
 
+/* Define to use the Windows transcode */
+#cmakedefine XERCES_USE_CHAR16_T 1
+
 /* Define to the 16 bit type used to represent Xerces UTF-16 characters */
 #define XERCES_XMLCH_T @XERCES_XMLCH_T@
 

Modified: xerces/c/trunk/configure.ac
URL: http://svn.apache.org/viewvc/xerces/c/trunk/configure.ac?rev=1803393&r1=1803392&r2=1803393&view=diff
==============================================================================
--- xerces/c/trunk/configure.ac (original)
+++ xerces/c/trunk/configure.ac Sat Jul 29 20:43:21 2017
@@ -332,22 +332,41 @@ AS_IF([test ! $ac_cv_cxx_have_bool],
 AS_IF([test $ac_cv_cxx_have_lstring],
 	AC_DEFINE([XERCES_LSTRSUPPORT], 1, [Define if there is support for L"widestring"]))
 
-# check if the Windows API is defined as using wchar_t or unsigned short; if it's wchar_t, we need to map XMLCh to be wchar_t
-# (this is safe because on Windows wchar_t is used to store UTF-16 codepoints, while it is not true on Unix)
-AC_MSG_CHECKING([whether the Windows SDK is available and using wchar_t as wide string])
-AC_COMPILE_IFELSE(  [AC_LANG_PROGRAM([[#include <windows.h>
-                                        wchar_t file[] = L"dummy.file";]],
-                                     [[DeleteFileW(file);]])],
+AC_MSG_CHECKING([whether C++11 char16_t is available])
+AC_COMPILE_IFELSE(  [AC_LANG_PROGRAM([[]],
+                                     [[const char16_t *unicode = u"Test ünícodè → ©";]])],
                     [
-                      xerces_cv_type_xmlch=wchar_t
+                      xerces_cv_type_xmlch=char16_t
+                      AC_DEFINE_UNQUOTED([XERCES_USE_CHAR16_T], [1], [Define if the C++11 char16_t type is to be used])
                       AC_MSG_RESULT([yes])
-                      AC_DEFINE_UNQUOTED([XERCES_INCLUDE_WCHAR_H], 1, [Define to have Xerces_autoconf_config.hpp include wchar.h])
                     ],
                     [
                       xerces_cv_type_xmlch=$xerces_cv_type_u16bit_int
                       AC_MSG_RESULT([no])
                     ]
                  )
+AM_CONDITIONAL([XERCES_USE_CHAR16], [test "x$xerces_cv_type_xmlch" = "xchar16_t"])
+
+if test "$xerces_cv_type_xmlch" != "char16_t"; then
+# fallback to check if the Windows API is defined as using wchar_t or
+# unsigned short; if it's wchar_t, we need to map XMLCh to be wchar_t
+# (this is safe because on Windows wchar_t is used to store UTF-16
+# codepoints, while it is not true on Unix)
+        AC_MSG_CHECKING([whether the Windows SDK is available and using wchar_t as wide string])
+        AC_COMPILE_IFELSE(  [AC_LANG_PROGRAM([[#include <windows.h>
+                                                wchar_t file[] = L"dummy.file";]],
+                                             [[DeleteFileW(file);]])],
+                            [
+                              xerces_cv_type_xmlch=wchar_t
+                              AC_MSG_RESULT([yes])
+                              AC_DEFINE_UNQUOTED([XERCES_INCLUDE_WCHAR_H], 1, [Define to have Xerces_autoconf_config.hpp include wchar.h])
+                            ],
+                            [
+                              xerces_cv_type_xmlch=$xerces_cv_type_u16bit_int
+                              AC_MSG_RESULT([no])
+                            ]
+                         )
+fi
 
 AC_DEFINE_UNQUOTED([XERCES_XMLCH_T], [$xerces_cv_type_xmlch], [Define to the 16 bit type used to represent Xerces UTF-16 characters])
 

Propchange: xerces/c/trunk/scripts/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Jul 29 20:43:21 2017
@@ -0,0 +1 @@
+run-test

Modified: xerces/c/trunk/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp?rev=1803393&r1=1803392&r2=1803393&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp Sat Jul 29 20:43:21 2017
@@ -173,7 +173,11 @@ bool Win32MsgLoader::loadMsg(const  XMLM
     const XMLSize_t actualChars = ((maxChars < (XMLSize_t)*pBlock) ? maxChars : (XMLSize_t)*pBlock);
 
     // Ok, finally now copy as much as we can into the caller's buffer
+#if defined(XERCES_USE_CHAR16_T)
+    wcsncpy(reinterpret_cast<wchar_t *>(toFill), reinterpret_cast<const wchar_t *>(pBlock + 1), actualChars);
+#else
     wcsncpy(toFill, pBlock + 1, actualChars);
+#endif
     toFill[actualChars] = 0;
 
     return true;

Modified: xerces/c/trunk/src/xercesc/util/NetAccessors/MacOSURLAccessCF/URLAccessCFBinInputStream.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/NetAccessors/MacOSURLAccessCF/URLAccessCFBinInputStream.cpp?rev=1803393&r1=1803392&r2=1803393&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/NetAccessors/MacOSURLAccessCF/URLAccessCFBinInputStream.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/NetAccessors/MacOSURLAccessCF/URLAccessCFBinInputStream.cpp Sat Jul 29 20:43:21 2017
@@ -44,7 +44,7 @@ URLAccessCFBinInputStream::URLAccessCFBi
     {
         stringRef = CFStringCreateWithCharacters(
             kCFAllocatorDefault,
-            urlText,
+            reinterpret_cast<const UniChar *>(urlText),
             urlLength
             );
     }

Modified: xerces/c/trunk/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp?rev=1803393&r1=1803392&r2=1803393&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp Sat Jul 29 20:43:21 2017
@@ -132,6 +132,44 @@ int _wcsicmp(LPCWSTR comp1, LPCWSTR comp
 }
 #endif
 
+
+static inline void xmlch_wcsupr(XMLCh* str)
+{
+#ifdef XERCES_USE_CHAR16_T
+    _wcsupr(reinterpret_cast<LPWSTR>(str));
+#else
+    _wcsupr(str);
+#endif
+}
+
+static inline int xmlch_wcsicmp(const XMLCh* comp1, const XMLCh* comp2)
+{
+#ifdef XERCES_USE_CHAR16_T
+    return _wcsicmp(reinterpret_cast<LPCWSTR>(comp1), reinterpret_cast<LPCWSTR>(comp2));
+#else
+    return _wcsicmp(comp1, comp2);
+#endif
+}
+
+static inline int xmlch_wcsnicmp(const XMLCh* comp1, const XMLCh* comp2, const XMLSize_t maxChars)
+{
+#ifdef XERCES_USE_CHAR16_T
+    return _wcsnicmp(reinterpret_cast<LPCWSTR>(comp1), reinterpret_cast<LPCWSTR>(comp2), maxChars);
+#else
+    return _wcsnicmp(comp1, comp2, maxChars);
+#endif
+}
+
+static inline void xmlch_wcslwr(XMLCh* str)
+{
+#ifdef XERCES_USE_CHAR16_T
+    _wcslwr(reinterpret_cast<LPWSTR>(str));
+#else
+    _wcslwr(str);
+#endif
+}
+
+
 // it's a local function (instead of a static function) so that we are not 
 // forced to include <windows.h> in the header
 bool isAlias(const   HKEY            encodingKey
@@ -235,7 +273,7 @@ CPMapEntry::CPMapEntry( const   char* co
         //  Upper case it because we are using a hash table and need to be
         //  sure that we find all case combinations.
         //
-        _wcsupr(fEncodingName);
+        xmlch_wcsupr(fEncodingName);
   }
 }
 
@@ -253,7 +291,7 @@ CPMapEntry::CPMapEntry( const   XMLCh* c
     //  Upper case it because we are using a hash table and need to be
     //  sure that we find all case combinations.
     //
-    _wcsupr(fEncodingName);
+    xmlch_wcsupr(fEncodingName);
 }
 
 CPMapEntry::~CPMapEntry()
@@ -478,7 +516,7 @@ Win32TransService::Win32TransService(Mem
                 );//new XMLCh[targetLen + 1];
                 ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, aliasBuf, -1, (LPWSTR)uniAlias, targetLen);
                 uniAlias[targetLen] = 0;
-                _wcsupr(uniAlias);
+                xmlch_wcsupr(uniAlias);
 
                 // Look up the alias name
                 CPMapEntry* aliasedEntry = fCPMap->get(uniAlias);
@@ -493,7 +531,7 @@ Win32TransService::Win32TransService(Mem
                         );//new XMLCh[targetLen + 1];
                         ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, nameBuf, -1, (LPWSTR)uniName, targetLen);
                         uniName[targetLen] = 0;
-                        _wcsupr(uniName);
+                        xmlch_wcsupr(uniName);
 
                         //
                         //  If the name is actually different, then take it.
@@ -533,7 +571,7 @@ Win32TransService::~Win32TransService()
 int Win32TransService::compareIString(  const   XMLCh* const    comp1
                                         , const XMLCh* const    comp2)
 {
-    return _wcsicmp(comp1, comp2);
+    return xmlch_wcsicmp(comp1, comp2);
 }
 
 
@@ -541,7 +579,7 @@ int Win32TransService::compareNIString(
                                         , const XMLCh* const    comp2
                                         , const XMLSize_t       maxChars)
 {
-    return _wcsnicmp(comp1, comp2, maxChars);
+    return xmlch_wcsnicmp(comp1, comp2, maxChars);
 }
 
 
@@ -570,12 +608,12 @@ bool Win32TransService::supportsSrcOfs()
 
 void Win32TransService::upperCase(XMLCh* const toUpperCase)
 {
-    _wcsupr(toUpperCase);
+    xmlch_wcsupr(toUpperCase);
 }
 
 void Win32TransService::lowerCase(XMLCh* const toLowerCase)
 {
-    _wcslwr(toLowerCase);
+    xmlch_wcslwr(toLowerCase);
 }
 
 XMLTranscoder*
@@ -592,7 +630,7 @@ Win32TransService::makeNewXMLTranscoder(
     //  table and we store them all in upper case.
     //
     XMLString::copyNString(upEncoding, encodingName, upLen);
-    _wcsupr(upEncoding);
+    xmlch_wcsupr(upEncoding);
 
     // Now to try to find this guy in the CP map
     CPMapEntry* theEntry = fCPMap->get(upEncoding);
@@ -744,7 +782,7 @@ Win32Transcoder::transcodeFrom( const
             , fFromFlags
             , (const char*)inPtr
             , toEat
-            , outPtr
+            , reinterpret_cast<LPWSTR>(outPtr)
             , 1
         );
 
@@ -816,7 +854,7 @@ Win32Transcoder::transcodeTo(const  XMLC
         (
             fIECP
             , fToFlags
-            , srcPtr
+            , reinterpret_cast<LPCWSTR>(srcPtr)
             , 1
             , (char*)outPtr
             , (int)(outEnd - outPtr)
@@ -890,7 +928,7 @@ bool Win32Transcoder::canTranscodeTo(con
     (
         fIECP
         , fToFlags
-        , srcBuf
+        , reinterpret_cast<LPCWSTR>(srcBuf)
         , srcCount
         , tmpBuf
         , 64
@@ -944,7 +982,7 @@ XMLSize_t Win32LCPTranscoder::calcRequir
     if (!srcText)
         return 0;
 
-    return ::WideCharToMultiByte(CP_ACP, 0, srcText, -1, NULL, 0, NULL, NULL);
+    return ::WideCharToMultiByte(CP_ACP, 0, reinterpret_cast<LPCWSTR>(srcText), -1, NULL, 0, NULL, NULL);
 }
 
 char* Win32LCPTranscoder::transcode(const XMLCh* const toTranscode,

Modified: xerces/c/trunk/tests/CMakeLists.txt
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/CMakeLists.txt?rev=1803393&r1=1803392&r2=1803393&view=diff
==============================================================================
--- xerces/c/trunk/tests/CMakeLists.txt (original)
+++ xerces/c/trunk/tests/CMakeLists.txt Sat Jul 29 20:43:21 2017
@@ -153,6 +153,15 @@ add_test_executable(XSValueTest
   src/XSValueTest/XSValueTest.hpp
 )
 
+if(XERCES_XMLCH_T STREQUAL "char16_t")
+  add_test_executable(Char16Test
+    src/Char16Test/Char16Test.cpp
+  )
+  if(MSVC)
+    set_target_properties(Char16Test PROPERTIES COMPILE_FLAGS "/utf-8")
+  endif()
+endif()
+
 # Run tests
 include(XercesTest)
 
@@ -195,3 +204,7 @@ add_xerces_test(MemHandlerTest1  COMMAND
 add_xerces_test(MemHandlerTest2  COMMAND MemHandlerTest -v=always -n -r=2 -s -f personal-schema.xml)
 
 add_xerces_test(DOMTypeInfoTest WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/DOM/TypeInfo" COMMAND DOMTypeInfoTest)
+
+if(XERCES_XMLCH_T STREQUAL "char16_t")
+  add_xerces_test(Char16Test       COMMAND Char16Test)
+endif()

Modified: xerces/c/trunk/tests/Makefile.am
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/Makefile.am?rev=1803393&r1=1803392&r2=1803393&view=diff
==============================================================================
--- xerces/c/trunk/tests/Makefile.am (original)
+++ xerces/c/trunk/tests/Makefile.am Sat Jul 29 20:43:21 2017
@@ -128,6 +128,11 @@ testprogs +=
 XSValueTest_SOURCES =                           src/XSValueTest/XSValueTest.cpp \
                                                 src/XSValueTest/XSValueTest.hpp
 
+if XERCES_USE_CHAR16
+testprogs +=                                    Char16Test
+Char16Test_SOURCES =                            src/Char16Test/Char16Test.cpp
+endif
+
 
 TESTS =					scripts/DOMTest \
 					scripts/DOMMemTest \
@@ -165,6 +170,10 @@ TESTS =					scripts/DOMTest \
 					scripts/MemHandlerTest2 \
 					scripts/DOMTypeInfoTest
 
+if XERCES_USE_CHAR16
+TESTS += scripts/Char16Test
+endif
+
 XFAIL_TESTS =				scripts/XSerializerTest \
 					scripts/InitTermTest \
 					scripts/ThreadTest \

Added: xerces/c/trunk/tests/scripts/Char16Test
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/scripts/Char16Test?rev=1803393&view=auto
==============================================================================
--- xerces/c/trunk/tests/scripts/Char16Test (added)
+++ xerces/c/trunk/tests/scripts/Char16Test Sat Jul 29 20:43:21 2017
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -e
+
+. ../scripts/run-test
+
+run_test Char16Test pass "" tests/Char16Test

Propchange: xerces/c/trunk/tests/src/Char16Test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Jul 29 20:43:21 2017
@@ -0,0 +1 @@
+.*

Added: xerces/c/trunk/tests/src/Char16Test/Char16Test.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/Char16Test/Char16Test.cpp?rev=1803393&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/Char16Test/Char16Test.cpp (added)
+++ xerces/c/trunk/tests/src/Char16Test/Char16Test.cpp Sat Jul 29 20:43:21 2017
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//---------------------------------------------------------------------
+//
+//  This test program is used to verify support for C++11 char16_t as
+//  XMLCh, along with direct use of u"" UTF-16 string literals with the
+//  DOM API.
+//
+//  This test requires C++11.
+//
+//---------------------------------------------------------------------
+
+#include <xercesc/util/PlatformUtils.hpp>
+#include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/XMLException.hpp>
+#include <xercesc/util/OutOfMemoryException.hpp>
+
+#include <xercesc/dom/DOM.hpp>
+
+#include <cassert>
+#include <iostream>
+#include <string>
+
+int main() {
+    try
+    {
+        xercesc::XMLPlatformUtils::Initialize();
+    }
+    catch (const xercesc::XMLException& toCatch)
+    {
+      std::cerr << "Error during initialization of xerces-c: "
+                << toCatch.getMessage()
+                << std::endl;
+        return 1;
+    }
+
+    const char16_t *ns = u"https://example.com/schema/char16";
+
+    int errorCode = 0;
+
+    xercesc::DOMImplementation* impl = xercesc::DOMImplementationRegistry::getDOMImplementation(u"LS");
+    if(impl)
+    {
+        try
+        {
+            xercesc::DOMDocument* doc = impl->createDocument
+                (ns, // root element namespace URI.
+                 u"catalogue", // root element name
+                 nullptr);
+
+            xercesc::DOMElement* rootElem = doc->getDocumentElement();
+
+            xercesc::DOMElement*  prodElem = doc->createElementNS(ns, u"produit");
+            rootElem->appendChild(prodElem);
+
+            xercesc::DOMText*    prodDataVal = doc->createTextNode(u"Xerces-C");
+            prodElem->appendChild(prodDataVal);
+
+            xercesc::DOMElement*  catElem = doc->createElementNS(ns, u"catégorie");
+            rootElem->appendChild(catElem);
+
+            catElem->setAttribute(u"idée", u"génial");
+
+            xercesc::DOMText*    catDataVal = doc->createTextNode(u"produit");
+            catElem->appendChild(catDataVal);
+
+            xercesc::DOMElement*  devByElem = doc->createElementNS(ns, u"développéPar");
+            rootElem->appendChild(devByElem);
+
+            xercesc::DOMText*    devByDataVal = doc->createTextNode(u"Fondation du logiciel Apache");
+            devByElem->appendChild(devByDataVal);
+
+            assert(std::u16string(u"produit") == prodElem->getTagName());
+            assert(std::u16string(u"catégorie") == catElem->getTagName());
+            assert(std::u16string(u"génial") == catElem->getAttribute(u"idée"));
+            assert(std::u16string(u"développéPar") == devByElem->getTagName());
+        }
+        catch (const xercesc::OutOfMemoryException&)
+        {
+            std::cerr << "OutOfMemoryException" << std::endl;
+            errorCode = 5;
+        }
+        catch (const xercesc::DOMException& e)
+        {
+            std::cerr << "DOMException code is:  " << e.code << std::endl;
+            errorCode = 2;
+        }
+        catch (...)
+        {
+            std::cerr << "An error occurred creating the document" << std::endl;
+            errorCode = 3;
+        }
+    }
+    else
+    {
+        std::cerr << "Requested DOM implementation is not supported" << std::endl;
+        errorCode = 4;
+    }
+
+    xercesc::XMLPlatformUtils::Terminate();
+    return errorCode;
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org