Solved

How to send blank for integer / long in XML ?

Posted on 2014-04-14
7
428 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now