DECO 3002 Advanced Technology Integrated Design Computing Studio Tutorial 5 – XML Basic School of Architecture, Design Science and Planning Faculty of Architecture Wei Peng [email protected]What is XML ? XML stands for eXtensible Markup Language which is a cross-platform, software and hardware independent tool for transmitting information XML is a markup language much like HTML – also a subset of Standard Generalized Markup Language (SGML) XML is for describing the data as HTML for displaying the data Before we introduce XML, have a look at HTML HTML (HyperText Markup Language) was introduced by Tim Berners-Lee and his colleagues in 1989 in order to manage and share large amounts of information among colleagues
21
Embed
DECO 3002 Advanced Technology Integrated Design Computing Studio Tutorial 5 – XML Basic School of Architecture, Design Science and Planning Faculty of.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture
XML stands for eXtensible Markup Language which is a cross-platform, software and hardware independent tool for transmitting information
XML is a markup language much like HTML – also a subset of
Standard Generalized Markup Language (SGML)
XML is for describing the data as HTML for displaying the data
Before we introduce XML, have a look at HTML
HTML (HyperText Markup Language) was introduced by Tim Berners-Lee and his colleagues in 1989 in order to manage and share large amounts of information among colleagues
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture
HTML is a markup language, a structured language that lets you identify common sections of a document in terms of headings, paragraphs, etc.
An HTML file includes text and HTML markup elements that indicate how the document sections appear in a browser
Examples: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN“> <HTML> <HEAD><TITLE>XML Introduction - What is XML</TITLE> </HEAD> <BODY> <H2>XML is a complement to HTML</H2> <P><B>XML is not a replacement for HTML.</B></P> <P> …… </P> …… </BODY> </HTML>
HTML mixed style information within the structure limits the cross-platform compatibility of the content
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture
Separating display information lets you reorient your content for multiple destinations.
Separation of style and structure was accomplished in 1996 by the W3C’s (www.w3c.org) specification for a Web style language named Cascading Style Sheets (CSS).
CSS only sets the format and placement of elements.
Such as:
Title (display: block; font-size: 16pt; font-weight: bold)
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture
XML was designed to describe data and focus on what data is. While HTML was designed to display data and focus on how data looks.
XML tags are not predefined – you must define your own tags – XML is thus a language that lets you describe a markup language, allowing you to create your own elements to meet your information needs.
XML is a complement to HTML, not a replacement for HTML – In future Web development it is most likely that XML will be used to describe the data, while HTML will be used to format and display the same data.
XML uses a Document Type Definition (DTD) or an XML Schema to describe the data
XML with a DTD or XML Schema is designed to be self-descriptive
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture
XML can separate data from HTML – in terms of data islands;
XML is used to exchange data – with XML, data can be exchanged between incompatible systems – relieve developers from the most time-consuming challenges;
XML and B2B – with XML, financial information can be exchanged over the Internet; XML is going to be the main language for exchanging financial information between businesses over the Internet;
XML can be used to share data because XML data is stored in plain text format, which provides a software- and hardware-independent way of sharing data;
XML can be used to store data – can be next generation database;
XML can be used to create new languages – such as WML (Wireless Markup Language) which is used to markup Internet applications for handheld devices like mobile phones.
…….
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture
An example: <?xml version="1.0" encoding="ISO-8859-1"?> XML declaration - defines the XML version and the character encoding
used in the document <note> -------------------------------------------------- this document is a note
<to>Bill</to> --------------------------------------- to Bill
<from>Hulk</from> ------------------------------- from Hulk
<heading>Reminder</heading> --------------- to remind Bill
<body>Don't forget to patch up my windows</body> </note>
All XML elements must have a closing tag – unlike HTML; XML tags are case sensitive – unlike HTML; All XML elements must be properly nested – <b> <i>This text is bold and italic</b></i> – not correct!!
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture
XML elements can have attributes in the start tag, just like HTML, which are used to provide additional information about elements;
such as <file type="gif">robot.gif</file>
Quote Styles, “male" = ‘male'? <person sex=“male"> should be same as <person sex='male'>
It is preferable to store data at bottom level: <note> <date> <day>12</day> <month>11</month> <year>2002</year> </date> <to>Bill</to> <from>Hulk</from> <heading>Reminder</heading> <body>Don't forget to patch up my windows!</body> </note>
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture
An XML document that has correct XML syntax is called “well formed”.
A valid XML file is well-formed file which has a Document Type Definition (DTD) and which conform to it.
The purpose of a DTD is to define the legal building blocks of an XML document. A DTD is for specifying the structure (only) of an XML file: it gives the names of the elements, attributes, and entities that can be used, and how they fit together.
XML Schema is an XML based alternative to DTD.
A valid file begins with a Document Type Declaration, but may have an optional XML Declaration pre-pended:
<?xml version="1.0"?> <!DOCTYPE advert SYSTEM "http://www.foo.org/ad.dtd"> <advert> <headline>...</headline> <text>...</text> </advert>
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture
A DTD can be declared inline in your XML document, or as an external reference.
Internal DOCTYPE declaration If the DTD is included in your XML source file, it should be wrapped in a DOCTYPE definition with the
following syntax: <?xml version="1.0"?> <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]> <note> <to>Bill</to> <from>Hulk</from> <heading>Reminder</heading> <body>Don't forget to patch up my windows!</body> </note>
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture
External DOCTYPE declaration: If the DTD is external to your XML source file, it should be wrapped in a DOCTYPE definition with the following syntax: <!
DOCTYPE root-element SYSTEM "filename">
Example: <?xml version="1.0"?> <!DOCTYPE note SYSTEM "note.dtd"> <note> <to>Bill</to> <from>Hulk</from> <heading>Reminder</heading> <body>Don't forget to patch up my windows!</body> </note>
The file note.dtd looks like: <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>
DECO 3002 Advanced Technology Integrated Design Computing Studio
Tutorial 5 – XML Basic
School of Architecture, Design Science and PlanningFaculty of Architecture