# Schema for the 0.2 snapshot of Pie/Echo/Atom/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.2: T. Bray, August 2003
#  July 12: fix sequence in feed/entry 
#           clean up "mode" attribute dispatching
#           s/Person/Writer/
#  August 16: Update for 0.2 snapshot

default namespace atom = "http://purl.org/atom/ns#"
namespace noNS = ""

# Structural elements
# -------------------
start = Feed

Feed = element feed
{
  # Attributes
  XLang, Version,

  # Required children
  Title, Link, Modified, 

  # Optional children
  Author?, Tagline?, Id?, Generator?, Copyright?, Contributor*, Entry*
}

Entry = element entry 
{
  # Attributes
  XLang,

  # Required children
  Title, Link, Id, Issued, Modified,

  # Optional children
  Created?, Summary?, Author?, Contributor*, (TopContent | AltContent)*
}

TopContent = element content
{
  # Attributes
  XLang,

  attribute type { "multipart/alternative" }, AltContent+
}

AltContent = element content
{
  # Attributes
  XLang, attribute type {text },

  ( ( attribute mode { "xml" }?, XML ) 
  | ( attribute mode { "escaped" }, text )
  | ( attribute mode { "base64" }, xsd:base64Binary ) 
  )
}

# Attributes
# ----------
Version = attribute version { "0.2" }
XBase = attribute xml:base { xsd:anyURI }
XLang = attribute xml:lang { xsd:language }?

# Payload elements, alphabetical order
# ------------------------------------
Author = element author { Writer }
Contributor = element contributor { Writer }
Copyright = element copyright { XLang, text }
Created = element created { xsd:dateTime }
Generator = element generator { attribute name {text}, xsd:anyURI }
Id = element id { xsd:anyURI }
Issued = element issued { xsd:dateTime }
Link = element link { xsd:anyURI }
Modified = element modified { xsd:dateTime }
Summary = element summary { XLang, text }
Tagline = element tagline { XLang, text }
Title = element title { XLang, text }
Writer =
  XLang,
  element name { text },
  element url { xsd:anyURI }?,
  element email { text }?

# Non-Atom content
# ----------------
NonAtom = element * - ( atom:* | noNS:* ) 
{
  attribute * - ( atom:* ) { text }*,
  mixed { NonAtom* }  
}

XML = mixed { NonAtom* }