Translating XQuery into XSLT - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Translating XQuery into XSLT

Description:

Translating XQuery into XSLT – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 22
Provided by: Lech1
Category:

less

Transcript and Presenter's Notes

Title: Translating XQuery into XSLT


1
Translating XQuery into XSLT
  • Stephan Lechner, Günter Preuner, Michael Schrefl
  • Johannes Kepler University of Linz
  • Homepage http//www.dke.uni-linz.ac.at

2
Contents
  • Introduction
  • XQuery to XSLT Differences to bridge
  • Translation and Transformation
  • XQ2XSL-Translator
  • Conclusion

3
1. Introduction
  • XSLT
  • Transformations and presentational markup
  • Adopted by industry (e.g. in Web-Browsers)
  • Most beneficial Client Side Processing
  • XQuery
  • Typed query language for XML documents
  • Most beneficial Server Side Processing
  • Comfortable to use

4
Scenario Different Views of Data
Authors and Books (XML)
Authors View (XSL)
Books View (XSL)
Client Side
Server Side
5
Views using XQuery and XQ2XSL
Authors View Transfor- mations (XQuery)
Templates For Presentation (XSL)
Authors View Presentation (XSL)
Authors View Transfor- mations (XSL)
XQ2XSL
Combine
Authors and Books (XML)
Authors View (XSL)
works on
6
Motivation
  • Expressing complex transformations for views
    conveniently using XQueries
  • Perform these transformations on Client Side
    using XSLT only (yet implemented by many
    browsers)

7
2. XQuery to XSLT Differences
  • Different data models
  • Node identity
  • Interim query results
  • Different language constructs
  • Closure
  • Parameter binding byposition vs. name
  • Nested variables scopes

8
Bridging Data Model Differences
  • To avoid case-distinctions, we use an Internal
    Data Model with...
  • Explicit Node Identifiers
  • Wrapper elements around attributes, PIs, comments

9
Language Construct Differences
  • FOR b
  • IN annualBooks(2001)
  • RETURN
  • LET b b/title
  • RETURN b
  • ltvariable name"FOR1_outer"gt
  • ltcall-template name"annualBooks"gt
  • ltwith-param name"yearParam"
  • select"2001"/gt
  • lt/gtlt/gt
  • ltfor-each select"FOR1_outer/"gt
  • ltvariable name"FOR1 select"."/gt
  • ltvariable name"LET1"gt
  • ltcopy-of select"FOR1/title"/gt
  • lt/gt
  • ltcopy-of select"LET1"/gt
  • lt/gt

10
3. Translation and Transformation
11
4. XQ2XSL Translator
  • Parse tree generation and augmentation
  • Names of auxiliary variables
  • Aliases for XQuery-variables
  • Determine parameter names and positions
  • Node Translation
  • Traverse the parse tree (depth first)
  • Translate each node

12
Parse Tree Generation Augmentation
LET b b/title RETURN b
letexp LET Variablevar EQUAL
Exprouter RETURN Exprinner
Alias(b)Let1
13
FOR b IN annualBooks(2001) RETURN LET b
b/title RETURN b
Param- pos1
Var
b
Proj
Var
Alias(b) Let1
b
14
Implementation CUP Parser Generator
Grammar (production)
  • letexp LET Variablevar
  • EQUAL Exprouter
  • RETURN Exprinner
  • Node n new LetExpressionNode ()
  • n.setChild ("Variable", var)
  • n.setChild ("OuterExpression", outer)
  • n.setChild ("InnerExpression", inner)
  • var.setParent (n)
  • outer.setParent (n)
  • inner.setParent (n)
  • inner.setAlias (var.getLiteralValue(),
  • Node.newAlias())
  • RESULT n

Parse Tree Generation and Augmentation using Seman
tic Actions
15
Parse Tree Traversal Node Translation
AN
16
Node Translation by Transition Rules
IF (Type(AN) LetExpression) THEN NV(AN)
ltvariable name1"gt2lt/gt3
1 Alias (Child (inner), LitValue
(Child (var)) 2 NV (Child (outer)) 3 NV
(Child (inner))
17
Implementation Node Translation (Java)
  • class LetExpressionNode extends Node
  • void translate ()
  • // Depth-first traversal
  • getChild (var").translate ()
  • ... translate the other children
  • // get values for the place holders
  • String alias getChild(inner).
  • getAlias (getChild
    (var).getLiteralValue())
  • ... values of the other place holders
  • // Evaluate the value of "self"
  • setNodeValue ("ltxslvariable name\""
  • alias ... )

18
5. Conclusion
  • Advantages of XQuery High-level query language
    with type-checking
  • Advantages of XSLT well suited for
    presentational markup, widely distributed and
    adopted by industry
  • Translating XQuery into XSLT complex
    transformations can be expressed in XQuery and
    performed as XSLT.

19
Future Work
  • Automatic splitting of XQueries into server-side
    and client-side parts
  • Parameterizing XQueries for personalization
    purpose
  • Extending the concept by runtime type information

20
(No Transcript)
21
(a) Views Data defined by XQueries
Authors and Books (XML)
Authors View Transfor- mations (XQuery)
Templates For Presentation (XSL)
Authors View Presentation (XSL)
XQuery
Combine
Authors View (XSL)
Authors View Data (XML)
works on
Write a Comment
User Comments (0)
About PowerShow.com