Comp150CPA: Clouds and Power-Aware Computing
Classroom Exercise 17
XML, Xschemas, XPATH
group member 1: ____________________________ login: ______________
group member 2: ____________________________ login: ______________
group member 3: ____________________________ login: ______________
group member 4: ____________________________ login: ______________
group member 5: ____________________________ login: ______________
In class we have described XML, XSchemas, and XPATH.
Let's explore these in a bit more detail.
- Consider the code:
<cat name=Fred><food amount='1' brand='Friskies'>Tuna</food></cat>
<dog name=George><food amount='1' brand='Purina'>Chow</food>
This is not legal XML! Why? Correct it "in place" so that it
becomes compliant XML.
What are the outputs of the following XPATHs when applied to the (corrected) XML above (as nodesets)?
dog/food[@amount > 1]
- Consider the partial XML schema:
<xs:attribute name="amount" type="xs:number"/>
<xs:attribute name="brand" type="xs:string"/>
Does this describe the (corrected) version of the "food" elements
in the above? Why or why not?
- One hidden "point" of today's lecture is that in order for an
XPATH to make sense, some known schema has to be valid. Give an XML
element and an XPATH that searches for something reasonable within the
XML, and then give an example of a different XML element for which the
XPATH does not function as expected.
- (Advanced) Note that string facets are all defined in terms of
regular expressions. Why is this computationally a good
idea? What can't you do in a facet because of this? Hint: consider
the language hierarchy in basic computation theory.