Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Static Type Analysis of Path Expressions in XQuery Using Rho-Calculus Wang Zhen (Selina) Oct 26, 2006.

Similar presentations


Presentation on theme: "1 Static Type Analysis of Path Expressions in XQuery Using Rho-Calculus Wang Zhen (Selina) Oct 26, 2006."— Presentation transcript:

1 1 Static Type Analysis of Path Expressions in XQuery Using Rho-Calculus Wang Zhen (Selina) Oct 26, 2006

2 2 Outline Background Related Work Typing XQuery Using Rho Calculus Conclusion and Future Work

3 3 Background XQuery: A query language for XML documents W3C Candidate Recommendation, 8 June 2006 Query processing (recommended for implementation):  Static analysis phase Parsing: parsed expression Static Context Processing: the static context (statEnv)statEnv Normalization: equivalent expression in Core Grammar [Expr]=core:Expr Static type analysis  Dynamic evaluation phase Dynamic Context Processing: the dynamic context (dynEnv)dynEnv Dynamic Evaluation (Dynamic type analysis)

4 4 Background Typing XQuery Static type analysis (STA):  Compile-time  Allows early detection of type errors  Can be used as the basis for certain classes of optimization. Dynamic type analysis (DTA):  Run-time  Can be avoided when STA is enabled, since: Any type error found during DTA can be found during STA

5 5 Background Rho-Calculus A framework embedding Lambda calculus and Term Rewriting Explicitly handles the rules, since the syntax allows rule definitions and rule applications Judgment: expresses whether a property holds or not. E.g.:  Type judgment: ( statEnv |- )? Expr: Type Rule application, e.g.: [X+Y →Y+X ](A+B) => B+A Rule definitionApplication

6 6 Background Rho-Calculus’s Typing System Subject reduction -- the type of a term does change during its reduction Type uniqueness Decidability -- given a term A in a context Γ, the following problems are decidable:  Whether there is a type , such that Γ├ A:   Given a type , whether it is true that Γ├ A: 

7 7 Related Work XQuery 1.0 and XPath 2.0 Formal Semantics W3C Candidate Recommendation “…uses several kinds of formal notations to define the relationships between [XPath/XQuery] expressions, XML values, and XML Schema types…” Some Important notations/definitions:  Judgment: expresses whether a property holds or not. E.g.: Type judgment: statEnv |- Expr: Type Subtype judgment: Type 1 <: Type 2  Typing rule: (All premises and the conclusion are judgments.)

8 8 Related Work XQuery 1.0 and XPath 2.0 Formal Semantics STA  Provides the typing rules for each kind of XQuery/XPath expression  Static typing works by recursively applying the rules over a given expression Other XML Query languages : XDuce/CDuce, µXQ, Tequyla-TX, …… STA: use rules

9 9 Related Work Problems 1 st Problem: Complicated, difficult to be fully implemented, E.g.: XQuery W3C Formal Semantics About 40~50 kinds of judgments Even more rules for each XQuery/XPath expression Many XQuery implementations, however:  Some of them do not support STA  Some support: encode the rules and judgments The specification is still being updated Difficult to keep up with the changes. 2 rd problem : difficult to prove the property of typing system, e.g.: soundness Question: whether we can use a “reasonable” and “safe” typing system, where the rules can be maintained easily

10 10 Typing XQuery Using Rho Calculus Some prefixes used later

11 11 Typing XQuery Using Rho Calculus XQuery W3C Formal Semantics STA [xq:Expr] FS = core:Expr Typed core:Expr Our approach: Rho-Normalization 『 fs:Definitions or core:Expr 』 Rho = mapped object XML Schema import fs:Definitions core:Expr fs:Definitions Mapped to judgments Rho term Typing rules Rho Calculus’s typing system

12 12 Typing XQuery Using Rho Calculus Type: extend the type definition in Rho calculus to meet the requirement of XQuery types fs:Type mapped rho:Type The definition of fs:Type Based on the six node types in XML document: document, element, attribute, comment, processing-instruction, text

13 13 Typing XQuery Using Rho Calculus Types Accordingly, we define fs:Type mapped rho:Type

14 14 Typing XQuery Using Rho Calculus

15 15 Typing XQuery Using Rho Calculus We extend the rho:Type definition as

16 16 Typing XQuery Using Rho Calculus Our approach:  Element definition: define element elemName of type typeName elemName: typeName  Attribute definition: define attribute attrName of type typeName {attrName: typeName}  Type definition: define type typeName {fs:Type} 『 fs:Type 』 → typeName fs:Definitions Mapped to judgments Rho term Rho Calculus’s typing system [xq:Expr] FS = core:Expr XML Schema import

17 17 Typing XQuery Using Rho Calculus Example: doc(“CTL.xml”)/catalogue catalogue.xsd

18 18 Typing XQuery Using Rho Calculus fs:Definitions Mapped to judgments Rho term Rho Calculus’s typing system [xq:Expr] FS = core:Expr XML Schema import

19 19 Typing XQuery Using Rho Calculus fs:Definitions Mapped to judgments Rho term Rho Calculus’s typing system [xq:Expr] FS = core:Expr XML Schema import Some variables used in the following slides : Currently we focus on  Path expressions: the key syntax in XQuery

20 20 Typing XQuery Using Rho Calculus XQuery Grammar XQuery Core Grammar Function calls FLWOR Expr (for-let-where- order by-return Expr) StepExpr

21 21 Typing XQuery Using Rho Calculus FLWOR Expr: for-let-where-order by-return In Core Grammar: ForClause + Return

22 22 Typing XQuery Using Rho Calculus FLWOR Expr: for-let-where-order by-return ForClause + Return

23 23 Typing XQuery Using Rho Calculus XQuery Grammar XQuery Core Grammar Function calls FLWOR Expr StepExpr

24 24 Typing XQuery Using Rho Calculus StepExpr in Core Grammar:

25 25 Typing XQuery Using Rho Calculus StepExpr Example: Child::NameTest, Child::KindTest Mapped to some function calls:

26 26 Typing XQuery Using Rho Calculus

27 27 Typing XQuery Using Rho Calculus XQuery Grammar XQuery Core Grammar Function calls FLWOR Expr StepExpr

28 28 Typing XQuery Using Rho Calculus Example: doc(“CTL.xml”)/catalogue catalogue.xsd

29 29 Typing XQuery Using Rho Calculus fs:Definitions Mapped to judgments Rho term Rho Calculus’s typing system [xq:Expr] FS = core:Expr XML Schema import

30 30 Typing XQuery Using Rho Calculus fs:Definitions Mapped to judgments Rho term Rho Calculus’s typing system [xq:Expr] FS = core:Expr XML Schema import [doc(“CTL.xml”)/catalogue] FS = Example: doc(“CTL.xml”)/catalogue

31 31

32 32 Conclusion and Future Work We analysis the current research work on STA for XML Query languages, specially XQuery Problems  The typing system is too complicated to be fully implemented  It’s not easy to maintain the implementation so that it can keep up with the update of the rules Solution: use Rho Calculus to express XQuery expressions, since the calculus  is designed to define and maintain rules easily.  provides “reasonable” and “safe” typing system Future work:  Analysis other syntax of XQuery using Rho Calculus  Analysis the property of the typing system under our extension

33 33


Download ppt "1 Static Type Analysis of Path Expressions in XQuery Using Rho-Calculus Wang Zhen (Selina) Oct 26, 2006."

Similar presentations


Ads by Google