An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

10
An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006

Transcript of An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

Page 1: An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

An Introduction to XML

Presented by Scott Nemec

at the UniForum Chicago meeting on 7/25/2006

Page 2: An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

Definition(s)

• XML expands out to: eXtensible Markup Language

• A text based data document that can be read by a person using a text editor.

Page 3: An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

What does XML do better?

• XML fits between SGML (Standard Generalized Markup Language) and HTML (HyperText Markup Language)– SGML – very generalized markup language that is too

complex for general usage– HTML – a markup language for display purposes that

is not meant to have its definition modified.– XML is meant to let people define how its elements

and attributes combine for each purpose it is used for.

Page 4: An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

Why use XML?

• Much more defined context and human-readable than other text like comma-delimited:

Apple, 300, IL

<sales>

<company>Apple</company>

<numberofIpods>300</numberofIpods>

<state>IL</state>

</sales>

Page 5: An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

What makes up an XML document?

• Elements– has a name, and contains a text value or another element(s)– An element can have more than one instance in a document– the element must show it being closed after the element value, if there

is any value (ie. <element>a</element>, <element/>) – Example with fruit element: <fruit>apple</fruit>

• Attributes– has a name, contains a text value, and is contained within an element.– it can only have one value per element instance in enclosing quotes – Example with ‘name’ attribute: <fruit name=‘apple’/>

• Optional header– Provides information about the document, including links to definitions to

be used for the document

Page 6: An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

Well Formed?

• ‘Well Formed’ means the xml document doesn’t have a syntax problem.– Every element has both an explicit start and

an explicit or implicit end. That includes having matching ‘<‘ and ‘>’.

– Attributes have a name, an ‘=‘ and single quotes (ie ‘ ) enclosing the value.

Page 7: An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

Valid?

• ‘Valid’ means the content of the format of the XML document matches a definition (either a schema or DTD) of what the content should be for the document.– An XML schema is the more modern definition which

includes much more detail in what is can be defined. A schema file is defined as an XML document itself.

– An XML DTD is the older definition specification. A DTD document is NOT defined as XML.

Page 8: An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

Simple Examples• <?xml version="1.0" encoding="UTF-8"?>

<element><element2>A</element2><element3>B</element3><element3>C</element3></element>

• <?xml version="1.0" encoding="UTF-8“?><q d=‘a’ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation=“filename.xsd"><z>1</z><z>2</z></q>

Page 9: An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

Advanced Topics

• XSLT - Extensible Stylesheet Language Transformations

• XPath - XML Path Language

• XQuery - a language designed for processing XML data (ie XML databases)

I recommend http://www.xml.com as a step for learning more about XML .

Page 10: An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.

References for further study

• “A Really, Really, Really Good Introduction to XML”

By Tom Myer

http://www.sitepoint.com/article/really-good-introduction-xml• W3C Recommendation for XML definition 1.0 (third edition)

http://www.w3.org/TR/REC-xml/• XML from the Inside Out (O’Reilly)

http://www.xml.com