473,404 Members | 2,195 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,404 software developers and data experts.

Can XML Schema represent this?

I would like to restrict the values of an attribute to boolean
expressions combining enumerated values. Is this possible?

An example instance document might look something like:

<myElement expression="apples OR oranges"/>

I thought I'd start with something like:

<xs:element name="myElement" type="myElementType"/>

<xs:complexType name="myElementType">
<xs:attribute name="expression" type="myAttributeType"/>
</xs:complexType>

<xs:simpleType name="myAttributeValues">
<xs:restriction base="xs:string">
<xs:enumeration value="apples"/>
<xs:enumeration value="oranges"/>
<xs:enumeration value="bananas"/>
<xs:enumeration value="pears"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="myAttributeType">
<xs:restriction base="myAttributeValues">

<!-- WHAT GOES HERE TO ALLOW BOOLEAN EXPRESSIONS
OF THE ENUMERATED TYPE VALUES? -->

</xs:restriction>
</xs:simpleType>
Jul 20 '05 #1
2 1290
In article <29**************************@posting.google.com >,
Steven Burr <sb***@adelphia.net> wrote:
I would like to restrict the values of an attribute to boolean
expressions combining enumerated values. Is this possible?
You would have to use a regular expression. Something like

"(apples|oranges|bananas|pears) (OR|AND) (apples|oranges|bananas|pears)"
<xs:restriction base="myAttributeValues">

<!-- WHAT GOES HERE TO ALLOW BOOLEAN EXPRESSIONS
OF THE ENUMERATED TYPE VALUES? -->

</xs:restriction>


This is not going to work, since it's not a restriction of the base
type. If a type R is a restriction of a type B, then all legal R values
are legal B values. But "apples OR oranges" is not a legal value for
myAttributeValues.

-- Richard
Jul 20 '05 #2
Richard Tobin wrote:
You would have to use a regular expression. Something like

"(apples|oranges|bananas|pears) (OR|AND) (apples|oranges|bananas|pears)"


I was trying to avoid this, as it gets more an more unwieldy the more
items there are in the enumeration.
<xs:restriction base="myAttributeValues">

<!-- WHAT GOES HERE TO ALLOW BOOLEAN EXPRESSIONS
OF THE ENUMERATED TYPE VALUES? -->

</xs:restriction>


This is not going to work, since it's not a restriction of the base
type. If a type R is a restriction of a type B, then all legal R values
are legal B values. But "apples OR oranges" is not a legal value for
myAttributeValues.


Would an extension work then? That would define a superset rather than a
subset. I take it there is no way to indicate a token from some
enumeration in a regular expression pattern? Is there any other facet
that I could extend to achieve this? If not, I'll either have to use the
regular expression workaround or else just leave it type="xs:string" and
call it a day.

Thanks,
Steve
Jul 20 '05 #3

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

Similar topics

1
by: Hari Om | last post by:
Subject: XML Schema to XML Schema Conversion I have an XML Schema A which needs to mapped to another XML Schema B. Is there any handy tool which I could use to convert from Schema A to Schema B?...
1
by: Andrey Brozhko | last post by:
Hi I need to represent custom type system (ints, bytes, chars, enums, bitmasks, arrays and some other types) in xml. It is easy to see how to represent enums in xml (using xs:enumeration), the...
1
by: s o | last post by:
Hi, I'm creating a xml schema for my existing database. I've about a dozen lookup tables, such as States, Unit of Measures, etc. I figured the most logical way to represent them is to create...
1
by: Ed Sutton | last post by:
I have data from an embedded device that I want to represent as an XML schema. Each data sample in the device's data log consists of a 24-bit pressure value plus a 1 byte temperature value. I am...
1
by: Neil | last post by:
Hi, I have got to transfer some data into a c# project from an old one that was written in delphi. I am new to XML, but it looks idea for transfering this data around. I have written a schema...
0
by: c j anderson, mcp | last post by:
Core Question: Is there a better way to dynamically pull the allowed values of an attribute out of a dataset's schema. I have an XML file that contains a string element with two attributes,...
2
by: Scott Zabolotzky | last post by:
I've got an XML file that contains both a data section and a custom schema section. The data may represent only a subset of the parameters defined by the schema. I'm new to XSLT and I'm trying...
2
by: SteveChamp | last post by:
I have been experimenting with .Net web services for a while and have a few questions about the schema in the automatically generated WSDL file, and whether its content can be manipulated...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
1
by: robtyketto | last post by:
Greetings, I'm designing an XML schema for a courier firm (university assignment) for delivery tracking purposes. One element I've included is a deliveryStatus, which will include the following...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.