Can one specify XML attribute values as CDATA ? If yes - what would be the schema for the same. If not - why is this limitation not addressed in XML ?
Asked
Active
Viewed 1.4k times
2 Answers
10
No you cannot do this.
There's a very fine line (and a very large debate) between what constitutes an attribute and what constitutes a child element. See here for example.
That given, the "limitation" isn't addressed in XML because it doesn't exist. You always have the ability to put this data in a child element, and in fact I would go so far as to say that if you even have to think about this, an element is the correct structure.
Edit: More reading material
-
10OK, but if I'm not designing anything but simply trying to uses someone else's DTD/Schema, and need to supply an attribute value that contains illegal characters, what are my options? – Mark Reed Jul 31 '14 at 00:08
1
The way you handle that is to use a child element rather than an attribute.

Joel Coehoorn
- 399,467
- 113
- 570
- 794