Hi Tom,
> I am having some trouble with enumeration in XML.
>
> Rather than doing this,
>
> <!ELEMENT TxnCode (BUY|SELL|DEP|INT)>
>
> I need to do the following, but it seems to be invalid,
>
> <!ENTITY % validCode "BUY|SELL|DEP|INT">
>
> <!ELEMENT TxnCode (%validCode;)>
I see two possible issues here
1- If Xerces-* does not allow you to use a PE in that context, then this is
a bug.
2- If Xerces-* tell you that you are doing something wrong but that this
entity reference is well placed that's because you can't define restrictions
on the character data of an element in a DTD. The construction you are using
defines the content model of your element, but it seems that you have not
defined those children elements. I strongly suggest that you use an
attribute as they are really meant to fill the purpose *I think* you are
describing here. However, there is a way to achieve the same result in using
elements :
<!ELEMENT BUY EMPTY>
<!ELEMENT SELL EMPTY>
<!ELEMENT DEP EMPTY>
<!ELEMENT INT EMPTY>
<!ELEMENT TxnCode (BUY|SELL|DEP|INT)>
Using it will result in :
<TxnCode>
<BUY/>
</TxnCode>
An other solution would be to use schemas.
I hope this help,
David