xml - Error: Invalid content was found starting with element -
i having trouble getting files validate.
here errors getting.
4: 14 cvc-complex-type.2.4.a: invalid content found starting element 'airportlist'. 1 of '{"":airport}' expected.
47: 15 xml document structures must start , end within same entity.
i post both xml document code , xsd schema below. i'm new this, i'm not sure i'm doing wrong. have changed formatting of files around still same errors.
<?xml version="1.0"?> <airportlist xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="simple_apoole33.xsd"> <airportlist> <airport> <name>abbotsford international airport</name> <community>abbotsford</community> <province>british columbia</province> <passengers>15</passengers> </airport> <airport> <name>atlin airport</name> <community>atlin</community> <province>british columbia</province> <passengers>15</passengers> </airport> <airport> <name>atlin water aerodrome</name> <community>atlin</community> <province>british columbia</province> <passengers>15</passengers> </airport> <airport> <name>baie-comeau water aerodrome</name> <community>baie-comeau</community> <province>quebec</province> <passengers>15</passengers> </airport> <airport> <name>beaver creek airport</name> <community>beaver creek</community> <province>yukon</province> <passengers>15</passengers> </airport> <airport> <name>bedwell harbour water aerodrome</name> <community>bedwell harbour</community> <province>british columbia</province> <passengers>15</passengers> </airport> <airport> <name>billy bishop toronto city airport</name> <community>toronto</community> <province>ontario</province> <passengers>15</passengers> </airport> </airportlist> <?xml version="1.0"?> <!-- xsd schema simple_apoole33_it_must_validate.xml --> <xsd:schema xmlns:xsd= "http://www.w3.org/2001/xmlschema"> <xsd:element name="airportlist"> <xsd:complextype> <xsd:sequence> <xsd:element name="airport" maxoccurs="unbounded"> <xsd:complextype> <xsd:sequence> <xsd:element name="name"type="xsd:string"/> <xsd:element name="community"type="xsd:string"/> <xsd:element name="province"type="xsd:string"/> <xsd:element name="passengers"type="xsd:integer" minoccurs = "0"/> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:schema>
you close. make these 2 changes:
- eliminate
airportlist
element in xml. - add spaces between
@name
,@type
attributes in xsd.
altogether, corrected xml,
<?xml version="1.0"?> <airportlist xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="simple_apoole33.xsd"> <airport> <name>abbotsford international airport</name> <community>abbotsford</community> <province>british columbia</province> <passengers>15</passengers> </airport> <airport> <name>atlin airport</name> <community>atlin</community> <province>british columbia</province> <passengers>15</passengers> </airport> <airport> <name>atlin water aerodrome</name> <community>atlin</community> <province>british columbia</province> <passengers>15</passengers> </airport> <airport> <name>baie-comeau water aerodrome</name> <community>baie-comeau</community> <province>quebec</province> <passengers>15</passengers> </airport> <airport> <name>beaver creek airport</name> <community>beaver creek</community> <province>yukon</province> <passengers>15</passengers> </airport> <airport> <name>bedwell harbour water aerodrome</name> <community>bedwell harbour</community> <province>british columbia</province> <passengers>15</passengers> </airport> <airport> <name>billy bishop toronto city airport</name> <community>toronto</community> <province>ontario</province> <passengers>15</passengers> </airport> </airportlist>
will validate against corrected xsd,
<?xml version="1.0"?> <!-- xsd schema simple_apoole33_it_must_validate.xml --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="airportlist"> <xsd:complextype> <xsd:sequence> <xsd:element name="airport" maxoccurs="unbounded"> <xsd:complextype> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="community" type="xsd:string"/> <xsd:element name="province" type="xsd:string"/> <xsd:element name="passengers" type="xsd:integer" minoccurs="0"/> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:schema>
as requested.
Comments
Post a Comment