Model Based Schema: Ivoa Registry Videocon 2004/05/13-14 Gerard Lemson 1

  • Uploaded by: sachin2410
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Model Based Schema: Ivoa Registry Videocon 2004/05/13-14 Gerard Lemson 1 as PDF for free.

More details

  • Words: 774
  • Pages: 13
Model based schema

IVOA Registry videocon 2004/05/13-14

Gerard Lemson

1

UML to XSD binding • • • • •

Start with UML model Generate XMI from UML Define UML to XSD binding Implement binding as XSLT script Run script

IVOA Registry videocon 2004/05/13-14

Gerard Lemson

2

Sample UML aas::A aas

-f

-id : integer -description : string

1

aas::F

0..1

-c

aas::B -data : real

cees::C -name : string

*

1

*

cees::D

cees

cees::D1

IVOA Registry videocon 2004/05/13-14

-dees

Gerard Lemson

cees::D2

3

Mapping “methodology” • Simple: as “1-1” as possible • Preserve semantics – Attributes owned by class – Children in parent-child composition relation owned by parent/container

• Focus on type definitions, complexType-s mainly • Valid documents (global elements) defined with respect to, but separate from the type definitions • Default document: contains an element definition under the root for each “root-entity-class”. • Possibility of reuse of schema type definitions in different special purpose document definitions. IVOA Registry videocon 2004/05/13-14

Gerard Lemson

4

Mapping: packages aas

• •

Package -> (target)namespace, in own file Dependency -> import of dependent namespace and file

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

targetNamespace="urn://xml.registry.gavo.org/aas" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.1"

xmlns:aas="urn://xml.domainmodel.gavo.org/aas" xmlns:base="urn://xml.domainmodel.gavo.org/"

xmlns:cees="urn://xml.domainmodel.gavo.org/cees">

cees

IVOA Registry videocon 2004/05/13-14

... <xsd:import namespace="urn://xml.registry.gavo.org/cees" schemaLocation="./cees.xsd" />

Gerard Lemson

5

Mapping Classes aas::A -id : integer -description : string

• • •

Every class -> globally defined complexType isAbstract -> abstract=“true” Attribute -> element of simplish-type, either built-in, or also generated

<xsd:complexType name="A" abstract="true"> <xsd:complexContent> <xsd:extension base="base:DataObject">

<xsd:sequence> <xsd:element name="id" type="xsd:integer" /> <xsd:element name="description" type="xsd:string"/>

aas::B

<xsd:element name="f" type="aas:F" minOccurs="0"/>

-data : real



IVOA Registry videocon 2004/05/13-14

Gerard Lemson

6

Mapping Classes II aas::A -id : integer -description : string



Inheritance -> extension of base class

<xsd:complexType name="B"> <xsd:complexContent>

<xsd:extension base="aas:A"> <xsd:sequence> <xsd:element name="data" type="xsd:double" /> <xsd:element name="c" type="cees:CProxy" />

aas::B -data : real

IVOA Registry videocon 2004/05/13-14

Gerard Lemson

7

Mapping Associations I cees::C -name : string

*

-dees

cees::D

IVOA Registry videocon 2004/05/13-14

• •

Parent-child relationship Composition -> element of appropriate complexType

<xsd:complexType name="C"> <xsd:complexContent> <xsd:extension base="base:DataObject"> <xsd:sequence> <xsd:element name="name" type="xsd:string"/>

<xsd:element name="dees" type="cees:D" minOccurs="0" maxOccurs="unbounded" />

Gerard Lemson

8

Mapping associations II aas::A -id : integer -description : string

-f 1

aas::F

0..1

• “Owned references” -> element of appropriate type <xsd:complexType name="A" abstract="true"> <xsd:complexContent> <xsd:extension base="base:DataObject"> <xsd:sequence> <xsd:element name="id" type="xsd:integer" /> <xsd:element name="description" type="xsd:string" />

<xsd:element name="f" type="aas:F" minOccurs="0"/>

IVOA Registry videocon 2004/05/13-14

Gerard Lemson

9

Mapping associations III -c

aas::B -data : real

-name : string *

• • • •

cees::C

1

Problem: shared references (also aggregations), many-to-1/many relations Does one want to replicate elements that are shared ? Multiple B-s can reference same C. Solutions: – Don‘t care, map ala composition, with cardinality maxOccurs=“0” – Use ID/IDREF or KEY/KEYREF declarations. Requires the C to exist in same document, possibly completely, i.e. containing all substructure. – Use explicit “proxy ” element, for example using a GUID (IVOA identifier?), which can/must be resolved before the referenced object can be obtained. This is the most tricky thing I think about XML schemas, how to properly embed the semantics of the shared association into a logical schema design.

IVOA Registry videocon 2004/05/13-14

Gerard Lemson

10

Default Document •

Root entity classes map also to an element in a document, but in a separate schema doc, depending on the type defining schema documents.

<xsd:schema targetNamespace="urn://xml.registry.gavo.org/doc" ...

xmlns:doc="urn://xml.registry.gavo.org/doc" xmlns:cees="urn://xml.registry.gavo.org/cees" xmlns:aas="urn://xml.registry.gavo.org/aas"> <xsd:import namespace="urn://xml.registry.gavo.org/cees" schemaLocation="./cees.xsd" /> <xsd:import namespace="urn://xml.registry.gavo.org/aas" schemaLocation="./aas.xsd" /> <xsd:element name="sample"> <xsd:complexType><xsd:sequence>

<xsd:element name="c" type="cees:C" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="a" type="aas:A" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="b" type="aas:B" minOccurs="0" maxOccurs="unbounded"/>

IVOA Registry videocon 2004/05/13-14

Gerard Lemson

11

Comments • • • •

Single inheritance mapping, only extension, no substitutionGroup Requires xsi:type construct (next slide) to indicate which precise class is used. No element ref construct. No global elements for attributes and contained classes. Analogy to Java binding : – Complex type <=> class – Typed <element> declarations <=> Fields in class definition – Default document <=> a main method using the classes. – Global elements <=> variable declarations local to main method

• Can support a more involved special purpose document to/from the “official” default registry document using XSLT scripts for example (view concept). • See also: http://www.xml.com/pub/a/2002/08/07/wxs_uml.html and others •

Probably more …

IVOA Registry videocon 2004/05/13-14

Gerard Lemson

12

xsi:type • xsi:type=‘’ construct from the xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” in document required to indicate precise class: <doc:sample xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:doc="urn://xml.registry.gavo.org/doc" xmlns:cees="urn://xml.registry.gavo.org/cees"> <doc:c> a C a D1 a D2

IVOA Registry videocon 2004/05/13-14

Gerard Lemson

13

Related Documents

Registry 1
December 2019 14
Registry
May 2020 25
Registry
November 2019 30
Registry
May 2020 17

More Documents from "syahbandi"