Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / May 2008

Tip: Looking for answers? Try searching our database.

how to make an xml schema?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy B - 13 May 2008 18:51 GMT
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?
Jeremy Shovan - 14 May 2008 00:25 GMT
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

> 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
[quoted text clipped - 36 lines]
>
> Any idea how to create this in xml schema format?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.