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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Schema formation help

Status
Not open for further replies.

Angate

Programmer
Mar 30, 2009
3
US
I am building an XML Schema for the first time, and I am diving in head first. What I have does not seem to work, and was wondering if anyone could give me any advice on making it better formed.

What it is is an image (TileSet) described by a Name Attribute and a FilePath attribute. The image can be broken down into two kinds of separate sections as defined by its Animation and Inanimate elements. Each Tileset can have any number of Animations and Inanimates.

This is what I have:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="tileSetContents"
targetNamespace=" elementFormDefault="qualified"
xmlns=" xmlns:mstns=" xmlns:xs=">

<xs:element name="TileSet">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="Animation">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element type="xs:string" nillable="false" name="Name" />
<xs:element type="xs:integer" nillable="false" name="X" />
<xs:element type="xs:integer" nillable="false" name="Y" />
<xs:element type="xs:integer" nillable="false" name="Width" />
<xs:element type="xs:integer" nillable="false" name="Height" />
<xs:element type="xs:integer" nillable="false" name="NumberOfTiles" />
<xs:element type="xs:integer" nillable="false" name="DurationOfAnimationMS" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Inanimate">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element type="xs:string" nillable="false" name="Name" />
<xs:element type="xs:integer" nillable="false" name="X" />
<xs:element type="xs:integer" nillable="false" name="Y" />
<xs:element type="xs:integer" nillable="false" name="Width" />
<xs:element type="xs:integer" nillable="false" name="Height" />
</xs:sequence>
</xs:complexType>
</xs:element >
</xs:sequence>
<xs:attribute name="Name" use="required" />
<xs:attribute name="ImagePath" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>


And I am pointing to it from an XML fie as such:

<TileSet xmlns="D:\Programming\animationClassLibrary\animationClassLibrary"
xmlns:xsi="xsi:schemaLocation="D:\Programming\animationClassLibrary\animationClassLibrary tileSetContents.xsd">

</TileSet>


Any ideas what is going wrong here?
 
I got it after playing with it some more.

This is what worked for those who may wonder:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="tileSetContents"
targetNamespace="D:\Programming\animationClassLibrary\animationClassLibrary"
elementFormDefault="qualified"
xmlns="D:\Programming\animationClassLibrary\animationClassLibrary\tileSetContents.xsd"
xmlns:mstns="D:\Programming\animationClassLibrary\animationClassLibrary\tileSetContents.xsd"
xmlns:xs=">

<xs:element name="TileSet">

<xs:complexType>

<xs:sequence minOccurs="1" maxOccurs="1">

<xs:element name="Animation" minOccurs ="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element type="xs:string" nillable="false" name="Name" />
<xs:element type="xs:integer" nillable="false" name="X" />
<xs:element type="xs:integer" nillable="false" name="Y" />
<xs:element type="xs:integer" nillable="false" name="Width" />
<xs:element type="xs:integer" nillable="false" name="Height" />
<xs:element type="xs:integer" nillable="false" name="NumberOfTiles" />
<xs:element type="xs:integer" nillable="false" name="DurationOfAnimationMS" />
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="Inanimate" minOccurs ="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element type="xs:string" nillable="false" name="Name" />
<xs:element type="xs:integer" nillable="false" name="X" />
<xs:element type="xs:integer" nillable="false" name="Y" />
<xs:element type="xs:integer" nillable="false" name="Width" />
<xs:element type="xs:integer" nillable="false" name="Height" />
</xs:sequence>
</xs:complexType>
</xs:element >

</xs:sequence>

<xs:attribute name="Name" use="required" />
<xs:attribute name="ImagePath" use="required" />

</xs:complexType>

</xs:element>

</xs:schema>



<?xml version="1.0" encoding="utf-8" ?>

<TileSet Name="Bla" ImagePath ="d:/"
xmlns="D:\Programming\animationClassLibrary\animationClassLibrary"
xmlns:xsi=" xsi:schemaLocation="D:\Programming\animationClassLibrary\animationClassLibrary tileSetContents.xsd">

<Animation>
<Name>Test</Name>
<X>0</X>
<Y>0</Y>
<Width>0</Width>
<Height>0</Height>
<NumberOfTiles>10</NumberOfTiles>
<DurationOfAnimationMS>1000</DurationOfAnimationMS>
</Animation>

<Inanimate>
<Name>Test</Name>
<X>0</X>
<Y>0</Y>
<Width>0</Width>
<Height>0</Height>
</Inanimate>

</TileSet>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top