473,770 Members | 5,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Schema question

Hi--I am having a problem designing a schema to fit my XML data, and I'm
hoping that someone can help. Essentially, I have a schema in mind and two
target vocabularies for it, where one vocabulary is a subset of the other. I
will describe one part of the schema to give you an idea of what my problem
is.

The "big" schema calls for 0 or more selector elements, each containing a
(required) name attribute and simple character data, as follows:

<selector name="wakka">fo o</selector>

The "small" schema calls for 1 or more selector elements with a name of
"key", followed by 0 or more selector elements with any value for the name
attribute:

<selector name="key">esti mate</selector>

<selector name="key">summ ary</selector>

<selector name="custom1"> low-priority</selector>

As you can see, the small schema is a subset of the large schema.

My problem is that I can't find a way to define a parent element than can
describe the sequence of selector elements required by the small schema.
I've looked at redefinition, substitution groups, and other tricks for
making a schema open-ended. The problem is that they all require me to write
something like the following within a complex type definition:

<xsd:sequence >

<xsd:element maxOccurs="unbo unded" minOccurs="1" name="selector"
type="selectorK eyType"/>

<xsd:element maxOccurs="unbo unded" minOccurs="0" name="selector"
type="selectorT ype"/>

</xsd:sequence>

....where selectorKeyType and selectorType are defined as follows:

<xsd:complexTyp e name="selectorT ype">

<xsd:simpleCont ent>

<xsd:extensio n base="xsd:token ">

<xsd:attribut e name="name" type="xsd:NCNam e"/>

</xsd:extension>

</xsd:simpleConte nt>

</xsd:complexType >

<!-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -->

<xsd:complexTyp e name="selectorK eyType">

<xsd:simpleCont ent>

<xsd:restrictio n base="selectorT ype">

<xsd:attribut e fixed="key" name="name" type="xsd:NCNam e"/>

</xsd:restriction >

</xsd:simpleConte nt>

</xsd:complexType >

The Xerxes parser reminds me that multiple elements with the same name must
have the same type:

[Message:E cos-element-consistent: Error for type '<ignore --gw>'. Multiple
elements with name 'selector', with different types, appear in the model
group. SystemID:file:/C:/xml/misc/schema-experiments/exper3/exper.xsd,
Line:35, Column:34, Offset:-1]

Of course, I could write my own code that would validate a given XML file
has been valid under the little schema, but the differences between the big
and little schemas are considerable. I could also describe the constrained
selector element using a slightly different name--cselector, for
example--but that would more or less negate the original design: namely,
that custom elements are distinguished from "official" elements only by the
value of the name attribute.

Is there a way to do what I want to do? Or is the inability of the XML
Schema to handle this situation an indication that what I am trying to do is
a Bad Thing? Thanks.

--gw
Jul 20 '05 #1
1 2724

"Gregg Williams" <gr****@NOSPAMp ubspace.com> wrote in message
news:vk******** ****@corp.super news.com...
Hi--I am having a problem designing a schema to fit my XML data, and I'm
hoping that someone can help. Essentially, I have a schema in mind and two
target vocabularies for it, where one vocabulary is a subset of the other. I will describe one part of the schema to give you an idea of what my problem is.

The "big" schema calls for 0 or more selector elements, each containing a
(required) name attribute and simple character data, as follows:

<selector name="wakka">fo o</selector>

The "small" schema calls for 1 or more selector elements with a name of
"key", followed by 0 or more selector elements with any value for the name
attribute:

<selector name="key">esti mate</selector>

<selector name="key">summ ary</selector>

<selector name="custom1"> low-priority</selector>
Can't do this. Elements with the same name in a sequence must have the same
type.

And (reading ahead a bit) you already know this! The Xerces parser told you
so.

Redesign your data model (which looks like a good idea in this case) or use
a more expressive schema language, like RELAX NG.

Bob Foster
As you can see, the small schema is a subset of the large schema.

My problem is that I can't find a way to define a parent element than can
describe the sequence of selector elements required by the small schema.
I've looked at redefinition, substitution groups, and other tricks for
making a schema open-ended. The problem is that they all require me to write something like the following within a complex type definition:

<xsd:sequence >

<xsd:element maxOccurs="unbo unded" minOccurs="1" name="selector"
type="selectorK eyType"/>

<xsd:element maxOccurs="unbo unded" minOccurs="0" name="selector"
type="selectorT ype"/>

</xsd:sequence>

...where selectorKeyType and selectorType are defined as follows:

<xsd:complexTyp e name="selectorT ype">

