473,774 Members | 2,128 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 2138
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
5511
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
2054
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
16920
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
2209
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
2985
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
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10040
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
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
8939
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
7463
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
6717
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();...
1
4012
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

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.