Data Mediation

jetmorebrisketSoftware and s/w Development

Aug 15, 2012 (4 years and 11 months ago)

351 views

Web Service

Data Mediation

Jun Han

Liren Ding

Rui Wang


Web Service Data Mediation


Motivation


Web service composition


Semantic heterogeneity messages


e.g. “last name” vs. “family name”


Structural heterogeneity messages


<xsd:complexType name=“name">




<xsd:sequence>




<xsd:element name=“first_name" type="xsd:string"/>




<xsd:element name=“last_name" type="xsd:string"/>




</xsd:sequence>


</xsd:complexType>


<xsd:complexType name=“name">



<xsd:sequence>




<xsd:element name=“last_name" type="xsd:string"/>




<xsd:element name=“first_name" type="xsd:string"/>




</xsd:sequence>


</xsd:complexType>


Web Service Data Mediation


Other heterogeneity (not applicable to web
service)


Syntactic heterogeneity


Different languages used for representing the
elements: e.g. html vs. xml


Model/Representation heterogeneity


Underlying models (ontologies, database) or
representations (RDF, OWL, Relational, Object
-
oriented)

Web Service Data Mediation


What is web service data mediation?


During web service composition, using web
services with heterogeneous schemas (input
and output message schemas are incompatible)


The process of resolving message
heterogeneities and transforming one message
format to another

Web Service Data Mediation


Current solutions:


Manual


AI Planning approach


HTN (Hierarchical Task Network) planning


Classic AI planning


Rule
-
based planning


Planning using model checking


GraphPlan planning


Web Service Data Mediation


Current solutions:


Semantic approach


Semantic web service


WSMO


Ontologies, Goals, Web Services, Mediators


OWL
-
S /DAML
-
S


WS Description Ontology (Profile, Service Model,
Grounding)


SWSF



Process
-
based Description Model & Language for WS


WSDL
-
S/SAWSDL


Semantic annotation of WSDL descriptions

Web Service Data Mediation


Our approach:


Semantic approach


Semi
-
automatic


Manually annotating WSDL files


Automatic matching bottom elements


Semantic heterogeneity


Semantic annotation
--
SAWSDL


Structural heterogeneity


Bottom annotation


Web Service Data Mediation


Our approach:


WS1

WS2

ontology

address

name

CEO

name

address

symbol

address

WS1 output

WS2 input

Web Service Data Mediation


Background technologies


Web service


WSDL: wsdl4j


SOAP: soupUI


BPEL: netbeans


Semantic web service


OWL: OwlApi, Protege


SAWSDL: sawsdl4j, radiant


XML


XSD: Jdom


XPATH: Jaxen


XSLT

SAWSDL

Jun Han

Liren Ding

Rui Wang


SAWSDL


SAWSDL
--
Semantic Annotations for WSDL and XML
Schema


Based on WSDL
-
S


Build on the existing extensibility framework of


WSDL 1.1


WSDL 2.0


XML Schema


Allow multiple semantic annotations


SAWSDL


modelReference


Extension attribute


Association between a WSDL or XML Schema
component and a concept in some semantic model
(ontology)


Annotate XML Schema


type definitions


element declarations


attribute declarations


Annotate WSDL


Interfaces


Operations


Faults

SAWSDL


liftingSchemaMapping

&
loweringSchemaMapping


Extension attribute


Specify mappings between semantic data and XML


Lifting schema mapping


Transform XML data into instances of a semantic model


Lowering schema mapping


Does the opposite


Annotate XML Schema


Element declarations


Type definitions


SAWSDL
--

examples

<xs:element name="OrderRequest"
sawsdl:modelReference="http://www.w3.org/2002/ws/sawsdl/spec/ontology/purchas
eorder#OrderRequest"
sawsdl:loweringSchemaMapping="http://www.w3.org/2002/ws/sawsdl/spec/mapping
/RDFOnt2Request.xml"
>

</xs:element>


<wsdl:operation name="order" pattern="http://www.w3.org/ns/wsdl/in
-
out"
sawsdl:modelReference="http://www.w3.org/2002/ws/sawsdl/spec/ontology/purchas
eorder#RequestPurchaseOrder"
>


