473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I specify a nullable xs:int?

I have one xsd which defines element "Port" as "xs:int", and there are
bunch of xml files use "Port" element. But a lot of those files
contains <Port/>, which is treated invalid in xml validation.

I am wondering whether there is anyway to specify nullable integer, say
treat <Port/> the same as <Port>0</Port>?

Thanks in advance.

Nov 23 '05 #1
2 2131


ja******@gmail.com wrote:

I am wondering whether there is anyway to specify nullable integer, say
treat <Port/> the same as <Port>0</Port>?


Yes, see <http://www.w3.org/TR/xmlschema-1/#declare-element>, you can do
<xs:element name="Port" type="xs:integer" nillable="true" />
and then the instance needs to have e.g.
<Port xsi:nil="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />

<http://www.w3.org/TR/xmlschema-1/#xsi_nil> explains that too.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 23 '05 #2
jacksuyu writes:
I am wondering whether there is anyway to specify nullable integer, say
treat <Port/> the same as <Port>0</Port>?


That's a defaulted xs:int, not a nullable one, and yes, just declare

<xs:element name="Port" type="xs:int" default="0"/>

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Adam Retter | last post by:
I would like to have an element defined in my XML Schema, that can hold either an xs:string or xs:int value. Is this possible? e.g. something like - <xs:element name="service">...
10
by: John Wood | last post by:
I was just looking at an article about using nullable value types. (value types that can effectively have no value and not be set). The syntax is to append a question-mark to the value type in...
2
by: Yolande | last post by:
Hi there, I have a C# web service and I want to specify the lower bound and upper bound of input value. e.g. public long MilesToKilometers(long lngMiles). I want the input value for lngMiles...
6
by: Steven Livingstone | last post by:
Bit of advice here folks. I am creating a default constructor that just initializes a new instance of my object and a secon constructor that takes an ID and loads an object with data from the...
3
by: rubikzube* | last post by:
Hi. I'm trying to write a snippet of code to detect if a variable is a nullable<t> struct, and I can't figure out the right syntax or if such a thing is even possible... Below are the results...
1
by: Joe Bloggs | last post by:
Hi, Can someone please kindly show me how to determine if a type (read value type) is Nullable. MSDN has this KB: How to: Identify a Nullable Type (C# Programming Guide)...
3
by: nshala | last post by:
Hallo, I wrote a complex XSD-Schema for validating complex XML files. By validating xs:int elements XmlValidatingReader does not validate it correctly. My XSD looks like this: .......
4
by: Bradley Plett | last post by:
It seems that the XSD tool supplied with VS2005 does not handle "xs:union". Am I doing something wrong? Is there a work-around? Here is a simple sample file:...
2
by: Tony Johansson | last post by:
Hello! These two declarations(1 and 2) are the same I assume. 1. System.Nullable<intnullable; 2. System.Nullable<intnullable = new System.Nullable<int(); So because these 1 and 2 are the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...

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.