Nikolai Weibull | 7 Feb 14:08
Picon
Gravatar

Problem with public entity references

What is going wrong here?  (Example files minimized to show the problem.)

a.dtd:
<!ENTITY % a PUBLIC "-//a//b//c" "">
%a;

a.ent:
<!ELEMENT a EMPTY>

a.xml:
<a/>

catalog:
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
  "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <public
    publicId="-//a//b//c"
    uri="a.ent"/>
</catalog>

% XML_DEBUG_CATALOG=1 XML_CATALOG_FILES=catalog xmllint --noout
--dtdvalid a.dtd a.xml
I/O error : Too many open files
I/O error : Too many open files
a.dtd:2: warning: failed to load external entity "a.dtd"
%a;
   ^
Entity: line 1:
(Continue reading)

Noam Postavsky | 8 Feb 02:52
Picon

Re: Problem with public entity references

Nikolai Weibull <now <at> bitwi.se> writes:

> What is going wrong here?  (Example files minimized to show the problem.)
>
> a.dtd:
> <!ENTITY % a PUBLIC "-//a//b//c" "">
> %a;
>
> a.ent:
> <!ELEMENT a EMPTY>

It looks like you swapped the entity definition with DTD definition.
Nikolai Weibull | 8 Feb 05:23
Picon
Gravatar

Re: Problem with public entity references

On Wed, Feb 8, 2012 at 02:52, Noam Postavsky
<npostavs <at> users.sourceforge.net> wrote:
> Nikolai Weibull <now <at> bitwi.se> writes:
>
>> What is going wrong here?  (Example files minimized to show the problem.)
>>
>> a.dtd:
>> <!ENTITY % a PUBLIC "-//a//b//c" "">
>> %a;
>>
>> a.ent:
>> <!ELEMENT a EMPTY>
>
> It looks like you swapped the entity definition with DTD definition.

No.  I’m including a DTD fragment (a.ent) in my main dtd (a.dtd).
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml <at> gnome.org
http://mail.gnome.org/mailman/listinfo/xml
Nikolai Weibull | 9 Feb 06:49
Picon
Gravatar

Re: Problem with public entity references

On Tue, Feb 7, 2012 at 14:08, Nikolai Weibull <now <at> bitwi.se> wrote:
> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

Changing this to

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">

doesn’t help.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml <at> gnome.org
http://mail.gnome.org/mailman/listinfo/xml
Noam Postavsky | 10 Feb 02:38
Picon

Re: Problem with public entity references

Nikolai Weibull <now <at> bitwi.se> writes:
>
> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
>
> doesn’t help.

I followed along in the debugger a bit, it looks like the catalog isn't
being consulted at all. It's getting stuck in a loop while parsing a.dtd:

1. Define %a as an entity in a.dtd
2. encounter %a
3. load the contents of a.dtd, i.e Go To Step 1

I guess it stops when it runs out of file descriptors.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml <at> gnome.org
http://mail.gnome.org/mailman/listinfo/xml
Nikolai Weibull | 14 Feb 13:34
Picon
Gravatar

Re: Problem with public entity references

On Fri, Feb 10, 2012 at 02:38, Noam Postavsky
<npostavs <at> users.sourceforge.net> wrote:
> Nikolai Weibull <now <at> bitwi.se> writes:
>>
>> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
>>
>> doesn’t help.
>
> I followed along in the debugger a bit, it looks like the catalog isn't
> being consulted at all. It's getting stuck in a loop while parsing a.dtd:
>
> 1. Define %a as an entity in a.dtd
> 2. encounter %a
> 3. load the contents of a.dtd, i.e Go To Step 1
>
> I guess it stops when it runs out of file descriptors.

I just remembered that I’ve asked about this previously.  Daniel then
pointed out that "" refers to the current document and leads to a
corner-case in the “XML standard(s)” that, in turn, lead to this
infinite regress.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml <at> gnome.org
http://mail.gnome.org/mailman/listinfo/xml
Liam R E Quin | 14 Feb 14:06
Favicon

Re: Problem with public entity references

On Tue, 2012-02-07 at 14:08 +0100, Nikolai Weibull wrote:
> What is going wrong here?  (Example files minimized to show the problem.)

It looks like there are some bugs, however...
> 
> a.dtd:
> <!ENTITY % a PUBLIC "-//a//b//c" "">

so the SYSTEM identifier of %a is actually "a.dtd", and system
identifers override public ones, so %a; includes a.dtd. I don't think
this is a bug.

If you change your DTD to use
<!ENTITY % a SYSTEM "boy">
and change the catalog to

<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog
V1.0//EN"
  "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
prefer="system">
  <system
    systemId="boy"
    uri="a.ent"/>
</catalog>

and use
SGML_CATALOG_FILES=catalog  xmllint --catalogs  --noout --dtdvalid a.dtd
a.xml localhost!lee ent> SGML_CATALOG_FILES=catalog  xmllint --catalogs
(Continue reading)

Nikolai Weibull | 14 Feb 14:20
Picon
Gravatar

Re: Problem with public entity references

On Tue, Feb 14, 2012 at 14:06, Liam R E Quin <liam <at> holoweb.net> wrote:
> On Tue, 2012-02-07 at 14:08 +0100, Nikolai Weibull wrote:
>> What is going wrong here?  (Example files minimized to show the problem.)

> It looks like there are some bugs, however...
>>
>> a.dtd:
>> <!ENTITY % a PUBLIC "-//a//b//c" "">
>
> so the SYSTEM identifier of %a is actually "a.dtd", and system
> identifers override public ones, so %a; includes a.dtd. I don't think
> this is a bug.

Well, I did add prefer="public" to the catalog in my follow-up, so it
should be preferring the public identifier, but it’s not.

> The bug that I see is that if your system identifier is "-//a//b//c"
> then xmllint doesn't obey the rewrite rule in the catalog, but tries to
> open a file called "-/a/b/c" -- probably it is doing hierarchical URI
> canonicalisation *before* checking the catalog.

"-//a//b//c" is a public identifier, not a system identifier, so I
don’t see how any of this is correct.

> In general, stay away from XML public identifiers if you can. They were
> a mistaken feature in the spec, not needed at all, and will only cause
> you problems!

I wish it were that simple.  The problem is that this is something
that occurs in a client’s files.  I currently have to manually (well,
(Continue reading)


Gmane