<?xml version="1.0" ?>
<!--
  Schematron schema for OLAC repositories, Steven Bird 2002-12-14

  This schema tests for the presence of XML elements, according to the
  OLAC Repository document.  Validation of the content of 
  these elements is tested elsewhere.

  ChangeLog:

  2005-11-29  Haejoong Lee  <haejoong@ldc.upenn.edu>
	* changed drafts/repositories.html to OLAC/repositories.html
  2003-03-11  Haejoong Lee  <haejoong@ldc.upenn.edu>
	* schema location check (for static-repository.xsd) added
  2003-03-10  Haejoong Lee  <haejoong@ldc.upenn.edu>
	* revised for static repositories
  2003-02-28  Haejoong Lee  <haejoong@ldc.upenn.edu>
	* ListRecords pattern: removed some <report> elements as Steven
	advised - those generates too many reports
  2003-02-27  Haejoong Lee  <haejoong@ldc.upenn.edu>
	* Bug fixes: <schema> tag is missing.  Reponse containers such as
	<Identify>, <ListRecords>, etc. shouldn't be top-level elements.
	* Namespace processing: added <ns> elements so that namespaces can
	be processed properly - no need to remove namespace-related
	attributes from testee xml files.
	* ListRecord pattern: added a rule for existence of <record> element.
	added <report> elements, which all other patterns already have.

-->
	
<schema xmlns="http://www.ascc.net/xml/schematron">

  <ns prefix="xs" uri="http://www.w3.org/2001/XMLSchema-instance"/>
  <ns prefix="oai" uri="http://www.openarchives.org/OAI/2.0/"/>
  <ns prefix="oai-identifier" uri="http://www.openarchives.org/OAI/2.0/oai-identifier"/>
  <ns prefix="sr" uri="http://www.openarchives.org/OAI/2.0/static-repository"/>
  <ns prefix="olac" uri="http://www.language-archives.org/OLAC/1.0/"/>
  <ns prefix="olac-archive" uri="http://www.language-archives.org/OLAC/1.0/olac-archive"/>
  <ns prefix="dc" uri="http://purl.org/dc/elements/1.1/"/>
  <ns prefix="dcterms" uri="http://purl.org/dc/terms/"/>

  <pattern name="Schema location requirement">
    <rule context="/sr:Repository">
      <assert test="not(contains(@xs:schemaLocation,'http://www.openarchives.org/OAI/2.0/static-repository.xsd'))">ERROR: Repository: schemaLocation contains http://www.openarchives.org/OAI/2.0/static-repository.xsd</assert>
      <assert test="contains(@xs:schemaLocation,'http://www.language-archives.org/OLAC/1.0/static-repository.xsd')">ERROR: Repository: schemaLocation doesn't contain http://www.language-archives.org/OLAC/1.0/static-repository.xsd</assert>
    </rule>
  </pattern>

  <pattern name="OLAC-PMH Identify requirement"
           see="http://www.language-archives.org/OLAC/repositories.html#Identify">
    <rule context="/sr:Repository">
      <assert test="sr:Identify|oai:Identify">ERROR: Repository doesn't have an Identify element</assert>
      <report test="sr:Identify|oai:Identify">Repository has an Identify element - OK</report>
    </rule>
    <rule context="/sr:Repository/sr:Identify">
      <assert test="oai:description/olac-archive:olac-archive">ERROR: Identify: description element has no olac-archive element</assert>
      <report test="oai:description/olac-archive:olac-archive">Identify: description element has an olac-archive element - OK</report>
      <assert test="oai:description/oai-identifier:oai-identifier">ERROR: Identify: description element has no oai-identifier element</assert>
      <report test="oai:description/oai-identifier:oai-identifier">Identify: description element has an oai-identifier element - OK</report>
    </rule>
  </pattern>

  <pattern name="OLAC-PMH ListMetadataFormats requirement"
           see="http://www.language-archives.org/OLAC/repositories.html#ListMetadataFormats">
    <rule context="/sr:Repository">
      <assert test="sr:ListMetadataFormats">ERROR: Repository doesn't have a ListMetadataFormats element</assert>
      <report test="sr:ListMetadataFormats">Repository has a ListMetadataFormats element - OK</report>
    </rule>
    <rule context="/sr:Repository/sr:ListMetadataFormats">
      <assert test="oai:metadataFormat/oai:metadataPrefix[normalize-space(text())='olac']">ERROR: ListMetadataFormats: olac missing</assert>
      <report test="oai:metadataFormat/oai:metadataPrefix[normalize-space(text())='olac']">ListMetadataFormats: olac present - OK</report>
    </rule>
    <rule context="/sr:Repository/sr:ListMetadataFormats/oai:metadataFormat">
      <assert test="count(oai:metadataPrefix) = 1">ERROR: ListMetadataFormats: incorrect number of metadataPrefix elements</assert>
      <report test="count(oai:metadataPrefix) = 1">ListMetadataFormats: correct number of metadataPrefix elements - OK</report>
    </rule>
  </pattern>

  <pattern name="OLAC-PMH ListRecords requirement"
           see="http://www.language-archives.org/OLAC/repositories.html#ListRecords">
    <rule context="/sr:Repository">
      <assert test="sr:ListRecords">ERROR: Repository doesn't have a ListRecords element</assert>
      <report test="sr:ListRecords">Repository has a ListRecords element - OK</report>
    </rule>
    <rule context="/sr:Repository/sr:ListRecords">
      <assert test="oai:record">ERROR: ListRecords: no record element was found</assert>
      <report test="oai:record">ListRecords: at least one record was found - OK</report>
    </rule>
    <rule context="/sr:Repository/sr:ListRecords/oai:record">
      <assert test="count(oai:metadata) = 1">ERROR: ListRecords: a record does not have exactly one metadata element</assert>
      <assert test="oai:metadata/olac:olac">ERROR: ListRecords: a metadata element has no olac sub-element</assert>
    </rule>
  </pattern>

</schema>
