I have a large XML file, in which every nodes requires a CDATA tag.
<root>
<a>
<id>my_id</id>
<tr><![CDATA[This is the data]]></tr>
</a>
<b>
...
</b>
</root>
How to avoid to place CDATA in every node? Does DTD or Schema provide a method for this?
The reason for this requirement comes from a in-house framework, for localization purposes. All tags which contain the messages are to be CDATA'd, because very often they contain special characters. The XML I wrote was just for demonstration purposes and does not represent the actual data that I handle.
How to avoid to place CDATA in every node? Does DTD or Schema provide a method for this?
No... DTD or Schema is no help to your problem.
The reason for this requirement comes from a in-house framework
Well... Of course the XML parser which parses the document knows whether the section was an CDATA-section or not. This is also represented in the DOM by distinguishing between the interface CDATASection and the interface Text. So it is very easy for someone who writes an XML parser to enforce the use of CDATA-sections instead of just plain text sections. In 99.9% of the cases this is plain stupid and you should not check for that. But on the other hand I have seen so many stupid things in my life, that I would not at all be surprised if your in-house framework does just that and enforce the existence of CDATA-sections.
If this is the case (just try it), then you have to write the CDATA sections and be happy with that. If you are not happy with that after all you can write a script that transforms your XML adding these CDATA-sections.