After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 120503 - xmlGetDocCompressMode returns -1 after load
xmlGetDocCompressMode returns -1 after load
Product: libxml2
Classification: Platform
Component: general
Other Linux
: Normal enhancement
: ---
Assigned To: William M. Brack
William M. Brack
Depends on:
Reported: 2003-08-22 21:50 UTC by Lars Clausen
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description Lars Clausen 2003-08-22 21:50:59 UTC
I'm trying to make Dia remember whether a diagram was loaded as compressed
or not.  However, when I call xmlGetDocCompressMode to check, I get -1
always, despite the docs claiming it's in the range 0-9.
Comment 1 William M. Brack 2003-08-23 14:02:38 UTC
I have looked at the coding and don't see any obvious error.  Could 
you give a little more detail on the steps you have gone through 
when you encounter the problem?  The value -1 is normally returned 
in only two instances - either the document compression mode has not 
been initialized by the user, or the document argument in the call 
to xmlGetDocCompressMode is NULL.

Comment 2 Lars Clausen 2003-08-25 13:18:58 UTC
This happens during the loading of a diagram.  These are the stages
that lead up to it:

  doc = xmlDiaParseFile(filename);

  if (doc == NULL){
    message_error(_("Error loading diagram %s.\nUnknown file
    return FALSE;
[...parse doc...]

At this point, xmlGetDocCompressMode(doc) returns -1.

Do you not set the compress mode when loading a document?  If not, the
docs should reflect this.
Comment 3 William M. Brack 2003-09-03 01:47:07 UTC
When I 'grep' through the source, the compression mode is actually 
contained in element "compression" within the context structure.  
This element is set by xmlSetDocCompression() and checked by 
xmlGetDocCompression().  There is no call to xmlSetDocCompression 
within the library, so I would conclude it is up to the user to take 
care of it.

If you would like to suggest an enhancement, I am sure it can be 
considered, else if you would suggest some particular document 
should be changed that can certainly be done.

Comment 4 Lars Clausen 2003-09-03 07:11:38 UTC

a) The docs ( should be updated to
clarify that the compression state is not set automatically when a
diagram is loaded (currently, it implies otherwise), or

b) (Better) The loader should call xmlSetDocCompression when it knows
whether the document is compressed or not.  I see in a comment in
xmlIO.c:xmlRegisterDefaultOutputCallbacks already thought a bit about
the problem of determining whether to write with compression or not. 
Instead of having to open an existing file, it'd be easier to keep the
info from loading.

Currently, it's throwing away a bit of information that's fairly
crucial to keeping the document similar to previously (important
especially for CVS users).
Comment 5 William M. Brack 2003-09-03 19:58:27 UTC
OK, I think I now fully understand the problem.  I'll have to do 
some further studying to find out whether (or how) the library can 
determine the compression mode of the input; if it's possible, then 
set the compression mode of the corresponding document (I'm not yet 
sure what to do with the "global" compression mode).  I'm going to 
change the severity of this bug to be a request for enhancement, 
since clearly the library does not do this at the moment.  I'll 
leave the documentation alone until this is resolved.  Thanks for 
your patience.
Comment 6 William M. Brack 2003-09-08 02:01:15 UTC
I have implemented some code in CVS which (I hope) will detect a 
compressed document and set doc->compression to be 9 if compressed, 
0 if not compressed, and -1 if not determined.  I tested it with 
some trivial cases, but would appreciate it if you could give it a 
more thorough test and let me know the results.
Comment 7 Daniel Veillard 2003-10-28 13:37:03 UTC
Seems fixed, if no the requested will have to report back,

Comment 8 Daniel Veillard 2003-11-05 23:54:41 UTC
Should be fixed in libxml2-2.6.2,