Re: Nested entity declarations in DTDs

Mukul Gandhi <[email protected]>
Newsgroups gmane.text.xml.devel
Message-ID <CANGHzgC8_ghFKmrW7OSZZy4RFfg3DO0jZtHD6B9f0fxwYuc=Uw@mail.gmail.com>
its the same behavior with XercesJ, with following findings.

The original XML document instance, produces following error,

[Fatal Error] test.xml:23:4: The parameter entity reference "%a;" cannot
occur within markup in the internal subset of the DTD.

But doing like following,

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE feed SYSTEM "nest1.dtd">
<feed xmlns="&a;">&b;</feed>

Parses without issues.

On Sun, Mar 13, 2022 at 9:57 PM David Carlisle <[email protected]>
wrote:

> You can have the definitions but you can't reference them as you can't
> have parameter entity references in the internal subset, rxp moans:
>
> $ rxp -sx nes1.xml
> Error: PE ref not allowed here in internal subset
>  in entity "g" defined at line 19 char 1 of file:///c:/tmp/nes1.xml
>  in unnamed entity at line 23 char 4 of file:///c:/tmp/nes1.xml
>
>
>
> If on the other hand you do this in an external DTD it is fine
>
> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE feed SYSTEM "nest1.dtd">
>
> <feed xmlns="&a;">&b;</feed>
>
> where nest1.dtd is
>
> <!ENTITY a 'http://www.w3.org/2005/Atom'>
> <!ENTITY b '&e;&f;&g;&h;&i;'>
> <!ENTITY c 'tag:xn--8ws00zhy3a.com,2006-05-04:/tests/atom/obfuscated/'>
> <!ENTITY d 'http://www.xn--8ws00zhy3a.com/tests/atom/obfuscated/'>
> <!ENTITY e '<title>Obfuscated Atom</title>
>   <updated>2007-10-19T00:00:00+00:00</updated>
>   <id>&c;</id><link rel="alternate" href="&d;"/>
>   <link rel="self" href="&d;1_4.atom"/>
>   <author><name>James Holderness</name></author>'>
> <!ENTITY % a '<entry><title>This is title #'>
> <!ENTITY % b '</title><updated>2007-10-18T23:'>
> <!ENTITY % c ':00+00:00</updated><id>&c;'>
> <!ENTITY % d '</id><link href="&d;'>
> <!ENTITY % e '.html"/><summary type="html">
>   This is the <code>summary</code> for entry number '>
> <!ENTITY % f '.</summary></entry>'>
> <!ENTITY % g '<!ENTITY f
> "&#37;a;1&#37;b;59&#37;c;1&#37;d;1&#37;e;1&#37;f;">'>
> <!ENTITY % h '<!ENTITY g
> "&#37;a;2&#37;b;58&#37;c;2&#37;d;2&#37;e;2&#37;f;">'>
> <!ENTITY % i '<!ENTITY h
> "&#37;a;3&#37;b;57&#37;c;3&#37;d;3&#37;e;3&#37;f;">'>
> <!ENTITY % j '<!ENTITY i
> "&#37;a;4&#37;b;56&#37;c;4&#37;d;4&#37;e;4&#37;f;">'>
> %g;%h;%i;%j;
>
>
> produces:
>
>
>
> $ rxp -x nes1.xml
> <feed xmlns="http://www.w3.org/2005/Atom"><title>Obfuscated
> Atom</title>&#10;  <updated>2007-10-19T00:00:00+00:00</updated>&#10;
>  <id>tag:xn--8ws00zhy3a.com,2006-05-04:/tests/atom/obfuscated/</id><link
> href="http://www.xn--8ws00zhy3a.com/tests/atom/obfuscated/"
> rel="alternate"></link>&#10;  <link href="
> http://www.xn--8ws00zhy3a.com/tests/atom/obfuscated/1_4.atom"
> rel="self"></link>&#10;  <author><name>James
> Holderness</name></author><entry><title>This is title
> #1</title><updated>2007-10-18T23:59:00+00:00</updated><id>tag:
> xn--8ws00zhy3a.com,2006-05-04:/tests/atom/obfuscated/1</id><link href="
> http://www.xn--8ws00zhy3a.com/tests/atom/obfuscated/1.html"></link><summary
> type="html">&#10;  This is the <code>summary</code> for entry number
> 1.</summary></entry><entry><title>This is title
> #2</title><updated>2007-10-18T23:58:00+00:00</updated><id>tag:
> xn--8ws00zhy3a.com,2006-05-04:/tests/atom/obfuscated/2</id><link href="
> http://www.xn--8ws00zhy3a.com/tests/atom/obfuscated/2.html"></link><summary
> type="html">&#10;  This is the <code>summary</code> for entry number
> 2.</summary></entry><entry><title>This is title
> #3</title><updated>2007-10-18T23:57:00+00:00</updated><id>tag:
> xn--8ws00zhy3a.com,2006-05-04:/tests/atom/obfuscated/3</id><link href="
> http://www.xn--8ws00zhy3a.com/tests/atom/obfuscated/3.html"></link><summary
> type="html">&#10;  This is the <code>summary</code> for entry number
> 3.</summary></entry><entry><title>This is title
> #4</title><updated>2007-10-18T23:56:00+00:00</updated><id>tag:
> xn--8ws00zhy3a.com,2006-05-04:/tests/atom/obfuscated/4</id><link href="
> http://www.xn--8ws00zhy3a.com/tests/atom/obfuscated/4.html"></link><summary
> type="html">&#10;  This is the <code>summary</code> for entry number
> 4.</summary></entry></feed>
>
> On Sun, 13 Mar 2022 at 15:40, <[email protected]> wrote:
>
>> Hello all,
>>
>> I was wondering if anyone could help clarify an aspect of the
>> specification for DTDs; I am currently working on an XML parser, but have
>> never really used DTDs myself.
>>
>> http://www.詹姆斯.com/blog/2007/10/obfuscated-atom
>> <http://www.xn--8ws00zhy3a.com/blog/2007/10/obfuscated-atom>
>>
>> In the above URL, there is a DTD (copied below) with nested entity
>> declarations, is this valid?
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <!DOCTYPE feed [
>> <!ENTITY a 'http://www.w3.org/2005/Atom'>
>> <!ENTITY b '&e;&f;&g;&h;&i;'>
>> <!ENTITY c 'tag:xn--8ws00zhy3a.com,2006-05-04:/tests/atom/obfuscated/'>
>> <!ENTITY d 'http://www.xn--8ws00zhy3a.com/tests/atom/obfuscated/'>
>> <!ENTITY e '<title>Obfuscated Atom</title>
>>   <updated>2007-10-19T00:00:00+00:00</updated>
>>   <id>&c;</id><link rel="alternate" href="&d;"/>
>>   <link rel="self" href="&d;1_4.atom"/>
>>   <author><name>James Holderness</name></author>'>
>> <!ENTITY % a '<entry><title>This is title #'>
>> <!ENTITY % b '</title><updated>2007-10-18T23:'>
>> <!ENTITY % c ':00+00:00</updated><id>&c;'>
>> <!ENTITY % d '</id><link href="&d;'>
>> <!ENTITY % e '.html"/><summary type="html">
>>   This is the <code>summary</code> for entry number '>
>> <!ENTITY % f '.</summary></entry>'>
>> <!ENTITY % g '<!ENTITY f "&#37;a;1&#37;b;59&#37;c;1&#37;d;1&#37;e;1&#37;f;">'>
>> <!ENTITY % h '<!ENTITY g "&#37;a;2&#37;b;58&#37;c;2&#37;d;2&#37;e;2&#37;f;">'>
>> <!ENTITY % i '<!ENTITY h "&#37;a;3&#37;b;57&#37;c;3&#37;d;3&#37;e;3&#37;f;">'>
>> <!ENTITY % j '<!ENTITY i "&#37;a;4&#37;b;56&#37;c;4&#37;d;4&#37;e;4&#37;f;">'>
>> %g;%h;%i;%j;
>> ]>
>> <feed xmlns="&a;">&b;</feed>
>>
>>
>>
>> Saxon and the XSLT processor in Chrome both say no, but if you try the
>> processor in Firefox it appears to process fine.
>>
>> http://xsltfiddle.liberty-development.net/jy6KM8g
>>
>> Any pointers in the right direction would be appreciated, many thanks in
>> advance. :)
>>
>

-- 
Regards,
Mukul Gandhi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.