external DTD with % as default attribute value

Discussion in 'XML' started by Sjoerd Mullender, Feb 12, 2008.

  1. 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 "%".

    --
    Sjoerd Mullender


    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.7 (GNU/Linux)
    Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

    iQCVAwUBR7IDUz7g04AjvIQpAQIEFQP/Wj+W2dk9PTEqCuo8eZpM+wRcThNpssz7
    mb8h9rRvmUQxB4rJx9SlcAKUXdBXjrDeC+FOb+zk6kB1OzShNeqpd4lVtNsOHR+G
    0yTR7iEvx+sRBMr9MAUawGTEfT02yxuxoK0iPP1Tyn/V/y0QOethvcy+F+4lMZ45
    t8PwTF4bfIg=
    =m8Fe
    -----END PGP SIGNATURE-----
     
    Sjoerd Mullender, Feb 12, 2008
    #1
    1. Advertising

  2. In article <181e3$47b20354$9163cdca$>,
    Sjoerd Mullender <> wrote:

    >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
    --
    :wq
     
    Richard Tobin, Feb 12, 2008
    #2
    1. Advertising

  3. On 2008-02-12 23:58, Richard Tobin wrote:
    > In article <181e3$47b20354$9163cdca$>,
    > Sjoerd Mullender <> wrote:
    >
    >> I am trying to create a DTD where some attributes are to have a default
    >> value of "100%".

    >
    > Annoying, isn't it.


    Frustrating is the word.

    >> 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.


    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.

    --
    Sjoerd Mullender


    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.7 (GNU/Linux)
    Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

    iQCVAwUBR7Km4D7g04AjvIQpAQJVuwQAoexhUk3L7f5qS19fxZdQKBSVRTc5Lf8z
    TEYJ5G5aPNphRvP+25yOTu0tkQ6tow9z6rzyQxLepwbVTVuAXnNPhbI29fbtrtnK
    wCb75my5j16/CoddZcPMvR8eszkExwCSX1Bn0nap0F1t92mHIYI/y8MFJl+JpDAk
    iNCnYIYv6f8=
    =sT5N
    -----END PGP SIGNATURE-----
     
    Sjoerd Mullender, Feb 13, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ajay Goel
    Replies:
    1
    Views:
    1,235
    Johannes Koch
    Jul 17, 2003
  2. blu4899
    Replies:
    4
    Views:
    1,731
    Bob Foster
    Oct 31, 2003
  3. Alexander
    Replies:
    0
    Views:
    317
    Alexander
    Jul 11, 2004
  4. Replies:
    1
    Views:
    4,288
    Joe Kesselman
    Aug 2, 2006
  5. dkmd_nielsen
    Replies:
    6
    Views:
    223
    Joel VanderWerf
    Nov 26, 2008
Loading...

Share This Page