I have a relationship between a parent Foo and its child Bar. When Bar contains anything within it, then it is mapped into a table containing the child-key column "FooID".
For instance, if the XML contains:
<Bar>
<Anything/>
</Bar>
then the FooID column will be populated.
|FooID|OtherColumns |...|
|--| --- | --- |
|FooID_1 | | |
However, my problem is that when Bar is empty or a self closing tag, then FooID is not populated. Is there a way to make a change from within the XML so that the child-key is set on the child even if the child is empty?
Current problematic functionality:
<Bar></Bar>
OR
<Bar/>
results in:
|FooID|OtherColumns |...|
|--| --- | --- |
| | | |
My .XSD:
<sql:relationship name="Foo_Bar" parent="Foo" parent-key="id" child="Bar" child-key="FooID"/>
<xsd:element name="Foo" sql:relation="Foo" sql:relationship="SomeRel_Foo">
<xsd:complexType>
<xsd:sequence>
...
<xsd:element name="Bar" sql:relation="Bar" sql:relationship="Foo_Bar">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="SomeElement1" type="xsd:string"/>
<xsd:element name="SomeElement2" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="FooID" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
...
UPDATE:
I also tried the following:
<xsd:attribute name="FooID" type="xsd:string" use="required"/>
AND
<xsd:element minOccurs="0" name="OrgForm" type="xsd:string" />