dbTalk Databases Forums  

Empty XML Tags when using XSD and SQL Server

microsoft.public.sqlserver.xml microsoft.public.sqlserver.xml


Discuss Empty XML Tags when using XSD and SQL Server in the microsoft.public.sqlserver.xml forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MIchael Bals
 
Posts: n/a

Default Empty XML Tags when using XSD and SQL Server - 01-23-2004 , 02:08 AM






I have a schema that allows the following XML.

<Data>
<Country>1150</Country>
<Hypertension>
<HypertensionSince>1995</HypertensionSince>
<HypertensionTreated>0</HypertensionTreated>
</Hypertension>
<Diabetes/>
</Data>

In the sql server, we have one table. In the XSD the
elements Hypertension and Diabetes are declared as followed:
<xs:element name="Hypertension"
type="basic:HypertensionType"
minOccurs="0" sql:relationship="XBS-XBS"
sql:relation="XBS_ExchangeBasis"/>

<xs:element name="Diabetes" type="basiciabetesType" minOccurs="0"
sql:relationship="XBS-XBS" sql:relation="XBS_ExchangeBasis"/>

So there is a selfjoin since all Data is stored in one table.

The problem is, when there are only null values for example the
diabetes fields then only an empty tag is created. I would like to
have no tag at all to be created when there is no data. At least the
child element for diabetes are not created since there is no data. But
how to avoid the creation of the empty parent tag?

Hope someone can help me out.

Greetings
Mike

Reply With Quote
  #2  
Old   
Bryant Likes
 
Posts: n/a

Default Re: Empty XML Tags when using XSD and SQL Server - 01-27-2004 , 10:05 PM






"MIchael Bals" <Michael.Bals (AT) web (DOT) de> wrote

[snip]
Quote:
The problem is, when there are only null values for example the
diabetes fields then only an empty tag is created. I would like to
have no tag at all to be created when there is no data. At least the
child element for diabetes are not created since there is no data. But
how to avoid the creation of the empty parent tag?
I think this is a problem with the current release and I don't believe there
is a fix for it.

--
Bryant




Reply With Quote
  #3  
Old   
Michael Rys [MSFT]
 
Posts: n/a

Default Re: Empty XML Tags when using XSD and SQL Server - 02-01-2004 , 11:06 PM



If you map a row that contains only NULL fields, then there exists a row
without properties and we map it (correctly in my opinion) to an element
that represents the present row without subelements or attributes.

If you do not want to have this appear, define a view that filters such rows
and map against the view.

I hope this helps.
Michael

"Bryant Likes" <bryant (AT) suespammers (DOT) org> wrote

Quote:
"MIchael Bals" <Michael.Bals (AT) web (DOT) de> wrote in message
news:af0a634e.0401230008.a6eeee9 (AT) posting (DOT) google.com...
[snip]
The problem is, when there are only null values for example the
diabetes fields then only an empty tag is created. I would like to
have no tag at all to be created when there is no data. At least the
child element for diabetes are not created since there is no data. But
how to avoid the creation of the empty parent tag?

I think this is a problem with the current release and I don't believe
there
is a fix for it.

--
Bryant





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.