XPath and Namespaces

Assignment 4 — XML Foundations (INFOSYS 242; Fall 2006)

Assigned: 2006-09-21 / Due: 2006-09-26

Authors: Bob Glushko & Erik Wilde / TA: Katrina Rhoads Lindholm

Introduction: Answer a set of questions about XPath and Namespaces.
Resources: XML Document to use for XPath Evaluations
Pretty (and Complete) HTML Version of the above XML Document
w3schools.com XPath Reference
Answer: Solutions
Instructions:

Open dret.xml in your XML editor. This is the XML document that you will use to conduct the XPath evaluations. For each of the selections below, tell us the XPath expression you would use to accomplish it. Next to each selection is a number in brackets. This number represents the count of the results returned when a proper selection is done. You can use this to check if your XPath expression is correct (simply use the count() function around your XPath expression.)

  1. Select all the references that list an author with a surname of Wilde. (Note: You don't have to look for the <names type="sharef:author"> attribute value, just assume that all names contain author names) [37]
  2. Select all the references that list an author with a surname of Wilde where there was at least one co-author. (Note: You don't have to look for the <names type="sharef:author"> attribute value, just assume that all names contain author names) [17]
  3. Select all the references published in 2003 in Germany [5]
  4. Select all the surnames of people with the givenname David [34]
  5. Select all persons which have published papers at the The OSI95 Transport Service with Multimedia Support. (Hint: Match the name and crossref attributes on a reference) [11]
  6. Select all the references that have more than one title element [82]
  7. Select all the references which are marked as being relevant for the topics xml and xmlschema. (Hint: This information is in the bibtex topic field; search for xml[0.9] to see how it works). [3]

The remaining questions relate to Namespaces/XSLT:

  1. Explain the difference between these three xslt stylesheets (only in terms of their namespace usage):
    • <stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
      </stylesheet>
    • <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      </xsl:stylesheet>
    • <xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform">
      </xslt:stylesheet>
  2. Explain how the following XSLT could be improved:
    • <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      	<xsl:template match="/">
      		<html xmlns="http://www.w3.org/1999/xhtml">
      			<head>
      				<title>test</title>
      			</head>
      			<body><xsl:apply-templates/></body>
      		</html>
      	</xsl:template>
      	<xsl:template match="person">
      		<b xmlns="http://www.w3.org/1999/xhtml"><xsl:value-of select="."/></b>
      	</xsl:template>
      </xsl:stylesheet>

Submission Instructions: Send us an email with a text file or Word document attached containing your answers to all of the above questions. Please name your file a4_firstname_lastname where firstname and lastname are replaced with your first and last names.


please send comments to dret@sims.berkeley.edu
last modification on Sunday, 10-Dec-2006 01:24:15 MET
valid CSS! valid XHTML 1.0!