how to make an xml schema?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy B

    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?



  • Jeremy Shovan

    #2
    Re: how to make an xml schema?

    This should do it for ya ...

    ---------------------------------------------------------------------------------------------------------------------------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">
    <xs:element name="Contracts ">
    <xs:complexType >
    <xs:sequence>
    <xs:element name="Glossary" type="GlossaryT ype"/>
    <xs:element name="Sections" type="SectionsT ype"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:complexTy pe name="SectionsT ype">
    <xs:sequence>
    <xs:element name="Section" type="SectionTy pe" maxOccurs="unbo unded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexTy pe name="GlossaryT ype">
    <xs:sequence>
    <xs:element name="Term" type="TermType" maxOccurs="unbo unded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexTy pe name="TermType" >
    <xs:simpleConte nt>
    <xs:extension base="xs:string ">
    <xs:attribute name="ID" type="xs:unsign edInt" use="required"/>
    <xs:attribute name="Word" type="xs:string " use="required"/>
    </xs:extension>
    </xs:simpleConten t>
    </xs:complexType>
    <xs:complexTy pe name="SectionTy pe">
    <xs:simpleConte nt>
    <xs:extension base="xs:string ">
    <xs:attribute name="ID" type="xs:unsign edInt" use="required"/>
    <xs:attribute name="Title" type="xs:string " use="required"/>
    </xs:extension>
    </xs:simpleConten t>
    </xs:complexType>
    </xs:schema>

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

    Jeremy Shovan



    "Andy B" <a_borka@sbcglo bal.netwrote in message
    news:#mcnxHStIH A.1316@TK2MSFTN GP06.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?
    >
    >
    >

    Comment

    Working...