TNS Internal:NDR/API/2.0/Schemata

From NSDLWiki

Jump to: navigation, search

Examples of the following schema documents are available here.

The NDR uses XML data in various places to transfer data back and forth. In order to facilitate this data traversal in an efficient manner, multiple schema documents have been created in a modular manner. Generally, there is one schema for each API call and one for each NDR object. The object schemata define two "versions" of each object: one complete version with all data about an object, and one "reference" version with the object's handle and some other identifying information. This was done to prevent loops in processing and allow for the user to determine the depth of detail in a response.

The latest version of all of these documents as they are implemented is available here, in the Subversion repository. All schemata are contained in the namespace /ndr/v2 in order to separate it from other versions of the NDR. Each schema document contains its own version number in case it changes within one NDR version. There are three sub-namespaces: models, requests and responses (though requests isn't used currently) which hold schema documents for their respective parts. Lastly, there are some miscellaneous and common schema documents in the root of the namespace.

Contents

[hide]

common

ndr

This defines some types that are used throughout the other documents.

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://ns.nsdl.org/ndr/v2" xmlns:foxml="info:fedora/fedora-system:def/foxml#" xmlns:this="http://ns.nsdl.org/ndr/v2" xmlns="http://www.w3.org/2001/XMLSchema" version="2.0">
	<import namespace="info:fedora/fedora-system:def/foxml#" schemaLocation="http://www.fedora.info/definitions/1/0/foxml1-0.xsd"/>

	<simpleType name="pidType">
		<restriction base="foxml:pidType">
			<pattern value="nsdl:\d+"/>
		</restriction>
	</simpleType>
	<simpleType name="emailAddress">
		<restriction base="string">
			<pattern value="([\.a-zA-Z0-9_\-])+@([a-zA-Z0-9_\-])+(([a-zA-Z0-9_\-])*\.([a-zA-Z0-9_\-])+)+"/>
		</restriction>
	</simpleType>

	<simpleType name="nonEmptyString">
		<restriction base="token">
			<minLength value="1"/>
		</restriction>
	</simpleType>

	<simpleType name="mime">
		<restriction base="token">
			<pattern value="([\.a-zA-Z0-9_\-])+/([\.a-zA-Z0-9_\-])+"/>
		</restriction>
	</simpleType>

	<simpleType name="handle">
		<restriction base="token">
			<pattern value="2200/([\.a-zA-Z0-9_\-])+"/>
		</restriction>
	</simpleType>

	<simpleType name="state">
		<restriction base="string">
			<enumeration value="active"/>
			<enumeration value="deleted"/>
			<enumeration value="inactive"/>
		</restriction>
	</simpleType>
</schema>

gsearch

This defines the layout of what the gSearch index returns, so we can digest it.

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://ns.nsdl.org/ndr/v2/gsearch" xmlns:foxml="info:fedora/fedora-system:def/foxml#"
	xmlns:this="http://ns.nsdl.org/ndr/v2/gsearch" xmlns="http://www.w3.org/2001/XMLSchema">
	<element name="resultPage">
		<complexType>
			<sequence>
				<element name="gFindObjects" type="this:gFindObjects"/>
			</sequence>
			<attribute name="indexName" type="string"/>
			<attribute name="dateTime" type="dateTime"/>
		</complexType>
	</element>

	<complexType name="gFindObjects">
		<sequence>
			<element name="objects" type="this:objects"/>
		</sequence>
		<attribute name="hitTotal" type="int"/>
		<attribute name="resultPageXslt" type="string"/>
		<attribute name="hitPageSize" type="int"/>
		<attribute name="hitPageStart" type="int"/>
		<attribute name="query" type="string"/>
	</complexType>

	<complexType name="objects">
		<sequence>
			<element name="objects" type="this:objects"/>
		</sequence>
	</complexType>

	<complexType name="object">
		<sequence>
			<element name="field" type="this:field"/>
		</sequence>
		<attribute name="no" type="int"/>
		<attribute name="score" type="decimal"/>
	</complexType>

	<complexType name="field">
		<simpleContent>
			<extension base="string">
				<attribute name="name"/>
			</extension>
		</simpleContent>
	</complexType>
</schema>

models

agent

The agent object does not have a "short" version since it consists of only attributes; it's already short.

<?xml version="1.0" encoding="UTF-8"?>
<schema version="1.0" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/models/agent" xmlns:this="http://ns.nsdl.org/ndr/v2/models/agent" xmlns:ndr="http://ns.nsdl.org/ndr/v2">
	<import namespace="http://ns.nsdl.org/ndr/v2" schemaLocation="../ndr.xsd"/>

	<attributeGroup name="attributes">
		<attribute name="handle" type="ndr:handle"/>
		<attribute name="state" type="ndr:state"/>
		<attribute name="type" type="this:types"/>
		<attribute name="value" type="string"/>
	</attributeGroup>

	<complexType name="agent">
		<attributeGroup ref="this:attributes"></attributeGroup>
	</complexType>

	<simpleType name="types">
		<restriction base="string">
			<enumeration value="host"/>
			<enumeration value="other"/>
			<enumeration value="user"/>
		</restriction>
	</simpleType>

	<complexType name="list">
		<sequence>
			<element maxOccurs="unbounded" minOccurs="0" name="agent" type="this:agent"/>
		</sequence>
	</complexType>
</schema>

aggregator

<?xml version="1.0" encoding="UTF-8"?>
<schema version="1.0" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/models/aggregator" xmlns:this="http://ns.nsdl.org/ndr/v2/models/aggregator" xmlns:agent="http://ns.nsdl.org/ndr/v2/models/agent" xmlns:ndr="http://ns.nsdl.org/ndr/v2" xmlns:resource="http://ns.nsdl.org/ndr/v2/models/resource">
	<import namespace="http://ns.nsdl.org/ndr/v2" schemaLocation="../ndr.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/agent" schemaLocation="agent.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/resource" schemaLocation="resource.xsd"/>

	<attributeGroup name="attributes">
		<attribute name="handle" type="ndr:handle"/>
		<attribute name="state" type="ndr:state"/>
	</attributeGroup>

	<complexType name="aggregator">
		<choice>
			<sequence>
				<element name="agent" type="agent:agent"/>
				<element name="resource" type="resource:resource"/>
			</sequence>
			<sequence></sequence>
		</choice>
		<attributeGroup ref="this:attributes"></attributeGroup>
	</complexType>

	<complexType name="list">
		<sequence>
			<element maxOccurs="unbounded" minOccurs="0" name="aggregator" type="this:aggregator"/>
		</sequence>
	</complexType>
</schema>

collection

<?xml version="1.0" encoding="UTF-8"?>
<schema version="1.0" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/models/collection"
	xmlns:this="http://ns.nsdl.org/ndr/v2/models/collection" xmlns:contact="http://ns.nsdl.org/ndr/v2/models/contact" xmlns:ndr="http://ns.nsdl.org/ndr/v2">

	<import namespace="http://ns.nsdl.org/ndr/v2" schemaLocation="../ndr.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/contact" schemaLocation="contact.xsd"/>

	<attributeGroup name="attributes">
		<attribute name="handle" use="required" type="ndr:handle"/>
		<attribute name="state" use="required" type="ndr:state"/>
		<attribute name="title" use="required" type="string"/>
	</attributeGroup>

	<complexType name="collection">
		<choice>
			<sequence>
				<element name="children" minOccurs="0" maxOccurs="1" type="this:list"/>
				<element name="contacts" minOccurs="0" maxOccurs="1" type="contact:list"/>
				<element name="description" type="string" minOccurs="1" maxOccurs="1"/>
				<element name="externalIdentifier" type="string" minOccurs="0" maxOccurs="1"/>
				<element name="parents" minOccurs="0" maxOccurs="1" type="this:list"/>
				<element name="resourceURL" type="string" minOccurs="0" maxOccurs="1"/>
			</sequence>
			<sequence/>
		</choice>
		<attributeGroup ref="this:attributes"/>
	</complexType>

	<complexType name="list">
		<sequence>
			<element maxOccurs="unbounded" minOccurs="0" name="collection" type="this:collection"/>
		</sequence>
	</complexType>
</schema>

contact

<?xml version="1.0" encoding="UTF-8"?>
<schema version="1.0" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/models/contact"
	xmlns:this="http://ns.nsdl.org/ndr/v2/models/contact" xmlns:ndr="http://ns.nsdl.org/ndr/v2">
	<import namespace="http://ns.nsdl.org/ndr/v2" schemaLocation="../ndr.xsd"/>

	<complexType name="contact">
		<attribute name="name" type="ndr:nonEmptyString"/>
		<attribute name="email" type="ndr:emailAddress"/>
	</complexType>

	<complexType name="list">
		<sequence>
			<element maxOccurs="unbounded" minOccurs="0" name="contact" type="this:contact"/>
		</sequence>
	</complexType>
</schema>

metadata

The NDR metadata object is actually represented as a "metadatum" object in the schema. This is because of the semantic problems between single and plural use of "data". There should be a difference between one piece of data and multiple data groups together, hence the singular latin "datum" for one piece of data and "data" for a group of many "datums".

<?xml version="1.0" encoding="UTF-8"?>
<schema version="1.0" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/models/metadata"
	xmlns:this="http://ns.nsdl.org/ndr/v2/models/metadata" xmlns:collection="http://ns.nsdl.org/ndr/v2/models/collection"
	xmlns:ndr="http://ns.nsdl.org/ndr/v2" xmlns:resource="http://ns.nsdl.org/ndr/v2/models/resource">
	<import namespace="http://ns.nsdl.org/ndr/v2" schemaLocation="../ndr.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/collection" schemaLocation="collection.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/resource" schemaLocation="resource.xsd"/>

	<attributeGroup name="attributes">
		<attribute name="handle" type="ndr:handle"/>
		<attribute name="state" type="ndr:state"/>
	</attributeGroup>

	<complexType name="metadatum">
		<choice>
			<sequence>
				<element name="data" maxOccurs="1" type="this:data"/>
				<element name="resource" maxOccurs="1" type="resource:resource"/>
				<element name="annotations" maxOccurs="1"/>
				<element name="collections" maxOccurs="1" type="collection:list"/>
			</sequence>
			<sequence></sequence>
		</choice>
		<attributeGroup ref="this:attributes"></attributeGroup>
	</complexType>

	<complexType name="datum">
		<simpleContent>
			<extension base="string">
				<attribute name="format" type="string" use="required"/>
				<attribute name="url" type="anyURI" use="required"/>
				<attribute name="mimeType" type="string" use="optional"/>
				<attribute name="size" type="long" use="optional"/>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="data">
		<sequence>
			<element name="datum" maxOccurs="unbounded" type="this:datum"/>
		</sequence>
	</complexType>

	<complexType name="list">
		<sequence>
			<element maxOccurs="unbounded" minOccurs="0" name="metadatum" type="this:metadatum"/>
		</sequence>
	</complexType>
</schema>

metadataprovider

<?xml version="1.0" encoding="UTF-8"?>
<schema version="1.0" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/models/metadataProvider"
	xmlns:this="http://ns.nsdl.org/ndr/v2/models/metadataProvider" xmlns:collection="http://ns.nsdl.org/ndr/v2/models/collection"
	xmlns:ndr="http://ns.nsdl.org/ndr/v2" xmlns:agent="http://ns.nsdl.org/ndr/v2/models/agent" xmlns:aggregator="http://ns.nsdl.org/ndr/v2/models/aggregator">
	<import namespace="http://ns.nsdl.org/ndr/v2" schemaLocation="../ndr.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/collection" schemaLocation="collection.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/agent" schemaLocation="agent.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/aggregator" schemaLocation="aggregator.xsd"/>

	<element name="metadataProvider" type="this:metadataProvider"/>

	<attributeGroup name="attributes">
		<attribute name="handle" type="ndr:handle"/>
		<attribute name="state" type="ndr:state"/>
	</attributeGroup>

	<complexType name="metadataProvider">
		<choice>
			<sequence>
				<element name="agent" type="agent:agent"/>
				<element name="aggregators" type="aggregator:list"/>
				<element name="collections" type="collection:list"/>
			</sequence>
			<sequence></sequence>
		</choice>
		<attributeGroup ref="this:attributes"></attributeGroup>
	</complexType>

	<complexType name="list">
		<sequence>
			<element maxOccurs="unbounded" minOccurs="0" name="metadataProvider" type="this:metadataProvider"/>
		</sequence>
	</complexType>
</schema>

object

The object "object" is just a wrapper that provides a root element for JAXB to use. JAXB complains if it doesn't have a singular root element to base a document on, and this provides that for the other model objects (which are not singular, they can be specified multiple times in various documents).

<?xml version="1.0" encoding="UTF-8"?>
<schema version="1.0" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/models/object"
	xmlns:this="http://ns.nsdl.org/ndr/v2/models/object" xmlns:ndr="http://ns.nsdl.org/ndr/v2" xmlns:agent="http://ns.nsdl.org/ndr/v2/models/agent"
	xmlns:aggregator="http://ns.nsdl.org/ndr/v2/models/aggregator" xmlns:collection="http://ns.nsdl.org/ndr/v2/models/collection"
	xmlns:contact="http://ns.nsdl.org/ndr/v2/models/contact" xmlns:metadata="http://ns.nsdl.org/ndr/v2/models/metadata"
	xmlns:metadataProvider="http://ns.nsdl.org/ndr/v2/models/metadataProvider" xmlns:resource="http://ns.nsdl.org/ndr/v2/models/resource">
	<import namespace="http://ns.nsdl.org/ndr/v2" schemaLocation="../ndr.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/agent" schemaLocation="agent.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/aggregator" schemaLocation="aggregator.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/collection" schemaLocation="collection.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/contact" schemaLocation="contact.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/metadata" schemaLocation="metadata.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/metadataProvider" schemaLocation="metadataprovider.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/resource" schemaLocation="resource.xsd"/>

	<element name="object">
		<complexType>
			<choice>
				<element name="agent" type="agent:agent"/>
				<element name="aggregator" type="aggregator:aggregator"/>
				<element name="collection" type="collection:collection"/>
				<element name="contact" type="contact:contact"/>
				<element name="metadata" type="metadata:metadatum"/>
				<element name="metadataprovider" type="metadataProvider:metadataProvider"/>
				<element name="resource" type="resource:resource"/>
			</choice>
		</complexType>
	</element>
</schema>

resource

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/models/resource" xmlns:this="http://ns.nsdl.org/ndr/v2/models/resource"
	xmlns:ndr="http://ns.nsdl.org/ndr/v2" xmlns:metadata="http://ns.nsdl.org/ndr/v2/models/metadata">
	<import namespace="http://ns.nsdl.org/ndr/v2" schemaLocation="../ndr.xsd"/>
	<import namespace="http://ns.nsdl.org/ndr/v2/models/metadata" schemaLocation="metadata.xsd"/>

	<element name="resource" type="this:resource"/>

	<attributeGroup name="attributes">
		<attribute name="handle" type="ndr:handle" use="required"/>
		<attribute name="mimeType" type="ndr:mime" use="required"/>
		<attribute name="state" type="ndr:state" use="required"/>
		<attribute name="url" type="anyURI" use="required"/>
	</attributeGroup>

	<complexType name="resource">
		<choice>
			<sequence>
				<element name="annotations" maxOccurs="1" minOccurs="1"/>
				<element name="metadata" type="metadata:list" maxOccurs="1" minOccurs="1"/>
			</sequence>
			<sequence></sequence>
		</choice>
		<attributeGroup ref="this:attributes"/>
	</complexType>

	<complexType name="list">
		<sequence>
			<element maxOccurs="unbounded" minOccurs="0" name="resource" type="this:resource"/>
		</sequence>
	</complexType>
</schema>

requests

There are no defined requests yet.

responses

getcollection

<?xml version="1.0" encoding="UTF-8"?>
<schema version="1.0" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/responses/getcollection"
	xmlns:this="http://ns.nsdl.org/ndr/v2/responses/getcollection" xmlns:collection="http://ns.nsdl.org/ndr/v2/models/collection">
	
	<import namespace="http://ns.nsdl.org/ndr/v2/models/collection" schemaLocation="../models/collection.xsd"/>
	<element name="response">
		<complexType>
			<all>
				<element name="collection" type="collection:collection" maxOccurs="1" minOccurs="1"/>
			</all>
		</complexType>
	</element>
</schema>

listcollections

<?xml version="1.0" encoding="UTF-8"?>
<schema version="1.0" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/responses/listcollections"
	xmlns:this="http://ns.nsdl.org/ndr/v2/responses/listcollections" xmlns:collection="http://ns.nsdl.org/ndr/v2/models/collection">
	
	<import namespace="http://ns.nsdl.org/ndr/v2/models/collection" schemaLocation="../models/collection.xsd"/>
	<element name="response">
		<complexType>
			<all>
				<element name="collections" type="collection:list" maxOccurs="1" minOccurs="0"/>
			</all>
		</complexType>
	</element>
</schema>

listresourcemetadata

<?xml version="1.0" encoding="UTF-8"?>
<schema version="1.0" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.nsdl.org/ndr/v2/responses/listresourcemetadata"
	xmlns:this="http://ns.nsdl.org/ndr/v2/responses/listresourcemetadata" xmlns:metadata="http://ns.nsdl.org/ndr/v2/models/metadata">
	<import namespace="http://ns.nsdl.org/ndr/v2/models/metadata" schemaLocation="../models/metadata.xsd"/>
	<element name="response">
		<complexType>
			<all>
				<element name="metadata" type="metadata:list" minOccurs="0" maxOccurs="1"/>
			</all>
		</complexType>
	</element>
</schema>
Personal tools