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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.