Upload
cecil-carr
View
212
Download
0
Embed Size (px)
Citation preview
XML Basics
Hope GreenbergCenter for Teaching & Learning
What is HTML?
• A set of markup tags for encoding elements of web documents.
• Encoding is the addition of codes to text in order to make it possible for a computer to process that text.
• Interpretation of elements is built into a web browser, helped by CSS.
• Presentational (sort of) not semantic.• Looks like:
<p>Hello world.</p><p class=“green”>Hello world.</p>
XML: W
hat, Why, W
hen and How
What is XML?
• A markup language for describing structured documents.
• Allows for creation of elements based on need.• Designed to be semantic (meaning is separate
from presentation).• Looks like:
<p>Hello world.</p>• But can also look like:
<para>Hello world.</para>
XML: W
hat, Why, W
hen and How
What is the TEI?
• Text Encoding Initiative founded in 1987.• Guidelines for encoding machine-readable texts in
the humanities and social sciences. • Includes standardized ways to mark up a
document’s semantics.
XML: W
hat, Why, W
hen and How
Why use the TEI?
• With HTML you could do this:
<p>Enter KING.</p>
<p>Queen.</p>
<p> Alas, look here, my lord.</p>
<p> Ophelia speaks </p>
<p> Oph.</p>
<p>Song.</p>
<p>Larded all with sweet flowers,</p>
XML: W
hat, Why, W
hen and How
Why use the TEI?
• With CSS you could add some classification:
<p.stage>Enter KING.</p>
<p.speaker>Queen.</p>
<p.speech> Alas, look here, my lord.</p>
<p.stage> Ophelia speaks </p>
• and then tell the CSS to make each class LOOK different.
XML: W
hat, Why, W
hen and How
Why use the TEI? <stage>Enter KING.</stage>
<sp who="Queen” type=“female”>
<speaker >Queen.</speaker>
<l n="37" part="Y"> Alas, look here, my lord.</l>
</sp>
<sp who="Oph” type=“female”>
<speaker>Ophelia</speaker>
<stage>Song. </stage>
<l n="38"> Larded all with sweet flowers,</l>
XML: W
hat, Why, W
hen and How
XML: The Pieces
XML: W
hat, Why, W
hen and How
XML File
Parser
xhtml.xsl
print.xsl
mobil.xsl
web
Mobildevice
css
Schema/DTD
XML File: The Pieces
• Declaration (what am I?)• Processing Instructions (what will you do with
me?)• Elements (what am I made of?)– (tag, attributes, content: PCDATA)
• Entities (what else do we need?)– Character, files,
• Comments (secret messages)• CDATA (just like this or else…)
XML: W
hat, Why, W
hen and How
XML File: The Pieces
• Declaration<?xml version=“1.0” encoding=“UTF-16”
standalone=“yes”>
• Processing instruction<?xml-stylesheet href=“classic.xsl”
type=“text/xml”?>
XML: W
hat, Why, W
hen and How
XML File: The Pieces• Elements
(tag, attributes, content: PCDATA)
<p>Hello World!</p><p type=“cliched”>Hello World!</p>
• Entities– Character
& & &– Text or other: external
<!ENTITY lady SYSTEM “http://www.uvm.edu/~hag/lady.jpeg NDATA jpeg><figure entity=“lady”></figure>
XML: W
hat, Why, W
hen and How
XML File: Some Rules
• XML tags are case sensitive.• All XML elements must have a closing tag.• All XML elements must be properly nested.• All XML documents must have a root element.• Attribute values must always be quoted.
XML: W
hat, Why, W
hen and How