You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by "Piras Sandro (KSDB 121)" <sa...@credit-suisse.com> on 2008/05/27 13:15:59 UTC

Crash in DOM_Document::createElement() when name an empty string

Hi all,
I'm trying to "migrate" some old C++ Code from Xerces 1.7.0 to Xerces
2.5.0 using the includes from the directory /dom/deprecated instead of
using the new classes. Now the application crashes. 

Here the code:

DOM_Document domDoc;
DOM_Node parent;

...

// parent created, the path is "CMF/Trade/Product/Identifiers"

DOM_Element element = domDoc.createElement(name); // name may be empty
-> name = ""
DOM_Text text = domDoc.createTextNode(value); // value may be empty ->
value = ""
element.appendChild(text);
parent.appendChild(element);


When the variables name and value were an empty string, on xerces 1.7.0
we got an empty-element tag:

...<Product><Identifiers/></Product>..

but on xerces 2.5.0 the method DOM_Document::createElement() crashes
because of XMLChar1_0::isValidName()

DOM_Document::createElement() -> DocumentImpl::createElement() ->
XMLChar1_0::isValidName()

I couldn't find anything about this in the migration specs or in the
faq.

May somebody tell me if it is not allowed anymore to call
createElement() with an empty string and if not allowed, how to generate
the empty-element tag?

Regards
S. Piras

RE: Unresolved Linking Error

Posted by "Sahoglu, Ozgur" <Oz...@intuit.com>.
Hi Dennis,

I am guessing that you're trying to link statically to the xerces-c++. In that case, build your application with the XML_LIBRARRY preprocessor define. Also make sure that the xerces-c++ library is defined in your library path.


Cheers,


-Ozgur Sahoglu

-----Original Message-----
From: Dennis Endt [mailto:dennis.endt@googlemail.com] 
Sent: Saturday, June 07, 2008 2:02 PM
To: c-users@xerces.apache.org
Subject: Re: Unresolved Linking Error

