Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Schema & Instance Document help pelase

Status
Not open for further replies.

icedz

Technical User
Jan 6, 2009
1
Hi all, I am new to XML and decided to try and self teach myself XML by following a few online help stuff. I am trying to create an xml schema and instance document, but I am not sure on how successful I have been because of my low experiance with XML.

Does anyone whether my schema and instance document are working correctly together?


Any help will be much appreciated.

Thanks, Rick.





XML Schema


<xsd:schema xmlns:xsd="
<xsd:element name="CarDocument" type="CarDocument"/>

<xsd:complexType name="CarDocument">
<xsd:sequence>
<xsd:element name="Car" type="Car"/>
<xsd:element name="LeaseDate" type="LeaseDate"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Car">
<xsd:sequence>
<xsd:element name="RegistrationNumberr" type="xsd:decimal"/>
<xsd:element name="LocationInformation" type="xsd:string"/>
<xsd:element name="TypeOfCar" type="xsd:string"/>
<xsd:element name="DescriptionTextOfCar" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="LeaseDate">
<xsd:sequence>
<xsd:element name="StartDate" type="xsd:date"/>
<xsd:element name="EndDate" type="xsd:date"/>
</xsd:sequence>
</xsd:complexType>

</xsd:schema>





XML Instance Document

<?xml version="1.0"?>
<xml:InstanceDocument xmlns:xsd="
<CarInfo
xsi:noNamespaceSchemaLocation="XMLCarDocument.xsd"
xmlns:cat="CarInfo.xml">
<xi:include href="CarInfo.xml"/>


<MonumentInfo schemaLocation="XMLCarDocument.xsd">
<Car>
<RegistrationNumberr>19285</RegistrationNumberr>
<LocationInformation>NEWYOK</LocationInformation>
<TypeOfCar>SPORTCAR</TypeOfCar>
<DescriptionTextOfCar>It is a sports car and is superfast!</DescriptionTextOfCar>
</Car>

<LeaseDate>
<StartDate>10/12/2008</StartDate>
<EndDate>5/06/2009</EndDate>
</LeaseDate>

</CarInfo>
 
[1] schema
[tt]
<xsd:schema xmlns:xsd="[ignore][/ignore]">

<xsd:element name="CarDocument" type="CarDocument"/>

<xsd:complexType name="CarDocument">
<xsd:sequence>
<xsd:element name="Car" type="Car"/>
<xsd:element name="LeaseDate" type="LeaseDate"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Car">
<xsd:sequence>
<xsd:element name="RegistrationNumberr" type="xsd:[blue]nonNegativeInteger[/blue]"/>
<xsd:element name="LocationInformation" type="xsd:string"/>
<xsd:element name="TypeOfCar" type="xsd:string"/>
<xsd:element name="DescriptionTextOfCar" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="LeaseDate">
<xsd:sequence>
<xsd:element name="StartDate" type="xsd:date"/>
<xsd:element name="EndDate" type="xsd:date"/>
</xsd:sequence>
</xsd:complexType>

</xsd:schema>
[/tt]
[2] a valid instance document
[tt]
<?xml version="1.0"?>
[red]<!--[/red]
<xml:InstanceDocument xmlns:xsd="[ignore][/ignore]">
[red]-->[/red]
[red]<!--[/red]
<CarInfo
xsi:noNamespaceSchemaLocation="XMLCarDocument.xsd"
xmlns:cat="CarInfo.xml">
<xi:include href="CarInfo.xml"/>
<MonumentInfo schemaLocation="XMLCarDocument.xsd">
[red]-->[/red]
<[red]CarDocument[/red]>
<Car>
<RegistrationNumberr>19285</RegistrationNumberr>
<LocationInformation>NEWYOK</LocationInformation>
<TypeOfCar>SPORTCAR</TypeOfCar>
<DescriptionTextOfCar>It is a sports car and is superfast!</DescriptionTextOfCar>
</Car>

<LeaseDate>
<StartDate>[red]2008-10-12[/red]</StartDate>
<EndDate>[red]2009-05-06[/red]</EndDate>
</LeaseDate>
<[red]/CarDocument[/red]>
[red]<!--[/red]
</CarInfo>
[red]-->[/red]
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top