W3C XML sample file produces "there are multiple root elements. line 4. position 9." error -
so urged test sample xml files out before creating 1 myself , stumble upon error when seek validate first sample xml file
here's sample xml code:
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns ="http://my-company.com/namespace" targetnamespace="http://my-company.com/namespace" elementformdefault="qualified" attributeformdefault ="unqualified" xmlns:xs="http://www.w3.org/2001/xmlschema" /> <xs:element name="company"> <xs:annotation> <xs:documentation>root element</xs:documentation> </xs:annotation> <xs:complextype> <xs:sequence> <xs:element name="address"/> <xs:complextype> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="street" type="xs:string"/> <xs:element name="city" type="xs:string"/> </xs:sequence> </xs:complextype> <xs:element name="person" maxoccurs="unbounded"/> <xs:complextype> <xs:sequence> <xs:element name="first" type="xs:string"/> <xs:element name="last" type="xs:string"/> <xs:element minoccurs="0" name="title" type="xs:string"/> <xs:element name="phoneext"> <xs:simpletype> <xs:restriction base="xs:integer"> <xs:maxinclusive value ="99"/> </xs:restriction> </xs:simpletype> </xs:element> <xs:element name="email" type="xs:string"/> </xs:sequence> </xs:complextype> </xs:sequence> </xs:complextype> </xs:element> </xs:schema>
no thought got but
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns ="http://my-company.com/namespace" targetnamespace="http://my-company.com/namespace" elementformdefault="qualified" attributeformdefault ="unqualified" xmlns:xs="http://www.w3.org/2001/xmlschema" />
change to
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns ="http://my-company.com/namespace" targetnamespace="http://my-company.com/namespace" elementformdefault="qualified" attributeformdefault ="unqualified" xmlns:xs="http://www.w3.org/2001/xmlschema" >
ie rid of lastly /
it's closing schema node off, follow rules else has within root node.
xml
No comments:
Post a Comment