Add XML schema for OPML 2.0

This commit is contained in:
~lucidiot 2023-11-19 21:01:39 +01:00
parent e8c1b81751
commit 755b4777c9
1 changed files with 352 additions and 0 deletions

352
xsd/opml.xsd Normal file
View File

@ -0,0 +1,352 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Outline Processor Markup Language 2.0 schema
Copyright (c) 2023 ~lucidiot
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="2.0"
>
<xs:annotation>
<xs:documentation>
Outline Processor Markup Language 2.0 XML Schema
</xs:documentation>
<xs:documentation>
<![CDATA[Derived from the specification at <http://opml.org/spec2.html>]]>
</xs:documentation>
</xs:annotation>
<xs:complexType name="OPML">
<xs:sequence>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="head" type="Head" minOccurs="1" maxOccurs="1" />
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="body" type="Body" minOccurs="1" maxOccurs="1" />
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="version" type="xs:string" use="required" fixed="2.0" />
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
<xs:simpleType name="RFC822Date">
<xs:restriction base="xs:string">
<xs:pattern value="((Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s*)?\d\d?\s+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+\d\d(\d\d)?\s+\d\d:\d\d(:\d\d)?\s+([+\-]?\d\d\d\d|[A-Z]{2,3})" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="EmailAddress">
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z0-9_\-][a-zA-Z0-9_.\-]*@[a-zA-Z0-9_\-][a-zA-Z0-9_.\-]*" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="Head">
<xs:all>
<xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="dateCreated" type="RFC822Date" minOccurs="0" maxOccurs="1" />
<xs:element name="dateModified" type="RFC822Date" minOccurs="0" maxOccurs="1" />
<xs:element name="ownerName" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="ownerEmail" type="EmailAddress" minOccurs="0" maxOccurs="1" />
<xs:element name="ownerId" type="xs:anyURI" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Address of a web page that identifies the author or allows contacting them.
</xs:documentation>
<xs:documentation>
No two authors have the same ownerId.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="docs" type="xs:anyURI" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Address of the specification for the OPML file format.
</xs:documentation>
<xs:documentation>
<![CDATA[The recommended value is <http://opml.org/spec2.opml>.]]>
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="expansionState" type="xs:string" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Comma-separated list of line numbers indicating which outline elements should be in an expanded state.
</xs:documentation>
<xs:documentation>
Expanding an outline will change the line numbers of the outlines below, allowing to expand outlines recursively.
</xs:documentation>
<xs:documentation>
Child outlines of non-expanded outlines cannot be stored as expanded.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="vertScrollState" type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Line number of the outline element that should be at the top of the window, calculated after the expansion state is already applied.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="windowTop" type="xs:integer" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Location of the top edge of the outliner's window, in pixels.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="windowLeft" type="xs:integer" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Location of the left edge of the outliner's window, in pixels.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="windowBottom" type="xs:integer" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Location of the bottom edge of the outliner's window, in pixels.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="windowRight" type="xs:integer" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Location of the right edge of the outliner's window, in pixels.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
<xs:complexType name="Body">
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="outline" type="Outline" />
<xs:any namespace="##other" processContents="lax" />
</xs:choice>
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
<xs:attributeGroup name="LinkIncludeAttributes">
<xs:annotation>
<xs:documentation>
Attributes that are defined for `type="link"` and `type="include"` outlines.
</xs:documentation>
<xs:documentation>
XSD 1.0 does not allow us to restrict those attributes to those two types.
</xs:documentation>
</xs:annotation>
<xs:attribute name="url" type="xs:anyURI" use="optional" />
</xs:attributeGroup>
<xs:simpleType name="RSSVersion">
<xs:annotation>
<xs:documentation>
Format and version of a feed described in a `type="rss"` outline.
</xs:documentation>
</xs:annotation>
<!-- Use a union to allow any string, but still suggest some known values -->
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string" />
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="RSS">
<xs:annotation>
<xs:documentation>
Recommended value for Really Simple Syndication 0.91, 0.92 or 2.0.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="RSS1">
<xs:annotation>
<xs:documentation>
Recommended value for RDF Site Summary 1.0.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="scriptingNews">
<xs:annotation>
<xs:documentation>
Recommended value for the Scripting News format.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="ATOM">
<xs:annotation>
<xs:documentation>
Recommended value for Atom 1.0.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:attributeGroup name="RSSAttributes">
<xs:annotation>
<xs:documentation>
Attributes that are defined for `type="rss"` outlines.
</xs:documentation>
<xs:documentation>
XSD 1.0 does not allow us to restrict those attributes to this type.
</xs:documentation>
</xs:annotation>
<xs:attribute name="xmlUrl" type="xs:anyURI" use="optional">
<xs:annotation>
<xs:documentation>
URL of the feed. This is required when using a `type="rss"` outline.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="htmlUrl" type="xs:anyURI" use="optional">
<xs:annotation>
<xs:documentation>
<![CDATA[URL reported as the <link> element of the RSS feed's channel, for `type="rss"` outlines.]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="title" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
<![CDATA[Contents of the <title> element of the RSS feed's channel, for `type="rss"` outlines.]]>
</xs:documentation>
<xs:documentation>
While `text` can contain a user-defined feed name, `title` should always contain the original title of the feed.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="version" type="RSSVersion" use="optional">
<xs:annotation>
<xs:documentation>
<![CDATA[Format and version of feed, for `type="rss"` outlines.]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="language" type="xs:language" use="optional">
<xs:annotation>
<xs:documentation>
<![CDATA[Language code reported as the <language> element of the RSS feed's channel, for `type="rss"` outlines.]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="description" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
<![CDATA[Contents of the <description> element of the RSS feed's channel, for `type="rss"` outlines.]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:simpleType name="OutlineType">
<xs:annotation>
<xs:documentation>
The type of an outline element.
</xs:documentation>
<xs:documentation>
An outline without a type is considered to be either a simple text outline if it does not contain any child outlines, or a directory.
</xs:documentation>
</xs:annotation>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="link">
<xs:annotation>
<xs:documentation>
A link to an online resource. Link outlines must have a `url` attribute.
</xs:documentation>
<xs:documentation>
When the link's URL ends with `.opml`, this outline behaves like an `include` outline, with the OPML file getting downloaded and this outline getting replaced with the OPML file's contents.
</xs:documentation>
<xs:documentation>
Otherwise, this outline should be rendered as a clickable link to any other resource.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="include">
<xs:annotation>
<xs:documentation>
A link to an OPML file. The `url` attribute must be set to the URL of the OPML file. The OPML file should be downloaded, and this outline should be replaced with its contents.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="rss">
<xs:annotation>
<xs:documentation>
A syndication feed. The `xmlUrl` attribute must be set to the URL of the feed. The `description`, `htmlUrl`, `language`, `title` and `version` attributes may be set to provide additional information.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:complexType name="Outline">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="outline" type="Outline" />
<xs:any namespace="##other" processContents="lax" />
</xs:choice>
<xs:attribute name="type" type="OutlineType" use="optional" />
<xs:attribute name="text" type="xs:string" use="required" />
<xs:attribute name="isComment" type="xs:boolean" use="optional" default="false">
<xs:annotation>
<xs:documentation>
Whether this outline is commented. If an outline is commented, all its child outlines are implicitly commented.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="isBreakpoint" type="xs:boolean" use="optional" default="false">
<xs:annotation>
<xs:documentation>
Whether or not a breakpoint is set on this outline. This is mostly used for outlines that allow editing scripts.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="created" type="RFC822Date" use="optional">
<xs:annotation>
<xs:documentation>
Date of creation of this outline.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="category" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
Comma-separated list of categories and tags, in a format similar to the Really Simple Syndication 2.0 category element.
</xs:documentation>
<xs:documentation>
A category starts with a slash, and a hierarchy of sub-categories can be defined: /Formats/OPML/2.0
</xs:documentation>
<xs:documentation>
A tag does not start with a slash, and there is no hierarchy.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attributeGroup ref="LinkIncludeAttributes" />
<xs:attributeGroup ref="RSSAttributes" />
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
<xs:element name="opml" type="OPML" />
</xs:schema>