Download presentation
Presentation is loading. Please wait.
Published byBlaze Short Modified over 9 years ago
1
Computer Information Systems Information Systems California State University Los Angeles Jongwook Woo CIS 561 Design of an E-Commerce Site Introduction to XML Jongwook Woo, PhD jwoo5@calstatela.edu California State University, Los Angeles Computer Information Systems Department
2
CSLA Computer Information Systems Information Systems Jongwook Woo 2 What is XML nstands for EXtensible Markup Language nXML is a markup language much like HTML nXML was designed to describe data nXML tags are not predefined. mYou must define your own tags nuses a Document Type Definition (DTD) or an XML Schema to describe the data mXML with a DTD or XML Schema is designed to be self-descriptive na W3C Recommendation
3
CSLA Computer Information Systems Information Systems Jongwook Woo 3 XML and HTML nThe Extensible Markup Language (XML) became a W3C Recommendation 10. February 1998. nThe Main Difference Between XML and HTML mXML was designed to carry data. –XML was designed to describe data and to focus on what data is. XML is about describing information mXML is not a replacement for HTML. –HTML was designed to display data and to focus on how data looks. HTML is about displaying information.
4
CSLA Computer Information Systems Information Systems Jongwook Woo 4 XML does not do anything nXML was created to structure, store and to send information Tove Jani Reminder Don't forget me this weekend! nIt is just pure information wrapped in XML tags. mSomeone must write a piece of software to send, receive or display it.
5
CSLA Computer Information Systems Information Systems Jongwook Woo 5 XML is Free and Extensible nXML tags are not predefined. mYou must "invent" your own tags. –define your own tags and your own document structure. mHTML tags –are predefined. The tags used to mark up HTML documents and the structure of HTML documents –use tags (like,, etc.). nThe tags in the example above (like and ) are not defined in any XML standard. mThese tags are "invented" by the author of the XML document.
6
CSLA Computer Information Systems Information Systems Jongwook Woo 6 XML is a Complement to HTML nXML is not a replacement for HTML. mused to describe the data, mwas designed to store, carry, and exchange data. mnot designed to display data –while HTML will be used to format and display the same data. nXML characteristics: mcross-platform, software and hardware independent tool for transmitting information. nXML is going to be everywhere in Web Development mHTML has been to the foundation of the Web mXML –the XML standard has been developed quickly a large number of software vendors have adopted the standard quickly. –will be the most common tool for all data manipulation and data transmission.
7
CSLA Computer Information Systems Information Systems Jongwook Woo 7 How can XML be Used nXML can Separate Data from HTML mWith XML, your data is stored outside your HTML. –When HTML is used to display data, the data is stored inside your HTML. –With XML, data can be stored in separate XML files. mconcentrate on using HTML for data layout and display, –changes in the underlying data will not require any changes to your HTML. nData Islands mXML data can also be stored inside HTML pages nXML Usage mExchange Data in incompatible data format –Share, Store data mB2B mFor more users mFor new XML language
8
CSLA Computer Information Systems Information Systems Jongwook Woo 8 XML is Used to Exchange Data ndata can be exchanged between incompatible systems. mIn the real world, computer systems and databases contain data in incompatible formats. –Datasource DB: Oracle, DB2, MS SQL etc. Repository mdevelopers need to build system to exchange data between such systems –Normally over the Internet these days. –One of the most time-consuming challenges for companies and developers mConverting the data to XML –and create data that can be read by many different types of applications –can greatly reduce this complexity
9
CSLA Computer Information Systems Information Systems Jongwook Woo 9 Other XML usages and B2B nWith XML, financial information can be exchanged over the Internet. mthe main language for exchanging financial information between businesses over the Internet. nXML Can be Used to Share Data mXML data is stored in plain text format, –XML provides a software- and hardware-independent way of sharing data. mmuch easier to create data that different applications can work with. measier to expand or upgrade a system to new operating systems, servers, applications, and new browsers.
10
CSLA Computer Information Systems Information Systems Jongwook Woo 10 Other XML usages (Cont’d) nXML Can Make your Data More Useful mXML data is available to more users. mXML data available to other than only standard HTML browsers. –Since XML is independent of hardware, software and application, –Other clients and applications can access your XML files as data sources, like they are accessing databases. –XML data can be made available to all kinds of "reading machines" (agents), EX: VoiceXML, available for blind people, or people with other disabilities.
11
CSLA Computer Information Systems Information Systems Jongwook Woo 11 Other XML usages (Cont’d) nXML Can be Used to Create New Languages mXML is the mother of WAP and WML. –The Wireless Markup Language (WML), used to markup Internet applications for handheld devices like mobile phones, is written in XML. mMany others –VoiceXML, BioXML, MathXML, RSS, Atom etc nIf Developers Have Sense mall future applications will exchange their data in XML. –word processors, spreadsheet applications and databases that can read each other's data in a pure text format, –without any conversion utilities in between.
12
CSLA Computer Information Systems Information Systems Jongwook Woo 12 XML Syntax Rules nvery simple and very strict. mThe rules are very easy to learn, and very easy to use. –creating software that can read and manipulate XML is very easy. mExample Tove Jani Reminder Don't forget me this weekend! mThe first line in the document - the XML declaration – –defines the XML version and the character encoding used in the document. the 1.0 specification of XML ISO-8859-1 (Latin-1/West European) character set.
13
CSLA Computer Information Systems Information Systems Jongwook Woo 13 XML Example (Cont’d) mdescribes the root element of the document –(like it was saying: "this document is a note"): n(to, from, heading, and body) tags mThe next 4 lines describe 4 child elements of the root mAnd finally the last line defines the end of the root element: nthe XML document contains a Note to Tove from Jani mXML is pretty self-descriptive, that is, the developer defines tags
14
CSLA Computer Information Systems Information Systems Jongwook Woo 14 All XML Elements Must Have a Closing Tag nillegal to omit the closing tag. nIn HTML some elements do not have to have a closing tag. mThe following code is legal in HTML: This is a paragraph This is another paragraph nIn XML all elements must have a closing tag: This is a paragraph This is another paragraph nXML declaration did not have a closing tag. mnot an error. mThe declaration is not a part of the XML document itself. –not an XML element, and it should not have a closing tag.
15
CSLA Computer Information Systems Information Systems Jongwook Woo 15 Other Syntaxes nXML Tags are Case Sensitive mUnlike HTML mthe tag is different from the tag. mOpening and closing tags must therefore be written with the same case: This is incorrect This is correct nXML Elements Must be Properly Nested mImproper nesting of tags makes no sense to XML. mIn HTML some elements can be improperly nested within each other: This text is bold and italic mIn XML all elements must be properly nested within each other : This text is bold and italic
16
CSLA Computer Information Systems Information Systems Jongwook Woo 16 Other Syntaxes (Cont’d) nXML Documents Must Have a Root Element mmust contain a single tag pair to define a root element. –Hierarchy All other elements must be within this root element. All elements can have sub elements (child elements). –Sub elements must be correctly nested within their parent element: Indentation is useful for readability of the hierarchy.....
17
CSLA Computer Information Systems Information Systems Jongwook Woo 17 Other Syntaxes (Cont’d) nXML Attribute Values Must be Quoted millegal to omit quotation marks around attribute values. min name/value pairs just like in HTML. –correct: date="12/11/2002". –incorrect: date=12/11/2002. Tove Jani Tove Jani
18
CSLA Computer Information Systems Information Systems Jongwook Woo 18 Other Syntaxes (Cont’d) nWith XML, White Space is Preserved mThis is unlike HTML. –HTML reduces multiple, consecutive white space characters to a single white space. –With HTML, a sentence like this: Hello my name is Tove, will be displayed like this: –Hello my name is Tove, nNew line in XML, mWith XML, a new line is always stored as LF. –CR / LF is Converted to LF mIn Windows applications, –use a pair of characters: carriage return (CR) and line feed (LF). mIn Unix applications, use only a LF character. mMacintosh applications, use only a CR character
19
CSLA Computer Information Systems Information Systems Jongwook Woo 19 Other Syntaxes (Cont’d) nComments in XML mThe syntax for writing comments in XML is similar to that of HTML. nThere is Nothing Special About XML mjust plain text –with the addition of some XML tags enclosed in angle brackets. mSoftware that can handle plain text can also handle XML. –In a simple text editor, the XML tags will be visible and will not be handled specially. –In an XML-aware application however, the XML tags can be handled specially. The tags may or may not be visible, or have a functional meaning, depending on the nature of the application.
20
CSLA Computer Information Systems Information Systems Jongwook Woo 20 XML Elements nXML Elements are Extensible mXML documents can be extended to carry more information. nLook at the following XML NOTE example: Tove Jani Don't forget me this weekend! nLet's imagine that we created an application to produce the output mthat extracted the,, and elements from the XML document : MESSAGE To: Tove From: Jani Don't forget me this weekend!
21
CSLA Computer Information Systems Information Systems Jongwook Woo 21 XML Elements (Cont’d) nthe author of the document added some extra information to it: 2002-08-01 Tove Jani Reminder Don't forget me this weekend! nShould the application break or crash? mNorammly No. –The application should still be able to find the,, and elements in the XML document and produce the same output. mXML documents are Extensible.
22
CSLA Computer Information Systems Information Systems Jongwook Woo 22 XML Elements have Relationships nElements are related as parents and children. mTo understand XML terminology, –you have to know how relationships between XML elements are named, –and how element content is described. nImagine that this is a description of a book: mMy First XML at Introduction to XML –What is HTML –What is XML mXML Syntax –Elements must have a closing tag –Elements must be properly nested
23
CSLA Computer Information Systems Information Systems Jongwook Woo 23 XML Elements have Relationships (Cont’d) My First XML Introduction to XML What is HTML What is XML XML Syntax Elements must have a closing tag Elements must be properly nested nBook is the root element. mchild elements of book. –Title, prod, and chapter are mBook is the parent element of title, prod, and chapter. msiblings (or sister elements) –Title, prod, and chapter because they have the same parent.
24
CSLA Computer Information Systems Information Systems Jongwook Woo 24 XML Elements have Content nElements can have different content types. mAn XML element is everything –from (including) the element's start tag to (including) the element's end tag. mAn element can have –element content, contains other elements –simple content, contains only text –mixed content contains both text and other elements. –empty content carries no information –also have attributes Name/value pair
25
CSLA Computer Information Systems Information Systems Jongwook Woo 25 XML Elements have Content (Cont’d) nIn the example above, book has element content, mbecause it contains other elements. mChapter has mixed content –because it contains both text and other elements. mPara has simple content (or text content) –because it contains only text. mProd has empty content, –because it carries no information. mIn the example above only the prod element has attributes. –The attribute named id has the value "33-657". –The attribute named media has the value "paper".
26
CSLA Computer Information Systems Information Systems Jongwook Woo 26 Element Naming nXML elements must follow these naming rules: mcan contain letters, numbers, and other characters –must not start with a number or punctuation character (.) –must not start with the letters xml (or XML, or Xml, etc) mcannot contain spaces nTake care when you "invent" element names and follow these simple rules: mThe idea is to make names descriptive. –Any name can be used, no words are reserved, mNames with an underscore separator are nice. nExamples:,. nThe ":" should not be used in element names mbecause it is reserved to be used for something called namespaces (more later).
27
CSLA Computer Information Systems Information Systems Jongwook Woo 27 Element Naming (Cont’d) nAvoid "-" and "." in names. mFor example, if you name something "first-name," –it could be a mess if your software tries to subtract name from first. mOr if you name something "first.name," –your software may think that "name" is a property of the object "first." nElement names can be as long as you like, but don't exaggerate. mNames should be short and simple, –like this: not like this:. nXML documents often have a corresponding database, min which fields exist corresponding to elements in the XML document. –use the naming rules of your database for the elements in the XML documents. nNon-English letters like éòá are perfectly legal in XML element names, mbut watch out for problems if your software vendor doesn't support them.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.