<wsdl:input element="OrderRequest"/>


<wsdl:output element="OrderResponse"/>

</wsdl:operation>


<xs:complexType name="itemType"
sawsdl:liftingSchemaMapping="http://example.org/mapping/ItemType2Ont.xslt"
>
<xs:sequence>



<xs:element ref="partDesc" />


</xs:sequence>


<xs:attribute name="ItemID" type="xs:string"/>


</xs:complexType>

XML Schema Definition
(XSD)

Jun Han

Liren Ding

Rui Wang


XML Schema Definition (XSD)


XML Schema is an XML
-
based alternative to DTD.


An XML Schema describes the structure of an XML document ,
just like a DTD.



XML Schemas are much more powerful than DTDs.


A Reference to an XML Schema

<?xml version="1.0"?>

<note
xmlns=
http://www.mywebsite.com

xmlns:xsi="http://www.w3.org/2001/XMLSchema
-
instance"
xsi:schemaLocation="http://www.mywebsite.com note.xsd"
>

<to>Jun, Liren</to>

<from>Rui</from>

<heading>Reminder</heading>


<body>The project is due soon!</body>

</note>

An XML Schema


<?xml version="1.0"?>


<xs:schema

xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.
mywebsite
.com"
xmlns=
http://www.mywebsite.com

elementFormDefault="qualified">



<xs:element name="note">


<xs:complexType>



<xs:sequence>




<xs:element name="to" type="xs:string"/>



<xs:element name="from" type="xs:string"/>



<xs:element name="heading" type="xs:string"/>



<xs:element name="body" type="xs:string"/>


</xs:sequence>


</xs:complexType>

</xs:element>

</xs:schema>


XSD Elements



XML Schemas define the elements of XML files.


simple element


<xs:element name="xxx" type="yyy"/>



empty elements


<product />


complex XML element



<employee>


<firstname>John</firstname>


<lastname>Smith</lastname>

</employee>


XSD Attributes


Define an Attribute

E.g. <lastname lang="EN">Smith</lastname>


<xs:attribute name="lang" type="xs:string"/>


If an element has attributes, it is considered to be
of a complex type. But the attribute itself is always
declared as a simple type.


built
-
in data types


xs:string


xs:decimal


xs:integer


xs:boolean


xs:date


xs:time


XSD Restrictions


Restrictions are used to define acceptable
values for XML elements or attributes.

E.g.

<xs:element name="age">

<xs:simpleType>


<xs:restriction base="xs:integer">





<xs:minInclusive value="0"/>




<xs:maxInclusive value="120"/>



</xs:restriction>

</xs:simpleType>

</xs:element>


Why Use XML Schemas


XML Schemas are much more powerful than
DTDs.


XML Schemas support data types


It is easier to describe allowable document content


It is easier to validate the correctness of data


It is easier to work with data from a database


It is easier to define data facets (restrictions on data)


It is easier to define data patterns (data formats)


It is easier to convert data between different data types


Why Use XML Schemas


XML Schemas are much more powerful than
DTDs.


XML Schemas use XML Syntax


You don't have to learn a new language


You can use your XML editor to edit your Schema files


You can use your XML parser to parse your Schema files


You can manipulate your Schema with the XML DOM


You can transform your Schema with XSLT

Why Use XML Schemas


XML Schemas are much more powerful than
DTDs.


XML Schemas Secure Data Communication


E.g. a date like: "03
-
11
-
2004" will, in some countries, be
interpreted as 3.November and in other countries as 11.March.


The XML data type "date" requires the format "YYYY
-
MM
-
DD".


Why Use XML Schemas


XML Schemas are much more powerful than
DTDs.


XML Schemas are extensible to future additions


With an extensible Schema definition you can:


Reuse your Schema in other Schemas


Create your own data types derived from the standard types


Reference multiple schemas in the same document

XPATH & XSLT

Jun Han

Liren Ding

Rui Wang


XSLT and XPath


XPath: XPath is a language for addressing
parts of an XML document, used in XSLT and
XPointer


XSLT: XSL Transformations, a language for
transforming XML documents into other XML
documents


