Xml Schema Conundrum

Last Post 26 Jun 2008 07:50 AM by 9C8C5230-DDFF. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
9C8C5230-DDFF
New Member
New Member

--
13 Jun 2008 12:14 PM
I'm working with typed xml in Sql server '05 and haven't been able to resolve a couple questions through the documentation or any of my searches so far - so fanfare aside here is the most immediate question:

If I have an XML Schema Collection with multiple namespaces how can I specify an xml column or variable that only targets one of the included namespaces?

i.e: (pretend this is SSMS)
- XML Schema Collections
----- dbo.FooSchema
--------- ns://mydomain.com/foo/
--------- ns://mydomain.com/importsFoo/

Is it possible to have a typed xml column/variable that is valid only if the content conforms to the 'ns://mydomain.com/importsFoo/' namespace?


Aside from this, if anyone has discovered any creative ways to resolve an xs:import against a schema stored in a different collection I'd love to hear about it.

In essence I have several namespaces under the same ns root and I would like to use them in schema collections to validate and operate on xml in the database, but I'm finding advanced support lacking. I'll eventually become an expert on the topic through trial and error, but I was hoping someone had already beat me to it.

So, any bytes?

Thanks;

Steve L.

9C8C5230-DDFF
New Member
New Member

--
26 Jun 2008 07:50 AM
No bites at all.

However the plot has thickened. Having more or less resigned myself to using check constraints to enforce conformity to specific namespaces from a xml schema collection containing more than one namespace, I've made a discovery that I do not recall having seen in the documentation.

Have a look at this version of this post:

http://sqlblog.com/forums/thread/7315.aspx

A gentleman posted a reply with an example and that got me to testing some constraints when I noticed what I'm going to have to call a bug.

To summarize:
the xml .exist() method dies when you point it at a schema namespace containing multiple root elements. The full description is at the location above. If you try to execute the method on typed xml it errors saying that no such element exists in the namespace, if you execute it on untyped xml that includes an xmlns dclaration and the namespace is registered in the schema collection the method always returns 0, regardless of the truth.
You are not authorized to post a reply.

Acceptable Use Policy