Comp 2513 XML e Xtensible Markup Language Daniel
Comp 2513 XML – e. Xtensible Markup Language Daniel L. Silver, Ph. D. 2001 Daniel L. Silver
Objectives To discuss problems with the HTML based web and introduce XML (and related methods) as the next generation markup language n References: DDEA Ch. 8, Sharma Ch. 7 and External Web Links n 2002 Daniel L. Silver 2
Outline Problems with the HTML based Web n The XML idea n XML fundamentals n XML use n 2002 Daniel L. Silver 3
Problems with the HTML based Web n n n HTML documents focus on display and not structure and meaning of data - an information maze devoid of meaning Inefficient use of tags (every instance of data must be tagged) Fixed number of tags - can not be extended (not extensible) HTML search is based on keywords without context Client-server applications cannot easily exchange data using HTML 2002 Daniel L. Silver 4
HTML focuses on display syntax HTML tags such as <B>Simpson<B> tell how to display the word “Simpson” n Focus is on presentation (format, syntax) n But its does not define what “Simpson” means n – A persons name? A city? A company? n Or its structural relationship to other data – Full name? Last name? First name? 2002 Daniel L. Silver 5
The XML idea e. Xtensible Markup Language n XML defines meaning (semantics): <lname>Simpson<lname> n In terms of structural relationships … <mail_adrs> n Independent of <fname>Homer<fname> presentation n <lname>Simpson<lname> <strnum>1234<strnum> <str>Hickup Lane<str> <mail_adrs> 2002 Daniel L. Silver 6
What is XML? n 1996 - A simplified form of SGML for the web (Standardized General Markup Language) n n SGML Both machine and human readable Separates content, structure XML HTML and presentation Extensible (users can define structure and meaning) Supports information reuse and processing autonomy (application decides how to use/present) 2002 Daniel L. Silver 7
The W 3 C’s Basic Requirements for XML n n n n n 2002 XML shall be straightforwardly usable over the Internet. XML shall support a wide variety of applications. XML shall be compatible with SGML. It shall be easy to write programs which process XML documents. The number of optional features in XML is to be kept to the absolute minimum, ideally zero. XML documents should be human-legible and reasonably clear. XML documents should be easy to prepare. The design of XML shall be formal and concise. Terseness in XML markup is of minimal importance. Daniel L. Silver 8
XML Fundamentals <? xml version = "1. 0"? > … <contacts> <contact> <Last. Name>Black</Last. Name> <First. Name>John</First. Name> </contact> … </contacts> XML Content <!ELEMENT contacts (contact)* > <!ELEMENT contact (Last. Name, First. Name) > <!ELEMENT Last. Name (#PCDATA) > <!ELEMENT First. Name (#PCDATA) > Presentation in Context DTD Structure XSL Presentation <? xml version="1. 0"? > <xsl: stylesheet xmlns: xsl = "http: //www. w 3. org/TR/WD-xsl"> … 2002 Daniel L. Silver 9
XML’s Intended Use n n n Standard format for exchanging data Promote cross-platform and cross-application schema – independent of data content, use and presentation Oriented toward giving meaning to data, and does not emphasize display issues Client – describes valid data for display Server – describes valid data for exchange 2002 Daniel L. Silver 10
XMLs Intended Use n n Allows organizations to maintain proprietary databases while at the same time communicate information with one another Schemas for specific domains have been created: – – – 2002 Music Chemical symbols Mathematical formulas Common industry models (EDI for B 2 B) Web resource descriptions (directories, addresses) Daniel L. Silver 11
XML versus HTML XML is not a replacement for HTML n XML and HTML were designed with different goals: n – HTML was designed to display data and to focus on how data looks – XML was designed to describe data and to focus on what data means n They complement each other 2002 Daniel L. Silver 12
XML e. Xtensibility XML allows you to create your own definitions of data and there relationship to other pieces of data <? xml version="1. 0"? > n Thus the name <People> <Person> e. Xtensible <Name> <First>Patrick</First> n ** Note that XML is <Last>Joe</Last> </Name> case sensitive ** </Person> n </People> 2002 Daniel L. Silver 13
Using IE to Explore XML You can use Internet Explorer to view an XML document directly n A plus (+) or minus sign (-) to the left of the XML elements can be clicked to expand or collapse the element structure n Or view the raw XML source using "View Source" from the browser menu n Example: cd_catalog. xml n 2002 Daniel L. Silver 14
Defining XML Structure DTD – Document Type Definition defines the fields in an XML document and their relation to one another (schema) n Meta-data : data about data n Can be included in. xml file <!ELMENT People (Person)* > <!ELMENT Person (Name) > <!ELMENT Name (First, Last) > or referenced as a. dtd file <!ELMENT First (#PCDATA) > <!ELMENT Last (#PCDATA) > n Used by applications to validate XML data n 2002 Daniel L. Silver 15
Processing an XML Document <? xml version="1. 0"? > <People> <Person> <Name> <First>Patrick</First> <Last>Joe</Last> </Name> </Person> </People> XML Content DOM = Document Object Model SAX = Simple API for XML 2002 <!ELMENT People (Person)* > <!ELMENT Person (Name) > <!ELMENT Name (First, Last) > <!ELMENT First (#PCDATA) > <!ELMENT Last (#PCDATA) > DTD Structure An application that wishes to use XML data should parse the data using a DTD. There are two approaches: • DOM – read the entire document using the DTD and build a tree of elements • SAX – parse on demand (interactively) as each new element is encountered Daniel L. Silver 16
Processing an XML Document Internet Explorer 5. 0 (+) has a built in DOM -based XML parser, msxml n DTD can be embedded in XML or referenced n Examples: n – simple_example. xml with DTD embedded – letter. xml and letter. dtd 2002 Daniel L. Silver 17
Displaying XML Documents Can be accomplished in various ways, any program that can parse the XML can display the information n Here is a simple HTML solution … n – simple_contact. html - XML is embedded, DTD is not required n Javascript could be used instead – article. xml and DOMexample. html – note. xml and note. html 2002 Daniel L. Silver 18
Displaying XML Documents n An XSL – e. Xtensible Stylesheet Layout can be used <? xml version="1. 0"? > <xsl: stylesheet xmlns: xsl = "http: //www. w 3. org/TR/WD-xsl"> … n Examples: Basic - contact 3. xml using contact_list 3. xsl Full function – contact. xml using contact_list. xsl Handheld – contact 2. xml using contact_list 2. xsl 2002 Daniel L. Silver 19
Transferring Data with XML n It is possible to use XML as a method of transferring meaningful data between applications even when application databases do not match JDBC DB 2 n App A XML ODBC App B Common DTD Oracle Adherence to XML DTD is the key 2002 Daniel L. Silver 20
Smart Searches on the Internet With XML and DTDs, keyword searches on the Internet can now be aimed at the appropriate systems, databases, pages n A syntactic search using IE: n “cook New York kitchen restaurant” … would become … n A semantic search: <occupation>cook</occupation> <city>New York</city> 2002 Daniel L. Silver 21
VXML Voice XML n Sound embedded as content and processed as per style sheet n Other media types will be used as well n 2002 Daniel L. Silver 22
eadmin and XML Eadmin n load. jsp? id=91 n servlet/Load. Store n Store. Loader(store, xmlfile) n store. xml 2002 store. dtd Daniel L. Silver 23
References http: //www. w 3. org/XML/ n http: //www. xmlfiles. com/xml/ n 2002 Daniel L. Silver 24
THE END danny. silver@acadiau. ca 2001 Daniel L. Silver
XML e. Xtensible Markup Language n HTML tags such as <B>Silver<B> tell how to display the word “Silver” n But its does not define what it means n XML defines meaning: <last_name>Silver<last_name> n And to create structure … n 2002 Daniel L. Silver 26
Major Architectural Components of the Web Bank Server Dedicated Client 1 Browser Client 2 HTTP TCP/IP Server A Internet HTTP Server Browser URL Server B 2002 App. Server index. html Database Server prog. cgi Bank Server Daniel L. Silver 27
- Slides: 27