Document Transformation and XSL

Chapter 6 • XML and Data Representation 247 Listing 6-11: Example XSL document. Original XML source: 1 ?xml version=1.0? 2 paraThis is a emphasistestemphasis.para XSL stylesheet: 1 ?xml version=1.0? 2 xsl:stylesheet 3 xmlns:xsl=http:www.w3.org1999XSLFormat version=1.0 4 5 xsl:template match=para 6 pxsl:apply-templatesp 7 xsl:template 8 9 xsl:template match=emphasis 10 ixsl:apply-templatesi 11 xsl:template 12 13 xsl:stylesheet Resultant HTML source: 1 ?xml version=1.0 encoding=utf-8? 2 pThis is a itesti.p XGMML eXtensible Graph Markup and Modeling Language 1.0 Draft http:www.cs.rpi.edu~puninjXGMMLdraft-xgmml.html Mark Pilgrim returns with his latest Dive into XML column, XML on the Web Has Failed, claiming that XML on the Web has failed miserably, utterly, and completely. Is Mark right or wrong? You be the judge. http:www.xml.compuba20040721dive.html

6.5 Summary and Bibliographical Notes

As a historical footnote, XML is derived from SGML Standard Generalized Markup Language, which is a federal FIPS 152 and international ISO 8879 standard for identifying the structure and content of documents. Ivan Marsic • Rutgers University 248 I have no intention of providing a complete coverage of XML since that would require more than a single book and would get us lost in the mind numbing number of details. My main focus is on the basic concepts and providing enough details to support meaningful discussion. I do not expect that anybody would use this text as an XML reference. The reader interested in further details should consult the following and other sources. XML is defined by the W3C in a number of related specifications available here: http:www.w3.orgTR . A great source of information on XML is http:www.xml.com . The standard information about HTTP is available here: http:www.w3.orgProtocols HTML standard information is available here: http:www.w3.orgMarkUp XML Tutorial online at: http:www.w3schools.comxmldefault.asp Reference [Lee Chu, 2000] reviews several alternative XML schema languages. A book by Eric van der Vlist, RELAX NG, O’Reilly Associates, is available online at: http:books.xmlschemata.orgrelaxngpage1.html . Problems Problem 6.1 Problem 6.2 Write the XML Schema that defines the production rules for the instance document shown in Listing 6-12 below. The parameters are specified as follows. Possible values for the attribute student status are “full time” and “part time” and it is required that this attribute appears. The student identification number must be exactly 9 digits long and its 4th and 5th digits must always be a zero ַ ַ ַ 00 ַ ַ ַ ַ . According to the US Social Security Administration, a number with a zero in the 4th and 5th digits will never be assigned as a person’s SSN. Hence, you can easily distinguish the difference between the student id and the SSN by scanning the 4th and 5th digits. Chapter 6 • XML and Data Representation 249 The school number must be a two-digit number including numbers with the first digit equal to zero. The graduation class field should allow only Gregorian calendar years. The curriculum number must be a three-digit number between 100 and 999. The student grade field is optional, but when present it can contain only one of the following values: “A,” “B+,” “B,” “C+,” “C,” “D,” and “F.” All elements are required, unless stated otherwise. As for the non-specified parameters, make your own reasonable assumptions. Write down any assumptions you make. Listing 7-12: Instance XML document containing a class roster. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ?xml version=1.0 encoding=UTF-8? -- associate here your schema with this document -- class-roster class-name Introduction to Software Engineering class-name index 61202 index semester Spring 2006 semester enrollment 58 enrollment student status=full-time student-id 201000324 student-id name first-name Jane first-name last-name Doe last-name name school-number 14 school-number graduation-class 2006 graduation-class curriculum 332 curriculum grade A grade student student status=part-time ... student class-roster Problem 6.3