COMPSCI 752 Big Data Management Strategic Exercise 2
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
COMPSCI 752
Big Data Management
Strategic Exercise 2
XPath
Application domain. For questions 1, 2, and 3, consider the following XML document:
<?xml version = ‘ ‘ 1 . 0 ’ ’ encoding = ‘ ‘UTF-8’ ’? >
<a><a><a/><b/><b/></a><a><a/><b><a/><a/></b></a></a>
Exercise 1 - XML documents and trees.
a. Draw the XML tree that corresponds to the XML document.
b. For each node, write down the pre- and post-identifiers.
Exercise 2 - XPath expressions.
Write the XPath expressions that correspond to the queries below, and evaluate the XPath expressions on the given XML document. Use the pre-identifiers to denote the output nodes of the queries.
a. select all a nodes that have a b-parent
b. select all b nodes that have no preceding b-elements
c. select all b nodes that are leaves
d. select all nodes with more than one b-sibling.
Exercise 3 - Node tests. Explain what the following XPath queries do and show the pre- identifier of nodes that are selected by them:
a. //a[2]
b. //a/*[preceding-sibling::a and preceding-sibling::b]
c. //*[count(a)=count(b)]
d. //*[count(preceding::a)>3]
e. //a[not(ancestor::b)] | //b[not(ancestor::a)]
<?xml version =”1.0” encoding=” iso -8859 -1”?>
<catalog >
<dvd year =”1954”>
<movie>The Seven Samuarai </movie>
<director >Akira Kurosawa</ director >
<actor >Toshiro Mifune </actor >
<feature >English Subtitles </ feature >
<price >29.99 </ price >
</dvd>
<dvd year =”2005”>
<movie>Finding Neverland </movie>
<musthave>Yes</musthave>
<actor >Johnny Depp</actor >
<actor >Kate Winslet t </actor >
<price >39.95 </ price >
</dvd>
<dvd year =”1994”>
<movie>Pulp Fiction </movie>
<director >Quentin Tarantino </ director >
<actor >Bruce Will is </actor >
<scratch >Yes</ scratch >
<feature >Making Of</ feature >
<price >9.99</ price >
</dvd>
</ catalog >
Exercise 4 - XML document and tree. Draw the corresponding XML tree.
Exercise 5 - Xpath queries. Write the following in XPath:
a. Select all the price elements.
b. Select all the price and movie elements.
c. Select the second dvd.
d. Select the self node of the second dvd.
e. Select the parent of the second dvd.
f. Select the ancestors of the second dvd.
g. Select the children of the second dvd.
h. Select the attribute children of the second dvd.
i. Select the descendant elements of the second dvd.
j. Select the descendant nodes of the second dvd.
k. Select the preceding elements of the second dvd.
l. Select the preceding nodes of the second dvd.
m. Select the preceding sibling elements of the second dvd.
n. Select the preceding sibling nodes of the second dvd.
o. Select the following elements of the second dvd.
p. Select the following nodes of the second dvd.
q. Select the following sibling elements of the second dvd.
r. Select the following sibling nodes of the second dvd.
2023-06-25