David Bertoni schrieb:
> Dennis Endt wrote:
>> Hi,
>>
>> I`m porting my Code from MFC to Qt and now I`m getting unresolved 
>> Linking Errors:
>>
>> LNK2019
>> LNK2001
>>
>> The Settings are the same as before. The lib is correct included.
>>
>> What`s wrong?
> Without information about the actual linker errors, who knows what's 
> wrong?  Please post the linker output.
>
> Dave
>
The whole linking Errors:

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) protected: __thiscall 
xercesc_2_8::DOMErrorHandler::DOMErrorHandler(void)" 
(__imp_??0DOMErrorHandler@xercesc_2_8@@IAE@XZ)" in Funktion ""public: 
__thiscall XMLBaseErrorHandler::XMLBaseErrorHandler(void)" 
(??0XMLBaseErrorHandler@@QAE@XZ)".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: virtual __thiscall 
xercesc_2_8::DOMErrorHandler::~DOMErrorHandler(void)" 
(__imp_??1DOMErrorHandler@xercesc_2_8@@UAE@XZ)" in Funktion ""public: 
virtual __thiscall XMLBaseErrorHandler::~XMLBaseErrorHandler(void)" 
(??1XMLBaseErrorHandler@@UAE@XZ)".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static void __cdecl 
xercesc_2_8::XMLPlatformUtils::Terminate(void)" 
(__imp_?Terminate@XMLPlatformUtils@xercesc_2_8@@SAXXZ)" in Funktion 
"__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static bool __cdecl 
xercesc_2_8::DOMImplementation::loadDOMExceptionMsg(enum 
xercesc_2_8::DOMException::ExceptionCode,unsigned short * const,unsigned 
int)" 
(__imp_?loadDOMExceptionMsg@DOMImplementation@xercesc_2_8@@SA_NW4ExceptionCode@DOMException@2@QAGI@Z)" 
in Funktion "__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgXercesUseCachedGrammarInParse" 
(__imp_?fgXercesUseCachedGrammarInParse@XMLUni@xercesc_2_8@@2QBGB)".

XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation" 
(__imp_?fgXercesSchemaExternalNoNameSpaceSchemaLocation@XMLUni@xercesc_2_8@@2QBGB)". 


XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgXercesSchemaFullChecking" 
(__imp_?fgXercesSchemaFullChecking@XMLUni@xercesc_2_8@@2QBGB)".

 XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgXercesSchema" 
(__imp_?fgXercesSchema@XMLUni@xercesc_2_8@@2QBGB)".

 XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgDOMValidation" 
(__imp_?fgDOMValidation@XMLUni@xercesc_2_8@@2QBGB)".

XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgDOMNamespaces" 
(__imp_?fgDOMNamespaces@XMLUni@xercesc_2_8@@2QBGB)".

XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static class xercesc_2_8::MemoryManager 
* xercesc_2_8::XMLPlatformUtils::fgMemoryManager" 
(__imp_?fgMemoryManager@XMLPlatformUtils@xercesc_2_8@@2PAVMemoryManager@2@A)". 


XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static class 
xercesc_2_8::DOMImplementation * __cdecl 
xercesc_2_8::DOMImplementationRegistry::getDOMImplementation(unsigned 
short const *)" 
(__imp_?getDOMImplementation@DOMImplementationRegistry@xercesc_2_8@@SAPAVDOMImplementation@2@PBG@Z)" 
in Funktion "__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static unsigned short * 
__cdecl xercesc_2_8::XMLString::transcode(char const * const)" 
(__imp_?transcode@XMLString@xercesc_2_8@@SAPAGQBD@Z)" in Funktion 
"__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static void __cdecl 
xercesc_2_8::XMLString::release(char * *)" 
(__imp_?release@XMLString@xercesc_2_8@@SAXPAPAD@Z)" in Funktion 
"__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static char * __cdecl 
xercesc_2_8::XMLString::transcode(unsigned short const * const)" 
(__imp_?transcode@XMLString@xercesc_2_8@@SAPADQBG@Z)" in Funktion 
"__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: unsigned short const * 
__thiscall xercesc_2_8::XMLException::getMessage(void)const " 
(__imp_?getMessage@XMLException@xercesc_2_8@@QBEPBGXZ)" in Funktion 
"__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static void __cdecl 
xercesc_2_8::XMLPlatformUtils::Initialize(char const * const,char const 
* const,class xercesc_2_8::PanicHandler * const,class 
xercesc_2_8::MemoryManager * const,bool)" 
(__imp_?Initialize@XMLPlatformUtils@xercesc_2_8@@SAXQBD0QAVPanicHandler@2@QAVMemoryManager@2@_N@Z)" 
in Funktion ""public: bool __thiscall XmlBase2Dialog::Init(char const 
*)" (?Init@XmlBase2Dialog@@QAE_NPBD@Z)".

XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static char const * const 
xercesc_2_8::XMLUni::fgXercescDefaultLocale" 
(__imp_?fgXercescDefaultLocale@XMLUni@xercesc_2_8@@2QBDB)".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static void __cdecl 
xercesc_2_8::XMLString::release(unsigned short * *)" 
(__imp_?release@XMLString@xercesc_2_8@@SAXPAPAG@Z)" in Funktion 
""public: __thiscall XStr::~XStr(void)" (??1XStr@@QAE@XZ)".

Dennis


Re: Unresolved Linking Error

Posted by Dennis Endt <de...@googlemail.com>.
David Bertoni schrieb:
> Dennis Endt wrote:
>> Hi,
>>
>> I`m porting my Code from MFC to Qt and now I`m getting unresolved 
>> Linking Errors:
>>
>> LNK2019
>> LNK2001
>>
>> The Settings are the same as before. The lib is correct included.
>>
>> What`s wrong?
> Without information about the actual linker errors, who knows what's 
> wrong?  Please post the linker output.
>
> Dave
>
The whole linking Errors:

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) protected: __thiscall 
xercesc_2_8::DOMErrorHandler::DOMErrorHandler(void)" 
(__imp_??0DOMErrorHandler@xercesc_2_8@@IAE@XZ)" in Funktion ""public: 
__thiscall XMLBaseErrorHandler::XMLBaseErrorHandler(void)" 
(??0XMLBaseErrorHandler@@QAE@XZ)".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: virtual __thiscall 
xercesc_2_8::DOMErrorHandler::~DOMErrorHandler(void)" 
(__imp_??1DOMErrorHandler@xercesc_2_8@@UAE@XZ)" in Funktion ""public: 
virtual __thiscall XMLBaseErrorHandler::~XMLBaseErrorHandler(void)" 
(??1XMLBaseErrorHandler@@UAE@XZ)".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static void __cdecl 
xercesc_2_8::XMLPlatformUtils::Terminate(void)" 
(__imp_?Terminate@XMLPlatformUtils@xercesc_2_8@@SAXXZ)" in Funktion 
"__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static bool __cdecl 
xercesc_2_8::DOMImplementation::loadDOMExceptionMsg(enum 
xercesc_2_8::DOMException::ExceptionCode,unsigned short * const,unsigned 
int)" 
(__imp_?loadDOMExceptionMsg@DOMImplementation@xercesc_2_8@@SA_NW4ExceptionCode@DOMException@2@QAGI@Z)" 
in Funktion "__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgXercesUseCachedGrammarInParse" 
(__imp_?fgXercesUseCachedGrammarInParse@XMLUni@xercesc_2_8@@2QBGB)".

XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation" 
(__imp_?fgXercesSchemaExternalNoNameSpaceSchemaLocation@XMLUni@xercesc_2_8@@2QBGB)". 


XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgXercesSchemaFullChecking" 
(__imp_?fgXercesSchemaFullChecking@XMLUni@xercesc_2_8@@2QBGB)".

 XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgXercesSchema" 
(__imp_?fgXercesSchema@XMLUni@xercesc_2_8@@2QBGB)".

 XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgDOMValidation" 
(__imp_?fgDOMValidation@XMLUni@xercesc_2_8@@2QBGB)".

XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static unsigned short const * const 
xercesc_2_8::XMLUni::fgDOMNamespaces" 
(__imp_?fgDOMNamespaces@XMLUni@xercesc_2_8@@2QBGB)".

XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static class xercesc_2_8::MemoryManager 
* xercesc_2_8::XMLPlatformUtils::fgMemoryManager" 
(__imp_?fgMemoryManager@XMLPlatformUtils@xercesc_2_8@@2PAVMemoryManager@2@A)". 


XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static class 
xercesc_2_8::DOMImplementation * __cdecl 
xercesc_2_8::DOMImplementationRegistry::getDOMImplementation(unsigned 
short const *)" 
(__imp_?getDOMImplementation@DOMImplementationRegistry@xercesc_2_8@@SAPAVDOMImplementation@2@PBG@Z)" 
in Funktion "__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static unsigned short * 
__cdecl xercesc_2_8::XMLString::transcode(char const * const)" 
(__imp_?transcode@XMLString@xercesc_2_8@@SAPAGQBD@Z)" in Funktion 
"__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static void __cdecl 
xercesc_2_8::XMLString::release(char * *)" 
(__imp_?release@XMLString@xercesc_2_8@@SAXPAPAD@Z)" in Funktion 
"__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static char * __cdecl 
xercesc_2_8::XMLString::transcode(unsigned short const * const)" 
(__imp_?transcode@XMLString@xercesc_2_8@@SAPADQBG@Z)" in Funktion 
"__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: unsigned short const * 
__thiscall xercesc_2_8::XMLException::getMessage(void)const " 
(__imp_?getMessage@XMLException@xercesc_2_8@@QBEPBGXZ)" in Funktion 
"__catch$?Init@XmlBase2Dialog@@QAE_NPBD@Z$0".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static void __cdecl 
xercesc_2_8::XMLPlatformUtils::Initialize(char const * const,char const 
* const,class xercesc_2_8::PanicHandler * const,class 
xercesc_2_8::MemoryManager * const,bool)" 
(__imp_?Initialize@XMLPlatformUtils@xercesc_2_8@@SAXQBD0QAVPanicHandler@2@QAVMemoryManager@2@_N@Z)" 
in Funktion ""public: bool __thiscall XmlBase2Dialog::Init(char const 
*)" (?Init@XmlBase2Dialog@@QAE_NPBD@Z)".

XmlBase2Dialog.obj : error LNK2001: Nicht aufgelöstes externes Symbol 
""__declspec(dllimport) public: static char const * const 
xercesc_2_8::XMLUni::fgXercescDefaultLocale" 
(__imp_?fgXercescDefaultLocale@XMLUni@xercesc_2_8@@2QBDB)".

XmlBase2Dialog.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""__declspec(dllimport) public: static void __cdecl 
xercesc_2_8::XMLString::release(unsigned short * *)" 
(__imp_?release@XMLString@xercesc_2_8@@SAXPAPAG@Z)" in Funktion 
""public: __thiscall XStr::~XStr(void)" (??1XStr@@QAE@XZ)".

Dennis

Re: Unresolved Linking Error

Posted by David Bertoni <db...@apache.org>.
Dennis Endt wrote:
> Hi,
> 
> I`m porting my Code from MFC to Qt and now I`m getting unresolved 
> Linking Errors:
> 
> LNK2019
> LNK2001
> 
> The Settings are the same as before. The lib is correct included.
> 
> What`s wrong?
Without information about the actual linker errors, who knows what's 
wrong?  Please post the linker output.

Dave

Unresolved Linking Error

Posted by Dennis Endt <de...@googlemail.com>.
Hi,

I`m porting my Code from MFC to Qt and now I`m getting unresolved 
Linking Errors:

LNK2019
LNK2001

The Settings are the same as before. The lib is correct included.

What`s wrong?

Greetings
D.E.

RE: Crash in DOM_Document::createElement() when name an empty string

Posted by "Piras Sandro (KSDB 121)" <sa...@credit-suisse.com>.
Hi Dave,
I created the Jira issue XERCESC-1806, but was not able to assign it to
you.
Regards
Sandro 

-----Original Message-----
From: David Bertoni [mailto:dbertoni@apache.org] 
Sent: Montag, 2. Juni 2008 19:39
To: c-users@xerces.apache.org
Subject: Re: Crash in DOM_Document::createElement() when name an empty
string

Piras Sandro (KSDB 121) wrote:
> Hi Dave,
> yes, it compiles.. at least the Sun compiler version 5.3 I'm actually 
> using.
Uggh.  I just noticed that you're using the deprecated DOM, which gone
in 3.0.  I think you'd be better off by spending your time porting to
the new DOM.

> 
> I copied the code from our project in a single sourcefile and without 
> all the object oriented stuff only to see how it works. Like in the 
> project, calling DOM_Document::createElement("") generates a core 
> file, the same when calling DOM_Document::createElement(name) when 
> name contains an empty string, it doesn't throw an exception.. I tried

> filling name with a space -> name = " ", then createElement() throws 
> an exception.
It's definitely a regression, due to some performance enhancement work
that assumed isValidName() would never be passed a string of length 0. 
Can you please file a Jira issue and assign it to me?

Dave

Re: Crash in DOM_Document::createElement() when name an empty string

Posted by David Bertoni <db...@apache.org>.
Piras Sandro (KSDB 121) wrote:
> Hi Dave,
> yes, it compiles.. at least the Sun compiler version 5.3 I'm actually
> using.
Uggh.  I just noticed that you're using the deprecated DOM, which gone 
in 3.0.  I think you'd be better off by spending your time porting to 
the new DOM.

> 
> I copied the code from our project in a single sourcefile and without
> all the object oriented stuff only to see how it works. Like in the
> project, calling DOM_Document::createElement("") generates a core file,
> the same when calling DOM_Document::createElement(name) when name
> contains an empty string, it doesn't throw an exception.. I tried
> filling name with a space -> name = " ", then createElement() throws an
> exception.
It's definitely a regression, due to some performance enhancement work 
that assumed isValidName() would never be passed a string of length 0. 
Can you please file a Jira issue and assign it to me?

Dave

RE: Crash in DOM_Document::createElement() when name an empty string

Posted by "Piras Sandro (KSDB 121)" <sa...@credit-suisse.com>.
Hi Dave,
yes, it compiles.. at least the Sun compiler version 5.3 I'm actually
using.

I copied the code from our project in a single sourcefile and without
all the object oriented stuff only to see how it works. Like in the
project, calling DOM_Document::createElement("") generates a core file,
the same when calling DOM_Document::createElement(name) when name
contains an empty string, it doesn't throw an exception.. I tried
filling name with a space -> name = " ", then createElement() throws an
exception.

See the function createNameValue(), the function createNameValue() will
be callend in main() in a try block. 

Regards
Sandro

Code:

#include <iostream>

#include <xercesc/dom/deprecated/DOM.hpp>


using namespace XERCES_CPP_NAMESPACE;


using std::cout;
using std::endl;


DOM_Document myDocument;


