Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Technologies COMP6115 Session 4: Adding a Database to a Web Site Dr. Paul Walcott Department of Computer Science, Mathematics and Physics University.

Similar presentations


Presentation on theme: "Web Technologies COMP6115 Session 4: Adding a Database to a Web Site Dr. Paul Walcott Department of Computer Science, Mathematics and Physics University."— Presentation transcript:

1 Web Technologies COMP6115 Session 4: Adding a Database to a Web Site Dr. Paul Walcott Department of Computer Science, Mathematics and Physics University of the West Indies, Cave Hill Campus Barbados 14/12/06 © 2006/2007 Dr. Paul Walcott

2 XML 2 Extensible Markup Language (or XML) is another markup language Extensible Markup Language (or XML) is another markup language XML is a subset of SGML (Standard Generalised Markup Language) XML is a subset of SGML (Standard Generalised Markup Language) –SGML is a meta language used to create other languages, e.g. XML and HTML The purpose of XML is different from HTML The purpose of XML is different from HTML

3 XML describe data in a structured way and is used to define other markup languages XML describe data in a structured way and is used to define other markup languages XML allows the creation of custom tags (unlike HTML whose tags are predefined) XML allows the creation of custom tags (unlike HTML whose tags are predefined) XML uses a DTD to describe the data XML uses a DTD to describe the data Several XML standards have been defined, for example to markup mathematical formula, and chemical molecular structures Several XML standards have been defined, for example to markup mathematical formula, and chemical molecular structures XML Cont’d

4 The main difference between XML and HTML are: 1 The main difference between XML and HTML are: 1 –XML was designed to carry data –HTML is about displaying information, while XML is about describing information –XML is not a replacement for HTML XML Cont’d

5 XML and HTML were designed with different goals: XML and HTML were designed with different goals: –XML was designed to describe data and to focus on what data is. –HTML was designed to display data and to focus on how data looks. XML Cont’d

6 XML Document Structure 2 XML documents are typically stored in text files with a.xml extension XML documents are typically stored in text files with a.xml extension An XML document contains one root element, which contains all other elements An XML document contains one root element, which contains all other elements The lines preceding the root element are the prolog of the XML document The lines preceding the root element are the prolog of the XML document Nested elements are called child elements Nested elements are called child elements

7 An XML parser is required to process an XML document An XML parser is required to process an XML document The XML parser The XML parser –Checks the document’s syntax –Reports any errors –Allows access to the contents of the document through program control XML Document Structure Cont’d

8 An XML document is well formed if An XML document is well formed if –It has one root element –It has a start and end tag for each element Except in the case of empty tags that have a special notation that allows the representation of a start and end tag in a single tag Except in the case of empty tags that have a special notation that allows the representation of a start and end tag in a single tag –The tags are properly nested E.g. 100 is a cross tag while 100 is properly nested E.g. 100 is a cross tag while 100 is properly nested

9 XML Document Structure Cont’d –Attribute values are in quotation marks, either single or double –Elements and attributes are correctly capitalised since XML is case sensitive

10 XML Document Structure Cont’d XML documents typically contain XML documents typically contain –Carriage returns, –Linefeeds –Elements and attributes –Unicode characters XML elements define structure XML elements define structure XML attributes describe elements XML attributes describe elements

11 XML Document Structure Cont’d An element may have zero or more attributes An element may have zero or more attributes Attributes are placed within the the start tag Attributes are placed within the the start tag Attribute values are enclosed in single or double quotes Attribute values are enclosed in single or double quotes

12 XML Document Structure Cont’d Element and attribute names: Element and attribute names: –May be of any length –May contain letters, digits, underscores, hyphens and periods –Must begin with a letter or underscore Spaces are not allowed in element or attribute names Spaces are not allowed in element or attribute names

13 XML Document Structure Cont’d If an element contains no data it is called an empty element, e.g. If an element contains no data it is called an empty element, e.g. – – An empty tag may be written more concisely as: An empty tag may be written more concisely as: For example, the before-mentioned element may be rewritten as: For example, the before-mentioned element may be rewritten as: – –

14 XML Parsers There are two main types of XML parsers There are two main types of XML parsers –Parsers that support the Document Object Model (DOM) –Parsers that support the Simple API for XML (SAX)

15 XML Parsers Cont’d A DOM parser builds a tree structure in memory that contains the document data A DOM parser builds a tree structure in memory that contains the document data A SAX parser processes the document and generates events when certain conditions are met, e.g. A SAX parser processes the document and generates events when certain conditions are met, e.g. –When the start of an element is encountered an event is triggered; the software can then read and the element name and its attributes and respond appropriately

16 XML Parsers Cont’d Some examples of XML Parsers are: Some examples of XML Parsers are: –msxml – Microsoft’s parser which is built into Microsoft Internet Explorer –Xerces – Apache’s XML project’s parser –JAXP – Sun Microsystem’s Java API for XML Parsing –XML4J – IBM’s XML parser for Java Many of these parsers are freely available Many of these parsers are freely available


Download ppt "Web Technologies COMP6115 Session 4: Adding a Database to a Web Site Dr. Paul Walcott Department of Computer Science, Mathematics and Physics University."

Similar presentations


Ads by Google