Solved

How to send blank for integer / long in XML ?

Posted on 2014-04-14
7
437 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
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 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