Olivier said:
I want to define an attribute as a list of values taken from a finite
set, with a singleton default. Intuitively I want to write
attrname (AA|BB|CC)* "AA"
but that is not valid syntax and I can't find a way. Any suggestion? Or
am I out of luck?
No, but as you found, it won't work using a token list enumeration.
However, it will work if you define dummy external non-XML entities for
the values you want to use, and declare the attribute as type ENTITIES.
<?xml version="1.0"?>
<!DOCTYPE test [
<!ELEMENT test EMPTY>
<!ATTLIST test stuff ENTITIES "foo">
<!NOTATION NONXML SYSTEM "nonxml">
<!ENTITY foo SYSTEM "foo" NDATA NONXML>
<!ENTITY bar SYSTEM "bar" NDATA NONXML>
<!ENTITY blort SYSTEM "blort" NDATA NONXML>
]>
<test stuff="bar blort"/>
Note that the SYSTEM identifiers for the NOTATION and ENTITY
declarations are not resolved (so your parser will not try to find or
open them as URIs or local files).
It would also work using the attribute type IDREFS, and then you
wouldn't need to make the dummy NOTATION and ENTITY declarations, but
you would have to have a suitable unused ID attribute on some element
type somewhere, and you would have to add matching ID instances to
sufficient occurrences of the bearer element type to satisfy the ID
constraint. Using the above technique is probably easier.
///Peter