Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tclxml3.2 suppressing error output from libxml2.9.1

54 views
Skip to first unread message

bjwi...@gmail.com

unread,
Aug 7, 2018, 2:18:59 PM8/7/18
to
We are having issues with suppressed error output in C++ libxml's (2.9.1) xmlParseFile after loading dom (or xml) from Tclxml3.2 in Tcl8.6.8. Before loading the dom package , we get output for all parser errors encountered during xmlParseFile. After we load dom, only the last line of the error message makes it out.

---------------------------------------------------------------------

% parse_xml
constraints.xml:21: parser error : Opening and ending tag mismatch: Cons line 13 and Con
</Con>
^
constraints.xml:23: parser error : error parsing attribute name
<Constraint Category = "Orent2" <!--test--> Name = "check2" Scop
^
constraints.xml:23: parser error : attributes construct error
<Constraint Category = "Orent2" <!--test--> Name = "check2" Scop
^
constraints.xml:23: parser error : Couldn't find end of Start Tag Constraint line 23
<Constraint Category = "Orent2" <!--test--> Name = "check2" Scop
^
constraints.xml:31: parser error : Opening and ending tag mismatch: Cons line 11 and Con
</Con>
^
constraints.xml:33: parser error : Opening and ending tag mismatch: Config line 3 and Cons
</Cons>
^
Error: unable to parse file "constraints.xml"

% package require dom
3.2
% parse_xml
Error: unable to parse file "constraints.xml"

%

---------------------------------------------------------------------
// test.C

#include <tcl.h>
#include <libxml/parser.h>


int parse_xml(
ClientData c_data,
Tcl_Interp *interp,
int argc,
Tcl_Obj * CONST argv[]
)
{
xmlDocPtr doc;
xmlInitParser();
const char *filename = "constraints.xml";

/* Produces parser error output before Tclxml3.2 is loaded in interpreter */
doc = xmlParseFile(filename);
if (doc == NULL) {
/* This is printed before and after Tclxml3.2 is loaded */
fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
return TCL_ERROR;
}

xmlCleanupParser();
return TCL_OK;
}

int Foo_Appinit( Tcl_Interp* interp ) {
int status = Tcl_Init(interp);
if (status != TCL_OK) {
return TCL_ERROR;
}

Tcl_CreateObjCommand(interp, "parse_xml", parse_xml, NULL, NULL);
return TCL_OK;
}

int main( int argc, char* argv[] ) {
Tcl_FindExecutable(argv[0]);
Tcl_Main( argc, argv, &Foo_Appinit );
}


---------------------------------------------------------------------
constraints.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Config Version = "1">
<Includes>
<Include Scope = "FOOBAR">foobar.xml</Include>
</Includes>
<Cons>
<Cons Category = "Orient" Name = "check1" Base = "FooCheck1">
<Parameters>
<Parameter Name = "rotation">90</Parameter>
</Parameters>
</Con>
<Constraint Category = "Orent2" <!--test--> Name = "check2" Scope = "Bar" Base = "" View = "Plan" Convention = "Bla">
<Parameters>
<Parameter Name = "rotation">270</Parameter>
</Parameters>
</Con>
</Cons>

---------------------------------------------------------------------

This is hindering our move to Tcl8.6. In our Tcl8.4 build (libxml 2.6.22, Tclxml3.1; tcldom3.0) the error output is not suppressed by loading dom or xml. We've tried displaying the error with xmlParserError and setting an error handler with xmlSetGenericErrorFunc, but none of these give us access to more than the last line of error output.

Brad Lanam

unread,
Aug 7, 2018, 3:15:42 PM8/7/18
to
This may not be what you want to hear, but have
you considered moving to a package that still has support
such as tDOM? I don't see any real activity for tclxml since
2009. Maybe it is an excellent package, but without
support, you're on your own unless you can find more
users of the packages.

Someone posted a patch for a memory leak in the tickets.
That's the first thing I would try.

You could also try and contact the user who has a patch
to bring tclxml up to version 3.3.

phil...@gmail.com

unread,
Aug 7, 2018, 5:53:11 PM8/7/18
to
Hi Brad,

Brian is working with me - so we are running into the issue discussed on the tDom licensing thread - the patent clause in the tDom license.

Phil

heinrichmartin

unread,
Aug 8, 2018, 3:01:24 AM8/8/18
to
On Tuesday, August 7, 2018 at 8:18:59 PM UTC+2, bjwi...@gmail.com wrote:
> We are having issues with suppressed error output in C++ libxml's (2.9.1) xmlParseFile after loading dom (or xml) from Tclxml3.2 in Tcl8.6.8. Before loading the dom package , we get output for all parser errors encountered during xmlParseFile. After we load dom, only the last line of the error message makes it out.

Have you looked into the return options? Imo the package should not write to stderr anyway, but return error messages. Maybe this was fixed in 3.2. See man catch/try/return, e.g. [catch {parse_xml} res opt; set $opt]

<sidenote>This seems like a pattern in Tcl packages: The http packages provides full details for error responses, but the rest packages forwards only the http error code to the caller...</sidenote>

I patch the package while debugging in such cases (simple for the rest package that is pure Tcl).

phil...@gmail.com

unread,
Aug 8, 2018, 12:25:23 PM8/8/18
to
The issue isn't what happens inside Tcl, but what happens inside C. Loading the Tcl package alters the behavior of the underlying C library.
0 new messages