[xml] Validating a XML document vs a Schema



Help me please.

I have a function which body is:
bool CXMLDocumento :: es_valido_contra_esquema( const basic_string< _TCHAR >
& _i_path_esquema ) const {
    bool ret;
    xmlSchemaParserCtxtPtr ctxt = xmlSchemaNewParserCtxt( ( xmlChar * )
_i_path_esquema.c_str() );
    if( ctxt ) {
        xmlSchemaPtr esquema = xmlSchemaParse( ctxt );
        if( esquema ) {
            xmlSchemaValidCtxtPtr v_ctxt = xmlSchemaNewValidCtxt( esquema );
            if( v_ctxt ) {
                xmlSchemaSetValidErrors( v_ctxt,
                    ( xmlSchemaValidityErrorFunc ) _aux_funcion_error,
                    ( xmlSchemaValidityWarningFunc ) _aux_funcion_warning,
                    ( void * ) this
                    );

                m_lista_errores.clear(); // Limpiamos la lista de errores.
                m_lista_warnings.clear(); // Limpiamos la lista de warnings.

                ret = xmlSchemaValidateDoc( v_ctxt, m_xml_doc ); //
m_xml_doc is the xmlDocPtr
                xmlSchemaFreeValidCtxt( v_ctxt );
            }
            else {
                ret = false;
            }
            xmlSchemaFree( esquema );
        }
        else {
            ret = false;
        }
        xmlSchemaFreeParserCtxt( ctxt );
    }
    else {
        ret = false;
    }

    return ret;
}

The documentation isn´t very extensive and the fuction xmlSchemaValidateDoc
(used as i wrote before) always return !=0.

I'd modified xmlwin32version.h and the BCB5 project to build the libxml2.lib
including this code:

/**
 * LIBXML_UNICODE_ENABLED
 *
 * Whether the Unicode related interfaces are compiled in
 */
#if 1
#define LIBXML_UNICODE_ENABLED
#endif

/**
 * LIBXML_REGEXP_ENABLED
 *
 * Whether the regular expressions interfaces are compiled in
 */
#if 1
#define LIBXML_REGEXP_ENABLED
#endif

/**
 * LIBXML_AUTOMATA_ENABLED
 *
 * Whether the automata interfaces are compiled in
 */
#if 1
#define LIBXML_AUTOMATA_ENABLED
#endif

/**
 * LIBXML_SCHEMAS_ENABLED
 *
 * Whether the Schemas validation interfaces are compiled in
 */
#if 1
#define LIBXML_SCHEMAS_ENABLED
#endif

after the DEBUG_MEMORY_LOCATION definition.

The questions are:
        1) Is correct the use of xmlSchemaValidateDoc?
        2) I know that the XSD file witch I validate de xml_doc is correct and the
xml_doc doesn't validate vs it. Do anyone help me?

Thank you.

Samuel Díaz García

samueldg telefonica net
samueldiazgarcia hotmail com
samueldiaz airtel net
samueldiaz teleline es

c/ Gardabosques, 1 - 5ºC
41015 - Sevilla

Tlf./Fax: 954 94 27 76




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]