473,788 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="C ustomers"
sql:key-fields="Custome rID">
<xs:complexType >
<xs:sequence>
<xs:element name="name" sql:field="Cont actName"
type="xs:string " />
<xs:element name="address" sql:is-constant="true" >
<xs:complexType >
<xs:sequence>
<xs:element name="street" sql:field="Addr ess"
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="Cust omerID" 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="htt p://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*******@myfam ilyinc.com
Nov 12 '05 #1
1 2139
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*******@myfam ilyinc.com (Jerry Collings) wrote in message news:<2d******* *************** ****@posting.go ogle.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="C ustomers"
sql:key-fields="Custome rID">
<xs:complexType >
<xs:sequence>
<xs:element name="name" sql:field="Cont actName"
type="xs:string " />
<xs:element name="address" sql:is-constant="true" >
<xs:complexType >
<xs:sequence>
<xs:element name="street" sql:field="Addr ess"
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="Cust omerID" 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="htt p://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*******@myfam ilyinc.com

Nov 12 '05 #2

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

Similar topics

5
5513
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 = datas.get(rowToDelete); String idName = idField.getColumnName(); Method method = dataObjectClass.getMethod("get" +
0
2055
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 goal is to have a .NET application read the XML into a DataSet using the inline schema, and the relations automatically created according to the nesting of the elements. My query in the stored procedure looks similar to this:
0
405
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 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"
8
16921
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. This works fine if all of the properties are at the top (root level) of the model but I'd like to keep them in nested classes to organize them better. So, for example, part of my data model looks like this (simplified) : public class MainClass
5
13600
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, what am I doing wrong? Is this possible? Example: CASE A1 WHEN NULL THEN CASE A2
0
2211
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 gridview I have set an ItemStyle property of width 20% for the first templated field which contains a hyperlink control, and an ItemStyle of width 80% for the second templated field which contains a label. Both of these controls are databound to...
5
2986
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 document into a text document with a single row for each parent node (that has all of the values from all of the child nodes for that row) The DataView within VS 2005 IDE displays my 15 or so child tables - and knows that some parent rows...
4
4571
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). But... and this is the crappy part, the nested repeater's events are fired twice. How do I know this? I setup global private counter variables that get incremented on the repeater's ItemDataBound event. The outer repeater is correct and only...
0
1434
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 opportunity to use the DB2 XML- capabilities. The following test scenario will make things easier to explain: drop table test.customer; create table test.customer
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7518
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.