introduction to xml. xml - connectivity is key need for customized page layout – e.g. filter to...

18
Introduction to XML

Upload: justin-green

Post on 29-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Introduction to XML

Page 2: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

XML - Connectivity is Key Need for customized page layout – e.g. filter to

display only recent data Downloadable product comparisons – e.g.

import to spreadsheet features, prices, etc. Application integration – translation of data

from various application sources e.g. human resource, accounts, projects

Data integration – coherent DB views Interchangeable files – enhance software

development via number of tools, exchange information effortlessly

Page 3: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Need for software to spontaneously connect across the globe, exchange information, process and record exchanges

Problems evident in Web pages – undifferentiated text makes

search ability problematic, need to for human intervention

HTML – page layout language, little scope for data analysis, need to slice and dice manually

Page 4: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Metadata – first step Spontaneous information exchange

requires metadata One party indicates what each piece of

information means, two or more parties agree on meaning, facilitating organisation of data in database schema

Formal way to describe what a piece of data means

Difficulty – parties need to agree on meaning

Page 5: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Shared Context Formal description of rules

metadata must follow Applies to particular type of

document, serves as contract between document sender and receiver

One party can design shared context, post on internet so available to anyone who wishes to use/add

Page 6: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

XML Approach Simple approach to metadata and shared

context Authors add metadata through tags

<author>William Shakespeare</author> Document designers add shared context

through Document Type Definitions (DTDs) – a set of declarations that specify allowable order, structure and attributes of tags for particular document

Structured via URL so any party can spontaneously access DTD, interpret its rules, and process the document

Page 7: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Goals of XML –

1. It shall be straightforward to use XML over the Internet

2. XML shall support a wide variety of applications3. XML shall be compatible with SGML4. It shall be easy to write programs that process

XML documents5. The number of optional features in XML is to be

kept to an absolute minimum, ideally zero XML documents should be human-legible and

reasonably clear XML design should be prepared quickly The design of XML should be formal and concise XML documents shall be easy to create Terseness in XML markup is of minimal

importance

Page 8: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

XML Conceptual Model Human and machine readability Defining content Defining structure Separation of content from

relationships Separation of structure from

presentation

Page 9: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

XML software support (5)

Fundamental software components – low level XML capabilities such as parsing and generating documents

Software development tool support – tools for rapid application development, include utilities for manipulating XML documents and integrating with document development tools

Document development tools – define DTDs and author XML documents easier than text editors. Graphical modeling tools/browsers for directly manipulating XML documents, support existing web content development and management

Page 10: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

XML software support Web infrastructure support – to develop

adaption momentum, browsers and servers must support XML – anyone can view XML from standard browser

Translation components – convert all data formats to XML, similar to WPs supporting ‘save as rich text format’ feature

Inevitable barriers to deployment = need to overcome

Page 11: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

XML Specifications (2) Document portion – specifies how

to use tagged markup to indicate meaning of data

DTD portion – specifies how to indicate allowable structure for a class of XML document

Page 12: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Simple example - content<business card>

<name><given_name>David</given_name><middle_name>John</middle_name><family_name>Brown</family_name>

</name><title>Software Technology Analyst</title><author/><contact-methods>

<phone>028 7137 5555</phone><phone>07741265894</phone>

</contact_methods></business card>

Page 13: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Simple example – DTD

<!ELEMENT business_card (name, title, author?, contact_methods)>

<!ELEMENT name (given_name, middle_name?, family_name)><!ELEMENT given_name (#PCDATA)><!ELEMENT middle_name (#PCDATA)><!ELEMENT family_name (#PCDATA)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT author EMPTY>

<!ELEMENT contact_methods (phone*)><!ELEMENT phone (#PCDATA)>

CONSTRAINTS? 0 or 1 elements* 0 or more

Page 14: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Elements

Fundamental unit of XML – author-specific chunk of information

Consists of element name and element content One element at top – root or document element Four types of allowable content

data content – contain only data Element content – contain only other elements Empty – contain neither data or elements Mixed content – contain both data and elements (viewed

as poor practice) Attributes – attribute name and value, bounded by

quotation marks database DBTYPE=“Oracle” column DATATYPE=“String”

Page 15: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Well formed XML There is one root element All nonempty elements have start

tags and end tags that match exactly

All empty elements have the correct empty tag syntax

Elements are strictly nested – no overlapping elements

Page 16: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Entities Elements and attributes are logical

mechanisms – enable authors to specify logical meaning of document content

Entities are structural mechanisms – enable authors to manipulate physical structure

Entity associates an entity name with a fragment of content

Page 17: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Entities in XML (4) Internal parsed entities –

<!ENTITY author “Kevin Parks”> would allow “&author” within document and have it replaced by Kevin Parks

External parsed entities – include entire file as part of document

<!ENTITY address_section SYSTEM “./address.xml”<!ENTITY lineitems_section SYSTEM “./lineitems.xml”<!ENTITY payment_section SYSTEM “./payment.xml”&address_section;&lineitems_section;&payment_section;

Page 18: Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons

Unparsed entities – allow authors to insert arbitrary data in document – may not be XML, XML process will not attempt to parse such an entity

Parameter entities – work only in DTDs to specify an enumerated list of allowable attribute values.

<!ENTITY % card_list “VISA|Mastercard|Amex|Discover”>CARDTYPE (%card_list;)#REQUIRED>