Using SQLXML Bulk Import with Complex Schema
I am trying to figure out how to use bulk SQLXML loading for a rather complex XML schema that I have no control over (this is nominally "standard"). A small example:
<RootElement>
<id root="e5404218-250a-4454-98d5-f9feee8a3589" />
<code code="93000" />
<time>
<low value="20140221095400.000" />
<high value="20140221095410.000" />
</time>
</RootElement>
Using the AXSD schema:
<?xml version="1.0"?>
<xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xs:element name="RootElement" sql:relation="re" >
<xs:complexType>
<xs:sequence>
<xs:element name="id" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:attribute name="root" type="xs:ID" sql:field="id" sql:identity="useValue"/>
</xs:complexType>
</xs:element>
<xs:element name="code" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="code" type="xs:long"/>
</xs:complexType>
</xs:element>
<xs:element name="time" type="timeRange"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="timeRange">
<xs:choice>
<xs:sequence>
<xs:element name="low">
<xs:complexType>
<xs:attribute name="value" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:sequence>
<xs:element name="high">
<xs:complexType>
<xs:attribute name="value" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:choice>
</xs:complexType>
</xs:schema>
My sticking point seems to come from the ID attached to the element's attribute, not the element's value, as no matter what setting I use, I get the error Schema: relationship expected on 'id'.
. There really is no relationship, it is just a container, as the committee that developed this schema apparently liked the attributes very much.
All examples I find have values that are the contents of the elements, not attributes. This includes decorating the element with sql:is-constant
(a Constant element cannot have attributes) and various element permutations sql:relation
.
The only option I could think of would be to do a preprocessing step that makes the attributes children and base the schema on them, but that seems like a hack.
Any suggestions on how to convince SQLXML to place my bets?
source to share
No one has answered this question yet
Check out similar questions: