Search code examples
xmlcdatarelaxng

Is it possible to force the use of CDATA via RelaxNG?


I'm looking for a way to use RelaxNG to require an element in an XML document to be populated with CDATA.

I don't see it listed in the Guidelines for using W3C XML Schema Datatypes with RELAX NG or the datatype library.

Is it possible?


Solution

  • According to the "Force use of CDATA in XML-schema" question, it's not possible to require CDATA in an element with RelaxNG. This is because validation works on the XML Infoset. The CDATA has already been processed out before it hits the validator. So, RelaxNG has no way of checking for it.


    Note: My searches of StackOverflow didn't turn up the other question. It only showed up buried in the "Questions with similar titles" list when I finished typing up the question. Based on the "It's OK to Ask and Answer Your Own Questions" post, I'm leaving this question up in hopes that it makes it easier to find.