xml presented by kushan athukorala. 2 agenda xml overview entity references elements vs. atributes...
TRANSCRIPT
2
Agenda
• XML Overview
• Entity References
• Elements vs. Atributes
• XML Validation
• DTD
• XML Schema
• Linking XML and CSS
• XSLT
3
The Difference Between XML and HTML
• XML was designed to transport and store data, with focus on what data is.
• HTML was designed to display data, with focus on how data looks.
4
XML
• XML Simplifies Data Sharing• In the real world, computer systems and databases contain data in
incompatible formats.
• XML Simplifies Data Transport• With XML, data can easily be exchanged between incompatible
systems.
• XML Simplifies Platform Changes• Upgrading to new systems (hardware or software platforms), is
always very time consuming. Large amounts of data must be converted and incompatible data is often lost.
5
XML contd.
• XML Makes Your Data More Available• Since XML is independent of hardware, software and application,
XML can make your data more available and useful.
• XML is Used to Create New Internet Languages• XHTML the latest version of HTML
• WSDL for describing available web services
• WAP and WML as markup languages for handheld devices
• RSS languages for news feeds• SMIL for describing multimedia for the web
6
An Example XML Document
<?xml version="1.0" encoding="ISO-8859-1"?><note> <-------- root element
<to>Tove</to> <-------- child elements
<from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body></note>
8
Answer
<bookstore> <book category=“anything"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book>
</bookstore>
9
Entity References
• Try to represent below message in XML• <message>if salary < 1000 then</message>
• There are 5 predefined entity references in XML:
10
Comments in XML
• The syntax for writing comments in XML is similar to that of HTML.• <!-- This is a comment -->
11
XML Elements vs. Attributes
• What is correct?• <person sex="female">
<firstname>Anna</firstname> <lastname>Smith</lastname></person>
• <person> <sex>female</sex> <firstname>Anna</firstname> <lastname>Smith</lastname></person>
• There are no rules about when to use attributes and when to use elements.• Attributes are handy in HTML.
• Avoid them in XML and use elements instead.
12
XML Validation
• XML with correct syntax is "Well Formed" XML.
• XML validated against a DTD is "Valid" XML.
13
XML DTD
• DTD defines the structure of an XML document• Example DTD file
• <!DOCTYPE note[<!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)>]>
• How to reference an external DTD file• <?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE note SYSTEM "Note.dtd"><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>
• XML Assignment1 – Implement the above example and show that the validations functions as expected
14
XML Schema
• XML-based alternative to DTD is called XML Schema• <xs:element name="note">
<xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence></xs:complexType>
</xs:element>
• XML Assignment2 – Implement the previous example using XML Schema and demonstrate the validation
15
Linking XML file to CSS file
• XML file- <CATALOG>- <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD>- <CD>
• CSS fileCATALOG { background-color: #ffffff; width: 100%; } CD { display: block; margin-bottom: 30pt; margin-left: 0; } TITLE { color: #FF0000; font-size: 20pt; } ARTIST { color: #0000FF; font-size: 20pt; } COUNTRY,PRICE,YEAR,COMPANY { display: block; color: #000000; margin-left: 20pt; }
16
Linking XML file to CSS file contd.
• How to combine the two• <?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/css" href="cd_catalog.css"?><CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD>
• Output will be as shown
• XML Assignment3 - Implement the above example
17
Displaying XML with XSLT
• XSLT is the recommended style sheet language of XML.
• XSLT (eXtensible Stylesheet Language Transformations)
• XSLT can be used to transform XML into HTML
• XML Assignment4 - Implement the previous example using XSLT
20
Web Services
• Web Services can convert your application into a Web-application, which can publish its function or message to the rest of the world
• What are Web Services?• Web services are application components
• Web services communicate using open protocols
• Web services are self-contained and self-describing
• Web services can be discovered using UDDI
• Web services can be used by other applications
• XML is the basis for Web services
21
Web Services Platform and Platform Elements
• Web Services platform is XML + HTTP
• Web services platform elements:• SOAP (Simple Object Access Protocol)
• UDDI (Universal Description, Discovery and Integration)
• WSDL (Web Services Description Language)
22
Web Services have Two Types of Uses
• Reusable application-components.• Web services can offer application-components like: currency
conversion, weather reports, or even language translation as services.
• These components are reusable
• Connect existing software.• Web services can help to solve the interoperability problem
by giving different applications a way to link their data.
• With Web services you can exchange data between different applications and different platforms.
23
What is SOAP?
• SOAP is an XML-based protocol to let applications exchange information over HTTP. SOAP is a protocol for accessing a Web Service.• SOAP stands for Simple Object Access Protocol
• SOAP is a communication protocol
• SOAP is a format for sending messages
• SOAP is designed to communicate via Internet
• SOAP is platform independent
• SOAP is language independent
• SOAP is based on XML
• SOAP is simple and extensible
• SOAP allows you to get around firewalls
• SOAP is a W3C standard
24
What is WSDL?
• WSDL is an XML-based language for locating and describing Web services.• WSDL stands for Web Services Description Language
• WSDL is based on XML
• WSDL is used to describe Web services
• WSDL is used to locate Web services
• WSDL is a W3C standard
25
What is UDDI?
• UDDI is a directory service where companies can register and search for Web services.• UDDI stands for Universal Description, Discovery and
Integration
• UDDI is a directory for storing information about web services
• UDDI is a directory of web service interfaces described by WSDL
• UDDI communicates via SOAP
27
USA INDIA SRILANKA UK
www.virtusa.com
© V I r t u s a C o r p o r a t i o n
"Virtusa" is a trademark of the company and a registered trademark in the EU and In India. "Productization" is a service mark of the company and a registered service mark in the United States.
"vRule" is a service mark of the company.
For more information please contact [email protected]