I'm getting improperly nested xml when a column contains null.
I modified the first row (customer ALFKI) to have a NULL Address
column.
I'm using the following XSD Annotated Schema against the NorthWind
database:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xs:element name="customer" sql:relation="Customers"
sql:key-fields="CustomerID">
<xs:complexType>
<xs:sequence>
<xs:element name="name" sql:field="ContactName"
type="xs:string" />
<xs:element name="address" sql:is-constant="true">
<xs:complexType>
<xs:sequence>
<xs:element name="street" sql:field="Address"
type="xs:string" />
<xs:element name="city" sql:field="City"
type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" sql:field="CustomerID" type="xs:string"
/>
</xs:complexType>
</xs:element>
</xs:schema>
When run with the following query template:
<resources xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<sql:xpath-query>customer[@id='ALFKI' or
@id='ANATR']</sql:xpath-query>
</resources>
I get the following XML:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<customer id="ALFKI">
<name>Maria Anders</name>
<address>
<street>
<city>Berlin</city>
</street>
</address>
<customer id="ANATR">
<name>Ana Trujillo</name>
<address>
<street>Avda. de la Constitución 2222</street>
<city>México D.F.</city>
</address>
</customer>
</customer>
</resources>
Notice how the first customer has the <city> tag nested inside the
<street> tag, but the second customer has the <city> tag as a sibling
to <street>
Can anyone explain why this is happening and what the solution might
be (short of modifying my database to not accept null values in
certain columns)?
Thanks,
Jerry Collings
MyFamily.com, Inc.
jc*******@myfamilyinc.com