Hjælp til XML Schema - namespace-forvirring
Hej,Jeg er i færd med at lave mig en RSS-reader, og i den forbindelse vil jeg lave en schema til at validere feeds med inden jeg begynder at arbejde med dem.
Nu er jeg så gået lidt i stå når det kommer til namespaces.
Jeg har lagt mærke til at nogle RSS 2.0 feeds har namespaces som sy, feedburner og selvfølgelig dc.
Jeg vil gerne have et "løst" schema, sådan de mest almindelige ukorrektheder folk laver i feeds ikke er en hindring.
Fx. skal det ikke betyde noget om man har brugt <dc:language> eller <language>.
Kan man få schema'et til at være ligeglad med namespaces?
Hvis ikke, hvordan gør jeg brug af namespaces i mit schema?
Mit schema:
-----------
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="rss">
<xs:complexType>
<xs:sequence>
<xs:element name="channel" type="channelType" />
</xs:sequence>
<xs:attribute name="version" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:complexType name="channelType">
<xs:sequence>
<xs:element name="title" type="xs:string" />
<xs:element name="link" type="xs:string" />
<xs:element name="description" type="xs:string" />
<xs:element name="language" type="xs:string" minOccurs="0" />
<xs:element name="creator" type="xs:string" minOccurs="0" />
<xs:element name="copyright" type="xs:string" minOccurs="0" />
<xs:element name="managingEditor" type="xs:string" minOccurs="0" />
<xs:element name="webMaster" type="xs:string" minOccurs="0" />
<xs:element name="pubDate" type="xs:string" minOccurs="0" />
<xs:element name="lastBuildDate" type="xs:string" minOccurs="0" />
<xs:element name="category" type="xs:string" minOccurs="0" />
<xs:element name="generator" type="xs:string" minOccurs="0" />
<xs:element name="docs" type="xs:string" minOccurs="0" />
<xs:element name="cloud" type="cloudType" minOccurs="0" />
<xs:element name="ttl" type="xs:int" minOccurs="0" />
<xs:element name="image" type="imageType" minOccurs="0" />
<xs:element name="rating" type="xs:string" minOccurs="0" />
<xs:element name="textInput" type="textInputType" minOccurs="0" />
<xs:element name="skipHours" type="skipHoursType" minOccurs="0" />
<xs:element name="skipDays" type="skipDaysType" minOccurs="0" />
<xs:element name="item" type="itemType" maxOccurs="unbounded" />
<xs:any namespace="##other" processContents="skip" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="itemType">
<xs:all>
<xs:element name="title" type="xs:string" minOccurs="0" />
<xs:element name="link" type="xs:string" minOccurs="0" />
<xs:element name="description" type="xs:string" minOccurs="0" />
<xs:element name="author" type="xs:string" minOccurs="0" />
<xs:element name="category" type="categoryType" minOccurs="0" />
<xs:element name="comments" type="xs:string" minOccurs="0" />
<xs:element name="enclosure" type="enclosureType" minOccurs="0" />
<xs:element name="guid" type="guidType" minOccurs="0" />
<xs:element name="pubDate" type="xs:string" minOccurs="0" />
<xs:element name="source" type="sourceType" minOccurs="0" />
</xs:all>
</xs:complexType>
<xs:complexType name="cloudType">
<xs:attribute name="domain" />
<xs:attribute name="port" />
<xs:attribute name="path" />
<xs:attribute name="registerProcedure" />
<xs:attribute name="protocol">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="xml-rpc" />
<xs:enumeration value="soap" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="imageType">
<xs:all>
<xs:element name="url">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="title" type="xs:string" minOccurs="0" />
<xs:element name="link" type="xs:string" minOccurs="0" />
<xs:element name="width" type="xs:int" minOccurs="0" />
<xs:element name="height" type="xs:int" minOccurs="0" />
<xs:element name="description" type="xs:string" minOccurs="0" />
</xs:all>
</xs:complexType>
<xs:complexType name="textInputType">
<xs:all>
<xs:element name="title" type="xs:string" minOccurs="0" />
<xs:element name="description" type="xs:string" minOccurs="0" />
<xs:element name="name" type="xs:string" minOccurs="0" />
<xs:element name="link" type="xs:string" minOccurs="0" />
</xs:all>
</xs:complexType>
<xs:complexType name="skipHoursType">
<xs:sequence>
<xs:element name="hour" type="xs:int" minOccurs="0" maxOccurs="24" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="skipDaysType">
<xs:sequence>
<xs:element name="day" minOccurs="0" maxOccurs="7">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Monday" />
<xs:enumeration value="Tuesday" />
<xs:enumeration value="Wednesday" />
<xs:enumeration value="Thursday" />
<xs:enumeration value="Friday" />
<xs:enumeration value="Saturday" />
<xs:enumeration value="Sunday" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sourceType">
<xs:attribute name="url" use="required" />
</xs:complexType>
<xs:complexType name="enclosureType">
<xs:attribute name="url" use="required" />
<xs:attribute name="length" use="optional" />
<xs:attribute name="type" use="optional" />
</xs:complexType>
<xs:complexType name="categoryType">
<xs:attribute name="domain" type="xs:string" />
</xs:complexType>
<xs:complexType name="guidType">
<xs:attribute name="isPermaLink" type="xs:boolean" />
</xs:complexType>
</xs:schema>
Jeg støder fx på denne fejl:
Line 2: The element 'channel' has invalid child element 'language' in namespace 'http://purl.org/dc/elements/1.1/'. List of possible elements expected: 'language, creator, copyright, managingEditor, webMaster, pubDate, lastBuildDate, category, generator, docs, cloud, ttl, image, rating, textInput, skipHours, skipDays, item'.
... når jeg forsøger at validere dette feed mod mit schema:
http://weblogs.asp.net/atlas-team/rss.aspx