Top Banner
Composing XSL Transformations with XML Publishing Views Chengkai Li University of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell Labs Henry F. Korth Lehigh University PPS Narayan Lucent Technologies, Bell Labs SIGMOD 2003
37

Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

Dec 14, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

Composing XSL

Transformations with XML

Publishing ViewsChengkai Li University of Illinois at Urbana-

Champaign

Philip Bohannon Lucent Technologies, Bell Labs

Henry F. Korth Lehigh University

PPS Narayan Lucent Technologies, Bell Labs

SIGMOD 2003

Page 2: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

2

MotivationMotivation

XML: popular for data representation and exchange

The data: stored in RDBMS

Vast majority of existing data stored in RDBMS

Efficiency, robustness of RDBMS for XML applications

XML Publishing Views (SilkRoute, XPERANTO)

The query: expressed as XSLT

Designed for document transformation

Popular as XML query language

How to evaluate queries on relational data posed in XSLT?

Page 3: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

3

XML PublishingXML Publishing

SQL queryes

Relational DB

Query Logic

Tagger

XML data

Publisher

view query: specifies the mapping between relational tables and resulting XML document.

view query

Page 4: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

4

Example: tables and schema of view

HOTEL

hotelid name star metro_id

1 Hyatt 2 NYC

2 Hilton 4 CHI

metroid name

NYC New York City

CHI Chicago

METROAREA

ROOM

hotel_id room # available

1 101 F

1 102 F

2 1 T

2 2 F

/

metro (name)

hotel (name, star)

