Intro to XML

advertisement
XML
Markup Languages
 What
does this number (100) mean?
– Actually, it’s just a string of characters!
– A markup language can be used to distinguish
this string of characters from other strings and
to add some meaning to it
A
markup language is simply a computer language of
codes and tags (a.k.a. containers)
<
100
Markup for Web Pages
 The
standard markup language used to
create Web pages is
– HTML (HyperText Markup Language)
(elements … containers) that
a document
containing text and data
 <title> Contains your document’s title</title>
 <body> Contains your document’s information
 <center>For centering things</center>
 <h1>For large text</h1>
 </body>
A
HTML (continued)
<html>
 <head>
 <title> My Web document </title>
 </head>
 <body>
 <center>

<h1> My professor’s weight is 100</h1>
 </center>
 </body>
 </html>

HTML is used to
but HTML cannot be used by other applications because it
XML: eXtensible Markup Language
 Extensible:
that which can be extended, it is
flexible, and can be added to.
 XML adds
that is
being transmitted.
– <weight>100</weight>
 Because
XML can be used to
businesses are beginning to adopt it as the “new”
standard for EDI (
).
XML is directly usable over the Internet and it can
be used to store, deliver, and exchange information
over and between networks.
How Would You Describe

A person
–
–
–
–
–
–
–
–
–
L
First Name
A
Gender
Hair Color
W
Height
Birthdate
College Major
 A building at
– N
– L
– When Built
– Architect
KSU
– Primary College Using the Building
A
university in the Big 12
–
–
–
–
–
–
N
City
State
Mascot
Abbreviation
C
(primary school color)


<?xml version=“1.0”?>
<SelectedBig12Universities>
– <University>
(an XML instance
document)
 <name>Kansas State University</name>
<city>Manhattan</city>
 <state>Kansas</state>
 <mascot>Wildcat</mascot>
 <abbreviation> KSU</abbreviation>
 <color> Purple</color>

– </University>
– <University>
<name> University of Kansas</name>
 <city>Lawrence</city>
 <state>Kansas</state>
 <mascot> Jayhawk </mascot>
 <abbreviation> KU</abbreviation>
 <color> Blue</color>


I
– </University>
</SelectedBig12Universities>
Instance
Document
Abbreviation
Name
Abbreviation
Name
City
Color
State Mascot
Abbreviation
Color
City
Name
State Mascot
University
University
A tree
State Mascot
University
R
SelectedBig12Universities
City
Color
element: Selected
Big 12 Universities
Mid-level elements:
individual universities
Individual data content
Core XML Technologies
 The
XML Instance document
–S
in a hierarchical format
– XML Instance documents are the heart of XML.
 XML
Schemas
– Defines the
of a
and
the types of values that elements may hold.
– XML Schemas are used to validate the XML instance
documents. Someone who has your schema knows what
the information that you will be sending them or exchanging
with them will look like.
 XSL
(the extensible Stylesheet Language)
– Describes how the XML data
– Used to convert an XML instance document from one
Some of the formatting can be undertaken using HTML.
to another.


<?xml version=“1.0”?>
<SelectedBig12Universities>
– <University>
An XML Instance
Document
<name>Kansas State University</name>
 <city>Manhattan</city>
 <state>Kansas</state>
 <mascot>Wildcat</mascot>
 <abbreviation> KSU</abbreviation>
 <color> Purple</color>
Follows a hierarchical

– </University>
– <University>
<name> University of Kansas</name>
 <city>Lawrence</city>
 <state>Kansas</state>
 <mascot> Jayhawk </mascot>
 <abbreviation> KU</abbreviation>
 <color> Blue</color>


– </University>
</SelectedBig12Universities>
format that you can
expand or collapse
Inventory
Schema
A description
of the
that
XML
instance
documents
Applications
that understand
a schema
and can process any
associated, valid documents. Schemas define the
of valid instance
documents.
Schema in e-business
 If
you are an e-business and you want to share and
automatically process xml documents with your
business partners, you will need schemas to define
the rules that your instance documents follow and the
rules that your partners’ documents follow. You will
share your schemas with your business partners so
that all of you can accurately process each others’
XML documents.
X
(eXtensible Business Reporting Language) is a
specific XML schema that describes the elements/data
in
Schema in e-business
 Accounting
firms and government agencies are
working on
 Schemas are being developed to facilitate the transfer
of financial information between banks, businesses,
and customers.
 e-Businesses are developing schemas to transfer
business transaction information via the Internet.
 The IRS is developing schemas for tax reporting and
electronic filing.
X
(eXtensible Business Reporting Language) is a
specific XML schema that describes the elements/data
in
Language of Love for Mutual Funds
XBRL (eXtensible Business Reporting Language)
• X
is one of the XML schemas (
that documents of a certain type
)
• If your organization is required to report data to a regulatory
body, they will dictate the rules that you have to follow when
doing your reporting. That is where schemas come into play.
• If data has been “tagged” using XML/XBRL, then it is very easy
to pull relevant data from long reports/filings, and then be able to
analyze and compare data across many different sources.
– After some sort of computer program is created, with the click of a
mouse, an XML processor can retrieve tagged data from whatever data
repository it is in
The XSL Stylesheet
Used to
instance
documents
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match = "/">
<HTML>
<TABLE BORDER = "1">
<TR>
<TH>Item</TH> <TH>Cost</TH> <TH>QOH</TH>
<TH>TOTAL</TH></TR>
<xsl:for-each select="inventory/item">
<TR>
<TD> <xsl:value-of select="name"/> </TD>
<TD> <xsl:value-of select="cost"/> </TD>
<TD> <xsl:value-of select="qoh"/> </TD>
<TD> <xsl:value-of select="cost * qoh"/> </TD></TR>
</xsl:for-each>
</TABLE>
</HTML>
</xsl:template>
</xsl:stylesheet>
XSL
Stylesheet
5 row, 4
column
table with
multiple
cells
Well-Formed XML Instance Documents
 Well-formed
XML documents can be processed
by an XML processor.
– Internet Explorer can serve as an XML processor.
– XML is also a feature built into Office XP and Office 2003
A
well-formed XML document
the XML
all of
– There is one and
– Tags must balance – every
– XML
– upper and lowercase
characters are different.
– Opening and closing tags must be the same, except
the closing tag starts with a slash (/).
XML Summary
Extensible Markup Language
 HTML
was designed to
on how data looks.
 XML was designed to
on what data is.
 XML Technologies
– Instance documents
– Schemas
and what they must contain)
– Stylesheets describe how to
 XML
and to focus
and to focus
(what they look like
is the new foundation/standard
Download