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

Is there a way to define this type via schema

Hi,

I have a primitive type int type which is restricted to the values of 0
to 23. Let me call the restricted type "HourType". I want to write out a
list of the form:

HourRangeType =HourType |
HourType '-' HourType
RangeList =HourRangeType ( ',' HourRangeType )*

Is there a way to express the RangeList type in schema?

Thanks,
Kenneth
Nov 10 '07 #1
1 1655
On 10 Nov, 11:59, Kenneth Stephen <kste...@us.ibm.comwrote:
Hi,

I have a primitive type int type which is restricted to the values of 0
to 23. Let me call the restricted type "HourType". I want to write out a
list of the form:

HourRangeType =HourType |
HourType '-' HourType
RangeList =HourRangeType ( ',' HourRangeType )*

Is there a way to express the RangeList type in schema?

Thanks,
Kenneth
I think the only way to impose this restriction is via a pattern facet
on xs:string. As schema doesn't allow fo variables with in it's
patterns, it can get rather messy! I defined the following sub-
expression for pattern:

HourTypeRE = (1?[0-9]|2[0-3]) # matches the integers 0-23
(hopefully)
HourRangeRE = HourTypeRE (-HourTypeRE)?
RangeListRE = HourRangeRE(,HourTypeRE)*

Expanding that out gives a pattern of:

RangeListRE = (1?[0-9]|2[0-3])(-(1?[0-9]|2[0-3]))?(,(1?[0-9]|2[0-3])(-
(1?[0-9]|2[0-3]))?)*

Giving an XML schema snippet of:

<xs:simpleType name='RangeList'>
<xs:restriction base='xs:string'>
<xs:pattern value='(1?[0-9]|2[0-3])(-(1?[0-9]|2[0-3]))?(,(1?[0-9]|
2[0-3])(-(1?[0-9]|2[0-3]))?)*'/>
</xs:restriction>
</xs:simpleType>

You would need to parse the resultant string in your application to
extract all the releavnt parts. In the light of that you may want to
consider defining a schema that makes more use of XML to tokenise the
sub-components. e.g. your XML instance ends up looking like:

<RangeList>
<HourRange from='1' to='14'/>
<HourRange from='6' to='12'/>
<HourRange from='4' to='4'/>
</RangeList>

HTH,

Pete Cordell
Codalogic
Visit http://www.codalogic.com/lmx/
for XML Schema to C++ data binding

Nov 11 '07 #2

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

Similar topics

0
by: Erik | last post by:
Hi I'm writing a schema for a particular soap message. In the soap schema any content is allowed in the header and body elements. Is it possible to define the elements allowed in the header and...
4
by: Jari Kujansuu | last post by:
I can successfully parse XML document using SAX or DOM and I can also validate XML document against schema. Problem is that my program should deal with user-defined schemas which means that when...
2
by: D. Alvarado | last post by:
Hello, I have an element that I would like to validate against an XML schema in which the element can be either one of 50 values or an arbitrary number of white space characters. The values would...
5
by: mhuhn.de | last post by:
I am using XML Schema for quite a while but haven't written a single line of Relax NG yet. For what I know, I cannot define static content within an XML Schema. For example, I have the following...
0
by: Ram | last post by:
Hey, I'v created a define typed DataSet using an XSD Schema, and I tried to read an XML file into the dataset and update my table with the new data. The problem is, that I have a feild in the...
0
by: Lloyd Dupont | last post by:
1. I have define A custom web control with, let's say, a property called Content, when I use it like that: <lloyd:MyControl runat=server> <Content>some content</Content> </lloyd:MyControl> ...
1
by: Ram | last post by:
Hey, I'v created a define typed DataSet using an XSD Schema, and I tried to read an XML file into the dataset and update my table with the new data. The problem is, that I have a feild in the...
1
by: JavaXMLDev | last post by:
Hi I'm new to XML schema work, but wondered how, if at all possible, can you specify a relationship between the values of an element's attributes. Essentially I want context sensitive...
3
by: Peter Wang | last post by:
Hi all, I want to write a schema file to validate my xml file, and encounter a problem as follow. the xml file contains a <pathnode£¬whose value should be a string not included by a blanklist(for...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.