CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

Transforming XML XMLNamespaces, XSLT. XML Namespaces Sometimes it is necessary to mix XML elements –Different types of content –Use of markup to convey.
What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
An Introduction to XML Based on the W3C XML Recommendations.
XML XML What XML is and what it means to me as a Computer Scientist By: Derek Edwards CS 376 March 10, 2003.
INF201 Fall2010 Intro. to Info. Technologies Department of Informatics University at Albany – SUNY Original Source: w3schools.com Prepared by Xiao Liang,
Lecture 10. Back to the table example We can now return to considering in detail the first XSLT style-sheet we saw –The one which, when applied to the.
IS 373—Web Standards Todd Will
Tutorial 11 Creating XML Document
Introduction to XML: Yong Choi CSU Bakersfield.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
1 HTML’s Transition to XHTML. 2 XHTML is the next evolution of HTML Extensible HTML eXtensible based on XML (extensible markup language) XML like HTML.
Understanding Page Template Components Lila Bronson Training Manager, OmniUpdate, Inc.
Introduction to XML This material is based heavily on the tutorial by the same name at
Introducing HTML & XHTML:. Goals  Understand hyperlinking  Understand how tags are formed and used.  Understand HTML as a markup language  Understand.
Introduce of XML Xiaoling Song CS157A. What is XML? XML stands for EXtensible Markup Language XML stands for EXtensible Markup Language XML is a markup.
ECA 228 Internet/Intranet Design I Intro to XML. ECA 228 Internet/Intranet Design I HTML markup language very loose standards browsers adjust for non-standard.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
 Using Microsoft Expression Web you can: › Create Web pages and Web sites › Set what you site will look like as you design it › Add text, images, multimedia.
Working with Namespaces Combining XML Vocabularies in a Compound Document.
WORKING WITH NAMESPACES
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
XML introduction to Ahmed I. Deeb Dr. Anwar Mousa  presenter  instructor University Of Palestine-2009.
DAT602 Database Application Development Lecture 14 HTML.
E X TENSIBLE M ARKUP L ANGUAGE (XML). What is XML?  XML stands for EXtensible Markup Language  XML is mainly designed to carry (or transmit) data, not.
CREATED BY ChanoknanChinnanon PanissaraUsanachote
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
XSLT transformations Or how to get your XML to become HMTL.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
WORKING WITH XSLT AND XPATH
Session II Chapter 2 – Chapter 2 – XSLhttp://
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
XML About XML Things to be known Related Technologies XML DOC Structure Exploring XML.
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
1 Dr Alexiei Dingli XML Technologies XML Advanced.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
CIS 375—Web App Dev II XSL. 2 XSL Introduction XSL stands for _____________________________. XSL is the language used for manipulating and displaying.
XML eXtensible Markup Language. Topics  What is XML  An XML example  Why is XML important  XML introduction  XML applications  XML support CSEB.
CIS 275—Web App Dev I XML. 2 Introduction to XMLXML XML stands for ________________________. HTML was designed to display data. XML was designed to _________.
Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
XML EXtensible Markup Language. Agenda Introduction to XML XML Rules XML Elements XML Attributes XML Validation XML Exercises XML Namespaces XML CDATA.
What it is and how it works
XML Design Goals 1.XML must be easily usable over the Internet 2.XML must support a wide variety of applications 3.XML must be compatible with SGML 4.It.
XML Basics A brief introduction to XML in general 1XML Basics.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
IS446: Internet Software Development Dr. Azeddine Chikh.
1 Tutorial 12 Working with Namespaces Combining XML Vocabularies in a Compound Document.
XML Presented by Kushan Athukorala. 2 Agenda XML Overview Entity References Elements vs. Atributes XML Validation DTD XML Schema Linking XML and CSS XSLT.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
Web Technologies Lecture 4 XML and XHTML. XML Extensible Markup Language Set of rules for encoding a document in a format readable – By humans, and –
IS444: Modern software development tools Dr. Azeddine Chikh.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
VCE IT Theory Slideshows by Mark Kelly study design By Mark Kelly, vceit.com, Begin.
XML – Basic Concepts (modified version from Dr. Praveen Madiraju) 2015, Fall Pusan National University Ki-Joune Li.
XML Introduction to XML Extensible Markup Language.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
XML intro. What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display.
XML stands for Extensible Markup Language.
Presentation transcript:

CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute of Information TechnologyT2-Lecture-4

eXtensible Markup Language (XML) Part - II For Lecture Material/Slides Thanks to:

Objectives XML Elements are extensible XML Attributes XML Namespaces XML Encoding Viewing XML Files 3 T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Elements are Extensible 4 XML elements can be extended to carry more information. Look at the following XML example: ◦ mumtaz tariq Don't forget to attend party on weekend! Let's imagine that we created an application that extracted the,, and elements from the XML document to produce this output: T2-Lecture-3 Ahmed Mumtaz Mustehsan Message To: Mumtaz From: Tariq Don't forget to attend party on weekend!

XML Elements are Extensible… 5 Imagine that the author of the XML document added some extra information to it: Mumtaz Tariq Reminder Don't forget to attend party on weekend! Should the application break or crash? No. The application should still be able to find the,, and elements in the XML document and produce the same output. One of the beauty of XML, is that it can be extended without breaking applications. T2-Lecture-3 Ahmed Mumtaz Mustehsan Message To: Mumtaz From: Tariq Don't forget to attend party on weekend!

XML Attributes

XML Attributes 7 In HTML, attributes provide additional information about elements: XML elements can have attributes, just like HTML. Attributes often provide information that is not a part of the data but it is information about data. Example computer.gif The file type is irrelevant to the data, but can be important to the software that wants to manipulate the element: T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Attributes Must be Quoted 8 Attribute values must always be quoted. Either single or double quotes can be used. Example: For a person's sex, the person element can be written like this: or like this: T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Attributes Must be Quoted 9 If the attribute value itself contains double quotes we can use single quotes. Example: or you can use character entities: T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Elements vs. Attributes 10 Example-1: Amna Atif Example-2: female Amna Atif T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Elements vs. Attributes… 11 In Example-1, sex is an attribute. In Example-2, sex is an element. Both examples provide the same information. Although there are no rules about when to use attributes or when to use elements, Attributes are handy in HTML. However: Recommendations are: In XML avoid attribute and use elements. T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML: Different ways to define information. 12 In XML documents the same information can be presented in different ways. The date is presented in three different ways: Example-1: A date is defined as an attribute: Mumtaz Tariq Reminder Don't forget me this weekend! T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML: Different ways to define information. 13 Example-2: A date is defined as an element : ◦ 10/01/2008 Mumtaz Tariq Reminder Don't forget me this weekend! T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML: Different ways to define information. 14 Example-3: A date is defined as an expanded date element: Mumtaz Tariq Reminder Don't forget me this weekend! T2-Lecture-4 Ahmed Mumtaz Mustehsan

Avoid XML Attributes? 15 Some of the problems with using attributes are: attributes cannot contain multiple values (elements can) attributes cannot contain tree structures (elements can) attributes are not easily expandable (for future changes) Attributes are difficult to read and maintain. Recommendations: Use elements for data. Use attributes for information that is not relevant to the data. Don't end up like this: ◦ T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Attributes for Metadata 16 Sometimes ID references are assigned to elements. These IDs can be used to identify XML elements the same way as the id attribute in HTML. Example: mumtaz tariq Reminder Don't forget me this weekend! mumtaz tariq Re: Reminder Thank you for attending the party T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Attributes for Metadata… 17 The id attributes above are for identifying the different notes. It is not a part of the note itself. Recommendations: Metadata (data about data) should be stored as attributes, and the data itself should be stored as elements. T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Namespaces

