Course Content Web Technologies and Applications • Introduction • Databases & WWW • Internet and WWW • SGML / XML Winter 2001 • Protocols • Managing servers • HTML and beyond • Search Engines CMPUT 499: SGML to XML • Animation & WWW • Web Mining • Java Script • CORBA Dr. Osmar R. Zaïane • Dynamic Pages • Security Issues • Perl Intro. • Selected Topics • Java Applets • Projects University of Alberta Dr. Osmar R. Zaïane, 2001 1 Dr. Osmar R. Zaïane, 2001 2 2 Web Technologies and Applications University of Alberta Web Technologies and Applications University of Alberta Outline of Lecture 11 Objectives of Lecture 11 SGML to XML SGML to XML • Brief Overview of SGML and the Origin of XML • Introduce the Extensible Markup Language • Introduction to XML XML and discuss its use. • Examples of XML Documents • Understand the parsing of XML documents • Syntax and Document Type Definition and how XML can be translated to HTML • Parsing XML for display • See examples of XML • Displaying XML: Style (XSL) & Transformation (XSLT) • Examples and Case Study Dr. Osmar R. Zaïane, 2001 Dr. Osmar R. Zaïane, 2001 3 4 Web Technologies and Applications University of Alberta Web Technologies and Applications University of Alberta
Brief Overview of SGML & the Origin of XML SGML, What is it for? • Separation: Syntax rules + content • SGML stands for Standard Generalized Markup document • Many sophisticated options DTD Language • SGML is a meta language, a language for defining other • Focuses on content structure languages. • Very powerful for creating: document document DTD • It was developed in the 1970s and was used by large document – Manuals corporations for representing content of large – Books documents. – Catalogs • SGML is very flexible and provides a set of features for – Document collection describing content of small documents such as short memos, or very long and complex documents such as – … technical manuals in several printed volumes. Dr. Osmar R. Zaïane, 2001 5 Dr. Osmar R. Zaïane, 2001 6 Web Technologies and Applications University of Alberta Web Technologies and Applications University of Alberta Simplified SGML Problems with SGML • SGML has too many optional features making • HTML is derived from SGML and so is XML the language complex • XML is a simplified version of SGML without the • SGML standard is very long and complicated many features that do not apply in the Web context. � difficult to maintain SGML � difficult to build parsers � difficult for programmers to write processing HTML XML programs � difficult to mark up content • XML is a meta-language with SGML flexibility and structure but without SGML complexities � Not always legible Dr. Osmar R. Zaïane, 2001 Dr. Osmar R. Zaïane, 2001 7 8 Web Technologies and Applications University of Alberta Web Technologies and Applications University of Alberta
Introduction to XML Outline of Lecture 11 • XML the eXtensible Markup Language is a • Brief Overview of SGML and the Origin of XML standard of the World-Wide Web Consortium • Introduction to XML • The official current version is 1.0 and was originally recommended in 1998 • Examples of XML Documents • The official specification from the W3C are: • Syntax and Document Type Definition http://www.w3.org/TR/1998/REC-xml-19980210 • Parsing XML • More info can be found at: http://www.w3.org/XML/ • Displaying XML: Style (XSL) & Transformation (XSLT) • Many working groups and advisory boards are • Examples and Case Study currently enhancing XML Dr. Osmar R. Zaïane, 2001 9 Dr. Osmar R. Zaïane, 2001 10 Web Technologies and Applications University of Alberta Web Technologies and Applications University of Alberta HTML vs. XML What is Special with XML <?xml version=“1.0” encoding=“ISO8859-1” ?> <Products> <product ID="123"> HTML • It is a language to markup data <HTML> <ProdName>Shovel</ProdName> conveys the <BODY> <price>10.59</price> <H1>Shovel</H1> <Quantity>4</Quantity> • There are no predefined tags like in HTML look-n-feel <H2>10.59</H2> </product> <H2>4</H2> <product ID="456"> <H1>Rake</H1> <ProdName>Rake</ProdName> • Extensible � tags can be defined and <H2>15.00</H2> <price>15.00</price> <HTML> <H2>1</H2> <Quantity>1</Quantity> <BODY> extended based on applications and needs <H1>Hoe</H1> </product> <Table border=1><TR> <H2>12.99</H2> <product ID="789"> <td>Shovel</td> <H2>2</H2> <ProdName>Hoe</ProdName> <td>10.59</td> <td>4</td> • Basically, you can create your own tags and </BODY> <price>12.99</price> </tr><tr> </HTML> <Quantity>2</Quantity> <td>Rake</td> </product> associate meanings to them <td>15.00</td><td>1</td> </Products> </tr><tr> Easy for us to <td>Hoe</td> In XML tags have • You need to follow rules for creating and pinpoint the <td>12.99</td> <td>2</td> </tr></table> meanings � easy for price of a hoe, </BODY> using tags </HTML> a program to find the but what about price of a hoe. a program? Dr. Osmar R. Zaïane, 2001 Dr. Osmar R. Zaïane, 2001 11 12 Web Technologies and Applications University of Alberta Web Technologies and Applications University of Alberta
XML inside HTML Rules for Creating XML Documents • Some browsers, such as Microsoft Internet Explorer allow XML inside an HTML document with the <XML> tag • Rule 1 : All terminating tags shall be closed <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <TABLE BORDER = "1" DATASRC = "#xmlDoc"> <BODY> – Omitting a closing XML tag is an error. Example: <THEAD> <XML ID = "xmlDoc"> <TR> <TH>Product Name</TH> <Products> <FirstName>Osmar</FirstName> <TH>Quantity</TH><TH>Price</TH></TR> <product ID="123"> <THEAD> <ProdName>Shovel</ProdName> • Rule 2 : All non-terminating tags shall be closed <TR> <price>10.59</price> <TD><SPAN DATAFLD = "ProdName"></SPAN></TD> <Quantity>4</Quantity> <TD><SPAN DATAFLD = "Quantity"></SPAN></TD> </product> – Omitting a forward slash for non-terminating tags is an error. <TD><SPAN DATAFLD = "price"></SPAN></TD> <product ID="456"> </TR> <ProdName>Rake</ProdName> Example <Available answer=“yes”/> </TABLE> <price>15.00</price> </BODY> <Quantity>1</Quantity> </HTML> • Rule 3 : XML shall be case sensitive </product> <product ID="789"> <ProdName>Hoe</ProdName> – Using the wrong case is an error. Example: <price>12.99</price> <Quantity>2</Quantity> <FirstName>Osmar</firstname> </product> </Products> – It is OK in HTML <H1>my header</h1> </XML> <XML ID=“xmlDoc” src=“products.xml”></xml> Dr. Osmar R. Zaïane, 2001 13 Dr. Osmar R. Zaïane, 2001 14 Web Technologies and Applications University of Alberta Web Technologies and Applications University of Alberta More Rules for Creating XML What is needed? • Rule 4 : An XML document shall have one root • XML needs to be parsed to check whether – Attempting to create more than one root element would generate a syntax error the documents are well formed • Rule 5 : Nesting tag terminations shall not be allowed • XML needs to be printed – Closing a parent tag before closing a child’s tag is an error. • XML needs to be interpreted for Example <Author><name>Osmar</Author></name> – It is OK in HTML <b><I>bold italic text</b></I> information exchange or populating • Rule 6 : Attributes shall be quoted database – Omitting quotes, either single or double, around and XML • XML needs to be queried efficiently attribute’s value is an error. Example <Product ID=“123”> Dr. Osmar R. Zaïane, 2001 Dr. Osmar R. Zaïane, 2001 15 16 Web Technologies and Applications University of Alberta Web Technologies and Applications University of Alberta
Recommend
More recommend