external DTD with % as default attribute value

Sjoerd Mullender

Usenet Archive
Joined
Feb 17, 2004
Messages
10
Reaction score
0
I am trying to create a DTD where some attributes are to have a default value of "100%". The DTD is modularized similarly to the XHTML DTD modularization, so that means I have parsed entities that reference other parsed entities in external subsets.

The problem I'm facing is that the validating parser that I wrote myself accepts my DTD, but libxml2, Xerces and PyXML don't, and I don't know how I can fix the DTD so that all parsers are happy, or indeed whether there is a bug in either my own parser or in the others.

Does anybody have any ideas?

Here is a small example:

File x.xml:
<?xml version="1.0"?>
<!DOCTYPE test PUBLIC "xyzzy" "x.dtd">
<test/>

File x.dtd:
<!ENTITY % test.x.module PUBLIC "plugh" "x.mod">
%test.x.module;

File x.mod:
<!ENTITY % test.test.qname "test">
<!ENTITY % level1 "
attr CDATA '100%'
">
<!ENTITY % level2 "
%level1;
">
<!ENTITY % test.test.content "EMPTY">
<!ELEMENT %test.test.qname; %test.test.content;>
<!ATTLIST %test.test.qname; %level2;>

I can change the value to '&#37;', but then I still get into trouble. My DTD has more levels of indirection than this example: there is effectively also an entity

<!ENTITY % level3 "
%level2;
">

and the ATTLIST refers to this level3 entity. The parsers complain again about the DTD. If I then change the value to &#38;#37; two of the three accept the document, but the third parser (PyXML) still complains.

Note that & is "&" and % is "%".
 

Richard Tobin

Usenet Archive
Joined
Jan 6, 2000
Messages
4,251
Reaction score
0
Sjoerd Mullender said:
I am trying to create a DTD where some attributes are to have a default value of "100%".

Annoying, isn't it.
If I then change the value to &#38;#37; two of
the three accept the document, but the third parser (PyXML) still complains.

I think that's a bug in PyXML.

I suggest you define a (general internal) entity:

<!ENTITY pct "%">

and then use:

<!ENTITY % level1 "
attr CDATA '100&pct;'
">

The general entity reference won't get expanded until the string is interpreted as an attribute value, so it shouldn't matter how much indirection you have.

-- Richard
 

Sjoerd Mullender

Usenet Archive
Joined
Feb 17, 2004
Messages
10
Reaction score
0
Annoying, isn't it.

Frustrating is the word.
I think that's a bug in PyXML.

Ok. But apart from the posible bug in PyXML, this would then be the correct way? Every parsed entity indirection should add an extra &?
I suggest you define a (general internal) entity:

<!ENTITY pct "%">

and then use:

<!ENTITY % level1 "
attr CDATA '100&pct;'
">

The general entity reference won't get expanded until the string is interpreted as an attribute value, so it shouldn't matter how much indirection you have.

The problem with this solution is that it changes the accepted language. Now document writers can use this entity in their documents. But the language that I'm writing the DTD for does not allow for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,246
Members
248,133
Latest member
DujonT

Latest Threads

Top