UserPreferences

RelaxSchema


The "ongoing" write-up is [WWW]here. The RelaxNG Schema is [WWW]here. The XSD version is [WWW]here. I've pasted both of them in below. Discussion should happen here, above the pasted-in source.

[TimBray] Updated per comments in source below. The main difference is that the order of child elements is fixed in <feed> and <entry>

[Cybarber] For Reference: I have used Microsofts "XSD inference tool" to generate a W3C Schema based on the sample feeds of Pilgrim, Isolani, Bersvendsen, Burton, Sopolsky, Watermasysks and Sam Ruby's. at folowing addres: http://cybarber.ath.cx/SAM01_1.xsd

[GordonWeakliem] Tim has a [WWW]version for 0.2 as well.


Here's the RelaxNG schema in compact syntax:

# Schema for the 0.1 snapshot of Pie/Echo/Whatever
# IMPORTANT: This authoritative version of this schema is in Relax NG
#  compact syntax; i.e. its name ends in ".rnc".  It would be very unwise
#  to edit any other version.
#
# V0.1: T. Bray, July 2003
#  July 12: fix sequence in feed/entry 
#           clean up "mode" attribute dispatching
#           s/Person/Writer/

default namespace = "http://www.intertwingly.net/wiki/pie/"
namespace xh = "http://www.w3.org/1999/xhtml"

start = Feed

Feed = element feed
{
  # attributes
  XMLbasics, Version,

  # children
  Title, Subtitle?, Link, Modified?, Entry*
}

Version = attribute version { "0.1" }
Title = element title { text }
Subtitle = element subtitle { text }
Link = element link { xsd:anyURI }
Id = element id { xsd:anyURI }
Modified = element modified { xsd:dateTime }

Entry = element entry {
  XMLbasics,
  Title, Subtitle?, Link, Id, Summary?,
  Author, Contributor*, 
  Created?, Modified, Issued,
  Content*
}

Issued = element issued { xsd:dateTime }
Created = element created { xsd:dateTime }

Summary = element summary { text }
Author = element author { Writer }
Contributor = element contributor { Writer }

Writer =
  element name { text },
  element homepage { xsd:anyURI }?,
  element weblog { xsd:anyURI }?

Content = element content 
{ 
  XMLbasics, attribute type { text }, 
  ( ( attribute mode { "xml" }?, XHTML ) 
  | ( attribute mode { "escaped" | "base64" }, text) 
  | ( attribute src  { xsd:anyURI } ) 
  ) 
} 

XHTML = element xh:*
{
  attribute * { text }*,
  ( text | XHTML)* 
}

XMLbasics =
  attribute xml:lang { text }?,
  attribute xml:base { xsd:anyURI }?

Here's the generated XML Schema:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Schema for the 0.1 snapshot of Pie/Echo/Whatever
  IMPORTANT: This authoritative version of this schema is in Relax NG
   compact syntax; i.e. its name ends in ".rnc".  It would be very unwise
   to edit any other version.
  
  V0.1: T. Bray, July 2003
   July 12: fix sequence in feed/entry 
            clean up "mode" attribute dispatching
            s/Person/Writer/
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.intertwingly.net/wiki/pie/" xmlns:pie="http://www.intertwingly.net/wiki/pie/">
  <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
  <xs:element name="feed">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="pie:title"/>
        <xs:element minOccurs="0" ref="pie:subtitle"/>
        <xs:element ref="pie:link"/>
        <xs:element minOccurs="0" ref="pie:modified"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="pie:entry"/>
      </xs:sequence>
      <xs:attributeGroup ref="pie:XMLbasics"/>
      <xs:attributeGroup ref="pie:Version"/>
    </xs:complexType>
  </xs:element>
  <xs:attributeGroup name="Version">
    <xs:attribute name="version" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="0.1"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:attributeGroup>
  <xs:element name="title" type="xs:string"/>
  <xs:element name="subtitle" type="xs:string"/>
  <xs:element name="link" type="xs:anyURI"/>
  <xs:element name="id" type="xs:anyURI"/>
  <xs:element name="modified" type="xs:dateTime"/>
  <xs:element name="entry">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="pie:title"/>
        <xs:element minOccurs="0" ref="pie:subtitle"/>
        <xs:element ref="pie:link"/>
        <xs:element ref="pie:id"/>
        <xs:element minOccurs="0" ref="pie:summary"/>
        <xs:element ref="pie:author"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="pie:contributor"/>
        <xs:element minOccurs="0" ref="pie:created"/>
        <xs:element ref="pie:modified"/>
        <xs:element ref="pie:issued"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="pie:content"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="issued" type="xs:dateTime"/>
  <xs:element name="created" type="xs:dateTime"/>
  <xs:element name="summary" type="xs:string"/>
  <xs:element name="author" type="pie:Writer"/>
  <xs:element name="contributor" type="pie:Writer"/>
  <xs:complexType name="Writer">
    <xs:sequence>
      <xs:element ref="pie:name"/>
      <xs:element minOccurs="0" ref="pie:homepage"/>
      <xs:element minOccurs="0" ref="pie:weblog"/>
    </xs:sequence>
  </xs:complexType>
  <xs:element name="name" type="xs:string"/>
  <xs:element name="homepage" type="xs:anyURI"/>
  <xs:element name="weblog" type="xs:anyURI"/>
  <xs:element name="content">
    <xs:complexType mixed="true">
      <xs:group minOccurs="0" ref="pie:XHTML"/>
      <xs:attributeGroup ref="pie:XMLbasics"/>
      <xs:attribute name="type" use="required"/>
      <xs:attribute name="mode">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="xml"/>
            <xs:enumeration value="escaped"/>
            <xs:enumeration value="base64"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="src" type="xs:anyURI"/>
    </xs:complexType>
  </xs:element>
  <xs:group name="XHTML">
    <xs:sequence>
      <xs:any namespace="http://www.w3.org/1999/xhtml" processContents="skip"/>
    </xs:sequence>
  </xs:group>
  <xs:attributeGroup name="XMLbasics">
    <xs:attribute ref="xml:lang"/>
    <xs:attribute ref="xml:base"/>
  </xs:attributeGroup>
</xs:schema>