Solved

How to send blank for integer / long in XML ?

Posted on 2014-04-14
7
440 Views
Last Modified: 2014-04-14
Hi
Below is my element in XSD. In 'ParentSDSID' I want to send blank. Just <ParentSDSID></ParentSDSID> and it can be long.
how to form the xsd? I tried nillable="true", but is it not accepting.

Can anyone suggest me please?

<xs:element type="xs:long" nillable="true" name="ParentSDSID"/>
0
Comment
Question by:GouthamAnand
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39999480
I don't think nillable is the answer
because then you need to explicitely set the xsi:nil attribute to make it work
is that acceptable?
<ParentSDSID xsi:nil="true"></ParentSDSID>
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39999499
Here is what I would do

    <xs:element type="long-and-null" name="ParentSDSID"/> 
    <xs:simpleType name="long-and-null">
        <xs:union memberTypes="stp-long stp-empty"/>
    </xs:simpleType>
    <xs:simpleType name="stp-long">
        <xs:restriction base="xs:long"/>
    </xs:simpleType>
    <xs:simpleType name="stp-empty">
        <xs:restriction base="xs:string">
            <xs:maxLength value="0"/>
        </xs:restriction>
    </xs:simpleType>

Open in new window

0
 

Author Comment

by:GouthamAnand
ID: 39999558
Hi
Attached is my schema. Could you please update it ?
I am confused with your xsd structure.
XYZRequestSchema.xsd
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 39999600
I understand you are confused because the element declaration that you have is a local declaration

The snippet I sent has three simple type declarations, they should be at the global level
(in a way you could say I am extending the type library)

then you could use the type in the element declaration

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="XYZDocStatusRequest">
        <xs:annotation>
            <xs:documentation>XYZ Message</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Header">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element type="xs:long" name="MsgId"/>
                            <xs:element type="xs:string" name="Source"/>
                            <xs:element type="xs:dateTime" name="SendTime"/>
                            <xs:element type="xs:string" name="Action"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="Body">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element type="xs:long" name="AOSID"/>
                            <xs:element type="long-and-null" name="ParentSDSID" minOccurs="0"/>
                            <xs:element name="AOSRegion">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element type="xs:short" name="Id"/>
                                        <xs:element type="xs:string" name="Name"/>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="ProductType">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element type="xs:long" name="Id"/>
                                        <xs:element type="xs:string" name="Name"/>
                                        <xs:element type="xs:string" name="FullPath"/>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="BookingCentreSDSId">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element type="xs:short" name="Id" maxOccurs="unbounded" minOccurs="0"/>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="Status">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element type="xs:short" name="Id"/>
                                        <xs:element type="xs:string" name="Name"/>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                            <xs:element type="xs:string" name="TaxDocumentationRequired"/>
                            <xs:element type="xs:string" name="UpdateReason"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <xs:simpleType name="long-and-null">
        <xs:union memberTypes="stp-long stp-empty"/>
    </xs:simpleType>
    <xs:simpleType name="stp-long">
        <xs:restriction base="xs:long"/>
    </xs:simpleType>
    <xs:simpleType name="stp-empty">
        <xs:restriction base="xs:string">
            <xs:maxLength value="0"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Open in new window

0
 

Author Closing Comment

by:GouthamAnand
ID: 39999620
Thanks a lot.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39999727
welcome
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question