XML

24
XML XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault

description

XML. A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault. XML HISTORY. Developed by work group, under authority of the W3C First seen in 1996, and standardized by the W3C in 1998 Simplified dialect of the SGML. - PowerPoint PPT Presentation

Transcript of XML

Page 1: XML

XMLXML

A web enabled data description language

4/22/2001

By Mark Lawson & Edward Ryan L’Herault

Page 2: XML

XML HISTORY

• Developed by work group, under authority of the W3C

• First seen in 1996, and standardized by the W3C in 1998

• Simplified dialect of the SGML

Page 3: XML

SGML "Standard Generalized Markup Language"

• A method for creating interchangeable, structured documents

• Standardized in 1986 (ISO8879:1986)• Can assemble a single document from

many sources• Defines a document structure using a

special grammar called a Document Type Definition

• Adds markup to show the structural units in a document

Page 4: XML

HTML vs XML vs SGML

• HTML is an SGML application (a DTD and set of processing conventions)– As such it’s much more limited than SGML and

XML– It’s easy to learn

• SGML is the mother of XML and HTML– It’s complicated – hundreds of pages in it’s

definition– It has many extraneous features that aren’t

needed on the web

Page 5: XML

HTML vs XML vs SGML II

• XML is a subset of SGML

– Valid SGML– Only uses the parts that are useful on the web– Requires more syntax checking than HTML– Is extendable like SGML– Has a small definition (25 pages)– Easy to learn

Page 6: XML

How do I execute or run How do I execute or run an XML file?an XML file?

• You can't and you don't.

• XML is not a programming language, so XML files don't ‘run’ or ‘execute’.

• XML is a markup specification language and XML files are data.

Page 7: XML

Constructing your own XMLConstructing your own XML

You must supply a Document Type Definition

What is a Document Type Definition (DTD)?

• A context-free grammar like Extended BNF• Provides the rules that define the elements

and structure of your new language• Thousands of SGML DTDs already in

existence • SGML DTDs need to be converted to XML

for use with XML systems

Page 8: XML

How is a DTD implemented?How is a DTD implemented?

• A DTD is a file (or several files to be used together), written in XML's Declaration Syntax

• It contains a formal description of a particular type of document

• It sets out what names can be used for element types, where they may occur, and how they all fit together

• Any browser (or application) with an XML parser could interpret an XML document instance by "learning" the rules defined by the DTD.

Page 9: XML

Defining the structure & Defining the structure & Semantics of XMLSemantics of XML

XML structure is defined in a schema

• Defines shared markup vocabularies • Provide a means for defining the structure,

content and semantics of XML • Introduces new levels of flexibility that may

accelerate the adoption of XML for significant industrial use

Page 10: XML

Schemas

• Schemas support inheritance and overriding old values

• Schemas are not yet a formal Recommendation, but a number of sites are starting to serve useful applications as both DTDs and Schemas

Page 11: XML

An XML exampleAn XML example• Example: Elements and Attributes This group of elements, attributes describe the contents

of an address book. It includes a DTD which describes how all of the pieces work as XML.

<?xml version=‘1.0’ ?>

<!DOCTYPE address-book SYSTEM ‘address-book.dtd’><!--loosely inspired by vCard 3.0 --><address-book>

<entry><name>

<fname>Jack</fname><lname>Smith</lname>

</name><tel>513-555-3465</tel><email href=‘mailto:[email protected]’/>

</entry></address-book>

Page 12: XML

RequiredRequired

1. The XML Declaration• <?xml version="1.0"

standalone="no"?>• This is what tells an XML parser that

the document is XML

2. XML Declaration w/ character set• <?xml version="1.0"

encoding="ISO-8859-1"?>

Page 13: XML

Basic Syntax

• All tags must be closed• The exception is an empty tag

(i.e. <line-break/> )• All nested tags must close before the tag

they are nested in• All attributes must have quotes• Case sensitive

Page 14: XML

Tags and DTDTags and DTD

The DTD describes every object that can appear in the document

An example section of a DTD is:

<!ELEMENT address-book (entry+)>

This is an entry that says the element <address-book> is composed of one or more <entry> elements.

Page 15: XML

Optional modifiers for the entries:

1. No modifier: Object appears once and only once in the element

2. +: Object appears at least once and can be repeated

3. *: Object appears zero or more times

4. ?: Object appears zero or one times

Page 16: XML

Elements composed of Elements composed of multiple entriesmultiple entries

An element can be composed of multiple entries, for example an entry in the address book has: a name, phone number, and email

<!ELEMENT entry (name,tel*,fax*,email*)>

Inside the parentheses are the elements that make up entry these can take the forms:

• (e1 , e2): These elements will appear once each in order e1 e2

• (e1 | e2): One of these elements will appear (either or)• These can be combined as in:

– (e1, (e2 | e3) )

Page 17: XML

Attributes of ElementsAttributes of Elements

Some elements have attributes, which are part of their data description. An attribute has:

– The attribute tag opening: <!ATTLIST– The name of the element it belongs to:

email– The attribute name: href– The attribute type: CDATA – Optionally a default value: #REQUIRED– The close bracket: >

Page 18: XML

Attributes of Elements IIAttributes of Elements II

There can be more than one attribute listed in one attribute tag:

<!ATTLIST email href CDATA #REQUIRED preferred (true |false) 'false'>

Page 19: XML

Referencing the DTDReferencing the DTD

A DTD is referenced in the document using it with the tag:

<!DOCTYPE address-book SYSTEM "address-book.dtd">

Page 20: XML

Referencing the DTD IIReferencing the DTD II

The section of the tag:SYSTEM "address-book.dtd">

Can be replaced with or followed by a [ and the actual DTD as in:

<!DOCTYPE name [ <!ELEMENT name (#PCDATA |fname |

lname)*>

<!ELEMENT fname (#PCDATA)>

<!ELEMENT lname (#PCDATA)>

]>

Page 21: XML

Viewing the XML: XSLViewing the XML: XSL

Because XML is just for describing data it isn’t inherently displayed in a particular way by a browser. XSL allows how things are displayed to be specified

• XSLT transforms the data into new forms• XSLFO allows the style of the objects to be set• A similar thing to XLSO which is more supported

is CSS

Page 22: XML

Uses of XMLUses of XML

1. intelligent agents - content personalization via smart pull/push (possibly with a date-stamped XML repository)

2. structured records (purchase order) object with methods and data (Java, and potentially JavaScript)

3. meta-content about your web site (improves searches) query results

4. graphical user interface of an application 5. persistent storage format (e.g. ODBMS-

powered XML repository)

Page 23: XML

Uses of XML IIUses of XML II

6. electronic service manuals7. online process/procedures

documentation 8. EDI (electronic data interchange) -

mapping data between purchasing and inventory departments of same or different companies

Page 24: XML

ReferencesReferences

http://www.w3.org/XML/ http://www.ucc.ie/xml http://www.xml.com/ http://www.gca.org/whats_xml/whats_xml_xmlfiles.htm http://www.schema.net/ 

most informative site: http://wdvl.com/Authoring/Languages/XML/Intro/

Also:

XML for DummiesXML by Example by Que