[libxml-devel] [ libxml-Bugs-27848 ] Error#code_to_s gives incosistent answer (sometimes wrong)

11 views
Skip to first unread message

nor...@rubyforge.org

unread,
Apr 23, 2011, 12:19:08 AM4/23/11
to nor...@rubyforge.org
Bugs item #27848, was opened at 2010-02-17 05:52
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=1971&aid=27848&group_id=494

Category: General
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 3
Submitted By: Jarl Friis (jarl)
>Assigned to: Charlie Savage (cfis)
Summary: Error#code_to_s gives incosistent answer (sometimes wrong)

Initial Comment:
Hi.

Version 1.1.3

I experience that LibXML::XML::Error#code_to_s gives answers that varies arbitrary.

If I have a Empty document, the parse will give me a Error object with code 4.
but when I use code_to_s on that object it some times returns "DOCUMENT EMPTY" and sometimes "DTD"

I believe it is because the constants defined in Error are not prefixed (as they are in libxml), hence there are two constants with the same value:

irb(main):004:0> XML::Error.const_get("DTD")
=> 4
irb(main):005:0> XML::Error.const_get("DOCUMENT_EMPTY")
=> 4

Jarl


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

>Comment By: Charlie Savage (cfis)
Date: 2011-04-22 22:19

Message:
The code is correct. Both XML::DTD and XML::DOCUMENT_EMPTY have the same value. They come from two different enums defined in Libxml. A bit confusing I know, but correct.

Thanks - Charlie

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

Comment By: Jarl Friis (jarl)
Date: 2010-02-17 06:31

Message:
I have made a workaround file, I would not go so far as to
call it a patch... It's a monkey patch.

In a Rails app, the file can be placed in app/helpers,
which works around the problem. Note also my new
implementation only creates the number to name map once.

Jarl

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

You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=1971&aid=27848&group_id=494
_______________________________________________
libxml-devel mailing list
libxml...@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

nor...@rubyforge.org

unread,
Apr 25, 2011, 1:42:51 PM4/25/11
to nor...@rubyforge.org
Bugs item #27848, was opened at 2010-02-17 13:52

Category: General
Group: None
Status: Closed
Resolution: Accepted
Priority: 3
Submitted By: Jarl Friis (jarl)
Assigned to: Charlie Savage (cfis)
Summary: Error#code_to_s gives incosistent answer (sometimes wrong)

Initial Comment:
Hi.

Version 1.1.3

I experience that LibXML::XML::Error#code_to_s gives answers that varies arbitrary.

If I have a Empty document, the parse will give me a Error object with code 4.
but when I use code_to_s on that object it some times returns "DOCUMENT EMPTY" and sometimes "DTD"

I believe it is because the constants defined in Error are not prefixed (as they are in libxml), hence there are two constants with the same value:

irb(main):004:0> XML::Error.const_get("DTD")
=> 4
irb(main):005:0> XML::Error.const_get("DOCUMENT_EMPTY")
=> 4

Jarl


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

>Comment By: Jarl Friis (jarl)
Date: 2011-04-25 19:42

Message:
So what is the reason that this bug has been marked closed.
Is it fixed? If so, in what version.

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

Comment By: Charlie Savage (cfis)

Date: 2011-04-23 06:19

Message:
The code is correct. Both XML::DTD and XML::DOCUMENT_EMPTY have the same value. They come from two different enums defined in Libxml. A bit confusing I know, but correct.

Thanks - Charlie

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

Comment By: Jarl Friis (jarl)

Date: 2010-02-17 14:31

nor...@rubyforge.org

unread,
Apr 25, 2011, 4:13:33 PM4/25/11
to nor...@rubyforge.org
Bugs item #27848, was opened at 2010-02-17 05:52

Category: General
Group: None
Status: Closed
Resolution: Accepted
Priority: 3
Submitted By: Jarl Friis (jarl)
Assigned to: Charlie Savage (cfis)
Summary: Error#code_to_s gives incosistent answer (sometimes wrong)

Initial Comment:
Hi.

Version 1.1.3

I experience that LibXML::XML::Error#code_to_s gives answers that varies arbitrary.

If I have a Empty document, the parse will give me a Error object with code 4.
but when I use code_to_s on that object it some times returns "DOCUMENT EMPTY" and sometimes "DTD"

I believe it is because the constants defined in Error are not prefixed (as they are in libxml), hence there are two constants with the same value:

irb(main):004:0> XML::Error.const_get("DTD")
=> 4
irb(main):005:0> XML::Error.const_get("DOCUMENT_EMPTY")
=> 4

Jarl


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

>Comment By: Charlie Savage (cfis)
Date: 2011-04-25 14:13

Message:
both those constants in the underlying libxml library have a value of #4.

They do come from different enums:

typedef enum {
XML_ERR_OK = 0,
XML_ERR_INTERNAL_ERROR, /* 1 */
XML_ERR_NO_MEMORY, /* 2 */
XML_ERR_DOCUMENT_START, /* 3 */
XML_ERR_DOCUMENT_EMPTY, /* 4 */
...
} xmlParserErrors;


typedef enum {
XML_FROM_DTD, /* The XML DTD validation with parser context*/
....
} xmlErrorDomain;


So the first one is the actual error, the second one is where the error came from. Perhaps we could have added two separate classes, one for each enum, but that didn't seem worth doing since the usage should be fairly separate. One is error.code, one is error.domain.

Hope that helps - not seeing that there is a bug here.

Charlie

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

Comment By: Jarl Friis (jarl)

Date: 2011-04-25 11:42

Message:
So what is the reason that this bug has been marked closed.
Is it fixed? If so, in what version.

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

Comment By: Charlie Savage (cfis)

Date: 2011-04-22 22:19

Message:
The code is correct. Both XML::DTD and XML::DOCUMENT_EMPTY have the same value. They come from two different enums defined in Libxml. A bit confusing I know, but correct.

Thanks - Charlie

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

Comment By: Jarl Friis (jarl)

Date: 2010-02-17 06:31

Reply all
Reply to author
Forward
0 new messages