Presentation is loading. Please wait.

Presentation is loading. Please wait.

Efficient XSLT Processing in Relational Database System Zhen Hua Liu Anguel Novoselsky Oracle Corporation VLDB 2006.

Similar presentations


Presentation on theme: "Efficient XSLT Processing in Relational Database System Zhen Hua Liu Anguel Novoselsky Oracle Corporation VLDB 2006."— Presentation transcript:

1 Efficient XSLT Processing in Relational Database System Zhen Hua Liu Anguel Novoselsky Oracle Corporation VLDB 2006

2 Agenda  XML Processing Languages Overview  XSLT Processing - Coprocessor Vs Integrated Approach  XSLT to XQuery Rewrite Translation Technique  Performance Evaluation  Conclusion  Q & A

3 XML Processing Languages  XQuery/XPath XSLT  SQL/XML –integration XML and XQuery/XPath into SQL (http://www.sqlx.org)http://www.sqlx.org  SQL/XML (Oracle XMLDB) –  XMLTransform – Oracle XMLDB extension operator: embedding XSLT in SQL  SELECT XMLTransform(emp.resume, ‘XSLT code’) FROM emp; // resume is of XMLType column of table emp

4 XQuery, XSLT, SQL/XML Comparison  All are Declarative Languages ! (Central Dogma in declarative query processing)  Share common XQuery Data Model  SQL/XML XMLType is based on XQuery Data Model  XQuery & SQL/XML  More database centric  Share the same paradigm – Selection, Projection (XML Construction), Join, Order  XSLT  Database Foreign - Template Rule Matching based Execution Model  XLST is more declarative than XQuery  Impedance Mismatch with XQuery/SQL Processing Model, how to run XSLT in RDBMS ?

5 Multi-Coprocessors Approach  Embed off-the-shelf Xquery/XSLT processors into a SQL engine XQuery Engine SQL Engine XQuery(XMLQue ry) XQuery Data Model Instances Input XQuery DM instances output XSLT(Transform) XSLT Engine

6 Issues & Challenges with Coprocessor Approach  Fully composable in SQL/XML: Can we optimize XSLT, XQuery, XPath as one language ? Cross Language Optimization Feasible ?  XML is stored & Indexed: Can XSLT processing leverage index on XML in RDBMS?  How to make XSLT template rule matching based execution model “fit” into RDBMS processing Model ?

7 XQuery/XSLT/SQL/XML Integrated Architecture XQuery XMLType Abstraction OR Storage SQLX View/Relational Data Binary XML/ XMLIndex Common algebraic operator tree – storage independent optimization XML Storage/Index dependent Optimization Extended/Hybrid Model XSLT XSLT to XQuery Rewrite SQL/XML

8 XSLT to XQuery Rewrite Translation

9 General XSLT to XQuery Translate Technique  Fokoue etc “Compiling XSLT 2.0 into XQuery 1.0” paper at WWW 2005  Translate XSLT template into XQuery Function  Translate XSLT instruction into corresponding XQuery construct  Translate into XQuery function calls with large XQuery conditional expression matching XSLT pattern  Issues  Resultant XQuery is cumbersome and requires aggressive optimization  Where to Add Intelligence in the translation ?

10 XSLT to XQuery Rewrite example  XMLType view over relational data CREATE VIEW dept_emp AS SELECT XMLElement("dept", XMLElement("dname", dname), XMLElement("loc", loc), XMLElement("employees", (SELECT XMLAgg(XMLElement("emp", XMLElement("empno", empno), XMLElement("ename", ename), XMLElement("sal", sal))) FROM emp WHERE emp.deptno = dept.deptno))) as dept_content FROM dept

11 Example contd..  Result of XMLType View ============================================================ dname>ACCOUNTING NEW YORK 7782 CLARK 2450 7934 MILLER 1300

12 Example- XSLT on XMLType -1 SELECT XMLTransform(dept_emp.dept_content, ' HIGHLY PAID DEPT EMPLOYEES Department name: Department location:

13 Example- XSLT on XMLType -2 Employees Table EmpNo Name Weekly Salary 2000]"/>

14 Example- XSLT on XMLType -3 ') FROM dept_emp;

15 Input XML Structural Info with XSLT template Analysis dept dnam e loc employees emp text roo t Text template emp template Employees template loc template dname template dept template default template

16 XSLT Template Invocation Graph Text template emp template Employees templateloc templatedname template dept template Default template Text template root dept dname loc employees text Emp[sal>2000] text

17 Example- XQuery from XSLT SELECT XMLQuery( 'declare variable $var000 :=.; (: builtin template :) ( let $var002 := $var000/dept return (: :) ( HIGHLY PAID DEPT EMPLOYEES, ( let $var003 := $var002/dname return (: :) {fn:concat("Department name: ", fn:string($var003))}, let $var003 := $var002/loc return (: :) {fn:concat("Department location: ",fn:string($var003))},

18 Example- XQuery from XSLT let $var003 := $var002/employees return (: :) ( Employees Table, { EmpNo, Name, Weekly Salary, (

19 Example- XQuery from XSLT Rewrite for $var005 in ($var003/emp[sal > 2000]) return (: :) {fn:string($var005/empno)} {fn:string($var005/ename)} {fn:string($var005/sal)} ) } ) )' PASSING dept_emp.dept_content RETURNING CONTENT) FROM DEPT FROM dept_emp

20 Final Optimized SQL/XML Query  SELECT XMLConcat( XMLElement( "H1",'HIGHLY PAID DEPT EMPLOYEES'), XMLElement( "H2",'Department name: ' ||"SYS_ALIAS_4"."DNAME"), XMLELement( "H2",'Department location:’ ||"SYS_ALIAS_4"."LOC"), XMLELement( "H2",'Employees Table'), XMLElement( "table",XMLAttributes('2' AS "border"), XMLElement( "td", XMLElement( "b",'EmpNo')), XMLElement( "td",XMLElement( "b",'Name')), XMLElement( "td",XMLElement( "b",'Weekly Salary')), (SELECT XMLAGG( XMLElement( "tr", XMLElement( "td","EMP"."EMPNO"), XMLElement( "td","EMP"."ENAME"), XMLElement( "td","EMP"."SAL"))) FROM EMP WHERE SAL > 2000 AND DEPTNO=DEPT.DEPTNO))) FROM DEPT

21 XSLT to XQuery Rewrite Key  Leverge XML structural information to generate Template Invocation Graph  XML Schema, DTD, SQL/XML construction functions  Inline Template with caller  This generates compact XQuery amendable for further optimization  Cancellation with XML view / relational data  Path/Value Index for binary XML

22 Partial Evaluation  Partial Evaluation to obtain template invocation graph  Application computation is described as F(X,Y), X changes less frequently than Y and significant part of F’s computation depends on X.  Optimize F statically by holding X as constant  Key observation – let F be the XSLT stylesheet, X be the input XML structural information, Y be the actual XML instance document content

23 Comparison with Related Work  Fokoue - “Compiling XSLT 2.0 into XQuery 1.0” WWW 2005  Not leveraging Input XML Structure Information for optimizing XQuery generation process  Concluded context sensitive flow analysis & function specialization for static optimization  Our work –  Optimization of XSLT based on input XML structure  Leverage Partial Evaluation for obtaining template invocation graph

24 Comparison with Related Work  Moerkotte - “Incorporating XSL Processing Into Database Engines” VLDB 2002  XSLT into internal algebra and integrate with RDBMS  Concluded future research in combined optimizations of XSLT with XML construction  Our work:  XSLT into XQuery  Combined optimizations of XSLT with XML input

25 Comparison with Related Work  Jain & Li etc - “Translating XSLT Programs to Efficient SQL Queries” WWW 2002 & “Composing XSL Transformations with XML Publishing Views” SIGMOD 2003  Our work:  XQuery as intermediate language  Work with any XML storage/Index Model

26 Performance Evaluation

27 XSLT Mark  Db-one row query – Index Probe (Table Scan Vs Index Scan) Rewrite – Integrated Approach No-Rewrite – Coprocessor Approach

28 XSLT Mark  Avts, metric: XML construction  Chart, total: XSLT uses xquery aggregate functions: count/sum

29 Conclusions  Efficient XSLT processing in RDBMS is feasible despite the template rule based XSLT language  Use XQuery as intermediate language to which XSLT is translated  Leverage XML input structural information to get efficient & compact XQuery  Index Probing, pull based execution model, parallel aggregation, sort applicable to XSLT in RDMS engine  XSLT is native to RDBMS, just as XQuery,SQL/XML

30 Questions


Download ppt "Efficient XSLT Processing in Relational Database System Zhen Hua Liu Anguel Novoselsky Oracle Corporation VLDB 2006."

Similar presentations


Ads by Google