I want to set up a parameter entity in order to declare attributes common to multiple elements.
What I am trying to do is make the "elem" element have the attribute "width CDATA "0". After I make that work, I would use it on more elements.
This is the code I came up with:
<?xml version="1.0"?>
<!DOCTYPE example [
<!ENTITY % attrs 'width CDATA "0"'>
<!ELEMENT example (elem) >
<!ELEMENT elem (#PCDATA) >
<!ATTLIST elem %attrs; > <!-- <This errors with "no name for attribute" -->
]>
<example>
<elem width="20">Hi how are you</elem>
</example>
The code I use is based on the accepted answer to a similar question (How do I declare attributes common to multiple elements?). However, when I run my code through XML validators (Exalt on SublimeText or xmlvalidation.com it errs.
On the site mentioned above, the error is:
The attribute name must be specified in the attribute-list declaration for element "elem1".
With Exalt, the error is:
ATTLIST: no name for Attribute at [...]
What I understand is that the name of the attribute is missing. But I put the name of the attribute on the parameter entity, so how can it not be detected?
If I replace %attrs; with 'width CDATA "0"', it works fine.
Why am I getting the error?