CIS 97 YT - Midterm

Make the following fragments of XML well-formed.  If a fragment is already well-formed, just write "OK".  These fragments are all independent of one another.

1.	<item><name>Frying Pan</item></name>

2.	<utensil>Fork</Utensil>

3.	<hr width="75%" noshade />

4.	<formula> 5 > x > 0 </formula>

5.	<formula> 0 < y < 5 </formula>

Here are some English language descriptions of XML.  Write the appropriate fragment of a DTD to describe them.

6.	A <tv-show> contains  a <channel>, <description>, an optional <movie>, and  required <start-time> element in that order. 

7.	A <channel> element contains text, and has an optional attribute named  kind, which may have the values premium or standard.

8.	The <description> element contains text  mixed with zero or more  <quote> elements.  Example:
<description><quote>Believe it or Leave It!</quote> - see the Tomb of Doom. Hosted by Moishe Pipik, lead actor on <quote>Mary and Todd</quote> last year.</description>

9.	Create a general entity named  tvpg which expands to Television Program Guide

10. 	Create a parameter entity named  temperature which expands to  hot | cold | warm

Now write the following descriptions in Relax NG.
11.	The <movie> element is an empty element, with a required attribute named  rating, which contains text.

	12.	The <tv-show> element has a required  vcr-code attribute, which is an ID. (Don't worry about the content of
<tv-show>; just write the outer element and attribute specification.)

	
13.	A <program-list> consists of one or more 
<tv-show> elements.  Your solution should
use <ref name="tv-show-defn"/> (You don't have to write the  <define> for   tv-show-defn; presume that someone else will write that.)
	14.	A <channel> element contains a positive integer, and has an optional attribute named kind, which may have the values premium or standard.

	

15.	The <description> element contains text  mixed with zero or more  <quote> elements, as in question 8.  The
<quote> element contains text.

Write Relax NG patterns for the following specifications. You do not have to include the
<param type="pattern">...</param>; just give the regular expression.

16.	Match a movie rating: G, PG-13, R, or NC-17.  Hint: don't try to be too clever!

17.	Match a De Anza course code, which consists of: three or four capital letters, followed by a dash, followed by three digits, a period, a dash, and two digits followed by an optional capital letter.

18.	A series of one or more "word characters", followed by one or more spaces, followed by any non-digit.