473,239 Members | 1,486 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,239 software developers and data experts.

xml schema null or double type

How can I define the schema so that myage element has to be double or
null?

<xs:simpleType name="myage">
<xs:restriction base="xs:double">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

Aug 11 '06 #1
5 7223
Hi,

You can define that as a union between double and a type that allows
only the null value:

<xs:simpleType name="myage">
<xs:union memberTypes="xs:double">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>

However, XML Schema has support for nillable elements, so if you want
to use this simple type for an element you might consider the
alternative of defining the element nillable. Then in the instance you
just need to add xsi:nil="true" to the element to mark it as having no
value.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

hello wrote:
How can I define the schema so that myage element has to be double or
null?

<xs:simpleType name="myage">
<xs:restriction base="xs:double">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Aug 11 '06 #2
when i use nill=true for the particular element i got the following error.

org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: '' is not a valid
value
for 'double'.

when i define the union like this.

<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:double" />
</xs:simpleType>
</xs:union>
</xs:simpleType>

i got this error.

org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.3: '' is not a valid
value
of union type '#AnonType_iims11526672818165646iims11526672557483 110'.

probably i am missing something.

SK
"George Bina" <ge****@oxygenxml.comwrote in message
news:11*********************@74g2000cwt.googlegrou ps.com...
Hi,

You can define that as a union between double and a type that allows
only the null value:

<xs:simpleType name="myage">
<xs:union memberTypes="xs:double">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>

However, XML Schema has support for nillable elements, so if you want
to use this simple type for an element you might consider the
alternative of defining the element nillable. Then in the instance you
just need to add xsi:nil="true" to the element to mark it as having no
value.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

hello wrote:
How can I define the schema so that myage element has to be double or
null?

<xs:simpleType name="myage">
<xs:restriction base="xs:double">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

Aug 11 '06 #3
Hi,

In the first case you need
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
otherwise you just add an attribute from no namespace with the same
local name as the nil attribute from the schema instance namespace.

In the second case I thoght you want the string "null" as value when
you said double or null. If you want the empty string as possible value
replace null from the enumeration value with an empty value:
<xs:enumeration value=""/>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

shuan wrote:
when i use nill=true for the particular element i got the following error.

org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: '' is not a valid
value
for 'double'.

when i define the union like this.

<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:double" />
</xs:simpleType>
</xs:union>
</xs:simpleType>

i got this error.

org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.3: '' is not a valid
value
of union type '#AnonType_iims11526672818165646iims11526672557483 110'.

probably i am missing something.

SK
"George Bina" <ge****@oxygenxml.comwrote in message
news:11*********************@74g2000cwt.googlegrou ps.com...
Hi,

You can define that as a union between double and a type that allows
only the null value:

<xs:simpleType name="myage">
<xs:union memberTypes="xs:double">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>

However, XML Schema has support for nillable elements, so if you want
to use this simple type for an element you might consider the
alternative of defining the element nillable. Then in the instance you
just need to add xsi:nil="true" to the element to mark it as having no
value.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

hello wrote:
How can I define the schema so that myage element has to be double or
null?
>
<xs:simpleType name="myage">
<xs:restriction base="xs:double">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Aug 12 '06 #4
Thanks, George,
In the first case you need
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
otherwise you just add an attribute from no namespace with the same
local name as the nil attribute from the schema instance namespace.
I am including this line.
>
In the second case I thoght you want the string "null" as value when
you said double or null. If you want the empty string as possible value
replace null from the enumeration value with an empty value:
<xs:enumeration value=""/>
Event I set to value="" I still get the same error.

"George Bina" <ge****@oxygenxml.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hi,

In the first case you need
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
otherwise you just add an attribute from no namespace with the same
local name as the nil attribute from the schema instance namespace.

In the second case I thoght you want the string "null" as value when
you said double or null. If you want the empty string as possible value
replace null from the enumeration value with an empty value:
<xs:enumeration value=""/>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

shuan wrote:
when i use nill=true for the particular element i got the following
error.

org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: '' is not a
valid
value
for 'double'.

when i define the union like this.

<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:double" />
</xs:simpleType>
</xs:union>
</xs:simpleType>

i got this error.

org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.3: '' is not a
valid
value
of union type '#AnonType_iims11526672818165646iims11526672557483 110'.

probably i am missing something.

