473,788 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSD Schema: complexType or Group?

Thanks for the response, Priscilla, it was very useful,

Now: what if I want to have an empty group that will only contain atomic
sub elements of the containing type:

<object>
<things>
<thing>
1
</thing>
<thing>
2
</thing>
<thing>
3
</thing>
</things>
</object>

How would this be best expressed? Would the "things" element be a
complexType, or a group, or something else? What should it be if it only
contains instances of the group moniker class?

Thanks,

Jason Hodge
Jul 20 '05 #1
2 8390
Hi Jason,

Every element that can contain other elements has to have a complex
type. So you would definitely need complex types for "object" and
"things". For example:

<xs:element name="object" type="objectTyp e"/>
<xs:complexTy pe name="objectTyp e">
<xs:sequence>
<xs:element name="things" type="thingsTyp e"/>
</xs:sequence>
</xs:complexType>
<xs:complexTy pe name="thingsTyp e">
<xs:sequence>
<xs:element name="thing" type="xs:intege r"
maxOccurs="unbo unded"/>
</xs:sequence>
</xs:complexType>

Groups (i.e. xs:group elements) are used when you want to reuse pieces
of the content model in more than one complex type. For example, if
every "product" element had a name, number and description (among other
children), and every "warehouse" element had the same 3 children, plus
some other warehouse-specific things. You could create a group that is
comprised of name, number and description, then refer to that group from
the complex types of both the "product" and "warehouse" elements.

Hope that helps,
Priscilla
-----------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema (Prentice Hall PTR)
http://www.datypic.com
-----------------------------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #2
Thanks! That's what I needed to know.

Jason
"Priscilla Walmsley" <no****@datypic .com> wrote in message
news:41******** **************@ news.newsgroups .ws...
Hi Jason,

Every element that can contain other elements has to have a complex
type. So you would definitely need complex types for "object" and
"things". For example:

<xs:element name="object" type="objectTyp e"/>
<xs:complexTy pe name="objectTyp e">
<xs:sequence>
<xs:element name="things" type="thingsTyp e"/>
</xs:sequence>
</xs:complexType>
<xs:complexTy pe name="thingsTyp e">
<xs:sequence>
<xs:element name="thing" type="xs:intege r"
maxOccurs="unbo unded"/>
</xs:sequence>
</xs:complexType>

Groups (i.e. xs:group elements) are used when you want to reuse pieces
of the content model in more than one complex type. For example, if
every "product" element had a name, number and description (among other
children), and every "warehouse" element had the same 3 children, plus
some other warehouse-specific things. You could create a group that is
comprised of name, number and description, then refer to that group from
the complex types of both the "product" and "warehouse" elements.

Hope that helps,
Priscilla
-----------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema (Prentice Hall PTR)
http://www.datypic.com
-----------------------------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #3

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

Similar topics

4
1677
by: Andrew | last post by:
Antony (4:26 PM) : Hello all ! I have a problem with XML schema. My XML document which I need to be validated can be one of the following two types: 1st type is
3
1722
by: Sony Antony | last post by:
Hello: ( Please redirect me to the correct list if this is not where I m supposed to ask this question ) Our application essentially sends xml 'commands' to another system. These commands are essentially one xml element signifying which command it is ( 3 types of commands ) and a corresponding data required by that
1
1854
by: Alex Sab | last post by:
Hi, I am having trouble describing in a schema that elements can be mandatory in one part and not mandatory in another part of the xml document. Here is a sample xml file <Model:Templates> <Node:Template Node:nodeId="nodeID"> <Node:Name Node:Comment="">Name</Node:Name> <Node:Name2 Node:Comment="">Name</Node:Name2> ...
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
1010
by: Sahatra Kumara | last post by:
I have the schema that was written by other people. This schema seems to be wrong. Altova XML SPY 2005 and .Net have found out the block of schema definition that contains error, namely non-determinism. <xsd:complexType name="typeRequisite"> <xsd:sequence> <xsd:choice> <xsd:group ref="edmsi:SubRequisitesGroup"/> <xsd:group ref="edmsi:SingleRequisiteValueGroup"/> </xsd:choice>
4
1351
by: Nicolas Mailhot | last post by:
Hi, I've been sent an xsd that uses the following construct : <xsi:element name="foo"> <xsi:complexType name="foo"> Is this something allowed ? I couldn't find anything that said it's wrong, but at the same time I have an xml parser that chokes on it and none of the public xsd examples I've ever seen used it. I'd like to
5
3417
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.
4
1306
by: olivier.scalbert | last post by:
Hello, I need to create an xsd to validate the following type of xml: <?xml version="1.0" encoding="UTF-8"?> <root <exception1 xsi:type="ExceptionAType"> <Type>1</Type> <Info>Bla bla</Info> </exception1>
0
3363
by: mk189 | last post by:
Hi, I am trying to create XML schema of custom markup language, enriched by XHTML. In simplified version, the XML documet could look like that: <a:alarm-manual xmlns:a="alarm-manual" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="alarm-manual alarm-manual.xsd" <h:p>Text ... <a:par-value name="myName"/... text </h:p>
1
4026
by: jan.geek | last post by:
Hi all, When reading the following ugly but valid (according to w3c XSV) xsd into a DataSet I get "Duplicated declaration PossiblesValue" error. Can anyone tell me why? This is a small part of a large xsd reverse engineered from an existing xml output from an application so despite the structure being crap it can't be changed. Thanks,
0
9656
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
9498
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
10175
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
7518
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
6750
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();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
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
3675
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.