CDATA sections are not needed. They are not a "relic of the past" because they have always been unnecessary.
This does not mean that they are not useful. Look at any programming language or library, and you can find a large number of things that you could do, not because they are semantically equivalent to something else, but which are useful if there is a person sitting there who needs to write material.
For that matter, even with software production it would also be convenient to use the opposite approach and use the CDATA sections for each individual fragment of c-data (bloated, but it could increase efficiency elsewhere).
FOR XML PATH does not include the person sitting there to write material. This is a tool for creating valid XML from SQL query results. (This is also not a question of parsing CDATA sections, but creating them is another matter).
And you can't really complain that FOR XML EXPLICIT is an alternative when you want very fine-grained control - the reason why FOR XML EXPLICIT is so unpleasant to use is sometimes because it gives you great control. Indeed, think about whether they first added support for CDATA partitions, and then added support for each other setting and setting, which seemed just as vital to someone else. How long will it take before FOR XML EXPLICIT becomes an automatic choice because it is simpler than FOR XML PATH‽
There are four cases where CDATA is useful:
- You are sitting at the keyboard, typing this material yourself.
- You are dealing with mixing different technologies with different standards developed at different times and which will be interpreted by different parsers differently (for example, javascript built into XHTML - although this is not 100% necessary here, this is a nightmare to do otherwise) .
- You are trying to parse XML with what XML does not understand.
- You are trying to use something built on a parser that provides access to low-level access between CDATA partitions and other character data and improper use of this low-level access.
Oddly enough, these four cases are also four cases where a ban on the adoption of CDATA partitions may make sense.
Case 1 does not apply here, it is not human-generated code. Case 2 can apply here if you are doing something really crazy. Honestly, the lack of CDATA sections is the least of your worries here; Switch to creating simplified XML in the request and converting it to another location. Case 3 may apply here, but it’s unfair to complain about SQL people, if so, when you have to complain about a broken XML parser that doesn’t consider <example> same as <![CDATA[<example>]]> . Case 4 may apply here, but again complains about the person who wrote the error code, not the SQL people.
source share