Xerces c++ xml log

Nuno

Usenet Archive
Joined
Feb 10, 2005
Messages
16
Reaction score
0
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
 

Boris Kolpackov

Usenet Archive
Joined
Aug 11, 2003
Messages
60
Reaction score
0
Nuno said:
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: ..."

This does not look like a size problem. Maybe your file is still opened when you try to open it again?

Is there any limit of data in an xml file?

The limit on file sizes is imposed by your hardware and/or OS. However your approach won't allow you to write more that the amount of RAM you have since you use DOM and it keeps all the data in memory.

how i can write more than this limit?

One approach would be to open a new log file when the the current file has grown too large. If you must keep everything in one file then you can use DOM to serialize just one record instead of the whole document. With this approach you will need to write the head and tail of your document by hand and set the option on DOMWriter not to write the XML declaration. I've described this method in a bit more detail in a post to the Xerces-C++ mailing list:

http://www.mail-archive.com//msg02647.html

hth,
-boris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,246
Members
248,133
Latest member
DujonT

Latest Threads

Top