Unix C++ Compiler Error

im trying to compile a c++program in unix enviroment at HPUX box via c++ Compiler, but im hit with below error.
Im not sure where it goes wrong as using the same file we are able to compile in Sun Solaris Enviroment

Error:
[89] % gmake -f xml.mk
g++ -g -D__USE_STD_IOSTREAM -DBSD -DOSFDEC10 -DAXPOSF -DAXP30 -ansi -I/usr/local/include -I/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/include -I/usr/local/include/g++-3 -I/export2/home/oracle/client/product/11.2.0/rdbms/demo -I/export2/home/oracle/client/product/11.2.0/rdbms/public -I/export2/mes/FASTech/SDT/include -I./ -I../../../../export/cxx/include -c action_store.cpp -o action_store.o
In file included from action_store.h:33,
from action_store.cpp:30:
tinyxml.h: In member function 'int TiXmlElement::AppendChild(const std::string&, const T&)':
tinyxml.h:1163: error: no matching function for call to 'TiXmlElement::InsertEndChild(TiXmlText&)'
tinyxml.h:587: note: candidates are: TiXmlNode* TiXmlNode::InsertEndChild(const TiXmlNode&)
gmake: *** [../../bld_default.mk:105: action_store.o] Error 1

Code
#ifdef TIXML_USE_STL
template < typename T >
int AppendChild( const std::string& name, const T& value )
{
std::ostringstream ss;
ss << value;
std::string valueStr = ss.str();

TiXmlText textNode(valueStr.c_str());
TiXmlElement childElement(name.c_str());

childElement.InsertEndChild(textNode);
this->InsertEndChild(childElement);

return TIXML_SUCCESS;
}
#endif

Note:Im using a standard tinyxml.h
1
2
3
4
5
6
TiXmlText foo;
TiXmlElement bar;

bar.InsertEndChild( foo ); // error:
// call to      TiXmlElement::InsertEndChild( TiXmlText &)
// candidates are: TiXmlNode::InsertEndChild(const TiXmlNode &) 

It seems that TiXmlElement inherits (IS-A) TiXmlNode,
but TiXmlText is not a TiXmlNode.
but both TiXmlElement and TiXmlText inherits TiXmlNode.

class TiXmlElement : public TiXmlNode


1
2
3
class TiXmlText : public TiXmlNode
{
	friend class TiXmlElement; 


Here is a snippet of tinyxml.h code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
	#ifdef TIXML_USE_STL
	template < typename T > int AppendChild( const std::string& name,  const T& value ) 
	{ 		
		std::ostringstream	ss;	
		ss << value; 
		std::string valueStr = ss.str(); 
		
		TiXmlText textNode(valueStr.c_str()) ;  
		TiXmlElement childElement(name.c_str()); 
		
		childElement.InsertEndChild(textNode); 
		this->InsertEndChild(childElement); 
		
		return TIXML_SUCCESS; 
	}
	#endif  


InsertEndChild function in tinyxml.cpp:

1
2
3
4
5
6
7
8
9
10
11
12
13
TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
{
	if ( addThis.Type() == TiXmlNode::DOCUMENT )
	{
		if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
		return 0;
	}
	TiXmlNode* node = addThis.Clone();
	if ( !node )
		return 0;

	return LinkEndChild( node );
}

Last edited on
1
2
class TiXmlText : public TiXmlNode
{

Does the "problematic code" know that?
please advise what should I do. I've tried many things for months

I know the error is at this line:

childElement.InsertEndChild(textNode); //TiXmlElement::InsertEndChild(TiXmlText&)

it should be :
//TiXmlNode::InsertEndChild(const TiXmlNode&)
After I changed TiXmlText to TiXmlElement, I don't get any error but the xml reply is incorrect and missing few header elements as well as message body:

1
2
3
4
5
6
7
8
9
10
11
#ifdef TIXML_USE_STL
	template < typename T >
	int AppendChild( const std::string& name, const T& value ) 
	{ 		
		std::ostringstream	ss;	
		ss << value; 
		std::string valueStr = ss.str(); 
		
		TiXmlElement textNode = (valueStr.c_str()) ;
                //TiXmlText textNode = (valueStr.c_str()); // 		
		TiXmlElement childElement = (name.c_str());


xml reply:

1
2
3
4
5
6
7
8
9
10
11
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<msg>
 <msgHeader>
          <msgOwner><F1MSAM04 /></msgOwner>
          <srvId><MES Adaptor2019-01-27 19:43:59 /></srvId>
          <timeStamp><2019-01-27 19:43:59 /></timeStamp>
          <locale><EN /></locale>
          <retCode><1 /></retCode>
  </msgHeader>
<msgBody />
</msg>
Topic archived. No new replies allowed.