28 October 2008 CIS 340# 1
Topics• To define XML as a technology• To place XML in the context of
system architectures
Online support:http://www.w3schools.com/xml/default.asp
Online community:http://www.oasis-open.org/home/index.php
Standards development:http://www.oasis-open.org/committees/committees.php#completed
28 October 2008 CIS 340# 2
Spectrum of “Technologies”
XPATH
DTD
XSD
XMLXSL
XSLT
XSL-FOXFORMS
XLINK
XQUERY
XPOINTER
XML
• XML stands for eXtensible Markup Language.• XML is designed to transport and store data.• XML is important to know, and very easy to learn.
28 October 2008 CIS 340# 3
28 October 2008 CIS 340# 4
XML ...
• Is a syntax for describing data– Almost any data
• Produces “vocabularies”– Anyone can produce an individualized
vocabulary– Sharing the vocabulary enables the
sharing of data
Organizational hub– http://www.xml.org/
28 October 2008 CIS 340# 5
XML History• Shares similar historical roots with HTML• Part of SGML (Standard Generalized
Markup Language – 1970s)
• HTML describes how to renderdescribes how to render information via a browser– “rendering” options are fixed via the language– Display potential fixed via the selected output
technology
HTML limitation?» Interpretation after transmission (e.g. useuse) requires human intervention
28 October 2008 CIS 340# 6
XML History (p. 2)
• XML enables human bypass• XML offers self-descriptive
labels equating to interpretation
• XML provides “meta information”
If XML used, Company B can:
•Have programs manipulate data
•Import data directly to database
•Store immediately within similar,
affiliated documents
•Manipulate data for specific needs
•continues....COMPANY A
COMPANY BFINANCIAL.rpt
A-WEB
28 October 2008 CIS 340# 7
Vocabularies
• Collection of elements• Not predefined• But related into a structure vocabularyvocabulary
• ““Instance of”Instance of” XML document
Def:Def:
28 October 2008 CIS 340# 8
Sample Defined Vocabularies (in progress)
• Accounting XML
• Advertising XML
• Astronomy XML
• Building XML
• Chemistry XML
• Construction XML
• Education XML
• Food XML
• Finance XML
• Government XML
• Healthcare XML
• Human Resources XML
• Instruments XML
• Insurance XML
• Legal XML
• Manufacturing XML
• News XML
• Photo XML
• Physics XML
• Publishing XML
• Real Estate XML
• Telecommunications XML
• Travel XML
28 October 2008 CIS 340# 10
XML Document• Prolog
– (optional)
– Describes the xml-specification
– Declares the document type (DTD)
• Body– (required)– collection of instantiated
vocabulary terms
• Epilog– (optional)– processing or comments
<?xml version = 1.0”?>
<!DOCTYPE book SYSTEM “book.dtd”>
<book category = “FICTION”>
<title>Golden Phoenix</title>
<author>J. K. Rowling</author>
</book>
<book category = “NON-FICTION”>
<title>Mythical Work</title>
<author>E. Yourdan</author>
</book>
28 October 2008 CIS 340# 11
Schemas» Document Type Definition (DTD)
» XML Schema Definition (XSD)
• Offers the legal structure of the elements of a vocabulary
• Enables the programmatic access of an XML “document”
• Meaning?• Declare element types• Qualify elements with attributes• Define parent-child relationships• Assign simple data types• Establish validation basis for data acceptance
DTD
28 October 2008 CIS 340# 12
!DOCTYPE note defines that the root element of this document is note!ELEMENT note defines that the note element contains four elements: to,from,heading,body"!ELEMENT to defines the to element to be of type "#PCDATA"!ELEMENT from defines the from element to be of type "#PCDATA"!ELEMENT heading defines the heading element to be of type "#PCDATA"!ELEMENT body defines the body element to be of type "#PCDATA"
28 October 2008 CIS 340# 13
EX: DTD Specification
<!DOCTYPE book [
<!ELEMENT book (title, author)>
<!ATTLIST book CATEGORY (Fiction |Non-Fiction)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
]>
EX: XSD Specification
(see p. 29)
address example
<?xml version = “1.0”?><xsd:schema xmlns:xsd=
http://www.w3.org/2001/XMLSchema><xsd:element name=“book”>
<xsd:complexType><xsd:sequence>
<xsd:element name=“title” type “xsd:string”/>
<xsd:element name=“author” type “xsd:string”/>
</xsd:sequence><xsd:attribute name = “category”>
<xsd:simpleType><xsd:restriction base=“xsd:string”/> <xsd:enumeration value = “Fiction”/> <xsd:enumeration value = “Non-Fiction”/></xsd:restriction>
</xsd:simpleType></xsd:attribute>
</xsd:complexType></xsd:element></xsd:schema>
28 October 2008 CIS 340# 15
XQUERY ... FLWR (“flower”)
• Query language
• aka SQL
• Designed for XML documents
• Allows for logic to be used to access embedded information of XML documents
28 October 2008 CIS 340# 16
XQUERY ... FLWR (“flower”)FLWR :: For Let Where Return General versions:
for Variable in Exp for Variable in Exp where Exp where Exp return Exp sortby(Exp)return Exp sortby(Exp)
let Variable := Exp let Variable := Exp where Exp where Exp
return Exp sortby(Exp)return Exp sortby(Exp)
for $x in document (“books.xml”) // bookfor $x in document (“books.xml”) // bookwhere $x/author = “J. K. Rowling”where $x/author = “J. K. Rowling”return $x/titlereturn $x/title
givesgives<title>Golden Phoenix</title><title>Golden Phoenix</title>
28 October 2008 CIS 340# 17
Connective LanguagesXSLT• XML XML SStylesheet
LLanguage TTransformations
• Mechanism for taking XML documents to different output renditions
XPATH• Collection of “utility
functions”• Enables the parsing
and traversing of XML structures
• Required mechanism for XSLT and XQUERY
Not defined via an XML-compliant syntax
Most XML languages are