Xerces c++ xml log

Discussion in 'XML' started by Nuno, Apr 4, 2007.

  1. Nuno

    Nuno Guest

    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
     
    Nuno, Apr 4, 2007
    #1
    1. Advertising

  2. "Nuno" <> writes:

    > 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


    --
    Boris Kolpackov
    Code Synthesis Tools CC
    http://www.codesynthesis.com
    Open-Source, Cross-Platform C++ XML Data Binding
     
    Boris Kolpackov, Apr 4, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henrik_the_boss
    Replies:
    0
    Views:
    2,715
    Henrik_the_boss
    Nov 5, 2003
  2. Amratash
    Replies:
    0
    Views:
    560
    Amratash
    Apr 13, 2004
  3. =?Utf-8?B?VG9tIFdpbmdlcnQ=?=

    My.Log.Writeexception not writing to Application Event Log.

    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=, Jan 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    2,417
    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=
    Jan 20, 2006
  4. cvissy
    Replies:
    0
    Views:
    640
    cvissy
    Nov 16, 2004
  5. Arvin Portlock
    Replies:
    0
    Views:
    161
    Arvin Portlock
    Jun 20, 2005
Loading...

Share This Page