473,666 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What would be a good schema for this xml file

All I want to do is have a xml file like this
<Entertainmen t>
<Movie>
<Title>(Title Here)</Title>
<Rating>(Rati ng Here)</Title>
</Movie>

<Movie>
<Title>(Title Here)</Title>
<Rating>(Rati ng Here)</Title>
</Movie>

<Movie>
<Title>(Title Here)</Title>
<Rating>(Rati ng Here)</Title>
</Movie>

<PS2>
<Title>(Title Here)</Title>
<Rating>(Rati ng Here)</Title>
</PS2>
</Entertainment>

I try something like the schema below but this schema doesn't work.
With this schema it is looking for a xml file like this. I want to be
able to add as many Movie or PS2 elements in any order without errors.

<Entertainmen t>
<Movie>
<Title>(Title Here)</Title>
<Rating>(Rati ng Here)</Title>
</Movie>
<PS2>
<Title>(Title Here)</Title>
<Rating>(Rati ng Here)</Title>
</PS2>
</Entertainment>
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Entertainme nt" targetNamespace ="http://mark/Homepage/"
elementFormDefa ult="qualified" xmlns="http://mark/Homepage/"
xmlns:mstns="ht tp://mark/Homepage/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Entertain ment">
<xs:complexType >
<xs:sequence>
<xs:element name="Movie" type="Informati on"></xs:element>
<xs:element name="PS2" type="Informati on" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexTy pe name="Informati on">
<xs:sequence>
<xs:element name="Descripti on" type="xs:string " />
<xs:element name="Genre" type="xs:string " />
<xs:element name="Hardware" type="xs:string " />
<xs:element name="Picture" type="xs:string " />
<xs:element name="Rating" type="xs:positi veInteger" />
<xs:element name="Title" type="xs:string " />
</xs:sequence>
</xs:complexType>
</xs:schema>
Jul 20 '05 #1
2 1476
co*******@mix-net.net (Mark Constant) writes:
All I want to do is have a xml file like this
[example elided]

I try something like the schema below but this schema doesn't work.
With this schema it is looking for a xml file like this. I want to be
able to add as many Movie or PS2 elements in any order without errors.

[example with single Movie and single PS2 element]

...
<xs:element name="Entertain ment">
<xs:complexType >
<xs:sequence>
<xs:element name="Movie" type="Informati on"></xs:element>
<xs:element name="PS2" type="Informati on" />
</xs:sequence>
</xs:complexType>
</xs:element>


Here's your problem: you are telling the schema processor that what
you want in an Entertainment element is a sequence consisting of
exactly one Movie element and exactly one PS2 element, in order.

You can use minOccurs and maxOccurs attributes on the xs:sequence or
xs:element elements to specify that more than one element can occur.

If we just specify maxOccurs="unbo unded" on the two elements, we allow
any positive number of Movie elements, followed by any positive number
of PS2 elements:

<xs:complexType >
<xs:sequence>
<xs:element name="Movie" type="Informati on" maxOccurs="unbo unded"/>
<xs:element name="PS2" type="Informati on" maxOccurs="unbo unded"/>
</xs:sequence>
</xs:complexType>

If you want to allow Entertainment elements without Movie elements
or PS2 elements, you can also add minOccurs="0" to the xs:element
elements.

Since you want to allow the Movie and PS2 elements to occur in any
order, however, you really need to change something else, too. One
way is to allow the sequence to repeat:

<xs:complexType >
<xs:sequence maxOccurs="unbo unded">
<xs:element name="Movie" type="Informati on"
minOccurs="0" maxOccurs="unbo unded"/>
<xs:element name="PS2" type="Informati on"
minOccurs="0" maxOccurs="unbo unded"/>
</xs:sequence>
</xs:complexType>

Note that since the sequence can repeat, the maxOccurs attributes on
the xs:element elements are no longer necessary and can be removed.

It is probably more usual, however, to express 'any number of Movie or
PS2 elements, in any order' not as a repeating sequence but as a
repeating choice, thus:

<xs:complexType >
<xs:choice minOccurs="0" maxOccurs="unbo unded">
<xs:element name="Movie" type="Informati on"/>
<xs:element name="PS2" type="Informati on"/>
</xs:choice>
</xs:complexType>

I hope this helps.

-C. M. Sperberg-McQueen
World Wide Web Consortium

Jul 20 '05 #2
cm****@acm.org (C. M. Sperberg-McQueen) wrote in message news:<m2******* *****@acm.org>. ..
co*******@mix-net.net (Mark Constant) writes:
All I want to do is have a xml file like this
[example elided]

I try something like the schema below but this schema doesn't work.
With this schema it is looking for a xml file like this. I want to be
able to add as many Movie or PS2 elements in any order without errors.

[example with single Movie and single PS2 element]

...
<xs:element name="Entertain ment">
<xs:complexType >
<xs:sequence>
<xs:element name="Movie" type="Informati on"></xs:element>
<xs:element name="PS2" type="Informati on" />
</xs:sequence>
</xs:complexType>
</xs:element>


Here's your problem: you are telling the schema processor that what
you want in an Entertainment element is a sequence consisting of
exactly one Movie element and exactly one PS2 element, in order.

