473,414 Members | 1,711 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,414 software developers and data experts.

how to make an xml schema?

I have to write an xml schema but don't remember exactly how to do that. I
tried using a bunch of different kinds of schema designers but something
doesn't seem right. One of them told me the following code was invalid:

<xs:element name ="Contract">
<xs:ComplexType>
</xs:ComplexType>
</xs:element>

it said that "name was an invalid attribute and doesn't belong here". This
is what I have to do:

1. The root element of the xml file needs to be called "Contract".
2. In the root node there will be different child nodes like "Sections",
"Glossary" and so on.

These are the main steps I forgot how to do. An example of what I need to
help me out is this (in xml format):

<Contracts>
<Glossary>
<Term ID="1" Word = "Contract">
The document you are reading.
</Term>
<Term ID="2" Word = "Host">
The person that pays the price of the contract.
</Term>
.....
</Glossary>
<Sections>
<Section ID = "1" Title = "Section 1 title here">
The text for section 1
</Section>
<Section ID = "2" Title = "Section 2 title goes here.">
Section 2 text.
</Section>
....
</Sections></Contract>

Any idea how to create this in xml schema format?

Jun 27 '08 #1
1 1436
This should do it for ya ...

---------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Contracts">
<xs:complexType>
<xs:sequence>
<xs:element name="Glossary" type="GlossaryType"/>
<xs:element name="Sections" type="SectionsType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="SectionsType">
<xs:sequence>
<xs:element name="Section" type="SectionType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="GlossaryType">
<xs:sequence>
<xs:element name="Term" type="TermType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TermType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="ID" type="xs:unsignedInt" use="required"/>
<xs:attribute name="Word" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="SectionType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="ID" type="xs:unsignedInt" use="required"/>
<xs:attribute name="Title" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>

---------------------------------------------------------------------------------------------------------------------------------------------

Jeremy Shovan

"Andy B" <a_*****@sbcglobal.netwrote in message
news:#m**************@TK2MSFTNGP06.phx.gbl...
I have to write an xml schema but don't remember exactly how to do that. I
tried using a bunch of different kinds of schema designers but something
doesn't seem right. One of them told me the following code was invalid:

<xs:element name ="Contract">
<xs:ComplexType>
</xs:ComplexType>
</xs:element>

it said that "name was an invalid attribute and doesn't belong here". This
is what I have to do:

1. The root element of the xml file needs to be called "Contract".
2. In the root node there will be different child nodes like "Sections",
"Glossary" and so on.

These are the main steps I forgot how to do. An example of what I need to
help me out is this (in xml format):

<Contracts>
<Glossary>
<Term ID="1" Word = "Contract">
The document you are reading.
</Term>
<Term ID="2" Word = "Host">
The person that pays the price of the contract.
</Term>
....
</Glossary>
<Sections>
<Section ID = "1" Title = "Section 1 title here">
The text for section 1
</Section>
<Section ID = "2" Title = "Section 2 title goes here.">
Section 2 text.
</Section>
...
</Sections></Contract>

Any idea how to create this in xml schema format?
Jun 27 '08 #2

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

Similar topics

4
by: stiank81 | last post by:
Hi. I have a problem witch I assume there is an answear to....? I have several XML schemas, and they all have quiet a lot of definitions in common. They still have to be seperated into...
1
by: Mike Kayser | last post by:
Hi, I have a schema which is fine except for one part giving me trouble: (...) <xs:element name="DOC"> <xs:complexType mixed="true"> <xs:sequence> <xs:any processContents="lax"...
2
by: RayAll | last post by:
Hi, I have a table which has 3 forign keys to three other tables.I's to make an schema out of this table which contains all the constrainsts and all its relations and also I'l like to have the...
11
by: David Pradier | last post by:
Hi ! I've just inherited the responsibility of a postgresql database of roughly 480 tables and 6460 columns, mainly without constraints, not even foreign keys. I'd like to make it a little...
1
by: cidney001 | last post by:
Hi, I am trying to create a schema with an inline schema in it. I have looked for a simple example of how to do this but i can't find one. I have included 2 simple schemas. How would i make the...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...

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.