Presentation is loading. Please wait.

Presentation is loading. Please wait.

Designing Streamable XPath Expressions Roger L. Costello January 5, 2014 1.

Similar presentations


Presentation on theme: "Designing Streamable XPath Expressions Roger L. Costello January 5, 2014 1."— Presentation transcript:

1 Designing Streamable XPath Expressions Roger L. Costello January 5, 2014 1

2 Acknowledgement The example shown in the following slides comes from the XSLT 3.0 specification. 2

3 Count the elements Suppose an XML document contains a bunch of elements. Every element has a child element. You are to create an XPath expression to count the elements that are within the elements. A element may contain a child element (in addition to its child element). Here is a sample XML document: … … 3 You are to design the XPath so that it can be used in a streaming program: you are to design a streamable XPath expression! count(xpath) should return 2.

4 Not a streamable XPath expression This XPath is not streamable: count(//section/head) Let’s see why. Consider our sample XML document: 4 … … This is the first section element that is fetched. Its head element is down here To fetch the second section element the XSLT processor would have to back up, which is not allowed in streaming. Therefore, this XPath expression is not streamable: //section/head

5 Streamable XPath expression A rule of streaming is that you can always access ancestors. So, to make the XPath expression viable for streaming, find each element that has a parent element: count(/descendant::head[parent::section]) 5 … … This is the first head element that is fetched. It has a parent section element. Therefore, this XPath expression is streamable: /descendant::head[parent::section]

6 Issues in streaming A streaming processor always moves forward, it can never back up. So if your program contains an XPath expression which would require the processor to back up, your program is not streamable. As a streaming processor descends the input document’s XML tree, it keeps a record of nodes it has visited. Thus, your program can reference ancestors. 6


Download ppt "Designing Streamable XPath Expressions Roger L. Costello January 5, 2014 1."

Similar presentations


Ads by Google