473,803 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Schema - Choice usage

Hi, Everyone!

I'd need a little help. I understand this is not valid, but is there
an (easy) way to make it valid?

<xs:complexTy pe name="control_T ype">
<xs:sequence>
<xs:element name="id" type="id_Type"/>
<xs:element name="position" type="pos_Type"/>
<xs:element name="name" type="xs:string "/>
<xs:choice>
<xs:sequence< !-- static -->
<xs:element name="type" type="xs:positi veInteger" fixed="28251"/>
<xs:element name="h_align" type="h_align_T ype"/>
<xs:element name="v_align" type="v_align_T ype"/>
<xs:element name="text" type="MultiLang Text_Type"/>
</xs:sequence>
<xs:sequence< !-- check -->
<xs:element name="type" type="xs:positi veInteger" fixed="28252"/>
<xs:element name="is_checke d" type="xs:boolea n"/>
<xs:element name="text" type="MultiLang Text_Type"/>
</xs:sequence>
<!-- other control types -->
</xs:choice>
</xs:sequence>
</xs:complexType>

Thank you very much!
Chris

Apr 5 '07 #1
2 2165
On 5 Apr, 08:49, "puffy" <puffy.ch...@gm ail.comwrote:
Hi, Everyone!

I'd need a little help. I understand this is not valid, but is there
an (easy) way to make it valid?

<xs:complexTy pe name="control_T ype">
<xs:sequence>
<xs:element name="id" type="id_Type"/>
<xs:element name="position" type="pos_Type"/>
<xs:element name="name" type="xs:string "/>
<xs:choice>
<xs:sequence< !-- static -->
<xs:element name="type" type="xs:positi veInteger" fixed="28251"/>
<xs:element name="h_align" type="h_align_T ype"/>
<xs:element name="v_align" type="v_align_T ype"/>
<xs:element name="text" type="MultiLang Text_Type"/>
</xs:sequence>
<xs:sequence< !-- check -->
<xs:element name="type" type="xs:positi veInteger" fixed="28252"/>
<xs:element name="is_checke d" type="xs:boolea n"/>
<xs:element name="text" type="MultiLang Text_Type"/>
</xs:sequence>
<!-- other control types -->
</xs:choice>
</xs:sequence>
</xs:complexType>

Thank you very much!
Chris
I don't think schema currently offers any great solutions to this.
One option might be to do something like:

<xs:complexTy pe name="control_T ype">
<xs:sequence>
<xs:element name="id" type="id_Type"/>
<xs:element name="position" type="pos_Type"/>
<xs:element name="name" type="xs:string "/>
<xs:choice>
<xs:sequence< !-- static -->
<xs:element name="type28251 "
type="empty"/>
<xs:element name="h_align"
type="h_align_T ype"/>
<xs:element name="v_align"
type="v_align_T ype"/>
<xs:element name="text"
type="MultiLang Text_Type"/>
</xs:sequence>
<xs:sequence< !-- check -->
<xs:element name="type28252 "
type="empty"/>
<xs:element name="is_checke d"
type="xs:boolea n"/>
<xs:element name="text"
type="MultiLang Text_Type"/>
</xs:sequence>
<!-- other control types -->
</xs:choice>
</xs:sequence>
</xs:complexType>

<xs:complexTy pe name="empty"/>

Even I don't think that's pretty though!

Another option might be to use xsi:type in some way, and define a
number of restrictions or extensions for the various types.

HTH,

Pete.
--
=============== =============== ===============
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx/
http://www.codalogic.com/lmx/
=============== =============== ===============

Apr 5 '07 #2
Hi,

"puffy" <pu*********@gm ail.comwrites:
<xs:complexTy pe name="control_T ype">
<xs:sequence>
<xs:element name="id" type="id_Type"/>
<xs:element name="position" type="pos_Type"/>
<xs:element name="name" type="xs:string "/>
<xs:choice>
<xs:sequence< !-- static -->
<xs:element name="type" type="xs:positi veInteger" fixed="28251"/>
<xs:element name="h_align" type="h_align_T ype"/>
<xs:element name="v_align" type="v_align_T ype"/>
<xs:element name="text" type="MultiLang Text_Type"/>
</xs:sequence>
<xs:sequence< !-- check -->
<xs:element name="type" type="xs:positi veInteger" fixed="28252"/>
<xs:element name="is_checke d" type="xs:boolea n"/>
<xs:element name="text" type="MultiLang Text_Type"/>
</xs:sequence>
<!-- other control types -->
</xs:choice>
</xs:sequence>
</xs:complexType>
You need to make the first element in the two sequences differ
so the schema processor can figure out which arm of the choice
it is parsing just by looking at the first element. So one way
would be to place the 'type' element at the end. Or make it an
attribute. I like the attribute option better since it has the
nice notion of storing "meta information" in attributes and
"data" in elements.
hth,
-boris
--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
Apr 5 '07 #3

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

Similar topics

6
2494
by: Pieter | last post by:
I've read a lot of posts on "why relax ng is so very good" and on "why w3c xml schema should be the only schema language". I'm, however, still not clear on why I should prefer one over the other. I've made a small list of some good and bad points of both. These points don't really go into the grammar aspects of these languages, but are more about secondary aspects. The grammar aspects are different, but both are suitable for validating...
0
1829
by: CJ | last post by:
I started with this schema: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="response"> <xs:complexType> <xs:sequence> <xs:element name="SysTime" type="xs:string"/> <xs:element name="Item"> <xs:complexType> <xs:sequence>
3
4564
by: Kimmo J?rvikangas | last post by:
Dear XML (Schema) experts, As an example I have the following schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="ROOT_ELEMENT"> <xs:complexType> <xs:choice>
2
3358
by: BillD | last post by:
I'm trying to derive a schema from a base schema. I want to redefine a "group" from the base schema in my derived schema in order to add more options to the "choice" aggregate (see schema1.xsd sample). schema1.xsd sample: <!-- Here is a clipped down version of the group I want to redefine. --> <xsd:group name="INSURANCESVCRQMSGS"> <xsd:choice> <xsd:element ref="HomePolicyAddRq" minOccurs="1" maxOccurs="1"/>
0
1578
by: Deep Purple | last post by:
I started with the following error... ------------------------------------------------------- An error occured while loading the schema with TargetNamespace 'http://www.w3.org/2001/XMLSchema' referenced in this document. The value for the 'base' attribute is invalid - 'xsd:string' is an invalid value for the 'base' attribute. An error occured at the file:///C:Program Files/Microsoft Visual Studio .NET 2003...
5
3418
by: j.tremlett | last post by:
Hi, I have read various articles on this and I have had a few suggestions but would like to know which is correct. I have an XML file with the element <root> Within <root> I can have a number of child elements occuring in any order and any number of times.
1
376
by: Chris Lieb | last post by:
I am new to XML Schema and am running into a bit of a snag. I have defined an XML-based scripting language for an updater program that I am working on. I would like to make a schema for this language since malformed XML documents break the updater. (I did not have time to add good error-handling code, so run-time errors can abound if the document is malformed.) A sample doc might look something like this: <manifest>
4
1223
by: cmay | last post by:
I am beginning to wonder if it is not possible to get this working. I am trying to do: <root> <a/> <b/> <c/> </root>
0
2634
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 the particle of the base this xsd file is valid as per w3c standard i am also providing error in detail and geometry.xsd file geometry.xsd <?xml version="1.0" encoding="UTF-8"?> <schema targetNamespace="http://www.opengis.net/gml"...
0
10555
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10300
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9127
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7607
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2974
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.