wiki:DASISH/XSD and XML

Version 23 (modified by olhsha, 11 years ago) (diff)

--

Contents

  1. XSD Schema
  2. Scenario XML's validated vs the given schema
    1. Responding GET api/user/uid
    2. Responding GET api/annotations?source="http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"&access=read
    3. Responding GET api/annotations/AID02 (example usage for resolvable target sources)
    4. Responding GET api/annotations/AID01 (example usage for unresolvable target sources)
    5. Responding GET api/annotations/AID01/sources (example usage for unresolvable target sources)
      1. Remarks by Menzo
      2. Olha's comment:
    6. Responding GET api/sources/SID05/cached/CID005A/metadata (example usage for unresolvable target sources)
    7. Request body for POST api/annotations

XSD Schema

The xsd schema is designed according to the following paradigm: -- There are five xsd-types corresponding five sorts of resources in DASISH: CachedRepresentation, Source, User, Annotation, Notebook. -- Each of these types has an obligatory attribute "URI" which contains DASISH identifier pointing to the location of the resource on DASISH server. -- There are five lists-of-reference types: {{CachedRepresentations?}}}, Sources, Users, Annotations, Notebooks. Their names are just plural English forms of the corresponding types. -- There five corresponding resource-infor types: CachedRepresentationInfo, SourceInfo, {{UserInfo?}}}, AnnotationInfo, NotebookInfo. They contain reference to the corresponding resource plus the most important information about the resource. -- There five corresponding list-of-resource-infor types: CachedRepresentationInfos, SourceInfos, {{UserInfos?}}}, AnnotationInfos,NotebookInfos. There is a number of auxiliary types as well. A commonly-used one is ResourceREF which contains the attribute "ref" of type xs:anyURI. It allows to have announce elements-references and avoid mixing-them-up with elements-resources, without adding REF to the name. For instance <owner ref="http:/dasish.eu/users/UIDefef" />.