SK
"George Bina" <ge****@oxygenxml.comwrote in message
news:11*********************@74g2000cwt.googlegrou ps.com...
Hi,
>
You can define that as a union between double and a type that allows
only the null value:
>
<xs:simpleType name="myage">
<xs:union memberTypes="xs:double">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
>
However, XML Schema has support for nillable elements, so if you want
to use this simple type for an element you might consider the
alternative of defining the element nillable. Then in the instance you
just need to add xsi:nil="true" to the element to mark it as having no
value.
>
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
>
hello wrote:
How can I define the schema so that myage element has to be double
or
null?

<xs:simpleType name="myage">
<xs:restriction base="xs:double">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
>

Aug 14 '06 #5
Hi,

Here it is the full working example:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="test">
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=""/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:double"/>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:element>
</xs:schema>

<test></test>

should be reported valid against the above schema.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Shuan wrote:
Thanks, George,
In the first case you need
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
otherwise you just add an attribute from no namespace with the same
local name as the nil attribute from the schema instance namespace.
I am including this line.

In the second case I thoght you want the string "null" as value when
you said double or null. If you want the empty string as possible value
replace null from the enumeration value with an empty value:
<xs:enumeration value=""/>
Event I set to value="" I still get the same error.

"George Bina" <ge****@oxygenxml.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hi,

In the first case you need
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
otherwise you just add an attribute from no namespace with the same
local name as the nil attribute from the schema instance namespace.

In the second case I thoght you want the string "null" as value when
you said double or null. If you want the empty string as possible value
replace null from the enumeration value with an empty value:
<xs:enumeration value=""/>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

shuan wrote:
when i use nill=true for the particular element i got the following
error.
>
org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: '' is not a
valid
value
for 'double'.
>
when i define the union like this.
>
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:double" />
</xs:simpleType>
</xs:union>
</xs:simpleType>
>
i got this error.
>
org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.3: '' is not a
valid
value
of union type '#AnonType_iims11526672818165646iims11526672557483 110'.
>
probably i am missing something.
>
SK
>
>
"George Bina" <ge****@oxygenxml.comwrote in message
news:11*********************@74g2000cwt.googlegrou ps.com...
Hi,

You can define that as a union between double and a type that allows
only the null value:

<xs:simpleType name="myage">
<xs:union memberTypes="xs:double">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>

However, XML Schema has support for nillable elements, so if you want
to use this simple type for an element you might consider the
alternative of defining the element nillable. Then in the instance you
just need to add xsi:nil="true" to the element to mark it as having no
value.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

hello wrote:
How can I define the schema so that myage element has to be double
or
null?
>
<xs:simpleType name="myage">
<xs:restriction base="xs:double">
<xs:enumeration value="null"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Aug 15 '06 #6

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

Similar topics

0
by: motoman | last post by:
i have the following code (see below), i run my validation and get unexpected results. Public ID: null System ID: file:///C:/DATA/Sandpit/Eclipse/workspace/dtdValidation/memory.xml Line number:...
1
by: eXavier | last post by:
Hi, I need to validate XML fragment against XSD schema. The main issue is that xml fragment does not contain refrence to schema, but I want to force the validation against the schema I have in...
3
by: Shailendra Batham | last post by:
hi guys I need your suggestions / opinion for doing this the right way. I have a XML and a Schema for the same What I want is when its validated against the schema, it should give custom...
1
by: Dan Bass | last post by:
There's an XML message I have, that has no namespace information. Then there is a XSD schema that is must validate against, but this has a targetNamespace and xmlns of...
1
by: Mike | last post by:
Hi! I have an Excel 2003 Schema I need to parse to extract elements names. I am puzzled with the System.Xml.Schema object. Here's the example of my schema: I need to get a collection of element...
4
by: bibsoconner | last post by:
Hi, I hope someone can please help me. I'm having a lot of trouble with schema files in .NET. I have produced a very simple example that uses "include" to include other schema files. It all...
0
by: Oswaldo | last post by:
Hi, I am new on webservices and xml and I am trying to return a dataset from my Sqlserver database. I have it running but I get the following result: <?xml version="1.0" encoding="utf-8" ?> -...
16
by: Bob Stearns | last post by:
The syntax diagram of DROP SCHEMA requires RESTRICT. Is there an easy way to drop an old, unnecessary, but populated schema?
2
by: pnmcosta | last post by:
Hi, I'm fairly new to XML Schema validation. We have XML being imported that must validate against the following schema: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.