Hi All,

I have a problem trying to parse and validate an Xml document with its dtd. 
When I run the code below in a console application, it runs well and the 
callback functions get called. But when the same code runs from a dll, no 
callback function gets called. Any help will be greatly appreciated. This 
code follows the Xerces EnumVal sample.

Regards,
Eyumotu

#include <util/PlatformUtils.hpp>
#include <framework/XMLValidator.hpp>
#include <parsers/SAXParser.hpp>
#include <validators/DTD/DTDValidator.hpp>
#include <iostream.h>
#include <string.h>
#include "DTDHandlers.h"

int main(int argC, char* argV[])
{
    // Initialize the XML4C system
    try
    {
         XMLPlatformUtils::Initialize();
    }
    catch (const XMLException& toCatch)
    {
                char * Msg = XMLString::transcode(toCatch.getMessage());
         cerr   << "Error during initialization! Message:\n"
                << Msg << endl;
                 delete [] Msg;
         XMLPlatformUtils::Terminate();
         return 1;
    }



    //  Create a DTD validator.
        DTDHandlers * dh = new DTDHandlers();

    DTDValidator* valToUse = new DTDValidator();
        valToUse->setDocTypeHandler(dh);

    SAXParser parser(valToUse);
        parser.setDoValidation(true);

    //  Get the starting time and kick off the parse of the indicated
    //  file. Catch any exceptions that might propogate out of it.
    try
    {
       parser.parse("c:\\list.xml");
    }
    catch (const XMLException& e)
    {
                cout << "Error occurred . ....." << "\n";
                char * Msg = XMLString::transcode(e.getMessage());
        cerr << "\nError during parsing. '" << "'\n"
             << "Exception message is:  \n"
             << Msg << "\n" << endl;
                delete [] Msg;
        XMLPlatformUtils::Terminate();
        return 3;
    }


    // And call the termination method
    XMLPlatformUtils::Terminate();
    return 0;
}


// Source for the dtd handler
#ifndef DTDHANDLERS_H
#define DTDHANDLERS_H

#include <validators/DTD/DocTypeHandler.hpp>

#ifndef AFXCOLL_H
#include <afxcoll.h>
#endif

class DTDHandlers : public DocTypeHandler
{
public:
    //  Constructors
        DTDHandlers();
    ~DTDHandlers();

    virtual void attDef
    (
        const   DTDElementDecl&     elemDecl
        , const DTDAttDef&          attDef
        , const bool                ignoring
    );

    virtual void doctypeComment
    (
        const   XMLCh* const    comment
    );

    virtual void doctypeDecl
    (
        const   DTDElementDecl& elemDecl
        , const XMLCh* const    publicId
        , const XMLCh* const    systemId
        , const bool            hasIntSubset
    );

    virtual void doctypePI
    (
        const   XMLCh* const    target
        , const XMLCh* const    data
    );

    virtual void doctypeWhitespace
    (
        const   XMLCh* const    chars
        , const unsigned int    length
    );

    virtual void elementDecl
    (
        const   DTDElementDecl& decl
        , const bool            isIgnored
    );

    virtual void endAttList
    (
        const   DTDElementDecl& elemDecl
    );

    virtual void endIntSubset();

    virtual void endExtSubset();

    virtual void entityDecl
    (
        const   DTDEntityDecl&  entityDecl
        , const bool            isPEDecl
        , const bool            isIgnored
    );

    virtual void resetDocType();

    virtual void notationDecl
    (
        const   XMLNotationDecl&    notDecl
        , const bool                isIgnored
    );

    virtual void startAttList
    (
        const   DTDElementDecl& elemDecl
    );

    virtual void startIntSubset();

    virtual void startExtSubset();

    virtual void TextDecl
    (
        const   XMLCh* const    versionStr
        , const XMLCh* const    encodingStr
    );

        // other methods
        void GetValidIdCols(CStringArray& IdList);
        void GetValidDataCols(CStringArray& DataList);
        void GetDTDFunctionTypes(CStringArray& DataFunctions);
        void GetDTDSortOrder(CStringArray& SortOrder);

private :
        void doSplitting(CStringArray& List, char * Value);
        CStringArray pIdList;
        CStringArray pDataList;
        CStringArray pDataFunctions;
        CStringArray pSortOrders;
};
#endif




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to