Before we Begin: a review of URI 19 Uniform Resource Identifier (URI) : A Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource. The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address. Another, not so common type of URI is the Universal Resource Name (URN). In our examples we will only use URLs. T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Namespaces 20 In XML, element names are defined by the developer. This often results in a conflict when trying to mix XML documents from different XML applications. XML Namespaces provide a method to avoid element name conflicts. Example-1: This XML example carries HTML table information: Apples Bananas T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Namespaces… 21 Example-2: This XML example carries information about a table (a piece of furniture): African Coffee Table If these XML fragments were added together, there would be a name conflict. Both contain a element, but the elements have different content and meaning. A user or an XML application will not know how to handle these differences. T2-Lecture-4 Ahmed Mumtaz Mustehsan

Solving the Name Conflict Using a Prefix 22 Name conflicts in XML can easily be avoided using a name prefix. This XML carries information about an HTML table, and a piece of furniture: ◦ Apples Bananas African Coffee Table In the example above, there will be no conflict because the two elements have different names. But are we allowed to use prefix with a : ? T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Namespaces : The xmlns Attribute 23 When using prefixes in XML namespace namespace for the prefix must be defined. xmlns attribute The namespace is defined by the xmlns attribute in the start tag of an element. The namespace declaration has the following syntax: Example xmlns:prefix="URI". T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Namespaces - The xmlns Attribute 24 The namespace declaration as an attribute can be defined: xmsns Example-1: each attribute is defined with separate xmsns Apples Bananas African Coffee Table T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Namespaces - The xmlns Attribute… 25 The namespace declaration as an attribute can be defined: xmsns defination Example-1: each attribute is defined with combined xmsns defination Apples Bananas African Coffee Table Note: The namespace URI is not used by the parser to look up information. The purpose is to give the namespace a unique name. However, often companies use the namespace as a pointer to a web page containing namespace information. T2-Lecture-4 Ahmed Mumtaz Mustehsan

Default Namespaces 26 Defining a default namespace for an element saves us from using prefixes in all the child elements. It has the following syntax: xmlns="namespaceURI" Example: 1. This XML carries HTML table information: Apples Bananas 2. This XML carries information about a piece of furniture: African Coffee Table T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Encoding

XML Encoding 28 XML documents may contain international characters, like Norwegian æøå, or French êèé. To avoid errors, we should specify the encoding used, or save the XML files as UTF-8. Character Encoding ◦ Character encoding defines a unique binary code for each different character used in a document. ◦ In computer terms, character encoding are also called character set, character map, code set, and code page. T2-Lecture-4 Ahmed Mumtaz Mustehsan

Unicode 29 Unicode is an industry standard for character encoding of text documents. It defines (nearly) every possible international character by a name and a number. Unicode has two variants: UTF-8 and UTF-16. UTF = Universal character set Transformation Format. UTF-8 uses a single byte (8-bits) to represent commonly used characters and two (or three) bytes for the rest. UTF-16 uses two bytes (16 bits) for most characters, and three bytes for the rest. T2-Lecture-4 Ahmed Mumtaz Mustehsan

UTF-8 - The Web Standard 30 UTF-8 is the standard character encoding on the web. It (UTF-8) is the default character encoding for: HTML-5, CSS, JavaScript, PHP, SQL, and XML. T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Encoding 31 The first line in an XML document is called the prolog: The prolog is optional. Normally it contains the XML version number. It can also contain information about the encoding used in the document. This prolog specifies UTF-8 encoding: The XML standard states that all XML software must understand both UTF-8 and UTF-16. UTF-8 is the default for documents without encoding information. In addition, most XML software systems understand encodings like ISO , Windows-1252, and ASCII. T2-Lecture-4 Ahmed Mumtaz Mustehsan

XML Errors 32 Most often, ◦ XML documents are created on one computer. ◦ uploaded to a server on a second computer, ◦ displayed by a browser on a third computer. If the encoding is not correctly interpreted by all the three computers, the browser might display meaningless text, or you might get an error message. Example: “This XML file does not appear to have any style information associated with it.” T2-Lecture-4 Ahmed Mumtaz Mustehsan

