]> git.sesse.net Git - mlt/commitdiff
Print useful information for xml parse errors.
authorBrian Matherly <pez4brian@yahoo.com>
Mon, 23 Jan 2012 04:47:17 +0000 (22:47 -0600)
committerBrian Matherly <pez4brian@yahoo.com>
Tue, 24 Jan 2012 02:38:30 +0000 (20:38 -0600)
src/modules/xml/producer_xml.c

index d863f70bb1ea02d81c6fa903dadf64dff6431a36..4795044c508f3d1b6b8d77919d103ead7158c3cb 100644 (file)
@@ -1469,6 +1469,13 @@ static xmlEntityPtr on_get_entity( void *ctx, const xmlChar* name )
        return e;
 }
 
+static void    on_error( void * ctx, const char * msg, ...)
+{
+       struct _xmlError* err_ptr = xmlCtxtGetLastError(ctx);
+       fprintf( stderr, "XML parse error: %s\trow: %d\tcol: %d\n",
+                        err_ptr->message, err_ptr->line, err_ptr->int2);
+}
+
 /** Convert a hexadecimal character to its value.
 */
 static int tohex( char p )
@@ -1607,9 +1614,6 @@ mlt_producer producer_xml_init( mlt_profile profile, mlt_service_type servtype,
        // We need to track the number of registered filters
        mlt_properties_set_int( context->destructors, "registered", 0 );
 
-       // Setup SAX callbacks
-       sax->startElement = on_start_element;
-
        // Setup libxml2 SAX parsing
        xmlInitParser(); 
        xmlSubstituteEntitiesDefault( 1 );
@@ -1665,12 +1669,15 @@ mlt_producer producer_xml_init( mlt_profile profile, mlt_service_type servtype,
        }
 
        // Setup SAX callbacks
+       sax->startElement = on_start_element;
        sax->endElement = on_end_element;
        sax->characters = on_characters;
        sax->cdataBlock = on_characters;
        sax->internalSubset = on_internal_subset;
        sax->entityDecl = on_entity_declaration;
        sax->getEntity = on_get_entity;
+       sax->error = on_error;
+       sax->fatalError = on_error;
 
        // Parse
        xmlcontext->sax = sax;