You can use minOccurs and maxOccurs attributes on the xs:sequence or
xs:element elements to specify that more than one element can occur.

If we just specify maxOccurs="unbo unded" on the two elements, we allow
any positive number of Movie elements, followed by any positive number
of PS2 elements:

<xs:complexType >
<xs:sequence>
<xs:element name="Movie" type="Informati on" maxOccurs="unbo unded"/>
<xs:element name="PS2" type="Informati on" maxOccurs="unbo unded"/>
</xs:sequence>
</xs:complexType>

If you want to allow Entertainment elements without Movie elements
or PS2 elements, you can also add minOccurs="0" to the xs:element
elements.

Since you want to allow the Movie and PS2 elements to occur in any
order, however, you really need to change something else, too. One
way is to allow the sequence to repeat:

<xs:complexType >
<xs:sequence maxOccurs="unbo unded">
<xs:element name="Movie" type="Informati on"
minOccurs="0" maxOccurs="unbo unded"/>
<xs:element name="PS2" type="Informati on"
minOccurs="0" maxOccurs="unbo unded"/>
</xs:sequence>
</xs:complexType>

Note that since the sequence can repeat, the maxOccurs attributes on
the xs:element elements are no longer necessary and can be removed.

It is probably more usual, however, to express 'any number of Movie or
PS2 elements, in any order' not as a repeating sequence but as a
repeating choice, thus:

<xs:complexType >
<xs:choice minOccurs="0" maxOccurs="unbo unded">
<xs:element name="Movie" type="Informati on"/>
<xs:element name="PS2" type="Informati on"/>
</xs:choice>
</xs:complexType>

I hope this helps.

-C. M. Sperberg-McQueen
World Wide Web Consortium


That helped a lot thank you.
Jul 20 '05 #3

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

Similar topics

2
4655
by: Olaf Meyer | last post by:
Apprentently xerces 2.6.0 (Java) does not validate against contraints specified in the schema (e.g. constraints specified via unique element). The validation works with the XML editor I'm using (XMLSpy4) but not with Xerces 2.6.0. I've included a really short and simple example to illustrate it. I would like to get some comments on the validation capabilities of Xerces 2.6.0. I though it *fully* supported W3C Schema!
0
1586
by: Aaron P Frenger | last post by:
Hello All, I have a very large XML file that I would like to split up into a few smaller files, but still use only one schema. I am using Xerces C++ libraries. My idea is to have one schema specified in the main file. At some point in the schema I would add a choice element that would either have a tag that specifies an external file or a tree of tags. Once the main xml file is loaded I would search for any instances where the
2
4770
by: pohmart | last post by:
I am using Xerces 2.6.2 and SAX on Windows2k. I want to validate an XML doc, which has no schema reference, with an external schema which is on my PC. I am setting the following properties and features: saxParser.setFeature("http://xml.org/sax/features/namespaces", true); saxParser.setFeature("http://xml.org/sax/features/namespace-prefixes", true); saxParser.setFeature("http://xml.org/sax/features/validation", true);...
10
43208
by: wackyphill | last post by:
I know in SQL Server the terms Database and Catalog are used interchangably. But a table is also assigned a schema. As seen in the INFORMATION_SCHEMA.Tables View. I don't get what this schema qualifier is all about. Like if a table has a schema of dbo. Can someone explain the relationship the schema has and what it is? Thanks.
2
10750
by: Vagabond Software | last post by:
I have translated a DTD to an XML Schema (XSD) file by hand, and the Schema View in Visual Studio .NET 2003 seems to diplay everything properly. However, when I specify the schemalocation in my xml files, VS.NET still reports that no schema could be located. Here are the relevant (maybe) portions of the files: FROM THE SCHEMA FILE (mydoc-v2.xsd) <?xml version="1.0" encoding="utf-8" ?> <xs:schema...
1
2969
by: Andy | last post by:
I am having some trouble validating XML using the XmlValidatingReader. I have created some xml and used the visual studio to generate the schema. So I am confident that the xml and schema match. The problem I am having is that the validation event fires for each node in the xml. It seems to be completely ignoring the schema that I have used. I'm wondering if I need to do something extra to tell the xml which schema to use.
0
1203
by: Aaron P Frenger | last post by:
Hello All, I have a very large XML file that I would like to split up into a few smaller files, but still use only one schema. I am using Xerces C++ libraries. My idea is to have one schema specified in the main file. At certain points in the schema I would add a choice element that would either have a tag that specifies an external file or a tree of tags. Once the main xml file is loaded I would search for any instances where the
1
1717
by: Szaki | last post by:
I use a BulkLoad to import file.xml to my base MS Server 2000. To import this xml file I need schema file. Mayby you know how to do this file mechanicy f.g. mayby somebody have some script in .net who generate this schema. for any help Thanks ======== My xml file ================================= <ROOT> <Customers> <CustomerId>5555</CustomerId>
4
7739
by: Stan R. | last post by:
Hello, I have xmllint and xsltproc installed and running on both my linux and win32 platforms, all seems good. I have a couple questions though. 1) If I have an external dtd file, which is included in my xml file, like <!DOCTYPE userlist SYSTEM "test.dtd">
0
8356
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
8869
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
8781
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...
0
8639
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
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
6198
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
4198
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...
1
2771
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
1775
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.