Comp150CPA: Clouds and Power-Aware Computing
Classroom Exercise 17
XML, Xschemas, XPATH
Spring 2011

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.

  1. 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.

  2. What are the outputs of the following XPATHs when applied to the (corrected) XML above (as nodesets)?
    1. dog//food
    2. food[@brand='Purina']
    3. dog/food[@amount > 1]

  3. Consider the partial XML schema:
    <xs:element name="food">
          <xs:extension base="xs:string">
            <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?

  4. 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.

  5. (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.