<?xml version="1.1" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.dasish.eu/ns/addit"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.dasish.eu/ns/addit"
    elementFormDefault="qualified">
    <xs:import namespace="http://www.w3.org/XML/1998/namespace"
        schemaLocation="http://www.w3.org/2005/08/xml.xsd"/>


    <!--////////////////////////////////////////////////////-->
    <!-- Annotation-body types according to the UML diagram -->
    
    <!-- DASISH resources (cached representations, sources, users, annotations, notebooks) have an obligatory URIdasih element-->
    <!-- The integrity of the references must be forced via the backend -->
    
        
    
    <xs:complexType name="ResourceREF">
        <xs:attribute name="ref" type="xs:anyURI"></xs:attribute>
    </xs:complexType>
    <!-- for a new annotation the reference to the source is absent, that's why this attribute is not obligatory-->
    

    
    <!--////////////////////////-->
    <!--Cached representations -->

    <xs:complexType name="CachedRepresentation">
        <xs:attribute name="URI" type="xs:anyURI" use="required"/>
        <xs:attribute name="mimeType" type="xs:string" use="required"/>
        <xs:attribute name="tool" type="xs:string" use="required"/>
        <xs:attribute name="type" type="xs:string" use="required"/>
    </xs:complexType>
   

    <xs:complexType name="CachedRepresentations">
        <xs:sequence>
            <xs:element name="cachedRepresentation" type="ResourceREF"
                maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <!--////////////////////////////-->
    <!-- Sources (== Targets in OA) -->


    <xs:complexType name="Source">
        <xs:sequence>
            <xs:element name="cachedRepresentations" type="CachedRepresentations" minOccurs="1"/>
            <xs:element name="action" type="Action" minOccurs="0"/>
            <xs:element name="versions-siblings" type="Versions" minOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="URI" type="xs:anyURI" use="required"/>
        <xs:attribute name="timeSatmp" type="xs:dateTime" use="required"/>
        <xs:attribute name="link" type="xs:anyURI" use="required"/>
        <xs:attribute name="version" type="xs:string" use="required"/>
    </xs:complexType>

 
    <xs:complexType name="Sources">
        <xs:sequence>
            <xs:element name="targetSource" type="ResourceREF" minOccurs="1"
                maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    
    
    <xs:complexType name="SourceInfo">
        <xs:complexContent>
            <xs:extension base="ResourceREF">
                <xs:sequence>
                    <xs:element name="action" type="Action" minOccurs="0" maxOccurs="1"/>
                    <xs:element name="link" type="xs:anyURI" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="version" type="xs:string" minOccurs="1" maxOccurs="1"/>
                </xs:sequence>  
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    
    <xs:complexType name="SourceInfos">
        <xs:sequence>
            <xs:element name="targetSource" type="SourceInfo" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    

    <xs:simpleType name="Action">
        <xs:restriction base="xs:string">
            <xs:enumeration value="CREATE_CACHED_REPRESENTATION"/>
        </xs:restriction>
    </xs:simpleType>
   
    
    <xs:complexType name="Versions">
        <xs:sequence>
            <xs:element name="version" type="ResourceREF" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
 
    <!--////////////////////////////-->
    <!-- Human Agents (Users) -->

    <xs:complexType name="User">
        <xs:sequence>
            <xs:element name="notebooksToRead" type="NotebookInfos"/>
            <xs:element name="notebooksToWrite" type="NotebookInfos"/>
            <xs:element name="additionalInfo">
                <xs:complexType>
                    <xs:sequence>
                        <xs:any processContents="lax" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:anyAttribute processContents="lax"/>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="URI" type="xs:anyURI" use="required"/>
        <xs:attribute name="name" type="xs:string" use="required"/>
    </xs:complexType>
    
    <xs:complexType name="Users">
        <xs:sequence>
            <xs:element name="user" type="ResourceREF" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>


    <xs:complexType name="UserInfo">
        <xs:complexContent>
            <xs:extension base="ResourceREF">
                <xs:sequence>
                    <xs:element name="notebooksToRead" type="NotebookInfos"/>
                    <xs:element name="notebooksToWrite" type="NotebookInfos"/>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    
    
    <xs:complexType name="UserInfos">
        <xs:sequence>
            <xs:element name="user" type="UserInfo" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="CurrentUserInfo">
        <xs:complexContent>
            <xs:extension base="ResourceREF">
                <xs:attribute name="currentUser" type="xs:boolean" use="required"/>   
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    


    <!--////////////////////////////-->
    <!-- Annotation -->
    
    
    <xs:complexType name="Annotation">
        <xs:sequence>
            <xs:element name="owner" type="ResourceREF" minOccurs="1"/>
            <xs:element name="headline" type="xs:string" minOccurs="1"/>
            <!-- schematron checks the length <== 100 -->
            <xs:element name="body" type="Body" minOccurs="1"/>
            <xs:element name="targetSources" type="SourceInfos" minOccurs="1"/>
            <xs:element name="readers" type="Readers" minOccurs="1"/>
            <xs:element name="writers" type="Writers" minOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="URI" type="xs:anyURI" use="required"/>
        <xs:attribute name="timeStamp" type="xs:dateTime" use="required"/>
    </xs:complexType>

  
    <xs:complexType name="Annotations">
        <xs:sequence>
            <xs:element name="annotation" type="ResourceREF" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType> 
    
    <xs:complexType name="AnnotationInfo">
        <xs:complexContent>
            <xs:extension base="ResourceREF"> 
                <xs:sequence>
                    <xs:element name="owner" type="ResourceREF" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="headline" type="xs:string" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="targetSources" type="Sources" minOccurs="1" maxOccurs="1"/>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent> 
    </xs:complexType>
    
    <xs:complexType name="AnnotationInfos">
        <xs:sequence>
            <xs:element name="annotation" type="AnnotationInfo" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="Body">
        <xs:sequence>
            <xs:any processContents="lax" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:anyAttribute processContents="lax"/>
    </xs:complexType>
    
    <xs:complexType name="Readers">
        <xs:sequence>
            <xs:element name="reader" type="ResourceREF" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="Writers">
        <xs:sequence>
            <xs:element name="writer" type="ResourceREF" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    
   
    <!--////////////////////////////-->
    <!-- Notebook -->

    <xs:complexType name="Notebook">
        <xs:sequence>
            <xs:element name="title" type="xs:string"/>
            <xs:element name="annotations" type="Annotations"/>
            <xs:element name="readers" type="Readers"/>
            <xs:element name="writers" type="Writers"/>
        </xs:sequence>
        <xs:attribute name="URI" type="xs:anyURI"/>
        <xs:attribute name="timeStamp" type="xs:dateTime" use="required"/>
    </xs:complexType>
    
 
    <xs:complexType name="Notebooks">
        <xs:sequence>
            <xs:element name="notebook" type="ResourceREF" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="NotebookInfo">
        <xs:complexContent>
            <xs:extension base="ResourceREF"> 
                <xs:sequence>
                    <xs:element name="notebook" type="ResourceREF"/>
                    <xs:element name="title" type="xs:string"/>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent> 
    </xs:complexType>

    <xs:complexType name="NotebookInfos">
        <xs:sequence>
            <xs:element name="notebook" type="NotebookInfo" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>



    <!--/////////////////////////////////////-->
    <!-- GET api/user/uid respond -->
    <xs:element name="currentUserInfo" type="CurrentUserInfo"/>
    
    <!--/////////////////////////////////////-->
    <!-- GET api/annotations?source="http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"&access=read  respond -->
    <xs:element name="annotationsOfLink" type="AnnotationInfos"></xs:element>
   

    <!--/////////////////////////////////////-->
    <!-- GET api/annotations/AIDxyz  respond -->
    <xs:element name="annotation" type="Annotation"/>


    <!--/////////////////////////////////////-->
    <!--  GET api/annotations/AID0xyz/sources   respond (non-resolvable)-->
    <xs:element name="sources" type="SourceInfos"/>

    <!--/////////////////////////////////////-->
    <!--  GET api/sources/SID0xyz/  respond  -->
    <xs:element name="source" type="Source  "/>
  
       <!--/////////////////////////////////////-->
    <!-- GET api/sources/SID05/cached/CID0efef/metadata (example usage for unresolvable target sources)   -->
    <xs:element name="cashedRepresentation" type="CachedRepresentation"/>

    <!--/////////////////////////////////////-->
    <!-- POST api/annotation, annotation body  -->
    <xs:element name="newAnnotation" type="Annotation"/>