Conclusion 33 When you write an XML document: Use an XML editor that supports encoding Make sure you know what encoding the editor uses Describe the encoding in the encoding attribute UTF-8 is the safest encoding to use which is a web standard T2-Lecture-4 Ahmed Mumtaz Mustehsan

Viewing XML Files

35 Raw XML files can be viewed in all major browsers. Don't expect XML files to be displayed as HTML pages. - mumtaz tariq Reminder Don't forget me this weekend! The XML document will be displayed with color-coded root and child elements. A plus (+) or minus sign (-) to the left of the elements can be clicked to expand or collapse the element structure. To view the raw XML source (without the + and - signs), select "View Page Source" or "View Source" from the browser menu. Note: In Safari, only the element text will be displayed. To view the raw XML, you must right click the page and select "View Source" T2-Lecture-4 Ahmed Mumtaz Mustehsan

Viewing an Invalid XML File 36 If an erroneous XML file is opened, some browsers might report the error, some may display it incorrectly. Try to open this XML file in different browsers: T2-Lecture-4 Ahmed Mumtaz Mustehsan

Why Does XML Display Like This? 37 XML documents do not carry information about how to display the data. Since XML tags are "invented" by the author of the XML document, browsers do not know if a tag like describes an HTML table or a dining table. Without any information about how to display the data, most browsers will just display the XML document as it is. T2-Lecture-4 Ahmed Mumtaz Mustehsan

The second line links the XML file to the CSS file: Empire Burlesque Bob Dylan USA Columbia Hide your heart Bonnie Tyler UK CBS Records A Section of the XML file. T2-Lecture-4 Ahmed Mumtaz Mustehsan 38

It is possible to use CSS to format an XML document. Below is an example of how to use a CSS style sheet to format an XML document: Take a look at this XML file: The CD catalogThe CD catalog Then look at this style sheet: The CSS fileThe CSS file Finally, view: The CD catalog formatted with the CSS fileThe CD catalog formatted with the CSS file Displaying your XML Files with CSS T2-Lecture-4 Ahmed Mumtaz Mustehsan 39

XML Technologies T2-Lecture-4 Ahmed Mumtaz Mustehsan 40 Some XML Technologies: XML XSLT XML Xpath XML Xlink XML Xpointer XML Xquery Recommended by W3C

Displaying XML with XSLT XSLT (eXtensible Stylesheet Language Transformations) is the recommended style sheet language for XML. XSLT is far more sophisticated than CSS. Elements and attributes can be added/removed Elements can also be rearranged and sorted, perform tests and make decisions about which elements to hide and display, etc. XSLT uses XPath to find information in an XML document. XML - XSLT T2-Lecture-4 Ahmed Mumtaz Mustehsan 41

XPath is Used in XSLT XPath is a syntax for defining parts of an XML document XPath uses path expressions to navigate in XML documents XPath contains a library of standard functions XPath is a major element in XSLT XPath is also used in XQuery, XPointer and XLink XML - Xpath T2-Lecture-4 Ahmed Mumtaz Mustehsan 42

XLink is used to create hyperlinks within XML documents Any element in an XML document can behave as a link XLink supports simple links (like HTML) and extended links (for linking multiple resources together) With XLink, the links can be defined outside the linked files XLink is a W3C Recommendation XML - XLink T2-Lecture-4 Ahmed Mumtaz Mustehsan 43

XPointer allows the links to point to specific parts of an XML document XPointer uses XPath expressions to navigate in the XML document XPointer is a W3C Recommendation XML - XPointer T2-Lecture-4 Ahmed Mumtaz Mustehsan 44

The End XML Part-II T2-Lecture-4 Thank You 45 T2-Lecture-4 Ahmed Mumtaz Mustehsan