room (#)total_room available

Page 5: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

5

Example: published XML document

/

metro (“Chicago”)metro (“New York City”)

room (2)total_room

availableroom (1)2

hotel (“Hilton”, 4)

room (102)total_room

room (101)2

hotel (“Hyatt”, 2)

Page 6: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

6

Example of View QueryExample of View QueryRelational Schema

Metroarea(metroid, metroname)

Hotel(hotelid, hotelname, starrating, metro_id)

Room(hotel_id, room#, available)

Desired Hierarchical Structure of Published XML

$m = SELECT metroid, metroname FROM metroarea

$h =SELECT * FROM hotel WHERE metro_id = $m.metroid AND starrating > 4

<metro>

<hotel>

<total_room> <available><room>

/

Page 7: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

7

Evaluate XSLT queries on relational data?Evaluate XSLT queries on relational data?

publisher

XSLTstylesheet

view query

view

Page 8: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

8

Approach 1: MaterializationApproach 1: Materialization

Approach 1

XML parsing relational engine for XML processing unnecessary materialization of nodes

1 XML data

publisher

XSLTstylesheet

view query

XSLT processor

materialized view

Page 9: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

9

Unnecessary MaterializationsUnnecessary Materializations

rule 1. metro [@name=“Chicago”] : output name

rule 2. hotel [@star>3]: no output

rule 3. total_room : output total number of rooms

nodes that do not satisfy type requirementnodes that do not satisfy selection conditionnodes not involved in output /

metro (“Chicago”)metro (“New York City”)

room (2)total_room

availableroom (1)2

hotel (“Hilton”, 4)

Page 10: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

10

Approach 2: View CompositionApproach 2: View Composition

+new

view query

publisher

1 2XML data

publisher

XSLTstylesheet

view query

XSLT processor

XSLTstylesheet

view query

XML data

materialized view

Approach 1 Approach 2

XML parsing relational engine for XML processing unnecessary materialization of nodes

Page 11: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

11

Algorithm OverviewAlgorithm Overview

nodes that do not satisfy type requirements:

What type of nodes are accessed?

nodes that do not satisfy selection condition:

What are the instances of these types of nodes?

nodes not involved in output: How do we avoid materializing uninvolved

nodes?

/

metro (“Chicago”)metro (“New York City”)

room (2)total_room

availableroom (1)2

hotel (“Hilton”, 4)

Page 12: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

12

Algorithm OverviewAlgorithm Overview

view query

XSLT stylesheet

new view query

+

Context Transition Graph(CTG)

Traverse View Query(TVQ)

Output Tag Tree(OTT)

What type of nodes are accessed?

What are the instances of these types of nodes?

How do we avoid materializing nodes uninvolved in output?

Page 13: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

13

Example of XSLT StylesheetExample of XSLT StylesheetR1:<xsl:template match=“/”> <result_metro> <A/> <xsl:apply-templates select=“metro/hotel/total_room”/> </result_metro></xsl:template>

R2:<xsl:template match=“total_room”> <result_total> <B/> <xsl:apply-templates select=“../available/../room”/> </result_total></xsl:template>

R3:<xsl:template match=“metro/hotel/room”> <xsl:value-of select=“.”/></xsl:template>

Page 14: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

14

Template RuleTemplate Rule

<xsl:template match=“/”> <result_metro> <A/> <xsl:apply-templates select=“metro/hotel/total_room”/> </result_metro></xsl:template>

A stylesheet consists of a set of template rules.

R = <match_pattern(r), output(r), select_expression(r) >

match the rootgenerate output process total_room for all hotels of all metro areas

Page 15: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

15

Simplified RepresentationSimplified RepresentationR1:match=“/”select=“metro/hotel/total_room”

R2:match=“total_room”select=“../available/../room”

R3:match=“metro/hotel/room”

Page 16: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

16

XSLT processingXSLT processingR1:match=“/”select=“metro/hotel/total_room”

R2:match=“total_room”select=“../available/../room”

R3:match=“metro/hotel/room”

<metro>

/

<metro>

<hotel> <hotel>

<room><total_room> <room><available>

(/, R1)

(total_room,R2)

(room,R3)

Page 17: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

17

Context Transition Graph (CTG)Context Transition Graph (CTG)

(/, R1)

(total_room,R2)

(room,R3)

Document instances of <total_room> may be matched by R2, which further selects document instances of <room>, which may be matched by R3.

MATCHQ: nodes SELECTQ: edges

CTG: Which type of nodes are accessed?

total_room: context node

room: new context node

Page 18: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

18

Instances of accessed nodes?Instances of accessed nodes?

(/, R1)

(total_room,R2)$t_new= …

(room,R3)

$r_new=?

Page 19: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

19

Traverse View Query (TVQ)Traverse View Query (TVQ)

(/, R1)

(total_room,R2)$t_new= …

(room,R3) $r_new =SELECT * FROM room WHERE hotel_id=$t_new.hotelid AND EXISTS (SELECT * FROM room WHERE hotel_id=$t_new.hotelid AND available = TRUE)

TVQ: Instances of accessed nodes

Page 20: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

20

TVQ: Instances of accessed nodesTVQ: Instances of accessed nodesR2:

match=“total_room”

select=“../available/../room”

R3:match=“metro/hotel/room”

<hotel>

<total_room><room>

<available>

<hotel>

<room>

<metro>

<hotel>

<total_room>

<room>

<available>

<metro>

Select-Match Tree

(/, R1)

(total_room,R2)$t_new= …

(room,R3)

$r_new=?

Page 21: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

21

Select-Match Tree: How does context transition happen?Select-Match Tree: How does context transition happen?

<hotel>

<total_room>

<room>

<available>

<metro>

Select-Match Tree

(/, R1)

(total_room,R2)$t_new= …

(room,R3)

$r_new=?

Page 22: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

22

UNBIND: Select-Match Tree tag queryUNBIND: Select-Match Tree tag query

<hotel>

<total_room>

<room>

<available>

<metro>

Select-Match Tree

(/, R1)

(total_room,R2)$t_new= …

(room,R3)

$r_new=?

Page 23: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

23

UNBIND: Select-Match Tree tag queryUNBIND: Select-Match Tree tag query

<hotel>

<total_room> <available>

<metro>

Select-Match Tree

(/, R1)

(total_room,R2)$t_new= …

(room,R3)

$r_new=?

<room> $r =SELECT * FROM room WHERE hotel_id=$h.hotelid

Page 24: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

24

UNBIND: Select-Match Tree tag queryUNBIND: Select-Match Tree tag query

<hotel>

<total_room> <available>

<metro>

Select-Match Tree

(/, R1)

(total_room,R2)$t_new= …

(room,R3)

$r_new=SELECT * FROM room WHERE hotel_id=$t_new.hotelid

<room> $r =SELECT * FROM room WHERE hotel_id=$h.hotelid

Page 25: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

25

UNBIND: Select-Match Tree tag queryUNBIND: Select-Match Tree tag query

<hotel>

<total_room>

<metro>

Select-Match Tree

(/, R1)

(total_room,R2)$t_new= …

(room,R3)

$r_new=SELECT * FROM room WHERE hotel_id=$t_new.hotelid

<room>

<available>$a=SELECT * FROM room WHERE hotel_id=$h.hotelid AND available = TRUE

Page 26: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

26

UNBIND: Select-Match Tree tag queryUNBIND: Select-Match Tree tag query

<hotel>

<total_room>

<metro>

Select-Match Tree

(/, R1)

(total_room,R2)$t_new= …

(room,R3)

$r_new =SELECT * FROM room WHERE hotel_id=$t_new.hotelid AND EXISTS (SELECT * FROM room WHERE hotel_id=$t_new.hotelid AND available = TRUE)

<room>

<available>$a=SELECT * FROM room WHERE hotel_id=$h.hotelid AND available = TRUE

Page 27: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

27

UNBIND: General Cases UNBIND: General Cases

General Select-Match Tree with Predicates

Unbind along the lowest common ancestor to the new context node (FROM)

Nest of all sub-trees not on the two paths (WHERE EXISTS)

Attribute access of all nodes (WHERE)

lowest common ancestor

a=10

b<5

context node

new context node

Page 28: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

28

Output Tag TreeOutput Tag Tree

(root, R1)

(total_room,R2)

(room,R3)

Page 29: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

29

Output Tag Tree (OTT)Output Tag Tree (OTT)

R1:<xsl:template match=``/''>

<result_metro> <A/>

<xsl:apply-templates select=``…''/> </result_metro></xsl:template>

<result_metro>

<A>

apply-template

(root, R1)

(total_room,R2)

(room,R3)

Page 30: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

30

Output Tag Tree (OTT)Output Tag Tree (OTT)

R2: <xsl:template match=``total_room''> <result_total> <B/> <xsl:apply-templates select=``...''/> </result_total></xsl:template>

<result_metro>

<A>

<result_total>

<B>

apply-template

(root, R1)

(total_room,R2)

(room,R3)

Page 31: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

31

Output Tag Tree (OTT)Output Tag Tree (OTT)

<result_metro>

<A>

<result_total>

<B>

<room>

R3: <xsl:template match=``metro/hotel/room''> <xsl:value-of select=''.''/> </xsl:template>

(root, R1)

(total_room,R2)

(room,R3)

Page 32: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

32

New View QueryNew View Query

<result_metro>

<A>

<result_total>

<B>

<room>

Forced Unbind during the generation of OTT

(root, R1)

(total_room,R2)

(room,R3)

Page 33: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

33

XSLT_basicXSLT_basic

no type coercionno document orderno “//”no functionno variable and parameterno recursionno predicate in expressionno flow-control elements

(<xsl:if>, <xsl:for-each>,<xsl:choose>)no conflicting rule resolutionselect of <xsl:value-of> is “.”

Page 34: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

34

Relaxing AssumptionsRelaxing Assumptions

recursion

predicate in expression

flow-control elements

(<xsl:if>, <xsl:for-each>,<xsl:choose>)

conflicting rule resolution

select of <xsl:value-of> be other than “.” and “@attribute”

Page 35: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

35

SummarySummary

Problem: Composing XSL Transformations with XML publishing views

Advantages compared with materialization approach

Algorithm Context Transition Graph

Traverse View Query

Output Tag Tree

Relaxing Assumptions

Page 36: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

36

Future WorkFuture Work

//: CTG graph multigraph

recursion

Page 37: Composing XSL Transformations with XML Publishing Views Chengkai LiUniversity of Illinois at Urbana-Champaign Philip Bohannon Lucent Technologies, Bell.

37

Related WorkRelated WorkTranslating XSLT into SQL queries: Jain et al, WWW 02

XML publishing middlewareSilkRoute: Fernandez et al, WWW 00, SIGMOD 01XPERANTO: Carey et al, WebDB 00 & Shanmugasundaram et al, VLDB 01

Incorporating XSL processing into database engines: Moerkotte, VLDB 02