Silent XQuery failures

A newsgroup post I read earlier today reminded me that there are cases where failure to get the expected result when using XQuery can sometimes be difficult to diagnose. Here’s what the poster was doing declare @xml xml set @xml = ‘<root><test></test></root>’ set @xml.modify(‘replace value of (/root/test/text())[1] with “test new value”‘) select @xml This user…

4

Mixed content (part 3)

It’s been a few weeks since my last post about mixed content so let’s pick up right where we left off. This time we will look at DML operations on mixed content.  We’ll keep using the XML schema as well as the table I created in the first post of this series.   Let’s insert…

1

Complementing XSD with CHECK constraints

I was recently asked to look at a customer’s question. This person wanted to write a schema that would validate instances like the following one. <TopElement>   <a>     <element1 att1=”data1″ att2=”data2″/>     <an_element att1=”data 1″ att2=”data 2″/>     <something att1=”abc” att2=”def”/>   </a> </TopElement>   The customer had two requirements for the children of…

3

Explaining the reasons behind some of XML datatype’s limitations

If you use XML in SQL Server 2005, and especially if you use it in association with schemas, I suggest you read Brandon’s recent blog post about the limitations that were placed on the XML datatype. Brandon is one of our developers and he’s got first-hand information about the design decisions that lie behind those limitations. On a…


Restricting the contents of a typed XML column using triggers

A typed XML column/variable is constrained by a schema collection. That means only instances that can be validated against the schemas in the collection will be accepted. You can tighten the rules a little bit with the use of the DOCUMENT facet, which adds the extra requirement that only well formed XML documents be accepted…


Importing the Microsoft Office 2003 schemas into the database

As promised earlier I’m going to give you an example using a real-world schema. I’ve chosen to work with the Office 2003 schemas but I’m going to limit myself to Word and Excel. First, you need to install the schemas from here. In the T-SQL samples below I’ll always assume that the installation was performed at the…


Download SP1 today!

Yesterday we released our first Service Pack for SQL Server 2005. You might remember a while back I had written a small post about being hard at work on SP1. Back then I avoided giving any details for fear of running afoul of corporate policy but since the bits are officially out, I can now…

3

Importing an existing XML schema into SQL Server 2005

In my last post I addressed the issue of non deterministic content models, which can be valid with respect to the W3C’s standards, but which are always rejected by SQL Server 2005. There are a few other XSD features that SQL Server 2005 doesn’t support. There are also challenges inherent to the nature of SQL…

12

Fixing non deterministic schemas

If you’ve been importing XML schemas into SQL Server 2005 you might have encountered this error message   XML Validation: XML instances of the content model of type or model group ‘…’ can be validated in multiple ways and are not supported.   The reason for this message is that the schema you tried to…

1

How to preserve whitespaces

For once I’m going to venture outside of the realm of typed XML and address an issue that might be of concern to users of untyped XML as well. We’ve been asked a few times if we had a solution to preserve non-significant whitespaces in an XML instance. The short answer is “Yes”. First, let’s…

1