What xs:key/xs:keyref are not

Several of my posts are focused around XML and my endeavor into declarative programming is not over yet.
Currently, I’m working on some XSLT+msxsl:script+helper assembly that allows me to define and execute workflows for importing data from COM objects into XML.
While trying to teach COM method dispatch to XSLT I came around the problem of defining a schema with some nested elements that are referenced by other elements in the document. In particular I wanted to make it validatable that a method invocation uses correct parameter specifications.
My structure is like Class[progId]/Method[name]/Parameter[name,type] for the declaration and Instance[progId]/Method[name]/ParameterSpec[parameter,value] for the invocation.
Since I have a number of key and unique constraints easily available (progId, name, …), I thought it would be as easy to reference these keys.
It is not. There is no way to define a key constraint that includes fields from parent elements, e.g. [../../@progId, ../@name, @name].
Also, there seems to be no way to reference key/unique constraints defined on sub-level elements.
It is just that multi-part keys, especially composed from different hierarchy levels are not supported, mentioned right there in the XML Schema spec: "Provision for multi-field keys etc. goes beyond what is supported by xsl:key."
So xs:key/xs:keyref are not a sufficient tool to declare constraints on complex data in an XML schema. Maybe that’s why it’s left entirely unsupported in SQL Server 2005.
An artificial limitation, who knows why necessary.
As with databases the remedy is probably to escalate parent key fields to the childs, although this is already made implicit by the nesting hierarchy. Yet there is no way to specify the constraint along the hierarchy.
Disp-only typelib-less IDispatch to legacy components is a nightmare, especially about parameter typing. Maybe I should have used VB6 in the first place.
This entry was posted in Software Development. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s