DOM_Node makeChild(const char* childName, DOM_Node parentNode, bool
bAllowDuplicate)
//**********************************************************************
************
{
   // Create child node if it does not exist, returns existing one
otherwise

   DOM_Node child = parentNode;
   if (!parentNode.isNull() && (strlen(childName) > 0))
   {
      child = parentNode.getFirstChild();
      while (!child.isNull() &&
!child.getNodeName().equals(DOMString(childName)) &&
             !bAllowDuplicate)
      {
         child = child.getNextSibling();
      } // end while

      if (child.isNull() || bAllowDuplicate)
      {
         child = myDocument.createElement(childName);
         parentNode.appendChild(child);
      } // end if (child.isNull() -> TRUE || (bAllowDuplicate -> TRUE)
   } // end if

   return child;
} // end makeChild()


DOM_Node makePath(const char* path, DOM_Node parentNode)
//******************************************************
{
   char* copyOfPath = new char[strlen(path) + 1];
   copyOfPath[strlen(path)] = '\0';

   strncpy(copyOfPath, path, strlen(path));

   char* pStart = (char*)copyOfPath;
   char* pEnd = pStart;

   bool bContinue = pEnd && *pEnd;
   while (bContinue)
   {
      if ((*pEnd == '/') || (*pEnd == '\0')) // Found the limiter
      {
         if ((*pEnd == '\0')) bContinue = false;
         *pEnd = '\0';

         // Create child node if it does not exist, returns existing one
otherwise
         parentNode = makeChild(pStart, parentNode, false);

         pStart = pEnd + 1;
      } // end if (*pEnd -> '/') OR (*pEnd -> '\0')

      pEnd++;
   } // end while (bContinue -> TRUE)

   return parentNode;
} // end makePath()


DOM_Node makePath(const char* path)
//*********************************
{
   DOM_Node nodeRet;

   if (myDocument.isNull()) myDocument = DOM_Document::createDocument();

   nodeRet = myDocument;

   nodeRet = makePath(path, nodeRet);

   return nodeRet;
} // end makePath()


void createNameValue(const char* name, const char* value, DOM_Node
parent)
//**********************************************************************
**
{
   if (!parent.isNull() && (name != NULL) && (value != NULL))
   {
      cout << "CreateNameValue() : " << "name = \"" << name << "\",
value = \"" << value << "\"" << endl;

      // Crashes when name is an empty string instead to throw an
exception
      //DOM_Element element = myDocument.createElement(name);
      // XXX check whats wrong
      DOM_Element element;
      if (strcmp(name, "") == 0)
      {
         cout << "createNameValue() : call createElement with empty
string" << endl;
         element = myDocument.createElement("");

         //cout << "createNameValue() : call createElement with one
space" << endl;
         //element = myDocument.createElement(" ");

         cout << "createNameValue() : createElement() was successfull"
<< endl;
      }
      else
      {
         cout << "createNameValue() : call createElement with name = \""
<< name << "\"" << endl;
         element = myDocument.createElement(name);
      }
      // XXX

      DOM_Text text = myDocument.createTextNode(value);
      element.appendChild(text);
      parent.appendChild(element);
   } // end if (parent.isNull() -> FALSE) AND (name <> NULL) AND (value
<> NULL)
} // end createNameValue()


int main()
{
   cout << "start" << endl;

   XMLPlatformUtils::Initialize();

   DOM_Node nodeProd = makePath("CMF/Trade/Product");

   const char* name = "";
   const char* value = "";

   cout << "name = \"" << name << "\"" << endl;
   cout << "value = \"" << value << "\"" << endl;

   try
   {
      createNameValue(name, value, makePath("Identifiers", nodeProd));
   }
   catch(...)
   {
     cout << "Exception caught in createNameValue()" << endl;
   }

} // end main()

-----Original Message-----
From: David Bertoni [mailto:dbertoni@apache.org] 
Sent: Donnerstag, 29. Mai 2008 19:22
To: c-users@xerces.apache.org
Subject: Re: Crash in DOM_Document::createElement() when name an empty
string

Piras Sandro (KSDB 121) wrote:
> Hi all
> thx for your help.
> 
> I tested also when filling directly an empty string with
> DOM_Document::createElement("") -> crashes
How does this even compile?  "" is not a pointer to a UTF-16 string. 
Can you please provide a small, isolated program that reproduces the
crash?

Dave


Re: Crash in DOM_Document::createElement() when name an empty string

Posted by David Bertoni <db...@apache.org>.
Piras Sandro (KSDB 121) wrote:
> Hi all
> thx for your help.
> 
> I tested also when filling directly an empty string with
> DOM_Document::createElement("") -> crashes
How does this even compile?  "" is not a pointer to a UTF-16 string. 
Can you please provide a small, isolated program that reproduces the crash?

