xsd:sequence

Comments

Transcription

xsd:sequence
Protocols::AstronomicalObservatory
Protocols::Query
Phenomenology::Substance
Phenomenology::SpatialSubjectType
Protocols::SourceExtraction
Protocols::Callibration
Protocols::Simulator
Phenomenology::ScientificArtifact
Phenomenology::TangibleObject
Protocols::Analysis
Protocols::Stacking
Protocols::DataProcessing
-type
Protocols::CrossMatching
Phenomenology::SubjectType
-name : string
-description : string
-type
1
-recipe
Experiments::Experiment
1
Protocols::Protocol
1..*
-identifier : string
-documentationURL : string
-identifier : string
*
1
-property
1
-property
-name : string
1
1
*
Experiments::Result
1
1
1
-inputDataType
-configuration
-protocol
Experiments::Configuration
Protocols::ConfigurationDescriptor
Protocols::InputDataType
*
1
-name : string
-description : string
1
Phenomenology::NumericPhenomenon
-field
1
-configurationParameter
Types::Field
-name : string
*
-type
-inputData
-phenomenon1
*
*
1
1
Experiments::TimeOrderedData
Phenomenology::Phenomenon
*
-type
-name : string
*
*
1
Types::AbstractType
1
-result
-phenomenon
Phenomenology::Property
1
Types::Datatype
Experiments::InputData
Types::Representation
Phenomenology::BaseNumericPhenomenon
*
*
Experiments::Image
*
*
-confidence
-observable
Protocols::Objective
-identifier : string
Experiments::ConfidenceIndication
*
*
Experiments::ObjectList
-locator : string
-description : string
-observable
-phenomenon
-power : rational
-amount : numeric
*
Protocols::Variable
-variables
-component
-name : string
-isIndependent : boolean
-artifact
-observation
*
1
*
1
Experiments::VisibilityData
*
Standards::ComponentUnit
*
Products::PhysicalArtifact
-subject
Phenomenology::CompositePhenomenon
1 1..*
-component
1
Standards::CompoundUnit
1..*
1
Phenomenology::AtomicNumericPhenomenon
1
Experiments::Subject
Phenomenology::PositionalPhenomenon
*
-variable
*
1
*
Standards::AtomicUnit
1
Phenomenology::DerivedNumericPhenomenon
-abbreviation : string
-amount : numeric
-values
Experiments::ValueAssignment
1
Standards::Constant
*
*
-component
1
Values::AtomicQuantity
-unit
-amount : numeric
1
-value
1
Standards::Unit
*
*
*1
1
1
-uncertainty
*
1..*
-type_1
-referenceSystem
0..1
-power : integer
-value
Experiments::Measurement
Values::Quantity
1
Experiments::Uncertainty
Standards::ReferenceSystem
-identifier : string
-description : string
1
Values::CompositeQuantity
Standards::EnergyBand
Standards::PhysicalConstant
-name : string
-name : string
-abbreviation : string
*
-components
Phenomenology::DerivedPhenomenonComponent
-quantity
Phenomenology::DecompositionalPhenomenon
1
Values::Value
*
Values::ComponentQuantity
1..*
Standards::NamingSystem
1
-name : string
-component
Experiments::Identification
1
-value
1
Standards::CoordinateSystem
*
*
-id
Values::Identifier
Standards::Name
-name : string
-description : string
*
-phenomenon
-object
Phenomenology::Identification
1
*
-baseClassifcation
Standards::ClassificationSystem
Standards::MagnitudeSystem
1
Experiments::Classification
*
*
1
-value
*
1..*
-category
Values::Classifier
-name : string
*
-possibleValue
-phenomenon
Phenomenology::CategoricalPhenomenon
1
*
*-baseClass
IVOA DM 2005/05/19
1
Standards::Category
Gerard Lemson
1
0..1
1
What to do with data models
A methodology for defining a binding
from UML to XML Schema
(and Java and RDBM)
+ an implementation
IVOA DM 2005/05/19
Gerard Lemson
2
Using UML data models
1: Define IVOA-standard extended subset of
UML syntax
2: Define UML to XSD (and Java and RDB and ...)
binding (translation)
3: Create tools implementing this binding
4: Define UML model
5: Generate XSD
6: Generate Java + Hibernate configuration files and
create meta-data repository
IVOA DM 2005/05/19
Gerard Lemson
3
Sample UML
protocol
«topLevelPackage»
IVOA Value Types::datatypes
responsibility
experiment
«valuetype»
datatypes::ivoIdentifier
storage
experiment::Experiment
-date : datetime
-description : string
protocol::Simulator
-name : string
-description : string
-documentation : anyURI
-simulator
-writer
responsibility::Individual
-name : string
-email : string
*
1
1
Filesystem
-baseURI : anyURI
experiment::Simulation
-identifier : ivoIdentifier
-documentationURI : anyURI
*
*
-snapshots
File
Snapshot
*
-storedIn
-index : integer
-redshift : real
*
IVOA DM 2005/05/19
-files
Gerard Lemson
1
-name : string
-directoryPath : string
-type
4
Mapping “methodology”
• Simple: as “1-1” as possible
• Preserve semantics
– Attributes owned by class
– Children in parent-child composition relation owned by
parent/container
– References not owned
• Focus on type definitions, complexType for object types,
simpleType for value types
• 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 DM 2005/05/19
Gerard Lemson
5
Mapping: packages
experiment
• 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.domain.gavo.org/experiment"
elementFormDefault="qualified"
attributeFormDefault="unqualified" version="0.1"
xmlns:exp="urn://xml.domain.gavo.org/experiment"
xmlns:base="urn://xml.domain.gavo.org/"
storage
IVOA DM 2005/05/19
xmlns:strg="urn://xml.domain.gavo.org/storage">
...
<xsd:import
namespace="urn://xml.domain.gavo.org/storage"
schemaLocation="./storage.xsd" />
Gerard Lemson
6
Mapping Object Types
•
•
•
Every class -> globally defined complexType
isAbstract -> abstract=“true”
Attribute -> element of simplish-type, either built-in, or also generated
experiment::Experiment
-date : datetime
-description : string
<xsd:complexType name=„Experiment" abstract="true">
<xsd:complexContent>
<xsd:extension base="base:DataObject">
<xsd:sequence>
<xsd:element name="date" type="xsd:datetime"/>
<xsd:element name="description" type="xsd:string"/>
...
</xsd:sequence>
experiment::Simulation
-identifier : ivoIdentifier
-documentationURI : anyURI
IVOA DM 2005/05/19
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Gerard Lemson
7
Mapping Object Types II
experiment::Experiment
-date : datetime
-description : string
experiment::Simulation
-identifier : ivoIdentifier
-documentationURI : anyURI
IVOA DM 2005/05/19
• Inheritance -> extension of base class
<xsd:complexType name="Simulation">
<xsd:complexContent>
<xsd:extension base="exp:Experiment">
<xsd:sequence>
<xsd:element name="identifier"
type="dt:ivoIdentifier"/>
<xsd:element name=„documentationURI"
type="xsd:anyURI"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Gerard Lemson
8
Mapping Value Types
• Every value type -> globally defined simpleType
«enumeration»
FileType
-csv
-xml
-littleEndian
IVOA DM 2005/05/19
<xsd:simpleType name="FileType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="csv"/>
<xsd:enumeration value="xml"/>
<xsd:enumeration value="littleEndian"/>
</xsd:restriction
</xsd:simpleType>
Gerard Lemson
9
Mapping Associations I
Filesystem
-baseURI : anyURI
*
-files
File
-name : string
-directoryPath : string
-type : FileType
IVOA DM 2005/05/19
• Parent-child relationship
• Composition -> element of appropriate
complexType
<xsd:complexType name="Filesystem">
<xsd:complexContent>
<xsd:extension base="base:DataObject">
<xsd:sequence>
<xsd:element name="baseURI"
type="xsd:string"/>
<xsd:element name="files" type="strg:File"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Gerard Lemson
10
Mapping associations II
experiment::Experiment
-date : datetime
-description : string
1..*
-experimenter
*
responsibility::Individual
-name : string
-email : string
protocol::Simulator
-name : string
-description : string
-documentation : anyURI
•
•
•
•
-writer
1
*
Problem: shared references (also aggregations), many-to-1/many relations
Does one want to replicate elements that are shared ?
Multiple A-s can reference same B.
Solutions:
– Don‘t care, map ala composition, with cardinality maxOccurs=“1”
– Use ID/IDREF or KEY/KEYREF declarations. Requires the B to exist in same
document as A, possibly completely, i.e. containing all substructure.
– Use implicit “pointer” element, for example using a GUID (IVOA
ResourceIidentifier?), which can/must be resolved before the referenced object can
be obtained.
– XInclude ??
•
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 DM 2005/05/19
Gerard Lemson
11
Default “Document Schema”
•
Root entity classes map also to an element in a document, but in a separate schema doc,
depending on the type defining schema documents.
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema targetNamespace="urn://xml.registry.gavo.org/doc" ...
xmlns:doc="urn://xml.domain.gavo.org/doc"
xmlns:exp="urn://xml.domain.gavo.org/experiment"
xmlns:strg="urn://xml.domain.gavo.org/storage"
... >
<xsd:import namespace="urn://xml.domain.gavo.org/experiment"
schemaLocation="./experiment.xsd" />
<xsd:import namespace="urn://xml.domain.gavo.org/storage"
schemaLocation="./storage.xsd" />
<xsd:element name="simulationDoc">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="experiment" type="exp:Experiment“
minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="simulation" type="exp:Simulation“
minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="fileSystem" type="strg:FileSystem"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
IVOA DM 2005/05/19
Gerard Lemson
12
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/root 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 DM 2005/05/19
Gerard Lemson
13
Implementation
• Design UML using MS Visio
• Generate XMI
• 3 XSLT scripts to generate:
– XSD
– Java
– Hibernate mapping
• DDL generation
IVOA DM 2005/05/19
Gerard Lemson
14
Example I:
Hydro-simulations of galaxy clusters
• Visualisation services at
http://gavows2.xray.mpe.mpg:8080/hydrosims
• Metadata repository based on UML
model+generation tools
• Java+Hibernate generated
• Java code for updating/querying database
IVOA DM 2005/05/19
Gerard Lemson
15
Protocol
-name : string
-description : string
-documentationURI : string
*
Individual
-owner
Filesystem
-name : string
-email : string
-baseURI : anyURI
1
Simulator
-owner
Experiment
-startTime : datetime
-endTime : datetime
ClusterFinder
-simulator
*
-protocol
1
«enumeration»
PrimitiveType
-t_string
-t_double
-t_float
-t_int
-t_datetime
-t_vospaceIdentifier
1
1
Simulation
-identifier : string
-documentationURI : anyURI
*
«enumeration»
fileType
-csv
-xml
-votable
-fitsbintable
-fitsimage
-image2D
-binary
-ascii
*
ClusterExtraction
-configurationFiles
ConfigurationFile
-description : string
*
*
-storedIn
Snapshot
*
-haloCatalogues
-snapshot*
-index : integer
-redshift : real
1
-name : string
-directoryPath : string
-type : fileType
*
-files
*
HaloCatalogue
-results
1
RelationalDatabase
*
JobResultFile
-process
-file
File
-snapshots
*
1
*
Job
-file
*
1
-name : string
*
-storedIn
RelationalTable
*
-name : string
ss
1
-tables
*
-columns
VOSpaceProcess
1
TableColumn
SimpleProcess
IVOA DM 2005/05/19
1
Gerard Lemson
-configurationDescription
-name : string
-ucd : string
16
TransientObjectManager tom = new TransientObjectManager(configuration ...);
Individual volker = new Individual(tom);
volker.setName("Volker Springel");
volker.setEmail("[email protected]");
Individual klaus = new Individual(tom);
klaus.setName("Klaus Dolag");
klaus.setEmail("[email protected]");
Process splotch = new SimpleProcess(tom);
splotch.setName("Splotch");
splotch.setDescription("Ray tracer for GADGET2 simulation files.");
splotch.setDocumentationURI("http://dipastro.pd.astro.it/~cosmo/Splotch/");
splotch.setOwner(klaus);
Process smac = new SimpleProcess(tom);
smac.setName("Smac");
smac.setDescription("Visualiser for physical quantities in GADGET2 and other
simulation files.");
smac.setDocumentationURI("...");
smac.setOwner(klaus);
...
tom.flush();
IVOA DM 2005/05/19
Gerard Lemson
17
Example II:
STC Region
•
•
•
•
•
AS asked for DDLs for STC Region.
Translated Arnold’s doc to “proper” UML
Generated Java and Hibernate source
Generated DDL from Hibernate
XML Schema comparison ???
IVOA DM 2005/05/19
Gerard Lemson
18
1
-one
stcregion::Region
1
-fill_factor : real = 1
-negated
-two
1
-two
*
1-one
1
«valuetype»
stcregion::SCValue
*
*
*
stcregion::RegionUnion
stcregion::RegionIntersect
«enumeration»
stcregion::Unit
stcregion::Circle
stcregion::RegionNegation
-radius : Value
*
«valuetype»
stcregion::Value
-value : real
-unit : Unit
stcregion::SkyIndexRegion
stcregion::Ellipse
-minorRadius : Value
-positionAngle : Value
stcregion::Polygon
stcregion::Convex
1
1
-vertex
stcregion::Vertex
-position : SCValue
1
stcregion::Constraint
*
1..*
-edge
1..*
-vector : SCValue
-offset : Value
-from
stcregion::PolygonEdge
-constraint
1 -to
1
*
*
stcregion::ConvexHull
stcregion::SmallCircle
stcregion::GreatCircle
-polePosition : SCValue
1
stcregion::Sector
stcregion::ConvexHullPoint
IVOA DM 2005/05/19 -point : Value
1..*
-point
-position : SCValue
-positionAngle : Value
-positionAngle2 : Value
Gerard Lemson
19
POINT_UNIT varchar(255) null,
primary key (ID)
);
create table VERTEX (
ID numeric(19,0) identity not null,
SUBCLASS varchar(255) not null,
UPDATE_TIMESTAMP datetime not null,
GUID varchar(36) null,
CONTAINER_ID numeric(19,0) not null,
primary key (ID)
);
create table POLYGONEDGE (
ID numeric(19,0) identity not null,
SUBCLASS varchar(255) not null,
UPDATE_TIMESTAMP datetime not null,
GUID varchar(36) null,
CONTAINER_ID numeric(19,0) not null,
TO_ID numeric(19,0) null,
FROM_ID numeric(19,0) null,
primary key (ID)
);
create table REGION (
ID numeric(19,0) identity not null,
SUBCLASS varchar(255) not null,
UPDATE_TIMESTAMP datetime not null,
GUID varchar(36) null,
FILL_FACTOR double precision null,
POSITIONANGLE_VALUE double precision null,
POSITIONANGLE_UNIT varchar(255) null,
POSITIONANGLE2_VALUE double precision null,
POSITIONANGLE2_UNIT varchar(255) null,
IVOA DM 2005/05/19
Lemson
NEGATED_ID numeric(19,0)Gerard
null,
ONE_ID numeric(19,0) null,
20

Similar documents