473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Improperly nested XML when column contains NULL

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
Nov 12 '05 #1
1 2104
I found a problem in some post processing code I was using that
handled empty elements improperly.
I could see that the annotated schema was working after I removed this
post processing step.

Jerry

jc*******@myfamilyinc.com (Jerry Collings) wrote in message news:<2d**************************@posting.google. com>...
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

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bernard Koninckx | last post by:
Hi everybody, The following code (putted in a inherited object from AbstractTableModel object) make some errors : public void deleteRow(int rowToDelete){ try{ Object dataObject =...
0
by: Chi | last post by:
This is a problem that has been nagging me for a while, and I cannot figure out how to best solve the problem: I have a stored procedure that returns multi-level "nested" XML and inline XDR. My...
0
by: Jerry Collings | last post by:
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...
8
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
5
by: cbielins | last post by:
I have a problem, and would like you input... I need to evaluate to columns and then base a third column on their values. But, I need to include NULL values and this statement isn't working,...
0
by: hammad.awan_nospam | last post by:
Hello, I am using ASP.NET 2.0. What I have done is nested a gridview inside another column of a gridview using a template data field column declaritively in my web form. Inside this child...
5
by: BMeyer | last post by:
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML...
4
by: =?Utf-8?B?SmFtZXMgR2V1cnRz?= | last post by:
On my page, I have one repeater that contains a literal control and a nested repeater. The nested repeater contains a literal control. Both repeaters are databound with only one object (string). ...
0
by: engelenfrederik | last post by:
Hello all, I ran into an interesting SQL/XML question yesterday. A customer wants to make a part of the relational data available through a webservice as XML. This seemed like the perfect...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.