N
Nuno
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:OMDocument* 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
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:OMDocument* 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