Presentation is loading. Please wait.

Presentation is loading. Please wait.

XPath Processor MQP Presentation April 15, 2003 Tammy Worthington Advisor: Elke Rundensteiner Computer Science Department Worcester Polytechnic Institute.

Similar presentations


Presentation on theme: "XPath Processor MQP Presentation April 15, 2003 Tammy Worthington Advisor: Elke Rundensteiner Computer Science Department Worcester Polytechnic Institute."— Presentation transcript:

1 XPath Processor MQP Presentation April 15, 2003 Tammy Worthington Advisor: Elke Rundensteiner Computer Science Department Worcester Polytechnic Institute

2 XPath Processor 2 XQuery Introduction MASS (A Multi-Axis Storage Structure for Large XML Documents) VAMANA (XPath Query Engine) XQuery Engine (future development) Execution TreeMass Interface Node Set XPath Expression XML Doc XPath Node Set Input XQuery XML Doc XPath Expression XPath Processor

3 XPath Processor 3 Processor Requirements Must conform with XPATH grammar as specified by W3C Implementation in C++ –Performance needed since XQuery can have several XPath expressions –MASS and VAMANA in C++ Parser interface that is independent of query engine –Existing parsers coupled to query engine (Xalan, Pathan, LibXPath, Sablotron) –Facilitates efficient development and testing Extensibility –Allow for user transformations of parse tree –Allow for XPath grammar changes Error handling –Show useful error message –Parse tree should be destroyed automatically if parse error occurs

4 XPath Processor 4 Processor Overview Generates independent parse tree –Parse tree is a structure of in-memory C++ objects –Small footprint due to compact parse tree representation Built-in transformations –Predicate transformation needed to facilitate data flow in query engines User implemented callback interface –Completely separate from query execution –Generates execution tree from parse tree User derives from parser class and provides implementation Implementation is a simple 1-to-1 transformation XPATH Expression Parse Tree Transformed Parse Tree Execution Tree Transformer Generator (Callbacks) Parser (Productions)

5 XPath Processor 5 Parse Tree Node Hierarchy Parse Node Step Node Axis Type Node Name Test Node Function Node Function Arg Node Filter Node Negative Node Predicate Node Unary Predicate Node Binary Predicate Node Set Operator Node Number Operator Node Literal Node

6 XPath Processor 6 Running Example XPath syntax –AxisName::NodeTest[predicate] –/child::company/descendant-or-self::employee[position() = 1] Abbreviated notation: /company//employee[1] Boston JohnDoe 471 54250 JaneDoe XML Document example

7 XPath Processor 7 Productions to Parse Tree /child::company/descendant-or-self::employee[position() = 1] Expr LocPath Step Nodetest Axis Pred LocPath FunctionLiteral 1 Binary Predicate Equals Function Position Step company Step employee Nodetest Axis Productions:Parse Tree:

8 XPath Processor 8 Abbreviated Notation Abbreviated expression –/company//employee[1] Normalized expression –/child::company/descendant-or-self::employee[position() = 1] Literal 1 Step company Step employee Binary Predicate Equals Function Position Parse Tree: Normalized Parse Tree:

9 XPath Processor 9 Transformed Parse Tree Data flow query engines require data to flow from the step node up through its predicate node which filters the data –Predicate nodes must be placed above their corresponding step node When could this be done? –While parsing Too complicated because productions expect certain inputs –While generating execution tree Would make user interface too complex –In post-processing of parse tree Simple recursive transformation

10 XPath Processor 10 Transformed Parse Tree /child::company/descendant-or-self::employee[position() = 1] Step company Step employee Literal 1 Binary Predicate Equals Function Position Literal 1 Binary Predicate Equals Function Position Parse Tree: Transformed Parse Tree:

11 XPath Processor 11 User Implementation of Callbacks Interface defines a callback for each node type –Callbacks supply parse tree parameters Value – axis, nodetest, literal, etc Role – relationship to parent –User implements callbacks to generate execution tree An in-order traversal of the tree is made and appropriate callbacks are called

12 XPath Processor 12 Callbacks /child::company/descendant-or-self::employee[position() = 1] Step company Step employee Literal 1 Binary Predicate equals Function position Start Predicate (equals, root) Start Step (employee, context) Start Step (company, context) End Step Start Function (position, operand) End Function Start Literal (1, operand) End Literal End Predicate Parse Tree:Corresponding Callbacks Invoked:

