hi Im having issues with creating a XSD to validate an XML document based on the Google Atom feed. here is my xml
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://ift.tt/r5ut6F' xmlns:g='http://ift.tt/15FVsV8'>
<title><![CDATA[Argos]]></title>
<link href='http://www.test.co.uk' rel='self'/>
<updated>2006-06-11T18:30:02Z</updated>
<entry>
<id>1</id>
<title><![CDATA[Revlon Age Defying DNA Cream Makeup - Fresh Ivory new]]></title>
<link href='http://http://drupal.develevaate.com/noArgos.xmlde/60'/>
<g:image_link>
<![CDATA[http://ift.tt/1Bgn41j;
<g:condition>new</g:condition>
<g:availability>in stock</g:availability>
<g:price>asdf</g:price>
<g:brand><![CDATA[Revlon]]></g:brand>
<g:mpn>1</g:mpn>
<g:description>
<![CDATA[Revlon Age Defying with DNA Advantage Cream Makeup combines makeup and a powerful anti-aging skincare to help protect skin's DNA and to help fight the visible signs of ageing. 96% of women saw flawless, younger-looking skin in only two weeks. Lines and wrinkles are visibly diminished while skin is refreshed, hydrated and revitalized. Contains SPF20 to protect the skin from harmful sun rays.]]></g:description>
<g:product_type>Face</g:product_type>
<g:extended_attribute>
<g:name>name</g:name>
<g:value>value</g:value>
</g:extended_attribute>
<g:extended_attribute>
<g:name>name2</g:name>
<g:value>value2</g:value>
</g:extended_attribute>
</entry>
</feed>
and here is my xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ift.tt/r5ut6F"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:atom="http://ift.tt/r5ut6F"
xmlns:xs="http://ift.tt/tphNwY"
>
<xs:import namespace="http://ift.tt/1ikcaie"
schemaLocation="http://ift.tt/1CnlDgM"/>
<xs:import namespace="http://ift.tt/15FVsV8"
schemaLocation="http://ift.tt/1Bgn2qe"/>
<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://ift.tt/lH0Osb" 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="atom:elevaateString" minOccurs="1" maxOccurs="1"/>
<xs:element name="value" type="atom:elevaateExtendedString" 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:elevaateString" minOccurs="1" maxOccurs="1"/>
<xs:element name="title" type="atom:elevaateString" minOccurs="1" maxOccurs="1"/>
<xs:element name="link" type="atom:linkType" minOccurs="1" maxOccurs="1"/>
<xs:element name="image_link" type="atom:elevaateString" minOccurs="1" maxOccurs="1"/>
<xs:element name="condition" type="atom:elevaateCondition" minOccurs="1" maxOccurs="1"/>
<xs:element name="availability" type="atom:elevaateAvailable" minOccurs="1" maxOccurs="1"/>
<xs:element name="price" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
<xs:element name="brand" type="atom:elevaateString" minOccurs="1" maxOccurs="1"/>
<xs:element name="mpn" type="atom:elevaateString" minOccurs="1" maxOccurs="1"/>
<xs:element name="description" type="atom:elevaateString" minOccurs="1" maxOccurs="1"/>
<xs:any namespace="##other" 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:simpleType name="elevaateString">
<xs:restriction base="xs:string">
<xs:maxLength value="255" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="elevaateExtendedString">
<xs:restriction base="xs:string">
<xs:maxLength value="2047" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="elevaateCondition">
<xs:restriction base="xs:string">
<xs:enumeration value="New"/>
<xs:enumeration value="Used"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="elevaateAvailable">
<xs:restriction base="xs:string">
<xs:enumeration value="In Stock"/>
<xs:enumeration value="Out of Stock"/>
</xs:restriction>
</xs:simpleType>
<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>
my error is Error - Line 13, 25: org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 25; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'g:availability'. its because availability is not declared in the inport Google-Base.xml but if i remove type="atom:elevaateAvailable" to type='elevaateAvailable' then is complains that that 'elevaateAvailable' has no namespace even though i have declared elevaateAvailable within my xsd. So im confused as to how i can add additional validation fields in my xsd that are not declared in the google base xml. If i remove the google base i get the errors stating that g: has not been declared. I can get round this by having processcontents = lax as previously advised but the issue here is that none of the validation is then carried out any help will be greatly appreciated. thanks Mark
No comments:
Post a Comment