</xs:schema>

Scenario XML's validated vs the given schema

See DASISH/Scenario

Responding GET api/user/uid

<?xml version="1.0" encoding="UTF-8"?>
<userInfo
    xmlns="http://www.dasish.eu/ns/addit"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/docs/XMLandXSD/DASISH-schema.xsd"
    currentUser="true">
    <uid>ID01</uid>
</userInfo>

Responding GET api/annotations?source="http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"&access=read

<?xml version="1.0" encoding="UTF-8"?>
<annotationsOfSource xmlns="http://www.dasish.eu/ns/addit"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/docs/XMLandXSD/DASISH-schema.xsd"> 
    <annotations>
        <annotation id="AID03">
            <owner ref="ID02"/>
            <headline>My client is not in a hurry</headline>
            <targetSources>
                <targetSource ref="SID015"/>
            </targetSources>
        </annotation>
        <annotation id="AID02">
            <owner ref="ID01"/>
            <headline>Nativity Facade</headline>
            <targetSources>
                <targetSource ref="SID015"/>
                <targetSource ref="SID017"/>
            </targetSources>
        </annotation>
        <annotation id="AID01">
            <owner ref="ID01"/>
            <headline>Nativity Facade (old site)</headline>
            <targetSources>
                <targetSource ref="SID005"/>
                <targetSource ref="SID007"/>
            </targetSources>
        </annotation>
    </annotations>
</annotationsOfSource>

Responding GET api/annotations/AID02 (example usage for resolvable target sources)

<?xml version="1.0" encoding="UTF-8"?>
<annotation xmlns="http://www.dasish.eu/ns/addit"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/docs/XMLandXSD/DASISH-schema.xsd" 
 xml:id="AID02" 
 URI="http://www.dasish.eu/DB/AID002" 
 timeStamp="2013-05-04T18:13:51.0Z">
    <owner ref="ID01"/>
    <headline>Nativity Facade</headline>
    <body type="relation">
        <relation>different</relation>
        <this ref="SID015"/>
        <that ref="SID017"/>   
    </body>
    <targetSources>
        <targetSource xml:id="SID015">
            <URI>http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#Nativity_Fa.C3.A7ade</URI>
            <version>5.0</version>
        </targetSource>
        <targetSource xml:id="SID017">
            <URI>http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#Passion_Fa.C3.A7ade</URI>
            <version>5.0</version>
        </targetSource>
    </targetSources>
    <readers>
        <reader ref="ID01"/>
        <reader ref="ID03"/>
        <reader ref="ID04"/>
    </readers>
    <writers>
        <writer ref="ID01"/>
        <writer ref="ID03"/>
    </writers>
</annotation>

Responding GET api/annotations/AID01 (example usage for unresolvable target sources)

The respond for an annotation with unresolved target sources and the respond for an annotation with resolved target sources (see above) are both instances of the same schema element.

<?xml version="1.0" encoding="UTF-8"?>
<annotation xmlns="http://www.dasish.eu/ns/addit"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/docs/XMLandXSD/DASISH-schema.xsd" 
    xml:id="AID01" 
    URI="http://www.dasish.eu/DB/AID002" 
    timeStamp="2010-05-04T18:13:51.0Z">
    <owner ref="ID01"/>
    <headline>Nativity Facade (old site)</headline>
    <body type="relation">
        <relation>different</relation>
        <this ref="SID005"/>
        <that ref="SID007"/>   
    </body>
    <targetSources>
        <targetSource xml:id="SID005">
            <URI>http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#Nativity_Fa.C3.A7ade</URI>
            <version>1.0</version>
        </targetSource>
        <targetSource xml:id="SID007">
            <URI>http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#Passion_Fa.C3.A7ade</URI>
            <version>1.0</version>
        </targetSource>
    </targetSources>
    <readers>
        <reader ref="ID01"/>
        <reader ref="ID03"/>
        <reader ref="ID04"/>
    </readers>
    <writers>
        <writer ref="ID01"/>
        <writer ref="ID03"/>
    </writers>
