This is weird, and while I'm an XML wonk, I haven't been a SQL wonk in a while. I created a new column in a database with the new SQL 2005 XML type. Then I went to the W3C XHTML page and copy/pasted the XSD for XHTML Strict. Since the syntax is
CREATE XML SCHEMA COLLECTION NorthwindCollection AS 'your xml schema here'
I needed to escape the quotes, so I converted all ' to '' via a selection-based replace. So then I had:
Use Northwind;CREATE XML SCHEMA COLLECTION NorthwindCollection AS '<?xml version="1.0" encoding="UTF-8"?><xs:schema version="1.0" xml:lang="en" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:xml="http://www.w3.org/XML/1998/namespace" elementFormDefault="qualified"> ...etc...lots more schema here...'
But I got this error:
Msg 2206, Level 16, State 1, Line 3Namespace prefix 'xml' can only be associated with the URI 'http://www.w3.org/XML/1998/namespace' and this URI cannot be used with other prefixes.
Which is weird, because the prefix IS obviously associated with the correct namespace and used correctly in the xml:lang attribute on the root node. Here's where it gets weird. If you REMOVE the xmlns:xml line from the ordinarily correct schema, it works fine and is added to SQL 2005's types section as a value XML Schema Collection. (see image)
It appears that this namespace is hard-coded inside the SQL 2005 somewhere along with the xml: prefix.
UPDATE: The reserved prefix is documented, but a smidge buried for my taste. Thanks to Harry for the pointer. I'm still not clear on why the namespace itself has to be removed from the document.
I have no conclusion here (yet) or idea why this works this way, but one day someone may need to get the XHTML schema into SQL Server to store notes or something for a content management system and this post may help them. I'll update it as I get more information or as I become less ignorant.
Now playing: Goapele - Intro
Scott at DevReach in Bulgaria in October
Developer Stand up Comedy - Coding 4 Fun
TechDays/DevDays Netherlands and Belgium:
Posts by Category Posts by Month
Greatest Hits Dev Tools List