370 likes | 499 Views
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. Motivation.
E N D
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
Motivation 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?
XML Publishing view query Query Logic SQL queryes Relational DB Tagger Publisher XML data view query: specifies the mapping between relational tables and resulting XML document.
Example: tables and schema of view METROAREA HOTEL ROOM / metro (name) hotel (name, star) total_room room (#) available
Example: published XML document / metro (“New York City”) metro (“Chicago”) hotel (“Hilton”, 4) hotel (“Hyatt”, 2) total_room total_room available room (1) room (2) room (101) room (102) 2 2
Relational 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 Example of View Query / <metro> <hotel> <available> <room> <total_room>
publisher Evaluate XSLT queries on relational data? view query view XSLT stylesheet
publisher XSLT processor Approach 1: Materialization view query materialized view XSLT stylesheet 1 XML data
Unnecessary Materializations nodes that do not satisfy type requirement nodes that do not satisfy selection condition nodes not involved in output / metro (“Chicago”) metro (“New York City”) hotel (“Hilton”, 4) total_room available room (1) room (2) 2 rule 1. metro [@name=“Chicago”] : output name rule 2. hotel [@star>3]: no output rule 3. total_room : output total number of rooms
publisher publisher XSLT processor Approach 2: View Composition view query view query new view query + materialized view XSLT stylesheet XSLT stylesheet 2 1 XML data XML data
Algorithm Overview / metro (“Chicago”) metro (“New York City”) hotel (“Hilton”, 4) total_room available room (1) room (2) 2 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?
Algorithm Overview XSLT stylesheet view query + Context Transition Graph (CTG) What type of nodes are accessed? Traverse View Query (TVQ) What are the instances of these types of nodes? Output Tag Tree (OTT) How do we avoid materializing nodes uninvolved in output? new view query
R1: <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> Example of XSLT Stylesheet
<xsl:template match=“/”> <result_metro> <A/> <xsl:apply-templates select=“metro/hotel/total_room”/> </result_metro> </xsl:template> Template Rule A stylesheet consists of a set of template rules. select_expression(r) output(r), match_pattern(r), > R = < match the root generate output process total_room for all hotels of all metro areas
R1: match=“/” select=“metro/hotel/total_room” R2: match=“total_room” select=“../available/../room” R3: match=“metro/hotel/room” Simplified Representation
R1: match=“/” select=“metro/hotel/total_room” R2: match=“total_room” select=“../available/../room” R3: match=“metro/hotel/room” XSLT processing / (/, R1) <metro> <metro> (total_room,R2) <hotel> <hotel> (room,R3) <available> <total_room> <room> <room>
Context Transition Graph (CTG) MATCHQ: nodes SELECTQ: edges (/, R1) total_room: context node room: new context node (total_room,R2) (room,R3) CTG: Which type of nodes are accessed? Document instances of <total_room> maybe matched by R2, which further selects document instances of <room>, which may be matched by R3.
Instances of accessed nodes? (/, R1) (total_room,R2) $t_new= … (room,R3) $r_new=?
Traverse View Query (TVQ) (/, R1) TVQ: Instances of accessed nodes (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)
<hotel> <total_room> <available> <room> <metro> <hotel> <available> <total_room> <room> Select-Match Tree <metro> <hotel> <room> TVQ: Instances of accessed nodes R2: match=“total_room” select=“../available/../room” (/, R1) (total_room,R2) $t_new= … (room,R3) $r_new=? R3:match=“metro/hotel/room”
Select-Match Tree: How does context transition happen? (/, R1) Select-Match Tree <metro> (total_room,R2) $t_new= … <hotel> <available> <total_room> <room> (room,R3) $r_new=?
UNBIND: Select-Match Tree tag query (/, R1) Select-Match Tree <metro> (total_room,R2) $t_new= … <hotel> <available> <total_room> <room> (room,R3) $r_new=?
UNBIND: Select-Match Tree tag query (/, R1) Select-Match Tree <metro> (total_room,R2) $t_new= … <hotel> <available> <total_room> <room> $r =SELECT * FROM room WHERE hotel_id=$h.hotelid (room,R3) $r_new=?
UNBIND: Select-Match Tree tag query (/, R1) Select-Match Tree <metro> (total_room,R2) $t_new= … <hotel> <available> <total_room> <room> $r =SELECT * FROM room WHERE hotel_id=$h.hotelid (room,R3) $r_new=SELECT * FROM room WHERE hotel_id=$t_new.hotelid
UNBIND: Select-Match Tree tag query (/, R1) Select-Match Tree <metro> (total_room,R2) $t_new= … <hotel> <total_room> <available> $a=SELECT * FROM room WHERE hotel_id=$h.hotelid AND available = TRUE <room> (room,R3) $r_new=SELECT * FROM room WHERE hotel_id=$t_new.hotelid
UNBIND: Select-Match Tree tag query (/, R1) Select-Match Tree <metro> (total_room,R2) $t_new= … <hotel> <total_room> <available> $a=SELECT * FROM room WHERE hotel_id=$h.hotelid AND available = TRUE <room> (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)
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) b<5 lowest common ancestor context node a=10 new context node
Output Tag Tree (root, R1) (total_room,R2) (room,R3)
Output Tag Tree (OTT) (root, R1) <result_metro> <A> apply-template (total_room,R2) R1: <xsl:template match=``/''> <result_metro> <A/> <xsl:apply-templates select=``…''/> </result_metro> </xsl:template> (room,R3)
Output Tag Tree (OTT) <result_metro> (root, R1) <A> <result_total> (total_room,R2) <B> apply-template R2: <xsl:template match=``total_room''> <result_total> <B/> <xsl:apply-templates select=``...''/> </result_total> </xsl:template> (room,R3)
Output Tag Tree (OTT) <result_metro> (root, R1) <A> <result_total> (total_room,R2) <B> <room> (room,R3) R3: <xsl:template match=``metro/hotel/room''> <xsl:value-of select=''.''/> </xsl:template>
New View Query (root, R1) <result_metro> <A> <result_total> (total_room,R2) <B> <room> (room,R3) Forced Unbind during the generation of OTT
XSLT_basic • no type coercion • no document order • no “//” • no function • no variable and parameter • no recursion • no predicate in expression • no flow-control elements (<xsl:if>, <xsl:for-each>,<xsl:choose>) • no conflicting rule resolution • select of <xsl:value-of> is “.”
Relaxing 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”
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 Summary
//: CTG graph multigraph recursion Future Work
Related Work • Translating XSLT into SQL queries: Jain et al, WWW 02 • XML publishing middleware • SilkRoute: Fernandez et al, WWW 00, SIGMOD 01 • XPERANTO: Carey et al, WebDB 00 & Shanmugasundaram et al, VLDB 01 • Incorporating XSL processing into database engines: Moerkotte, VLDB 02