Why CDATA fails to parse in XML 1.1?

46 views Asked by At

Java SAX parser throws error if a CDATA section ends with a "]" and XML version is 1.1.

<?xml version="1.1" encoding="UTF-8"?>
<book>
  <description><![CDATA[Release year [1997]]]></description>
</book>

Error:

XML document structures must start and end within the same entity.

The same works just fine with XML 1.0.

<?xml version="1.0" encoding="UTF-8"?>
<book>
  <description><![CDATA[Release year [1997]]]></description>
</book>

Having the text end with a "]" should not be a problem. Only the sequence "]]>" is not allowed there. Why would XML 1.1 not work here?

My Java version:

openjdk version "17.0.7" 2023-04-18

0

There are 0 answers