Add general abstract classes for tests, starting with test classes for
RSS feeds
This commit is contained in:
parent
9c49afe416
commit
88458df949
500
assets/xsd/Rss2.xsd
Normal file
500
assets/xsd/Rss2.xsd
Normal file
@ -0,0 +1,500 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
XML Schema for RSS v2.0
|
||||
Copyright (C) 2003-2008 Jorgen Thelin
|
||||
|
||||
Microsoft Public License (Ms-PL)
|
||||
|
||||
This license governs use of the accompanying software.
|
||||
If you use the software, you accept this license.
|
||||
If you do not accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
|
||||
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
|
||||
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
|
||||
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
|
||||
|
||||
-->
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
elementFormDefault="unqualified"
|
||||
version="2.0.2.16">
|
||||
<xs:annotation>
|
||||
<xs:documentation>XML Schema for RSS v2.0 feed files.</xs:documentation>
|
||||
<xs:documentation>Project home: http://www.codeplex.com/rss2schema/ </xs:documentation>
|
||||
<xs:documentation>Based on the RSS 2.0 specification document at http://cyber.law.harvard.edu/rss/rss.html </xs:documentation>
|
||||
<xs:documentation>Author: Jorgen Thelin</xs:documentation>
|
||||
<xs:documentation>Revision: 16</xs:documentation>
|
||||
<xs:documentation>Date: 01-Nov-2008</xs:documentation>
|
||||
<xs:documentation>Feedback to: http://www.codeplex.com/rss2schema/WorkItem/List.aspx </xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:element name="rss">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="channel" type="RssChannel"/>
|
||||
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="version" type="xs:decimal" use="required" fixed="2.0"/>
|
||||
<xs:anyAttribute namespace="##any"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:complexType name="RssItem">
|
||||
<xs:annotation>
|
||||
<xs:documentation>An item may represent a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed), and the link and title may be omitted.</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:sequence>
|
||||
<xs:choice maxOccurs="unbounded">
|
||||
<xs:element name="title" type="xs:string" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The title of the item.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="description" type="xs:string" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The item synopsis.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="link" type="xs:anyURI" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The URL of the item.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="author" type="EmailAddress" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Email address of the author of the item.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="category" type="Category" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Includes the item in one or more categories. </xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="comments" type="xs:anyURI" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>URL of a page for comments relating to the item.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="enclosure" type="Enclosure" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Describes a media object that is attached to the item.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="guid" type="Guid" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>guid or permalink URL for this entry</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="pubDate" type="Rfc822FormatDate" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Indicates when the item was published.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="source" type="Source" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The RSS channel that the item came from.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Extensibility element.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:any>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
<xs:anyAttribute namespace="##any"/>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="RssChannel">
|
||||
<xs:sequence>
|
||||
<xs:choice maxOccurs="unbounded">
|
||||
<xs:element name="title" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The name of the channel. It's how people refer to your service. If you have an HTML website that contains the same information as your RSS file, the title of your channel should be the same as the title of your website.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="link" type="xs:anyURI">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The URL to the HTML website corresponding to the channel.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="description" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Phrase or sentence describing the channel.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="language" type="xs:language" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The language the channel is written in. This allows aggregators to group all Italian language sites, for example, on a single page. A list of allowable values for this element, as provided by Netscape, is here. You may also use values defined by the W3C.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="copyright" type="xs:string" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Copyright notice for content in the channel.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="managingEditor" type="EmailAddress" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Email address for person responsible for editorial content.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="webMaster" type="EmailAddress" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Email address for person responsible for technical issues relating to channel.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="pubDate" type="Rfc822FormatDate" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The publication date for the content in the channel. All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred).</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="lastBuildDate" type="Rfc822FormatDate" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The last time the content of the channel changed.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="category" type="Category" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Specify one or more categories that the channel belongs to.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="generator" type="xs:string" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A string indicating the program used to generate the channel.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="docs" type="xs:anyURI" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A URL that points to the documentation for the format used in the RSS file. It's probably a pointer to this page. It's for people who might stumble across an RSS file on a Web server 25 years from now and wonder what it is.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="cloud" type="Cloud" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="ttl" type="xs:nonNegativeInteger" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="image" type="Image" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Specifies a GIF, JPEG or PNG image that can be displayed with the channel.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="rating" type="xs:string" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The PICS rating for the channel.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="textInput" type="TextInput" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Specifies a text input box that can be displayed with the channel.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="skipHours" type="SkipHoursList" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A hint for aggregators telling them which hours they can skip.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="skipDays" type="SkipDaysList" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A hint for aggregators telling them which days they can skip.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Extensibility element.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:any>
|
||||
</xs:choice>
|
||||
<xs:element name="item" type="RssItem" minOccurs="1" maxOccurs="unbounded">
|
||||
<!--
|
||||
HACK: According to the RSS 2.0 spec, it should strictly be possible to have zero item elements,
|
||||
but this makes the schema non-deterministic with regard to extensibility elements
|
||||
so for the moment we undid bug-fix 10231 and set minOccurs=1 to work around this problem.
|
||||
-->
|
||||
</xs:element>
|
||||
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Extensibility element.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:any>
|
||||
</xs:sequence>
|
||||
<xs:anyAttribute namespace="##any"/>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="SkipHour">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A time in GMT when aggregators should not request the channel data. The hour beginning at midnight is hour zero.</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:restriction base="xs:nonNegativeInteger">
|
||||
<xs:minInclusive value="0"/>
|
||||
<xs:maxInclusive value="23"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="SkipHoursList">
|
||||
<xs:sequence>
|
||||
<xs:element name="hour" type="SkipHour" minOccurs="0" maxOccurs="24"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="SkipDay">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A day when aggregators should not request the channel data.</xs:documentation>
|
||||
</xs:annotation>
|
||||
<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:complexType name="SkipDaysList">
|
||||
<xs:sequence>
|
||||
<xs:element name="day" type="SkipDay" minOccurs="0" maxOccurs="7">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A time in GMT, when aggregators should not request the channel data. The hour beginning at midnight is hour zero.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Category">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute name="domain" type="xs:string" use="optional"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Image">
|
||||
<xs:all>
|
||||
<xs:element name="url" type="xs:anyURI">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The URL of the image file.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="title" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Describes the image, it's used in the ALT attribute of the HTML <img> tag when the channel is rendered in HTML.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="link" type="xs:anyURI">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The URL of the site, when the channel is rendered, the image is a link to the site. (Note, in practice the image <title> and <link> should have the same value as the channel's <title> and <link>. </xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="width" type="ImageWidth" default="88" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The width of the image in pixels.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="height" type="ImageHeight" default="31" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The height of the image in pixels.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="description" type="xs:string" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Text that is included in the TITLE attribute of the link formed around the image in the HTML rendering.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="ImageHeight">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The height of the image in pixels.</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:restriction base="xs:positiveInteger">
|
||||
<xs:maxInclusive value="400"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="ImageWidth">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The width of the image in pixels.</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:restriction base="xs:positiveInteger">
|
||||
<xs:maxInclusive value="144"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="Cloud">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Specifies a web service that supports the rssCloud interface which can be implemented in HTTP-POST, XML-RPC or SOAP 1.1. Its purpose is to allow processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:attribute name="domain" type="xs:string" use="required"/>
|
||||
<xs:attribute name="port" type="xs:positiveInteger" use="required"/>
|
||||
<xs:attribute name="path" type="xs:string" use="required"/>
|
||||
<xs:attribute name="registerProcedure" type="xs:string" use="required"/>
|
||||
<xs:attribute name="protocol" type="CloudProtocol" use="required"/>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="CloudProtocol">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="xml-rpc"/>
|
||||
<xs:enumeration value="http-post"/>
|
||||
<xs:enumeration value="soap"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="TextInput">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The purpose of this element is something of a mystery! You can use it to specify a search engine box. Or to allow a reader to provide feedback. Most aggregators ignore it.</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:all>
|
||||
<xs:element name="title" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The label of the Submit button in the text input area.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="description" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Explains the text input area.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="name" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The name of the text object in the text input area.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="link" type="xs:anyURI">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The URL of the CGI script that processes text input requests.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="EmailAddress">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Using the regexp definiton of E-Mail Address by Lucadean from the .NET RegExp Pattern Repository at http://www.3leaf.com/default/NetRegExpRepository.aspx </xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="Rfc822FormatDate">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A date-time displayed in RFC-822 format.</xs:documentation>
|
||||
<xs:documentation>Using the regexp definiton of rfc-822 date by Sam Ruby at http://www.intertwingly.net/blog/1360.html </xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="(((Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)), *)?\d\d? +((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec)) +\d\d(\d\d)? +\d\d:\d\d(:\d\d)? +(([+\-]?\d\d\d\d)|(UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|\w)"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="Source">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute name="url" type="xs:anyURI"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Enclosure">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute name="url" type="xs:anyURI" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>URL where the enclosure is located</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="length" type="xs:nonNegativeInteger" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Size in bytes</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>MIME media-type of the enclosure</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Guid">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute name="isPermaLink" type="xs:boolean" use="optional" default="true"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
|
||||
<!--
|
||||
TODO:
|
||||
- Need to add regexp pattern for MIME media-type value of tEnclosure/type
|
||||
- Need to add regexp pattern for checking contents of guid is a URL when isPermaLink=true"
|
||||
- Need to add some form of constraint to check on an item that one, or other, or both of title and description are present.
|
||||
However, I'm not sure it is possible to represent these constraints in XML Schema language alone.
|
||||
- Need some way to enforce cardinality constraints preventing repeated elements in channels or items
|
||||
- Unfortunately the bug-fix for issue 10231 made this schema non-deterministic with respect to extensibitity elements.
|
||||
We can't tell whether an extension element in tRssChannel is within the choice or after the item elements.
|
||||
Need to reconsider the solution to bug-fix 10231.
|
||||
-->
|
||||
|
||||
<!--
|
||||
Change Log:
|
||||
Date Revision Description
|
||||
31-Mar-2003 1 Initial version released for comment
|
||||
31-Mar-2003 2 Changes based on feedback from Gudge:
|
||||
- Remove targetNamespace="" and use elemenfFormDefault="unqualified" instead
|
||||
- Use namespace="##other" on <any>'s to create a more deterministic data model.
|
||||
- Added missing xs:documentation inside xs:annotation at the schema level.
|
||||
- Use xs:language for ISO Language Codes in <language> element.
|
||||
- Change guid to a single declaration. This loses some of the checking of the
|
||||
URL when the contents of the guid is a permaLink, so we will need to add
|
||||
that back in with a regexp pattern.
|
||||
14-Apr-2003 3 Changes to solve some element ordering problems.
|
||||
- Use xs:all in place of xs:sequence to support flexible ordering of elements.
|
||||
Although the ordering constraints for elements is not clear from the
|
||||
original specification, the custom and practice seems to be that
|
||||
element ordering is freeform.
|
||||
- Use elemenfFormDefault="qualified" for explicit intent.
|
||||
15-Apr-2003 4 Changes to solve some element ordering problems.
|
||||
- Use xs:choice in place of xs:all as previous usage of <all> was invalid.
|
||||
This creates the problem that unsufficient constraints can be applied
|
||||
by the schema - for example, it can't prevent two title elements for an item.
|
||||
- Use elemenfFormDefault="unqualified" for to get the correct behavious
|
||||
when importing and combining schemas.
|
||||
15-Apr-2003 5 Putting the extensibility element inside the repeating choice solves
|
||||
all problems with element ordering.
|
||||
15-Apr-2003 6 - skipHours and skipDays should contain a nested list of values,
|
||||
not just a single value.
|
||||
- Added version attribute to schema definition.
|
||||
- Corrected type of the cloud element
|
||||
25-Apr-2003 7 - Add regexp for RFC-822 date suggested by Sam Ruby
|
||||
- I had to leave the base type of the tRfc822FormatDate type
|
||||
as xs:string due to the problems with using
|
||||
a pattern with xs:dateTime described at
|
||||
http://www.thearchitect.co.uk/weblog/archives/2003/04/000142.html
|
||||
19-Jun-2003 8 - Fixed a bug the Oxygen XML Editor spotted in the regexp for RFC-822 dates
|
||||
23-Jun-2003 9 - Added legal boilerplate license text for LGPL.
|
||||
- Minor formatting changes.
|
||||
24-Jun-2003 10 - Missing types for item/title and item/description - Spotted by Andreas Schwotzer.
|
||||
01-Jan-2008 11 - Copy made available under the Microsoft Public License (MS-PL).
|
||||
25-May-2008 12 - Bug fix 10231 from Ken Gruven - channel can contain zero or more items.
|
||||
06-Sep-2008 13 - Fixed tab-space whitespace issues. Now always use spaces.
|
||||
- Undid the fix for bug-fix 10231 since it made the schema non-deterministic
|
||||
with respect to extensibility eleemnts in tRssChannel - need to reconsider the fix.
|
||||
08-Sep-2008 14 - Removed 't' prefixes from type names to improve class names
|
||||
that get code-generated from the schema.
|
||||
22-Sep-2008 15 - Move type def for rss element in-line for improved compativility with Java 1.6 tools.
|
||||
01-Nov-2008 16 - Added the missing rating element from the spec to RssChannel.
|
||||
-->
|
||||
|
||||
</xs:schema>
|
@ -419,6 +419,44 @@ final class MD_STD {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a URL is reachable (200) using curl.
|
||||
*
|
||||
* @param string $url URL to validate.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkUrlIsReachable(string $url):bool {
|
||||
|
||||
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
|
||||
throw new MDInvalidUrl("URL to check (" . $url . ") does not seem to be a valid URL");
|
||||
}
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_AUTOREFERER => true,
|
||||
CURLOPT_CONNECTTIMEOUT => 5,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_MAXREDIRS => 1,
|
||||
CURLOPT_NOBODY => true,
|
||||
CURLOPT_TIMEOUT => 5,
|
||||
// It's very important to let other webmasters know who's probing their servers.
|
||||
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2',
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0,
|
||||
CURLOPT_TCP_FASTOPEN => true,
|
||||
]);
|
||||
curl_exec($ch);
|
||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($code !== 200) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets and returns user language based on a session cookie.
|
||||
*
|
||||
|
60
src/testing/MD_STD_RSS_TEST.php
Normal file
60
src/testing/MD_STD_RSS_TEST.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Test for ensuring that search RSS feeds are generated correctly.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
/**
|
||||
* Tests for the manifest.
|
||||
*/
|
||||
abstract class MD_STD_RSS_TEST extends TestCase {
|
||||
|
||||
protected string $feed;
|
||||
|
||||
/**
|
||||
* Protected function testRssFeedValidity.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
final public function testRssFeedValidity() {
|
||||
|
||||
$domDoc = new DomDocument();
|
||||
self::assertTrue($domDoc->loadXML($this->feed));
|
||||
self::assertTrue($domDoc->schemaValidate(__DIR__ . "/../../assets/xsd/Rss2.xsd"));
|
||||
unset($domDoc);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the availability of RSS feed links and encosures.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
final public function testRssFeedLinksAndEnclosure() {
|
||||
|
||||
if (!($xmlData = simplexml_load_string($this->feed))) {
|
||||
throw new Exception("Failed to load RSS feed string to SimpleXML element");
|
||||
}
|
||||
|
||||
self::assertNotEmpty((string)$xmlData->channel->title);
|
||||
self::assertTrue(MD_STD::checkUrlIsReachable((string)$xmlData->channel->image->url), "Path " . $xmlData->channel->image->url . " does not appear to be a reachable URL");
|
||||
self::assertTrue(MD_STD::checkUrlIsReachable((string)$xmlData->channel->image->link), "Path " . $xmlData->channel->image->link . " does not appear to be a reachable URL");
|
||||
|
||||
self::assertTrue(MD_STD::checkUrlIsReachable((string)$xmlData->channel->item->link), "Path " . $xmlData->channel->item->link . " does not appear to be a reachable URL");
|
||||
|
||||
if (($firstEntryImg = $xmlData->channel->item->enclosure) === null) {
|
||||
throw new Exception("First item does not seem to have an enclosure");
|
||||
}
|
||||
if (($firstEntryImgAttr = $firstEntryImg->attributes()) === null) {
|
||||
throw new Exception("First enclosure does not seem to have attributes");
|
||||
}
|
||||
|
||||
self::assertTrue(MD_STD::checkUrlIsReachable((string)$firstEntryImgAttr->url), "First enclosure does not appear to be a reachable URL (" . $firstEntryImgAttr->url . ")");
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user