You must define your own tags XML uses an XML Schema or a Document Type Definition DTD to describe the data yeah, but….. XML Components So Far One root element One or more elemen
Trang 1The Good, the Bad,
and the Ugly
Trang 2XML Process Overview
Trang 3XML
Trang 4XML Process in Motion
Showtime!!
Trang 5XML: Overview
XML does NOT DO Anything!
XML stands for EXtensible Markup Language
XML is a markup language much like HTML
XML was designed to describe data
XML tags are not predefined You must define your
own tags
XML uses an XML Schema or a Document Type
Definition (DTD) to describe the data (yeah, but…).
XML with an XML Schema or a DTD is designed to be
self-descriptive (whatever that means…)
Trang 7XML Overview: Root Element
One Root Element
Trang 8XML Overview: Empty Elements
Empty, but not forgotten
<FACT>I made up these tags to suit my purpose.</FACT>
<FACT>My purpose was to help you read XML.</FACT>
<CONCLUSION>I made up these tags to help
you.</CONCLUSION>
</ARGUMENT>
</EXAMPLES_OF_LOGIC>
Trang 9<FACT>Socrates was a man.</FACT>
<FACT>All men are created equal.</FACT>
<CONCLUSION>Socrates was Plato.</CONCLUSION> </ARGUMENT>
</EXAMPLES_OF_LOGIC>
Trang 10XML Overview:
Declarations (Duuude, I'm XML!)
Declare that a file contains XML and
conforms to version 1.0 (the current and only version, but hey!)
<?xml version="1.0"?>
(location: if used, line 1 always)
Declare other attributes
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="iso-8859-1"?>
Trang 11XML Components So Far
One root element
One or more elements (can be nested)
Empty Elements optional
Attributes optional
XML declaration—optional
Trang 12XML Overview: Namespaces
Where is Martha Stewart when you
need her?? (And what ARE these?)
The result: naming conflicts
(are we having fun yet?)
XML uses Namespaces to prevent
like-named elements from being confused
(and there is nothing worse than a
confused element, trust me…)
Trang 13XML Namespace Example
<TRAINING_MODULE xmlns=“http://www.wordsite.com/NameSpace1”> <BUILDING_BLOCK>
<NAME>Element</NAME>
<DESCRIPTION>An element consists of a start tag, an end tag, and the data
that lies between the start and end tags For example, this sentence is part
of a DESCRIPTION element.</DESCRIPTION>
<FUNCTION>Stores data.</FUNCTION>
<NOTE>Elements can be nested inside other elements For example, this
NOTE element is nested inside a BUILDING_BLOCK element The preceding NAME element, DESCRIPTION element, and FUNCTION element are also nested inside the same BUILDING_BLOCK element.</NOTE>
</BUILDING_BLOCK>
……….
</TRAINING_MODULE>
XSLT
Trang 14XML: Graduation
The (mostly) Whole Enchalada
One root element
One or more elements (can be nested)
Empty Elements optional
Attributes optional
XML declaration—optional
Trang 15XSLT
Trang 17XSLT Overview:
eXtensible Stylesheet Language
Purpose (porpoise, papoose):
Transform XML data to some type of output format – html files, PDF files, another xml file, etc for presentation.
Specialized XML vocabulary
Single Sourcing (oooh, wow…)
Multiple XSLT files can be applied to one
xml file to create multiple outputs.
Separate Data from Presentation
Trang 18<H2>Building Blocks of XML: A Teacher Guide</H2>
<H3>Instructions for teacher:</H3>
Trang 19XSD:
eXtensible Stylesheet Definition
Trang 20XSD Overview: Schema Pupose
Purpose:
A schema is an XML file that describes the structure of an XML data file and the rules for what kind of data can be stored there
Trang 21XSD Schema Example
Take a look at your schema handout for an example of a
schema
Go to www.w3schools.com and Microsoft for more
information about schema construction
Trang 22XML Transformation:
Example
View a real life XML transform
See how the components fit together
Trang 23XML Uses: The Good Stuff
Web: Table of Contents, table oriented data
Word and Excel import/export
RoboHelp import/export
Trang 27XML : The Bad
What They Never Tell You
Trang 28XML: The BAD
How DOES XML Get Displayed?????
Things they don't tell you…
No shoes, no shirt, no display
Requires XML-aware software and the extra stuff
necessary to display it
Special encoding and character display
Trang 29XML Display Gotchas
Special characters like < > & and others
need special handling so that the xml
parser doesn’t get confused and think they are part of the XML data.
Trang 30XML: The Ugly
My Data, YOUR Browser
Browsers use different ways of displaying XML (requires
browser detection)
How the heck does XML actually GET displayed???
Client display and Server display
Validation and Error Interception
Trang 31My Data, YOUR Browser
Browser Detection
Option 1: Script Detection
//**** JavaScript Browser Variables ****
var isIE = (document.all) ? true : false;
var isDOM=
(document.getElementById && !document.all) ? true : false;
var isNetscape=(document.layers) ? true : false;
Option 2 Put all XSLT and CSS references in the XML
file and sort of forget about Browser detection
Trang 32My Data, YOUR Browser
Are You Being Served?
Server or Client Display
Trang 33My Data, YOUR Browser
What Really, Really Happens
Load the XML file into memory using the browser’s
method Look out for the bad guys
Load the XSLT file into memory using the browser’s
method Same bad guy check
Call the Transform process of the Browser you’re using
and write it out to the current page
Trang 34XML A good option even so!
Example 1: An XML TOC and data display
Trang 35Sources and Links
(cf Building Documents with XML, XSL, and CSS)
DOCBook: www.docbook.org and
www.docbook.sourceforge.net
http://www.codehound.com/xml/
Trang 36XML Tools and Editors
Free, free, free
http://architag.com/xray/