SQL Server 2005 CTP XML functionality enhancement (also known as the SQL Server XML Christmas presents)
As I mentioned earlier, we are working on adding some requested features to Beta3. The December CTP build (981.04) already contains one of them.
Per default, if you parse an XML instance, we drop some whitespace characters unless they are guarded with an xml:space="preserve" attribute or are entitized.
For example,
select CONVERT(XML, '<a> </a>')
will return
<a/>
which means that the whitespace only content has been dropped. Note that this is not 100% XML 1.0 spec conformant but conforms to the 95% user expectation.
So,
select CONVERT(XML, '<a xml:space="preserve"> </a>')
will return
<a xml:space="preserve"> </a>
and
select CONVERT(XML, '<a>   </a>')
will return
<a> </a>
which preserves the whitespace.
However, often users cannot change their data to protect the whitespace. Therefore we have added a new convert option that will preserve the whitespace regardless. So it is my pleasure to introduce:
select CONVERT(XML, '<a> </a>', 1)
which returns
<a> </a>
Some additional things we are working on for the next CTP and Beta3 are (standard disclaimer is that this may or may not be included according to last minute decisions):
- Performance, performance and (you guessed it) performance.
- Disabling DTD and entity declaration processing during parsing by default. This is a security item to minimize the danger of “entity expansion“ overload. You will still be able to get the DTD functionality with a CONVERT style option.
- Further alignment of the implemented XQuery functionality to the July 2004 WD stage. This will be most likely the state with which we will ship RTM. So if you have any issues, please let us know (and start adding those semi-colons after the namespace declarations now! :-)).
- Adding namespace support to FOR XML PATH.
- Restricting datetime, time and date values to values with timezones and serialize them with Z (this is the result of the recent customer survey). Enabling value() method returning a Z-normalized value to datetime.
Merry Christmas, hohoho :-)