Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Xerces c++ xml log

From: "Nuno" <nuno.esculcas@-----.--->
To: NULL
Date: 4/3/2007 5:48:00 PM

Hi,

I'm trying to use the xerces api to write the contents of my
application log. But i'm thinking that my approach is not the best
one, i need an approach that can write large amout of data and with a
considered speed (this is not the most important, the amount of data
is more important and i'm not achiving this objective).

So my approach is the following:

1) first step, i create the xml document if not exist:
DOMDocument* pcDoc = impl->createDocument(
	// root element namespace URI.
	XMLStr(XML_EXIF_LOG_DTD),
	XMLStr(XML_EXIF_LOG_ROOT_ELEM_NAME),     // root element name
	0);
and then i save it using the:
LocalFileFormatTarget local(m_strLogFileFullName.c_str());
DOMWriter* pcSerializer = impl->createDOMWriter();
pcSerializer->writeNode(&local, *((DOMNode*)pcDoc));

2) after the xml file is created i open it (maybe my problem is
here):
xercesc::XercesDOMParser*	m_pcDomParser = new
xercesc::XercesDOMParser;
m_pcDomParser->parse( m_strLogFileFullName.c_str() ) ;

and i save the variable m_pcDomParser for future use.

3) when i need to add a new log entry i do the following:
xercesc::DOMDocument* pcDoc = m_pcDomParser->getDocument() ;
DOMElement* rootElem = pcDoc->getDocumentElement();
DOMElement*  pcLogRec = pcDoc->createElement(XMLStr(XML_LOG_RECORD));
rootElem->appendChild(pcLogRec);

//... write the values for the correspondig xml elements

//then i saved it
DOMImplementation* pImp = pcDoc->getImplementation();
LocalFileFormatTarget local(m_strLogFileFullName.c_str());
DOMWriter* pcSerializer = pImp->createDOMWriter();
pcSerializer->writeNode(&local, *((DOMNode*)pcDoc));

And it's all...

The speed is not the desired one, but i can live with this, but my
biggest problem is that when i reach aproximilly the 22378 lines in
the xml document when i'm doing the following instruction of code:
LocalFileFormatTarget local(m_strLogFileFullName.c_str());
the xerces return an xercesc::XMLException saying "Could not open
file: ..."

Is there any limit of data in an xml file? how i can write more than
this limit?
And my approach is the best one? exist any problem with this aproach?
exist any another way of doing this?

Thanks
Nuno



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent