20
XML Extensible Markup Language

XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

Embed Size (px)

Citation preview

Page 1: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

XMLExtensible Markup Language

Page 2: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

XML

• The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language),

– which is derived from Standard Generalized Markup Language (SGML),

– in 1996.

• XML is for electronic data exchange and storage.– A widely supported open technology (i.e., nonproprietary) – A language used to create other markup languages to describe

data in a structured manner.

Page 3: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

What is XML?

• XML is the Extensible Markup Language.

– Language for creating markup languages• Mathematical formulas• Molecular structure of chemicals• Music• Recipes

– Create new tags• Used for Storing Data in structured manner.• Not a Formatting Language.• Describes data of virtually any type.

• Not just for Web pages.

• Defined by W3C to be application and vender neutral in 1996.

Page 4: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

XML describes structure and semantics, not formatting

• XML documents contain only data and

• Structure markups,

• Not formatting.

• Formatting can be added with:– a browser that knows how to render these knew

marked-up data.

– a style sheet (css).

– an Extensible Stylesheet Language (XSL).

Page 5: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

Article.xml

1 <?xml version = "1.0"?>

2

3 <!-- Fig. 20.1: article.xml -->

4 <!-- Article structured with XML -->

5

6 <article>

7

8 <title>Simple XML</title>

9

10 <date>September 19, 2001</date>

11

12 <author>

13 <firstName>Tem</firstName>

14 <lastName>Nieto</lastName>

15 </author>

16

17 <summary>XML is pretty easy.</summary>

18

19 <content>Once you have mastered XHTML, XML is easily

20 learned. You must remember that XML is not for

21 displaying information but for managing information.

22 </content>

23

24 </article>

XML declaration.Element article is the root element.

Elements title, date, author, summary and content are child elements of article.

Page 6: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

Article.xml

1 <?xml version = "1.0"?>

2

3 <!-- Fig. 20.1: article.xml -->

4 <!-- Article structured with XML -->

5 <?xml-stylesheet type="text/css" href="article.css"?>

6 <article>

7

8 <title>Simple XML</title>

9

10 <date>September 19, 2001</date>

11

12 <author>

13 <firstName>Tem</firstName>

14 <lastName>Nieto</lastName>

15 </author>

16

17 <summary>XML is pretty easy.</summary>

18

19 <content>Once you have mastered XHTML, XML is easily

20 learned. You must remember that XML is not for

21 displaying information but for managing information.

22 </content>

23

24 </article>

Page 7: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

Rendering XML documents using CSS“article.css”

title { display: block; font-family: Helvetica, Arial, sans; font-size: 32pt; font-weight: bold; text-align: center}

date { font-family: New York, Times New Roman, serif; font-size: 24pt; background-color: white; color: green; display: block } author { font-family: New York, Times New Roman, serif; font-size: 14pt; background-color: white; color: black; display: block }

content { font-family: courier; font-size: 14pt; background-color: white; color: blue }

Page 8: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

Article.xml

1 <?xml version = "1.0"?>

2

3 <!-- Fig. 20.1: article.xml -->

4 <!-- Article structured with XML -->

5 <?xml-stylesheet type="text/css" href="article.xsl"?>

6 <article>

7

8 <title>Simple XML</title>

9

10 <date>September 19, 2001</date>

11

12 <author>

13 <firstName>Tem</firstName>

14 <lastName>Nieto</lastName>

15 </author>

16

17 <summary>XML is pretty easy.</summary>

18

19 <content>Once you have mastered XHTML, XML is easily

20 learned. You must remember that XML is not for

21 displaying information but for managing information.

22 </content>

23

24 </article>

Page 9: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

Rendering XML documents using XSL“article.xsl”

<?xml version="1.0"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="/"> <html> <body> <h1>

<font color="RED"> <xsl:value-of select="article"/>

</font> </h1> </body> </html> </xsl:template></xsl:stylesheet>

Page 10: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

Create Markup

• XML permits document authors to create markup for virtually any type of information.

• This extensibility enables document authors to create entirely new markup languages for describing specific types of data, including

– mathematical formulas, – chemical molecular structures, – music, recipes, etc.

• Some XML-based markup languages include:– XHTML (Chapters 4 and 5), – MathML (for mathematics), – VoiceXMLTM (for speech), – SMILTM (Synchronous Multimedia Integration Language-for multimedia

presentations), – CML (Chemical Markup Language-for chemistry) and – XBRL (Extensible Business Reporting Language-for financial data

exchange).

Page 11: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

Rendering: http://www.xml.com/style/

FO

IE

Amaya

Page 12: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

XML Parser

• Processing an XML document requires a software program called an XML parser (or an XML processor).

• Most XML parsers are available at no charge and for a variety of programming languages (such as Java, python, C++, etc.).

• Parsers check an XML document's syntax and enable software programs to process marked-up data.

• XML parsers can support – the Document Object Model (DOM) or – the Simple API for XML (SAX).

Page 13: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

DOM-based parsers• DOM-based parsers build tree structures containing XML document

data in memory.

• DOM-based parsers enable software programs to manipulate data in an XML document.

Page 14: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

SAX-based parsers• SAX-based parsers process XML documents and generate events

when the parser encounters tags, text, comments, etc. – These events contain data from the XML document. – Software programs can "listen" for these events to obtain data from the

XML document.

• Several Independent Software Vendors have developed XML parsers, which can be found at

www.xml.com/xml/pub/Guide/XML_Parsers

Page 15: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

XML document's structure

• An XML document optionally can reference a document that defines that XML document's structure.

• This document is either a Document Type Definition (DTD) or a schema.

• When an XML document references a DTD or schema, some parsers (called validating parsers) can read the DTD/schema and check that the XML document follows the structure that the DTD/schema defines.

• Parsers that cannot check for document conformity against DTD/schemas are nonvalidating parsers.

Page 16: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

valid , nonvalid, well formed• If the XML document conforms to the DTD/schema (i.e.,

the document has the appropriate structure), the XML document is valid.

• If the XML document does not conform to the DTD/schema, the XML document is nonvalid.

• If an XML parser (validating or non-validating) can process an XML document successfully, that XML document is well formed (i.e., it is syntactically correct).

– By definition, a valid XML document also is well-formed.

Page 17: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

Microsoft XML Validatorhttp://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/

xml/xml_validator/default.asp

• This sample web page allows you to enter in the URL of an XML document and both parse and validate that document.

Page 18: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

CML

• CML Web based application – CML Molecules Viewer:

http://www.xml-cml.org/jumbo3/jumbo3-JS/jumbo.html

http://www.xml-cml.org/

http://www.xml-cml.org/jumbo3/jumbo3-JS/

Page 19: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

SVG

• Scalable Vector Graphics (SVG) is an exciting new XML-based language for Web graphics from the World Wide Web Consortium (W3C).

http://www.adobe.com/svg/

http://www.adobe.com/svg/demos/samples.html

Page 20: XML Extensible Markup Language. XML The World Wide Web Consortium's (W3C's) XML Working Group developed XML (Extensible Markup Language), –which is derived

XML Basics

http://www.ibiblio.org/xml/slides/sd99east/basics/

• XML FAQ:http://www.ucc.ie/xml/