XSL (Extensible Stylesheet Language) = XSLT
+ XSL
-
FO (formatting object, an XML
vocabulary for specifying formatting
semantics).


XSL to XML is like CSS to HTML


Big Picture

Nodes and Node Tree


When an application want to operate on an
XML document, it will build an internal model
of what the document look like, which is
known as Document Object Model or DOM.


In XSLT and XPath, it is called Node Tree,
which contains nodes to represent every part
of an XML document

Types of Node


Root nodes


The top of the node tree


Element nodes


XML elements


Attribute nodes


XML attributes


Text nodes


Textual content in XML elements


Comment nodes


XML comments


Processing Instruction nodes


XML processing instructions


Namespace nodes


The in
-
scope namespace on an element


XPath Expressions


The primary syntactic construct in XPath is
the expression.


An evaluation of XPath expression will yield:


node
-
set (an unordered collection of nodes
without duplicates)


boolean (true or false)


number (a floating
-
point number)


string (a sequence of UCS characters)




XPath Expressions (cont.)


Expression evaluation occurs with respect to
a context. The context consists of:


a node (the
context node
)


a pair of non
-
zero positive integers (the
context position

and the
context size
)


a set of variable bindings


a function library


the set of namespace declarations in scope
for the expression

Location Path of XPath


Location Path consists of:


Common Syntax:

axis::node test[predicate]


Axis: child(by default), parent, descendant


node test: which node to be collected


Predicate: filters to the node set


Sample


child::paragraph


child::paragraph

[attribute::type=warning]

[position()=2]


Location Path of XPath (cont.)


Absolute path: / by itself selects the root
node of the document, i.e., /RN/step/step


Relative path: relative path to the context
node, i.e., step/step


Some more examples:


<xsl:for
-
each select=‘child::paragraph’>


<xsl:apply
-
templates
select=“/document/paragraph"/>


select=‘presidents/president/[position()
=3]/name’




XPath functions library


The function library consists of a
mapping from function names to
functions.


Some frequently used functions include:


Node set function, i.e.:

count
(
node
-
set
)
will return the size of node
-
size


String function, Number function, Boolean
function, i.e.: concat, round, not, etc…



XSLT


XSLT is used to transform XML
documents. By
transformation
, we
mean the rules of transforming a source
XML tree into a result tree.


This can involve adding, removing, or
rearranging nodes, as well as
presenting nodes in a new way

XSLT process

XSLT vs. CSS


CSS is used to apply style elements to
markup languages to affect formatting in a
single pass, top
-
down fashion


XSLT produces a separate result tree and
can iterate and perform conditional logic


XSLT and CSS do not conflict with each
other, and they can be used together to
generate, i.e., process the XML using XSLT
in the server side and present the result
using CSS in the client side

XSLT logic


<xsl:template match=“XPath expression”>


<xsl:for
-
each select=“expression”>


<xsl:value
-
of select=“exp”>


e.g., <xsl:for
-
each select=“paragraph”>




<xsl:value
-
of select=“name” />


</xsl:for
-
each>


xsl:attribute


xsl:if


xsl:choose / xsl:when / xsl:otherwise



A simple example for XPath + XSLT


Sample xml document


http://www.cs.uga.edu/~jun/project/produ
cts.xml



Style sheet


http://www.cs.uga.edu/~jun/project/produ
cts.xsl


Resources


Xpath spec:


http://www.w3.org/TR/xpath


XSLT spec:


http://www.w3.org/TR/xslt


XSL spec:


http://www.w3.org/TR/xsl/




Homework 11


Compose city.xsl to transform the given xml file
city.xml into cityNew.xml


http://www.cs.uga.edu/~wang/8370adb/file/city.xml



http://www.cs.uga.edu/~wang/8370adb/file/cityNew.x
ml



Download command line tool below and evaluate
your city.xsl file.


http://www.microsoft.com/downloads/details.aspx?Fami
lyId=2FB55371
-
C94E
-
4373
-
B0E9
-
DB4816552E41&displaylang=en



Command:


msxsl city.xml city.xsl
-
o cityNew.xml