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

Mixed content (part 2)

Following last week’s introduction to the concept of mixed content, let’s look in detail at a validated XML instance with mixed content.   Taking a look at the children nodes of the <letter> element   Let’s reuse the instance we stored in our table last time. We can query it and look at all the nodes under…

1

Mixed content (part 1 of many)

I started working on this two days ago. I quickly realized that when I’m done I’ll most likely have material for multiple posts. My original plan was to finish the article in the next few days, and then publish it as several posts over time. However I eventually decided to start posting now, while the work is…

4

xsi:nil magic (part 2/2)

Last time we looked at what happens to the xsi:nil attributes when replacing the value of a simply typed element. In this post, we’re going to look at complex types. First let’s create a schema collection with complex types and elements. CREATE XML SCHEMA COLLECTION SCnil_cplx AS ‘   <xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema” targetNamespace=”urn:nil” xmlns=”urn:nil”>        …


xsi:nil magic (part 1/2)

A few months ago I wrote a post about the interesting behavior of the xsi:type attribute. Today we’re going to look at his no so distant relative xsi:nil. But first let’s do a quick recap. Any element can be made nillable by adding the attribute nillable=”true” to its declaration. Practically it means that this element…

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

xsi:type magic

As I said in my previous post, the past few weeks have been demanding and I had little time to spend on blog post.  However I recently rediscovered an interesting behavior in typed XML DML and I felt I should make some time for a quick post. Today’s post deals with xsi:type. If you don’t…

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…


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…