13 XPath Processor 13 Execution Tree Generation User derives from parser class and provides implementation of the callback interfaces –Implementation specific to execution tree stored in derived class Stack required to maintain context in execution tree –Each Start callback creates a node, attaches it to its parent (top of stack) and pushes it onto the stack –Each End callback pops a node off the stack Implemented parser interface for VAMANA query engine –1-to-1 mapping makes execution tree generation simple

14 XPath Processor 14 Execution Tree Generation /child::company/descendant-or-self::employee[position() = 1] Start Predicate (equals, root) Start Step (employee, context) Start Step (company, context) End Step Start Function (position, operand) End Function Start Literal (1, operand) End Literal End Predicate Predicate (equals, root) Step (employee, context) Step (company, context) Stack: Mass Node company Mass Node employee V Literal 1 V Function position V Binary Predicate equals Start Predicate (equals, root) Start Step (employee, context) Start Step (company, context) End Step Start Function (position, operand) End Function Start Literal (1, operand) End Literal End Predicate Function (position, expr)Literal (1, expr) Callbacks: Execution Tree:

15 XPath Processor 15 Evaluation Numerous XPATH expressions were tested including all of the examples in W3C’s XPath specifications Each tree was printed, enabling visual evaluation (example to follow) Error messages helpful in locating parse error –Example (using \ instead of /) child::company\descendant-or-self::employee[position() =1] –Output child::company\descendant-or-self::employee[position() =1] -------------------^ Parse Error!

16 XPath Processor 16 Printed Trees /child::company/descendant-or-self::employee[position() = 1] --------------- |child | |company | |CONTEXT| /~ ------------- ------------------------- |descendant-or-self| |employee | | ROOT | ------------------------- | --------------- | |position | | |FUNCTION| | |OPERAND| | /~ -------------- \_ ---------- | = | |BIPRED| | PRED | ----------- \_ --------------- | 1 | |LITERAL | |OPERAND| --------------- |position | |FUNCTION| |OPERAND | /~ -------------- ----------- | = | |BIPRED| | ROOT | | |\_ -------------- | | | 1 | | | |LITERAL | | | |OPERAND| | | --------------- ----------- | -------------- | | child | | |company | | |CONTEXT| | /~ ------------- \_ ------------------------ |descendant-or-self| | employee | | CONTEXT | ------------------------- ----------------- |position | |VFUNCTION| | OPERAND | /~ ---------------- ------------- | = | |VBIPRED | | ROOT | | |\_ -------------- | | | 1 | | | |VLITERAL | | | |OPERAND| | | --------------- -------------- | -------------- | | child | | |company | | |CONTEXT| | /~ ------------- \_ ------------------------ |descendant-or-self| | employee | | CONTEXT | ------------------------- Parse Tree:Transformed Parse Tree:Execution Tree:

17 XPath Processor 17 Conclusion Successful implementation XPath Processor completely independent of query engine Successful integration with VAMANA and MASS Successful MQP overall

18 XPath Processor 18 Thanks I would like to thank Elke Rundensteiner, Kurt Deschler and Venkatesh Raghavan. This XPATH Processor was a contribution to both the MASS and VAMANA projects and is the result of a collaborated effort.

19 XPath Processor 19 References 1.Tim Bray, Jean Paoli, C. M. Sperberg-Mcqueen and Eve Maler. Extensible Markup Language (XML), Version 1.0, Second Edition, W3C Recommendation, October 6, 2000. http://www.w3.org/TR/REC-xml 2.Jim Clark and Steve DeRose. XML Path Language (XPATH), Version 1.0, W3C Recommendation, November 16, 1999. http://www.w3.org/TR/xpath.html 3.Don Chamberlin, Peter Fankhauser, Massimo Marchiori and Jonathan Robie. XML Query Requirements, W3C Working Draft, February 15, 2001. http://www.w3.org/TR/xmlquery-req 4.Kurt W. Deschler and Elke Rundensteiner. MASS: A Multi-Axis Storage Structure for Large XML Documents, 2002, Technical Report in progress. 5.Venkatesh Raghavan. VAMANA – Efficient Xpath Query Engine Exploiting the MASS Index, October 23, 2002, Master’s Thesis Proposal.

20 Questions?


Download ppt "XPath Processor MQP Presentation April 15, 2003 Tammy Worthington Advisor: Elke Rundensteiner Computer Science Department Worcester Polytechnic Institute."

Similar presentations


Ads by Google