12
XML Basics Hope Greenberg Center for Teaching & Learning

XML Basics Hope Greenberg Center for Teaching & Learning

Embed Size (px)

Citation preview

Page 1: XML Basics Hope Greenberg Center for Teaching & Learning

XML Basics

Hope GreenbergCenter for Teaching & Learning

Page 2: XML Basics Hope Greenberg Center 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

Page 3: XML Basics Hope Greenberg Center for Teaching & Learning

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

Page 4: XML Basics Hope Greenberg Center for Teaching & Learning

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

Page 5: XML Basics Hope Greenberg Center for Teaching & Learning

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

Page 6: XML Basics Hope Greenberg Center for Teaching & Learning

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

Page 7: XML Basics Hope Greenberg Center for Teaching & Learning

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

Page 8: XML Basics Hope Greenberg Center for Teaching & Learning

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

Page 9: XML Basics Hope Greenberg Center for Teaching & Learning

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

Page 10: XML Basics Hope Greenberg Center for Teaching & Learning

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

Page 11: XML Basics Hope Greenberg Center for Teaching & Learning

XML File: The Pieces• Elements

(tag, attributes, content: PCDATA)

<p>Hello World!</p><p type=“cliched”>Hello World!</p>

• Entities– Character

&amp; &#x26; &#38;– 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

Page 12: XML Basics Hope Greenberg Center for Teaching & Learning

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