1 / 12

XML – A Quick Introduction

XML – A Quick Introduction. Kerry Raymond (stolen from others). What is XML?. XML = Extensible Mark-up Language XML is a simplified version of SGML (Standard Generalized Mark-up Language) Standardised by W3C. Example XML. <?xml version=“1.0” standalone=“yes” ?> <bibliography>

finola
Télécharger la présentation

XML – A Quick Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML – A Quick Introduction Kerry Raymond(stolen from others)

  2. What is XML? • XML = Extensible Mark-up Language • XML is a simplified version of SGML (Standard Generalized Mark-up Language) • Standardised by W3C

  3. Example XML <?xml version=“1.0” standalone=“yes” ?> <bibliography> <bibItem id=“horgan96” type=“book”> <title>The End of Science</title> <author>John Horgan</author> <date><year>1996</year></date> <publisher>Little, Brown and Company</publisher> </bibItem> <!-- More bibItem elements. --> </bibliography>

  4. XML mark up • The main parts of an XML document are: • Tag • Element • Attribute

  5. XML mark up - Tag • Tags are the most familiar aspect of XML mark up. • Kinds of tags: • Start tag: <title>. • End tag: </title>. Start and end tags form pairs, with some content between them. • Empty tags (no content): <newLine/>.

  6. XML mark up - Element • The portion of a document between an opening tag and its corresponding closing tag. • Example: • <title>The End of Science</title> • May be empty or have nested content.

  7. XML mark up - Attribute • Attributes belong to the element, rather than to the content of the element. • For example, the attribute “id”: • <bibItem id=“horgan96”> • Attributes are typed. For example: • CDATA (string). • Enumeration (one of a list of values) • ID (a unique identifier) • IDREF (reference to an ID – simple cross-reference)

  8. XML example <?xml version=“1.0” standalone=“yes” ?> <bibliography> <bibItem id=“horgan96” type=“book”> <title>The End of Science</title> <author>John Horgan</author> <date><year>1996</year></date> <publisher>Little, Brown and Company</publisher> </bibItem> <!-- More bibItem elements. --> </bibliography>

  9. Well-formed vs. valid XML has two levels of acceptability: • Well-formed documents. • Minimal level required by XML • Syntactically correct andopening and closing tags are properly nested. • Valid documents. • Document must be well-formed and must satisfy the Document Type Definition in all details.

  10. DTD • A document type is defined by a DTD. The DTD defines: • The tree structure a document of a given type can form. • The positions of elements, attributes and so on in document instances of that type. • The relationships between elements. • Any constraints on each of the elements and attributes.

  11. DTD – Example <!DOCTYPE bibliography [ <!ELEMENT bibliography (bibItem)+> <!ELEMENT bibItem (title, (author | editor)*, date, publisher?)> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT editor (#PCDATA)> <!ELEMENT date (year, month?)> <!ELEMENT year (#PCDATA)> <!ELEMENT month (#PCDATA)> <!ELEMENT publisher (#PCDATA)> <!ATTLIST bibItem id ID #REQUIRED type (article | book | report | video | audio) 'article'> ]>

  12. So is it valid? <?xml version=“1.0” standalone=“yes” ?> <!DOCTYPE bibliography SYSTEM “biblio.dtd”> <bibliography> <bibItem id=“horgan96” type=“book”> <title>The End of Science</title> <author>John Horgan</author> <date><year>1996</year></date> <publisher>Little, Brown and Company</publisher> </bibItem> <!-- More bibItem elements. --> </bibliography>

More Related