ATTLIST and enumerations

M

Manfred Lotz

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?
 
M

Manfred Lotz

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;>
 
P

Peter Flynn

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
 
M

Manfred Lotz

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

Peter Flynn

On Mon, 24 Feb 2014 06:37:54 +0100

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
 

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

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top