My XML Document and XML Schema are working together

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SavRak
    New Member
    • May 2010
    • 2

    My XML Document and XML Schema are working together

    Hi,
    I seem to be having an issue linking my XML document and XML Schema together.
    Both are not working, and do not seem to be validating when using:
    http://tools.decisions oft.com/schemaValidate/

    Im not sure if what I have will work, or does work, as I can still output the XML via an XSLT fine :S

    Ive attached my XML page and XML Schema, if someone could have a look I would be very grateful!
    Thanks,

    Sav.

    XML PAGE
    Code:
    <?xml version="1.0"?>
    <premierleague xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="myschema.xsd">
    
      <team area="London" leaguechamp="yes" europeanchamp="no" domesticwinner="yes">
        <clubname>Arsenal F.C.</clubname>
        <nickname>The Gunners</nickname>
        <stadium>
    	<name>Emirates Stadium</name>
    	<capacity>60355</capacity>
        </stadium>
        <manager>Arsene Wenger</manager>
        <captain>Francesc Fabregas</captain>
        <sponsor>Emirates</sponsor>
        <trophy>
          <leaguetitle>13</leaguetitle>
          <domestic>12</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="1" URI="images/badges/arsenal.gif"/>
      </team>
    
     <team area="Mid" leaguechamp="yes" europeanchamp="yes" domesticwinner="yes">
        <clubname>Aston Villa F.C.</clubname>
        <nickname>The Villa</nickname>
        <stadium>
    	<name>Villa Park</name>
    	<capacity>42788</capacity>
        </stadium>
        <manager>Martin O'Neill</manager>
        <captain>Stilian Petrov</captain>
        <sponsor>Acorn</sponsor>
        <trophy>
          <leaguetitle>7</leaguetitle>
          <domestic>12</domestic>
          <europeanchamp>1</europeanchamp>
        </trophy>
       <Image ID="2" URI="images/badges/villa.gif"/>
      </team>
    
     <team area="Mid" leaguechamp="no" europeanchamp="no" domesticwinner="yes">
        <clubname>Birmingham City F.C.</clubname>
        <nickname>Blues</nickname>
        <stadium>
    	<name>St Andrew's</name>
    	<capacity>30009</capacity>
        </stadium>
        <manager>Alex McLeish</manager>
        <captain>Lee Carsley</captain>
        <sponsor>F and C Investments</sponsor>
        <trophy>
          <leaguetitle>0</leaguetitle>
          <domestic>1</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="3" URI="images/badges/bham.gif"/>
      </team>
    
    <team area="NorthWest" leaguechamp="yes" europeanchamp="no" domesticwinner="yes">
        <clubname>Blackburn Rovers F.C.</clubname>
        <nickname>Rovers</nickname>
        <stadium>
    	<name>Ewood Park</name>
    	<capacity>31367</capacity>
        </stadium>
        <manager>Sam Allardyce</manager>
        <captain>Ryan Nelsen</captain>
        <sponsor>Crown Paints</sponsor>
        <trophy>
          <leaguetitle>1</leaguetitle>
          <domestic>2</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="4" URI="images/badges/blackburn.gif"/>
      </team>
    
    
    <team area="NorthWest" leaguechamp="no" europeanchamp="no" domesticwinner="yes">
        <clubname>Bolton Wanderers F.C.</clubname>
        <nickname>The Trotters</nickname>
        <stadium>
    	<name>Reebok Stadium</name>
    	<capacity>28723</capacity>
        </stadium>
        <manager>Owen Coyle</manager>
        <captain>Kevin Davies</captain>
        <sponsor>188BET</sponsor>
        <trophy>
          <leaguetitle>0</leaguetitle>
          <domestic>4</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="5" URI="images/badges/bolton.gif"/>
      </team>
    
    <team area="NorthWest" leaguechamp="no" europeanchamp="no" domesticwinner="yes">
        <clubname>Burnley F.C.</clubname>
        <nickname>The Clarets</nickname>
        <stadium>
    	<name>Turf Moor</name>
    	<capacity>22546</capacity>
        </stadium>
        <manager>Brian Laws</manager>
        <captain>Alexander</captain>
        <sponsor>Cooke</sponsor>
        <trophy>
          <leaguetitle>0</leaguetitle>
          <domestic>1</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="6" URI="images/badges/burnley.gif"/>
      </team>
    
    <team area="London" leaguechamp="yes" europeanchamp="no" domesticwinner="yes">
      <clubname>Chelsea F.C.</clubname>
        <nickname>The Blues</nickname>
        <stadium>
    	<name>Stamford Bridge</name>
    	<capacity>31367</capacity>
        </stadium>
        <manager>Carlo Ancelotti</manager>
        <captain>John Terry</captain>
        <sponsor>Samsung</sponsor>
        <trophy>
          <leaguetitle>3</leaguetitle>
          <domestic>2</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="7" URI="images/badges/chelsea.gif"/>
      </team>
    
    <team area="NorthWest" leaguechamp="no" europeanchamp="no" domesticwinner="yes">
        <clubname>Everton F.C.</clubname>
        <nickname>The Clarets</nickname>
        <stadium>
    	<name>Goodison Park</name>
    	<capacity>22546</capacity>
        </stadium>
        <manager>David Moyes</manager>
        <captain>Phillip Neville</captain>
        <sponsor>Chang Beer</sponsor>
        <trophy>
          <leaguetitle>0</leaguetitle>
          <domestic>1</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="8" URI="images/badges/everton.gif"/>
      </team>
    
    <team area="London" leaguechamp="no" europeanchamp="no" domesticwinner="no">
        <clubname>Fulham F.C.</clubname>
        <nickname>The Cottagers</nickname>
        <stadium>
    	<name>Craven Cottage</name>
    	<capacity>22700</capacity>
        </stadium>
        <manager>Roy Hodgson</manager>
        <captain>Danny Murphy</captain>
        <sponsor>LG</sponsor>
        <trophy>
          <leaguetitle>0</leaguetitle>
          <domestic>0</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="9" URI="images/badges/fulham.gif"/>
      </team>
    
    <team area="NorthEast" leaguechamp="no" europeanchamp="no" domesticwinner="no">
        <clubname>Hull City A.F.C</clubname>
        <nickname>The Tigers</nickname>
        <stadium>
    	<name>KC Stadium</name>
    	<capacity>22404</capacity>
        </stadium>
        <manager>Ian Dowie</manager>
        <captain>Ian Ashbee</captain>
        <sponsor>Karoo</sponsor>
        <trophy>
          <leaguetitle>0</leaguetitle>
          <domestic>0</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="10" URI="images/badges/hull.gif"/>
      </team>
    
    <team area="NorthWest" leaguechamp="yes" europeanchamp="yes" domesticwinner="yes">
        <clubname>Liverpool F.C.</clubname>
        <nickname>The Reds</nickname>
        <stadium>
    	<name>Anfield</name>
    	<capacity>45276</capacity>
        </stadium>
        <manager>Rafael Benitez</manager>
        <captain>Steven Gerrard</captain>
        <sponsor>Carlsberg</sponsor>
        <trophy>
          <leaguetitle>18</leaguetitle>
          <domestic>17</domestic>
          <europeanchamp>8</europeanchamp>
        </trophy>
        <Image ID="11" URI="images/badges/lfc.gif"/>
      </team>
    
    <team area="NorthWest" leaguechamp="no" europeanchamp="no" domesticwinner="yes">
        <clubname>Manchester City F.C.</clubname>
        <nickname>The Citizens</nickname>
        <stadium>
    	<name>City of Manchester Stadium</name>
    	<capacity>47726</capacity>
        </stadium>
        <manager>Roberto Mancini</manager>
        <captain>Kolo Toure</captain>
        <sponsor>Etihad Airways</sponsor>
        <trophy>
          <leaguetitle>0</leaguetitle>
          <domestic>6</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="12" URI="images/badges/mancity.gif"/>
      </team>
    
    <team area="NorthWest" leaguechamp="yes" europeanchamp="yes" domesticwinner="yes">
        <clubname>Manchester United F.C.</clubname>
        <nickname>Red Devils</nickname>
        <stadium>
    	<name>Old Trafford</name>
    	<capacity>75957</capacity>
        </stadium>
        <manager>Sir Alex Ferguson</manager>
        <captain>Gary Neville</captain>
        <sponsor>AIG</sponsor>
        <trophy>
          <leaguetitle>18</leaguetitle>
          <domestic>15</domestic>
          <europeanchamp>3</europeanchamp>
        </trophy>
        <Image ID="13" URI="images/badges/manutd.gif"/>
      </team>
    
    <team area="South" leaguechamp="yes" europeanchamp="no" domesticwinner="yes">
        <clubname>Portsmouth F.C.</clubname>
        <nickname>Pompey</nickname>
        <stadium>
    	<name>Fratton Park</name>
    	<capacity>20224</capacity>
        </stadium>
        <manager>Avram Grant</manager>
        <captain>David James</captain>
        <sponsor>OKI</sponsor>
        <trophy>
          <leaguetitle>2</leaguetitle>
          <domestic>2</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="14" URI="images/badges/pompey.gif"/>
      </team>
    
    <team area="NorthWest" leaguechamp="no" europeanchamp="no" domesticwinner="yes">
        <clubname>Stoke City F.C.</clubname>
        <nickname>The Potters</nickname>
        <stadium>
    	<name>Britannia Stadium</name>
    	<capacity>28383</capacity>
        </stadium>
        <manager>Tony Pulis</manager>
        <captain>Abdoulaye Faye</captain>
        <sponsor>Britannia</sponsor>
        <trophy>
          <leaguetitle>0</leaguetitle>
          <domestic>1</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="15" URI="images/badges/stoke.gif"/>
      </team>
    
    <team area="NorthEast" leaguechamp="yes" europeanchamp="no" domesticwinner="yes">
        <clubname>Sunderland F.C.</clubname>
        <nickname>The Black Cats</nickname>
        <stadium>
    	<name>Stadium of Light</name>
    	<capacity>49000</capacity>
        </stadium>
        <manager>Steve Bruce</manager>
        <captain>Lorik Cana</captain>
        <sponsor>Boyle Sport</sponsor>
        <trophy>
          <leaguetitle>6</leaguetitle>
          <domestic>2</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="16" URI="images/badges/sunder.gif"/>
      </team>
    
    <team area="London" leaguechamp="yes" europeanchamp="yes" domesticwinner="yes">
        <clubname>Tottenham Hotspur F.C.</clubname>
        <nickname>Spurs</nickname>
        <stadium>
    	<name>White Hart Lane</name>
    	<capacity>36310</capacity>
        </stadium>
        <manager>Harry Redknapp</manager>
        <captain>Ledley King</captain>
        <sponsor>Mansion.com</sponsor>
        <trophy>
          <leaguetitle>2</leaguetitle>
          <domestic>12</domestic>
          <europeanchamp>2</europeanchamp>
        </trophy>
        <Image ID="17" URI="images/badges/spurs.gif"/>
      </team>
    
    <team area="London" leaguechamp="no" europeanchamp="no" domesticwinner="yes">
        <clubname>West Ham United F.C.</clubname>
        <nickname>The Hammers</nickname>
        <stadium>
    	<name>Upton Park</name>
    	<capacity>35303</capacity>
        </stadium>
        <manager>Gianfranco Zola</manager>
        <captain>Matthew Upson</captain>
        <sponsor>SBOBET</sponsor>
        <trophy>
          <leaguetitle>0</leaguetitle>
          <domestic>3</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="18" URI="images/badges/westham.gif"/>
      </team>
    
    <team area="NorthWest" leaguechamp="no" europeanchamp="no" domesticwinner="no">
        <clubname>Wigan Athletic F.C.</clubname>
        <nickname>Latics</nickname>
        <stadium>
    	<name>DW Stadium</name>
    	<capacity>25138</capacity>
        </stadium>
        <manager>Roberto Martinez</manager>
        <captain>Mario Melchiot</captain>
        <sponsor>188BET</sponsor>
        <trophy>
          <leaguetitle>0</leaguetitle>
          <domestic>0</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="19" URI="images/badges/wigan.gif"/>
      </team>
    
    <team area="Mid" leaguechamp="yes" europeanchamp="no" domesticwinner="yes">
        <clubname>Wolverhampton Wonderers  F.C.</clubname>
        <nickname>Wolves</nickname>
        <stadium>
    	<name>Molineux Stadium</name>
    	<capacity>29303</capacity>
        </stadium>
        <manager>Mick McCarthy</manager>
        <captain>Karl Henry</captain>
        <sponsor>Sporting Bet</sponsor>
        <trophy>
          <leaguetitle>3</leaguetitle>
          <domestic>6</domestic>
          <europeanchamp>0</europeanchamp>
        </trophy>
        <Image ID="20" URI="images/badges/wolves.gif"/>
      </team>
    
    </premierleague>
    XML SCHEMA
    Code:
    <?xml version="1.0"?>
    
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
    
    <xs:element name="premierleague">
    	<xs:complexType>
    	<xs:sequence>
    				<xs:element name="team">
    					<xs:complexType>
    					<xs:attribute name="area" type="xs:string"/>
    					<xs:attribute name="leaguechamp" type="xs:string"/>
    					<xs:attribute name="europeanchamp" type="xs:string"/>
    					<xs:attribute name="domesticwinner" type="xs:string"/>
          			<xs:sequence>
    								<xs:element name="clubname" type="xs:string"/>
    								<xs:element name="nickname" type="xs:string"/>
    								<xs:element name="stadium">
    								  <xs:complexType>
        							 <xs:sequence>
          						  <xs:element name="name" type="xs:string"/>
          						  <xs:element name="capacity" type="xs:integer"/>
        							 </xs:sequence>
      								</xs:complexType>
    								</xs:element>
    								<xs:element name="manager" type="xs:string"/>
    								<xs:element name="captain" type="xs:string"/>
    								<xs:element name="sponsor" type="xs:string"/>
    								<xs:element name="trophy">
    								   <xs:complexType>
        							  <xs:sequence>
          						    <xs:element name="leaguetitle" type="xs:integer"/>
    										  <xs:element name="domestic" type="xs:integer"/>
    										  <xs:element name="europeanchamp" type="xs:integer"/>
        							  </xs:sequence>
      								 </xs:complexType>
    								</xs:element>
    						</xs:sequence>
    					</xs:complexType>
    				</xs:element>
    			</xs:sequence>
    	</xs:complexType>
    </xs:element>
    </xs:schema>
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    In Team, put attributes after the sequence.
    You're missing a definition for Image.

    You have multiple team elements. Either specify that the sequence has maxoccurs="unbo unded", or the team element has maxoccurs="unbo unded"

    Comment

    • SavRak
      New Member
      • May 2010
      • 2

      #3
      Thanks very much for your quick reply, apologies for not tagging the thread accordingly.

      I think ive got it correct now, both my XML document and XML Schema pass through the validator.

      I have defined the Image as below:

      Code:
      <xs:element name="Image">
      									<xs:complexType>
      										<xs:attribute name="ID" type="xs:integer"/>
      										<xs:attribute name="URI" type="xs:string"/>
        								</xs:complexType>
      								</xs:element>

      Is this adequate?

      Thanks very much for your support.

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        Looks to be so; you have more access to your data than we do.

        Comment

        Working...