Dave


RE: Crash in DOM_Document::createElement() when name an empty string

Posted by "Piras Sandro (KSDB 121)" <sa...@credit-suisse.com>.
Hi all
thx for your help.

I tested also when filling directly an empty string with
DOM_Document::createElement("") -> crashes

I suppose there must be a memory management problem somewhere in our
huge code and using all the different
new libraries (not only xerces) let it cause the crash.

Regards
Sandro

-----Original Message-----
From: David Bertoni [mailto:dbertoni@apache.org] 
Sent: Donnerstag, 29. Mai 2008 03:03
To: c-users@xerces.apache.org
Subject: Re: Crash in DOM_Document::createElement() when name an empty
string

Piras Sandro (KSDB 121) wrote:
> Hi Alberto,
> the code is in a try block and I catch the exceptions. So far as I can

> see XMLChar1_0::isValidName() doesn't throw an exception and the crash

> happens there.
Perhaps you're passing in a null pointer, rather than an empty string?

> When avoiding to call createElement() with name empty, would I have 
> the empty-element tag like before (according to the code)?
An element with no children will be serialized as an empty tag.

Dave

Re: Crash in DOM_Document::createElement() when name an empty string

Posted by David Bertoni <db...@apache.org>.
Piras Sandro (KSDB 121) wrote:
> Hi Alberto,
> the code is in a try block and I catch the exceptions. So far as I can
> see XMLChar1_0::isValidName() doesn't throw an exception and the crash
> happens there.
Perhaps you're passing in a null pointer, rather than an empty string?

> When avoiding to call createElement() with name empty, would I have the
> empty-element tag like before (according to the code)?
An element with no children will be serialized as an empty tag.

Dave

RE: Crash in DOM_Document::createElement() when name an empty string

Posted by Jesse Pelton <js...@PKC.com>.
If you create an element and append it to another element in the
document, the new element is part of the document and will be serialized
along with the rest of the document.  If it has children, they will be
serialized between separate start and end tags.  If it has no children,
you'll get an empty-element tag.

An element is empty because it has no children, not because it has a
child element with an empty name.  As Alberto pointed out, an element
must have a name.

-----Original Message-----
From: Piras Sandro (KSDB 121) [mailto:sandro.piras@credit-suisse.com] 
Sent: Wednesday, May 28, 2008 2:22 AM
To: c-users@xerces.apache.org
Subject: RE: Crash in DOM_Document::createElement() when name an empty
string

Hi Alberto,
the code is in a try block and I catch the exceptions. So far as I can
see XMLChar1_0::isValidName() doesn't throw an exception and the crash
happens there.

When avoiding to call createElement() with name empty, would I have the
empty-element tag like before (according to the code)?

Regards
Sandro



-----Original Message-----
From: Alberto Massari [mailto:amassari@datadirect.com] 
Sent: Dienstag, 27. Mai 2008 16:05
To: c-users@xerces.apache.org
Subject: Re: Crash in DOM_Document::createElement() when name an empty
string