<xsd:simpleCont ent>

<xsd:extensio n base="xsd:token ">

<xsd:attribut e name="name" type="xsd:NCNam e"/>

</xsd:extension>

</xsd:simpleConte nt>

</xsd:complexType >

<!-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -->

<xsd:complexTyp e name="selectorK eyType">

<xsd:simpleCont ent>

<xsd:restrictio n base="selectorT ype">

<xsd:attribut e fixed="key" name="name" type="xsd:NCNam e"/>

</xsd:restriction >

</xsd:simpleConte nt>

</xsd:complexType >

The Xerxes parser reminds me that multiple elements with the same name must have the same type:

[Message:E cos-element-consistent: Error for type '<ignore --gw>'. Multiple elements with name 'selector', with different types, appear in the model
group. SystemID:file:/C:/xml/misc/schema-experiments/exper3/exper.xsd,
Line:35, Column:34, Offset:-1]

Of course, I could write my own code that would validate a given XML file
has been valid under the little schema, but the differences between the big and little schemas are considerable. I could also describe the constrained
selector element using a slightly different name--cselector, for
example--but that would more or less negate the original design: namely,
that custom elements are distinguished from "official" elements only by the value of the name attribute.

Is there a way to do what I want to do? Or is the inability of the XML
Schema to handle this situation an indication that what I am trying to do is a Bad Thing? Thanks.

--gw

Jul 20 '05 #2

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

Similar topics

0
5063
by: Antony | last post by:
Hi there, firstly thank you for thinking about this problem of mine. This is a long message because I want to put all the facts (the XML and the schema) to try to get a solution from you helpful readers of the newsgroup. Here is my problem. I have defined the following XML schema. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:simpleType name="currencySymbol">
4
2943
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 I parse some element from XML document I don't know until runtime the type of the element (it depends on the type used in user-defined schema). XML parser obviously validates that the value of the element is correct type but still I receive that...
7
2674
by: Andrei Ivanov | last post by:
This happend again, but now, postgresql tells me where it happens: pg_dump: SQL command failed pg_dump: Error message from server: ERROR: did not find '}' at end of input node pg_dump: The command was: select (select usename from pg_user where usesysid = datdba) as dba, pg_encoding_to_char(encoding) as encoding, datpath from pg_database where datname = 'dc' pg_dumpall: pg_dump failed on database "dc", exiting
2
6933
by: PeterW | last post by:
I have an xml file from which I want to generate an xsd schema and at a later stage a cs class. The xml file has a mix of defined namespaces and also an empty namespace. These are defined as follows: <silcn:silcn xmlns:silcn='http://silcn.org/200309' xmlns='http://xmlprobe.com/200312'> it contains an element <report> off the root and also a separate <Silcn:report> again off the root.
4
2293
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 works with SPY, but when I pick "Validate Schema" from the .NET 2003 menu, it fails with message: "Type XType is not declared." As I hinted at in my subject line, I suspect that it has to do with including another schema multiple times.
4
2628
by: cmc | last post by:
I need some clarification to help me understand the DB2 strucure more. The questions are about "implicit schema" 1. This is a very interest concpet that DB2 let every user to create new schema (as this is part of the PUBLIC group privilege - if I am not wrong). From a practical stand point, what is the application of such concept. 2. Suprisingly, if the schema is an implicitly created, everyone else can create objects in it too. What...
1
20764
by: drb | last post by:
Hi, Newbie question #2 - hope that's OK! I'm trying to create a WSDL file using one or more XSD schema files. While WSDL.exe doesn't seem to support the XSD "import" function, if I include a single huge XSD schema file on the command line input to WSDL.exe, I can essentially achieve the desired result. (So, first question: is it true that WSDL.exe does not support *any* kind of <wsdl:import ...> or <xsd:import...> function?)
1
1943
by: brucepickford001 | last post by:
Hi, I have a not simple problem. I want the following XML to be schema valid <PopulationDemographic> <PersonName>Joe Blogs</PersonName> <Age>2</Age> <Category>baby</Category> </PopulationDemographic>
0
2261
by: jrhitokiri | last post by:
QUESTION 1: I'm trying to create a room reservation system for school using wicket and MySQL, and I'm a bit confused with this one. I've already created the user database and rooms database. My question is how do I create a schema that accepts both repeating and non-repeating schedules? example (repeating): I can reserve a room for class at 9:00am - 12:00pm every Monday and Thursday, from June - October of 2009. How do I represent this in...
0
9592
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10231
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...
1
10005
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
8887
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
7416
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
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
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
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.