</annotation>

Responding GET api/annotations/AID01/sources (example usage for unresolvable target sources)

<?xml version="1.0" encoding="UTF-8"?>
<sources xmlns="http://www.dasish.eu/ns/addit"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/docs/XMLandXSD/DASISH-schema.xsd">
    <targetSource xml:id="SID005" lastModified="2006-05-04T18:13:51.0Z">
        <URI>http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#Nativity_Fa.C3.A7ade</URI>
        <version>1.0</version>
        <versions>
            <version ref="SID005"/>
            <version ref="SID015"/>
        </versions>
        <cachedRepresentations>
            <cachedRepresentation xml:id="CID005" URI="http://www.dasish.eu/DB/CID005" mimeType="text/html" tool="tool1" type="text"/>
            <cachedRepresentation xml:id="CID005A" URI="http://www.dasish.eu/DB/CID005A" mimeType="image/png" tool="tool2" type="screenshot"/>
            <cachedRepresentation xml:id="CID015" URI="http://www.dasish.eu/DB/CID015" mimeType="mimeType3" tool="tool3" type="type3"/>
        </cachedRepresentations>
    </targetSource>
    <targetSource xml:id="SID007" lastModified="2006-05-04T18:13:51.0Z">
        <URI>http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#Passion_Fa.C3.A7ade</URI>
        <version>1.0</version>
        <versions>
            <version ref="SID007"/>
            <version ref="SID017"/>
        </versions>
        <cachedRepresentations>
            <cachedRepresentation xml:id="CID007" URI="http://www.dasish.eu/DB/CID007" mimeType="mimeType5" tool="tool5" type="type5"/>
            <cachedRepresentation xml:id="CID017" URI="http://www.dasish.eu/DB/CID017" mimeType="mimeType7" tool="tool7" type="type7"/>
        </cachedRepresentations>
    </targetSource>
</sources>

Remarks by Menzo

The versions list contains the version you looking at as well, e.g., the version list of SID005 consists of SID005 and SID015. Is this so because the list is ordered and we can determine the position of the version under consideration?

For very dynamic and popular target sources the version list might become big, that could be a reason to move it to a separate call. Actually we have already GET api/sources/<sid>/versions, so I would leave them out here.

Olha's comment:

We have agreed earlier that the list of versions would include all the "siblings", include the source itself.Are there alternative ways to get all the siblings of a given source?

Responding GET api/sources/SID05/cached/CID005A/metadata (example usage for unresolvable target sources)

<?xml version="1.0" encoding="UTF-8"?>
<cashedRepresentation xmlns="http://www.dasish.eu/ns/addit"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/docs/XMLandXSD/DASISH-schema.xsd" 
 xml:id="CID005A" URI="http://www.dasish.eu/DB/CID005A" mimeType="image/png" tool="tool2" type="screenshot"/>

Request body for POST api/annotations

<?xml version="1.0" encoding="UTF-8"?>
<newAnnotation xmlns="http://www.dasish.eu/ns/addit"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/docs/XMLandXSD/DASISH-schema.xsd" 
    xml:id="tempAID06" 
    timeStamp="2013-05-04T18:13:51.0Z">
    <owner ref="ID02"/>
    <headline>Organ</headline>
    <body>
        <note>installed in 2010</note>
    </body>
    <targetSources>
        <targetSource xml:id="SID018">
            <URI>http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#Organ</URI>
            <version>5.0</version>
        </targetSource>
    </targetSources>
    <readers>
        <reader ref="ID02"/>
    </readers>
    <writers>
        <writer ref="ID02"/>
    </writers>
</newAnnotation>

The version of the POST with an unknown target source, signalling the client to provide a cached representation for it:

<?xml version="1.0" encoding="UTF-8"?>
<newAnnotation xmlns="http://www.dasish.eu/ns/addit"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/docs/XMLandXSD/DASISH-schema.xsd" 
    xml:id="tempAID06" 
    timeStamp="2013-05-04T18:13:51.0Z">
    <owner ref="ID02"/>
    <headline>Organ</headline>
    <body>
        <note>installed in 2010</note>
    </body>
    <targetSources>
        <targetSource xml:id="SID018">
            <URI>http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#Organ</URI>
            <version>5.0</version>
            <action>CREATE_CACHED_REPRESENTATION</action>
        </targetSource>
    </targetSources>
    <readers>
        <reader ref="ID02"/>
    </readers>
    <writers>
        <writer ref="ID02"/>
    </writers>
</newAnnotation>