I'm getting the following error whilst trying to validate an XML document based on the Google Atom feed.
Error - Line 8, 10: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 10; cvc-complex-type.2.4.a: Invalid content was found starting with element 'g:brand'. One of '{"xxx..w3.org/2005/Atom":id, "xxx.w3.org/2005/Atom":title, ".w3.org/2005/Atom":link, "xxx.w3.org/2005/Atom":brand}' is expected.
Here is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:g="http://base.google.com/ns/1.0">
<title>The name of your data feed.</title>
<link rel="self" href="http://www.example.com"/>
<updated>2006-06-11T18:30:02Z</updated>
<entry>
<title>Red wool sweater</title>
<g:brand>Acme</g:brand>
<g:condition>new</g:condition>
<summary>Comfortable and soft, this sweater will keep you warm on those cold winter nights.</summary>
<id>1</id>
<g:image_link>http://www.example.com/image1.jpg</g:image_link>
<link href="http://www.example.com/item1-info-page.html"/>
<g:mpn>ABC123</g:mpn>
<g:price>25</g:price>
<g:product_type>Clothing & Accessories > Clothing > Outerwear > Sweaters</g:product_type>
<g:quantity>3</g:quantity>
<g:shipping>
<g:country>US</g:country>
<g:region>MA</g:region>
<g:service>Ground</g:service>
<g:price>5.95</g:price>
</g:shipping>
<g:shipping>
<g:country>US</g:country>
<g:region>024*</g:region>
<g:service>Ground</g:service>
<g:price>7.95</g:price>
</g:shipping>
<g:tax>
<g:country>US</g:country>
<g:region>CA</g:region>
<g:rate>8.25</g:rate>
<g:tax_ship>y</g:tax_ship>
</g:tax>
<g:tax>
<g:country>US</g:country>
<g:region>926*</g:region>
<g:rate>8.75</g:rate>
<g:tax_ship>y</g:tax_ship>
</g:tax>
<g:upc>0001230001232</g:upc>
<g:weight>0.1 lb</g:weight>
</entry>
</feed>
And here is my XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.w3.org/2005/Atom"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:g="http://base.google.com/ns/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
<xs:element name="feed" type="atom:feedType"/>
<xs:element name="entry" type="atom:entryType"/>
<xs:element name="extended_attribute" type="atom:extendedAttributeType"/>
<xs:complexType name="textType" mixed="true">
<xs:sequence>
<xs:any namespace="http://www.w3.org/1999/xhtml" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="text"/>
<xs:enumeration value="html"/>
<xs:enumeration value="xhtml"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:complexType>
<xs:complexType name="idType">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="feedType">
<xs:choice minOccurs="3" maxOccurs="unbounded">
<xs:element name="link" type="atom:linkType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="title" type="atom:textType" minOccurs="1" maxOccurs="1"/>
<xs:element name="updated" type="atom:dateTimeType" minOccurs="1" maxOccurs="1"/>
<xs:element name="entry" type="atom:entryType" minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:complexType>
<xs:complexType name="extendedAttributeType">
<xs:choice maxOccurs="unbounded">
<xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="value" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:choice>
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:complexType>
<xs:complexType name="entryType">
<xs:choice maxOccurs="unbounded">
<xs:element name="id" type="atom:idType" minOccurs="1" maxOccurs="1"/>
<xs:element name="title" type="atom:textType" minOccurs="1" maxOccurs="1"/>
<xs:element name="link" type="atom:linkType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="brand" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:complexType>
<xs:complexType name="linkType" mixed="true">
<xs:attribute name="href" use="required" type="xs:anyURI"/>
<xs:attribute name="rel" type="xs:string" use="optional"/>
<xs:attribute name="type" use="optional" type="xs:string"/>
<xs:attribute name="hreflang" use="optional" type="xs:NMTOKEN"/>
<xs:attribute name="title" use="optional" type="xs:string"/>
<xs:attribute name="length" use="optional" type="xs:positiveInteger"/>
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:complexType>
<xs:complexType name="dateTimeType">
<xs:simpleContent>
<xs:extension base="xs:dateTime">
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:attributeGroup name="commonAttributes">
<xs:attribute ref="xml:base"/>
<xs:attribute ref="xml:lang"/>
<xs:anyAttribute namespace="##other"/>
</xs:attributeGroup>
</xs:schema>
I'm guessing the error has to do with my namespace declared in the XML (xmlns:g="http://base.google.com/ns/1.0"
). I have entered this in the targetNamespace
of the XSD, but I cannot get it to work.