Hi Sandro,
elements must have a name, so you should not be allowed to create one
with an empty string (and probably the application crashes because it
doesn't catch the exception being thrown). Add a check and avoid the
call to createElement when "name" is empty

Alberto

Piras Sandro (KSDB 121) wrote:
> Hi all,
> I'm trying to "migrate" some old C++ Code from Xerces 1.7.0 to Xerces 
> 2.5.0 using the includes from the directory /dom/deprecated instead of

> using the new classes. Now the application crashes.
>
> Here the code:
>
> DOM_Document domDoc;
> DOM_Node parent;
>
> ...
>
> // parent created, the path is "CMF/Trade/Product/Identifiers"
>
> DOM_Element element = domDoc.createElement(name); // name may be empty
> -> name = ""
> DOM_Text text = domDoc.createTextNode(value); // value may be empty ->

> value = ""
> element.appendChild(text);
> parent.appendChild(element);
>
>
> When the variables name and value were an empty string, on xerces 
> 1.7.0 we got an empty-element tag:
>
> ...<Product><Identifiers/></Product>..
>
> but on xerces 2.5.0 the method DOM_Document::createElement() crashes 
> because of XMLChar1_0::isValidName()
>
> DOM_Document::createElement() -> DocumentImpl::createElement() ->
> XMLChar1_0::isValidName()
>
> I couldn't find anything about this in the migration specs or in the 
> faq.
>
> May somebody tell me if it is not allowed anymore to call
> createElement() with an empty string and if not allowed, how to 
> generate the empty-element tag?
>
> Regards
> S. Piras
>
>   


RE: Crash in DOM_Document::createElement() when name an empty string

Posted by "Piras Sandro (KSDB 121)" <sa...@credit-suisse.com>.
Hi Alberto,
the code is in a try block and I catch the exceptions. So far as I can
see XMLChar1_0::isValidName() doesn't throw an exception and the crash
happens there.

When avoiding to call createElement() with name empty, would I have the
empty-element tag like before (according to the code)?

Regards
Sandro



-----Original Message-----
From: Alberto Massari [mailto:amassari@datadirect.com] 
Sent: Dienstag, 27. Mai 2008 16:05
To: c-users@xerces.apache.org
Subject: Re: Crash in DOM_Document::createElement() when name an empty
string

Hi Sandro,
elements must have a name, so you should not be allowed to create one
with an empty string (and probably the application crashes because it
doesn't catch the exception being thrown). Add a check and avoid the
call to createElement when "name" is empty

Alberto

Piras Sandro (KSDB 121) wrote:
> Hi all,
> I'm trying to "migrate" some old C++ Code from Xerces 1.7.0 to Xerces 
> 2.5.0 using the includes from the directory /dom/deprecated instead of

> using the new classes. Now the application crashes.
>
> Here the code:
>
> DOM_Document domDoc;
> DOM_Node parent;
>
> ...
>
> // parent created, the path is "CMF/Trade/Product/Identifiers"
>
> DOM_Element element = domDoc.createElement(name); // name may be empty
> -> name = ""
> DOM_Text text = domDoc.createTextNode(value); // value may be empty ->

> value = ""
> element.appendChild(text);
> parent.appendChild(element);
>
>
> When the variables name and value were an empty string, on xerces 
> 1.7.0 we got an empty-element tag:
>
> ...<Product><Identifiers/></Product>..
>
> but on xerces 2.5.0 the method DOM_Document::createElement() crashes 
> because of XMLChar1_0::isValidName()
>
> DOM_Document::createElement() -> DocumentImpl::createElement() ->
> XMLChar1_0::isValidName()
>
> I couldn't find anything about this in the migration specs or in the 
> faq.
>
> May somebody tell me if it is not allowed anymore to call
> createElement() with an empty string and if not allowed, how to 
> generate the empty-element tag?
>
> Regards
> S. Piras
>
>   


Re: Crash in DOM_Document::createElement() when name an empty string

Posted by Alberto Massari <am...@datadirect.com>.
Hi Sandro,
elements must have a name, so you should not be allowed to create one 
with an empty string (and probably the application crashes because it 
doesn't catch the exception being thrown). Add a check and avoid the 
call to createElement when "name" is empty

Alberto

Piras Sandro (KSDB 121) wrote:
> Hi all,
> I'm trying to "migrate" some old C++ Code from Xerces 1.7.0 to Xerces
> 2.5.0 using the includes from the directory /dom/deprecated instead of
> using the new classes. Now the application crashes. 
>
> Here the code:
>
> DOM_Document domDoc;
> DOM_Node parent;
>
> ...
>
> // parent created, the path is "CMF/Trade/Product/Identifiers"
>
> DOM_Element element = domDoc.createElement(name); // name may be empty
> -> name = ""
> DOM_Text text = domDoc.createTextNode(value); // value may be empty ->
> value = ""
> element.appendChild(text);
> parent.appendChild(element);
>
>
> When the variables name and value were an empty string, on xerces 1.7.0
> we got an empty-element tag:
>
> ...<Product><Identifiers/></Product>..
>
> but on xerces 2.5.0 the method DOM_Document::createElement() crashes
> because of XMLChar1_0::isValidName()
>
> DOM_Document::createElement() -> DocumentImpl::createElement() ->
> XMLChar1_0::isValidName()
>
> I couldn't find anything about this in the migration specs or in the
> faq.
>
> May somebody tell me if it is not allowed anymore to call
> createElement() with an empty string and if not allowed, how to generate
> the empty-element tag?
>
> Regards
> S. Piras
>
>