ATTLIST and enumerations

Discussion in 'XML' started by Manfred Lotz, Feb 24, 2014.

  1. Manfred Lotz

    Manfred Lotz Guest

    Hi there,
    I have an enumeration in a DTD which will be used at different places.

    Minimal example:

    <!ATTLIST mydoc
    bla CDATA #REQUIRED
    myenum (v1|vx|s|a) #IMPLIED>
    ....
    <!ATTLIST comment
    name CDATA #REQUIRED
    myenum (v1|vx|s|a) #IMPLIED>

    I don't want to have the enum list at different places in the DTD.

    Is it possible to have an enumeraton defined in one place of a DTD and
    refer to this in different ATTLIST statements?



    --
    Manfred
    Manfred Lotz, Feb 24, 2014
    #1
    1. Advertising

  2. Manfred Lotz

    Manfred Lotz Guest

    On Mon, 24 Feb 2014 06:37:54 +0100
    Manfred Lotz <> wrote:

    > Hi there,
    > I have an enumeration in a DTD which will be used at different places.
    >
    > Minimal example:
    >
    >



    > ...
    > <!ATTLIST comment
    > name CDATA #REQUIRED
    > myenum (v1|vx|s|a) #IMPLIED>
    >
    > I don't want to have the enum list at different places in the DTD.
    >
    > Is it possible to have an enumeraton defined in one place of a DTD and
    > refer to this in different ATTLIST statements?
    >
    >
    >


    Ok, I found it. Here is the solution, just for the records.


    <!ENTITY % enumtype "myenum (v1|vx|s|a) #IMPLIED">

    and then
    !ATTLIST mydoc
    bla CDATA #REQUIRED
    %enumtype;>


    --
    Manfred
    Manfred Lotz, Feb 24, 2014
    #2
    1. Advertising

  3. Manfred Lotz

    Peter Flynn Guest

    On 02/24/2014 06:01 AM, Manfred Lotz wrote:
    > On Mon, 24 Feb 2014 06:37:54 +0100
    > Manfred Lotz <> wrote:
    >
    >> Hi there,
    >> I have an enumeration in a DTD which will be used at different places.

    [...]
    >> Is it possible to have an enumeraton defined in one place of a DTD and
    >> refer to this in different ATTLIST statements?

    >
    > Ok, I found it. Here is the solution, just for the records.
    >
    > <!ENTITY % enumtype "myenum (v1|vx|s|a) #IMPLIED">
    >
    > and then
    > !ATTLIST mydoc
    > bla CDATA #REQUIRED
    > %enumtype;>


    Yes, that's the standard way to reuse a specification fragment.
    Most of the larger popular DTDs do this.

    It's also possible to put the list in an external text file, eg

    v1|
    vx|
    s|
    a

    and declare it as an external entity, then use the entity reference in
    the ATTLIST declaration. That way the list can be maintained externally
    to the DTD, sometimes by a non-XML person who doesn't have to edit the
    DTD to keep the list up to date.

    ///Peter
    Peter Flynn, Feb 24, 2014
    #3
  4. Manfred Lotz

    Manfred Lotz Guest

    On Mon, 24 Feb 2014 19:25:11 +0000
    Peter Flynn <> wrote:

    > On 02/24/2014 06:01 AM, Manfred Lotz wrote:
    > > On Mon, 24 Feb 2014 06:37:54 +0100
    > > Manfred Lotz <> wrote:
    > >
    > >> Hi there,
    > >> I have an enumeration in a DTD which will be used at different
    > >> places.

    > [...]
    > >> Is it possible to have an enumeraton defined in one place of a DTD
    > >> and refer to this in different ATTLIST statements?

    > >
    > > Ok, I found it. Here is the solution, just for the records.
    > >
    > > <!ENTITY % enumtype "myenum (v1|vx|s|a) #IMPLIED">
    > >
    > > and then
    > > !ATTLIST mydoc
    > > bla CDATA #REQUIRED
    > > %enumtype;>

    >
    > Yes, that's the standard way to reuse a specification fragment.
    > Most of the larger popular DTDs do this.
    >
    > It's also possible to put the list in an external text file, eg
    >
    > v1|
    > vx|
    > s|
    > a
    >
    > and declare it as an external entity, then use the entity reference in
    > the ATTLIST declaration. That way the list can be maintained
    > externally to the DTD, sometimes by a non-XML person who doesn't have
    > to edit the DTD to keep the list up to date.
    >
    > ///Peter
    >
    >


    You are right, this is also possible. In my case I prefer to have it in
    the DTD itself.


    --
    Thanks, Manfred
    Manfred Lotz, Feb 27, 2014
    #4
  5. Manfred Lotz

    Peter Flynn Guest

    On 02/27/2014 07:55 AM, Manfred Lotz wrote:
    > On Mon, 24 Feb 2014 19:25:11 +0000
    > Peter Flynn <> wrote:
    >
    >> On 02/24/2014 06:01 AM, Manfred Lotz wrote:
    >>> On Mon, 24 Feb 2014 06:37:54 +0100
    >>> Manfred Lotz <> wrote:
    >>>
    >>>> Hi there,
    >>>> I have an enumeration in a DTD which will be used at different
    >>>> places.

    >> [...]
    >>>> Is it possible to have an enumeraton defined in one place of a DTD
    >>>> and refer to this in different ATTLIST statements?
    >>>
    >>> Ok, I found it. Here is the solution, just for the records.
    >>>
    >>> <!ENTITY % enumtype "myenum (v1|vx|s|a) #IMPLIED">
    >>>
    >>> and then
    >>> !ATTLIST mydoc
    >>> bla CDATA #REQUIRED
    >>> %enumtype;>

    >>
    >> Yes, that's the standard way to reuse a specification fragment.
    >> Most of the larger popular DTDs do this.
    >>
    >> It's also possible to put the list in an external text file, eg
    >>
    >> v1|
    >> vx|
    >> s|
    >> a
    >>
    >> and declare it as an external entity, then use the entity reference in
    >> the ATTLIST declaration. That way the list can be maintained
    >> externally to the DTD, sometimes by a non-XML person who doesn't have
    >> to edit the DTD to keep the list up to date.
    >>
    >> ///Peter
    >>
    >>

    >
    > You are right, this is also possible. In my case I prefer to have it in
    > the DTD itself.


    Yes, it's only really useful when the list has to be maintained by a
    third party, or perhaps by a database (eg part numbers).

    ///Peter
    Peter Flynn, Feb 27, 2014
    #5
    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. exquisitus
    Replies:
    12
    Views:
    22,398
    Tilman Bohn
    Feb 19, 2005
  2. rblah
    Replies:
    3
    Views:
    457
    Peter Flynn
    Jan 18, 2004
  3. Alain Ketterlin

    ATTLIST id ID not working?

    Alain Ketterlin, Oct 1, 2003, in forum: XML
    Replies:
    4
    Views:
    552
    Eric Sirois
    Oct 3, 2003
  4. Christopher Benson-Manica

    reinterpret_cast and enumerations

    Christopher Benson-Manica, Nov 2, 2004, in forum: C++
    Replies:
    5
    Views:
    819
    Ron Natalie
    Nov 3, 2004
  5. Replies:
    1
    Views:
    386
    Ian Collins
    Jun 29, 2006
Loading...

Share This Page