AIR 2004 Presentation

advertisement
Demystifying the eXtensible
Markup Language
Nick Roberts & Jim Few
http://ir.kennesaw.edu
Agenda
 What is XML?
 Why should I care?
 How can I use XML?
What is XML?
 The eXtensible Markup Language (XML) is a
markup language that provides a format for
describing structured data.
 XML was designed to describe, store, carry, and
exchange data.
 XML tags are not predefined like HTML. You must
define your own tags.
 XML uses an XML schema to describe the data.
 XML can be transformed into other formats with
XSLT.
W3C: http://www.w3schools.com/xml/xml_whatis.asp
What XML is Not
 Something to be afraid of
 A replacement for HTML
 A replacement for relational databases
 A programming language like Java, C++, VB
 A forgiving syntax
 A silver bullet
Text File Format
ID
Lname
Fname
Gender
Ethnicity
83492 Clark
Betty
F
W
89430 Bhatt
Soham
M
A
94032 Jones
Jim
M
W
48392 Klein
Kim
F
B
XML Format
Why should I care?
 Standard (Non-proprietary)
 Extensible
 Flexible
 Easy to share
 Web-friendly
 Separates content from presentation
 Richer than flat text files
 It will be everywhere
XML Syntax
 XML documents use a self-describing syntax
 All XML elements must have a closing tag
 XML tags are case sensitive
 All XML elements must be properly nested
 All XML documents must have a root element
W3C: http://www.w3schools.com/xml/xml_syntax.asp
Who supports XML?
 Microsoft
 IBM
 Sun Microsystems
 Oracle
 SAS
 BEA
 Business Objects
 Novell
 SPSS
 W3C
 Adobe
 SAP
 Computer Associates
 PeopleSoft
Anyone who is a player in the computing world
Data Islands
Oracle
MS Excel
PDF
Crystal
MS Word
MS
Access
HTML
XML Data Sharing
Oracle
MS Excel
SQL
Server
MS Word
DB2
XML
Dreamweaver
Crystal
MS
Access
Text Versus XML
Student Record
<Student>
<Last-Name>Roberts</Last-Name>
Nick Roberts
<First-Name>Nick</First-Name>
0001462395
<ID>0001462395</ID>
143 Main St
<Street>143 Main St</Street>
Paradise, CA
<City>Paradise</City>
90210
<State>CA</State>
24
<Zip-Code>90210</Zip-Code>
3.4
<Age>24</Age>
3.8
<GPA-Cumulative>3.4</GPA-Cumulative>
<GPA-Term>3.8</GPA-Term>
</Student>
HTML Versus XML
<b>Student Record</b>
<Student>
<br>
<Last-Name>Roberts</Last-Name>
<br>
<First-Name>Nick</First-Name>
Nick Roberts<br>
<ID>0001462395</ID>
0001462395<br>
<Street>143 Main St</Street>
143 Main St<br>
<City>Paradise</City>
Paradise, CA<br>
<State>CA</State>
90210<br>
<Zip-Code>90210</Zip-Code>
24
<Age>24</Age>
</Student>
What is XML Schema?
 An XML schema describes the structure of an XML
document
 An XML schema defines:
 Elements that can appear in a document
 Attributes that can appear in a document
 Which elements are child elements
 The order of child elements
 The number of child elements
 Whether an element is empty or can include text
 Data types for elements and attributes
 Default and fixed values for elements and attributes
W3C: http://www.w3schools.com/schema/schema_why.asp
So, What is XML Schema?
 An XML schema manages the expectations of those
sharing an XML document
 The sender can describe the data in a way that the
receiver can understand
 A schema enforces business constraints and
ensures data validation
 For example, we can create a standard definition
for social security number (data type is string,
format=###-##-####, required field, etc.).
W3C: http://www.w3schools.com/schema/schema_intro.asp
XML Schema Example
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:od="urn:schemas-microsoft-com:officedata">
<xsd:element name="ID" minOccurs="1" od:jetType="text“
od:sqlSType="nvarchar" od:nonNullable="yes">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="9" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xs:schema>
What is XSL?
 XSL stands for eXtensible Stylesheet Language
 Think of XSL as a set of languages that can:
 Transform XML into XHTML
 Filter and sort XML data
 Define parts of an XML document
 Format XML data based on the data value, like
displaying negative numbers in red
 Output XML data to different media, like web
browsers, screens, paper, or voice.
W3C: http://www.w3schools.com/xsl/xsl_languages.asp
XSL Example
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<strong>Student Record</strong>
<br />
<br />
<xsl:value-of select="Student/First-Name" />
<xsl:value-of select="Student/Last-Name" />
<br />
<xsl:value-of select="Student/Street" />
<br />
<xsl:value-of select="Student/City" />,
<xsl:value-of select="Student/State" />
<xsl:value-of select="Student/Zip-Code" />
<br />
<xsl:value-of select="Student/Age" />
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML Workflows
Database
Text or
XML Editor
XML
Document
Schema
Validation
Stylesheet
Transformation
XML
Application
Database
XML
Document
Print
Document
Web
Browser
XML Workflow Example
Database
XML
Document
ASP.NET
XSL
Stylesheet
Web
Browser
The End
Questions?
Comments?
Angry Outbursts?
http://ir.kennesaw.edu
Download