Are schemas better than DTDs for defining entities?

Discussion in 'XML' started by Curious, May 20, 2007.

  1. Curious

    Curious Guest

    Defining your own Entities in a DTD is rather pointless because Firefox &
    certain other browsers don't read the DTD.
    Is there a similar mechanism in schemas which works for all browsers?
    Curious, May 20, 2007
    #1
    1. Advertising

  2. > Is there a similar mechanism in schemas which works for all browsers?

    Entities are one of the DTD features which was *not* carried forward to
    Schemas. The assumption was that people would use other mechanisms --
    XInclude, inline XPointer, possibly stylesheet-assisted -- to implement
    named-block/macro referencing. Or do server-side inclusion.

    I haven't done a survey recently, so I don't know what's safe to assume
    for "all browsers". But one of those standards-based approaches might do
    the job for you.


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, May 20, 2007
    #2
    1. Advertising

  3. * Curious wrote in comp.text.xml:
    >Defining your own Entities in a DTD is rather pointless because Firefox &
    >certain other browsers don't read the DTD.


    They do, if you put the code in the internal subset rather than in some
    external document. There is no other way, except perhaps using scripts
    that dynamically load content, but then I am not sure what the point is.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Bjoern Hoehrmann, May 20, 2007
    #3
  4. Curious

    Peter Flynn Guest

    Curious wrote:
    > Defining your own Entities in a DTD is rather pointless because Firefox &
    > certain other browsers don't read the DTD.


    Browsers don't read an external DTD. Declared entities appear to work in
    browsers if you put the DTD in the internal subset of the document. In
    general, browser support for XML at the moment is poor and should be
    avoided in favour of server-side support where possible.

    > Is there a similar mechanism in schemas which works for all browsers?


    Not as such. W3C Schemas don't have a concept of entities. XML entities
    were inherited from SGML, and they continue to be important for normal
    text document work, but W3C Schemas are targeted more at describing data
    structures than text documents.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
    Peter Flynn, May 20, 2007
    #4
  5. Curious

    Curious Guest

    I tried defining an entitiy in the internal dtd using the files "simple.xml"
    and "navbar.xml" shown below. This did not work with Firefox 2.0.0.3. Only
    the title text was displayed.

    simple.xml file
    --------------
    <?xml version="1.0"?>
    <!DOCTYPE book SYSTEM "book.dtd"[
    <!ENTITY navbar SYSTEM "navbar.xml">
    ]>
    <book>
    <title>The Wit and Wisdom of George W. Bush</title>
    &navbar;
    </book>


    navbar.xml file
    ---------------
    <h1>This is the navbar text</h1>



    Curious.


    "Bjoern Hoehrmann" <> wrote in message
    news:p...
    > * Curious wrote in comp.text.xml:
    > >Defining your own Entities in a DTD is rather pointless because Firefox &
    > >certain other browsers don't read the DTD.

    >
    > They do, if you put the code in the internal subset rather than in some
    > external document. There is no other way, except perhaps using scripts
    > that dynamically load content, but then I am not sure what the point is.
    > --
    > Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    > Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    > 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Curious, May 21, 2007
    #5
  6. In article <7K44i.4024$>,
    Curious <> wrote:

    >I tried defining an entitiy in the internal dtd using the files "simple.xml"
    >and "navbar.xml" shown below. This did not work with Firefox 2.0.0.3. Only
    >the title text was displayed.


    > <!ENTITY navbar SYSTEM "navbar.xml">


    I don't think most browsers read external entities any more than they
    read the external subset. It would probably have worked if you did

    <!ENTITY navbar "<h1>This is the navbar text</h1>">

    though that may not be much use to you.

    -- Richard
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
    Richard Tobin, May 21, 2007
    #6
    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. Clifford W. Racz
    Replies:
    4
    Views:
    2,020
    Clifford W. Racz
    Feb 13, 2004
  2. Peter Bencsik
    Replies:
    2
    Views:
    826
  3. D McGilvray
    Replies:
    2
    Views:
    366
    D McGilvray
    Aug 1, 2007
  4. Jim Higson
    Replies:
    3
    Views:
    223
    Eric Amick
    Jul 25, 2004
  5. Replies:
    2
    Views:
    52
    Mark H Harris
    May 13, 2014
Loading...

Share This Page