1 / 23

XML – 1h

XML – 1h. XML: Contents. What is XML? What is “Well Formed” XML? What is “Valid” XML? Document Type Definitions Scalable Vector Graphics (SVG) XML in 10 Points Some Questions for You. What is XML?.

karsen
Télécharger la présentation

XML – 1h

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 – 1h

  2. XML: Contents • What is XML? • What is “Well Formed” XML? • What is “Valid” XML? • Document Type Definitions • Scalable Vector Graphics (SVG) • XML in 10 Points • Some Questions for You

  3. What is XML? XML is a method of putting structured data in a file format. It is not a programming language; it doesn’t DO anything • An XML document includes text and mark-up; just like HTML. • XML permits new markup tags to be defined • XML is rather more strict than HTML

  4. An Easy Example (SVG) <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "../../svg11-flat.dtd"> <svg width="12cm" height="4cm" viewBox="0 0 1200 400" xmlns="http://www.w3.org/2000/svg" version="1.1"> <circle cx="600" cy="200" r="100" fill="red" stroke="blue" stroke-width="10" /> <rect width="20" height="10"/> <text>Kilroy was here.</text> </svg>

  5. What is “Well Formed” XML? • 1. Taken as a whole, it matches the production labelled document. • 2. It meets all the well-formedness constraints given in the W3 specification. • 3. Each of the parsed entities which is referenced directly or indirectly within the document is well-formed. …I find this a bit vague…

  6. What is “Well Formed” XML? • There are Elements, Tags and Character Data, eg: <person> Alan Turing </person> • The whole example was a person Element. • Alan Turing was Character Data • <person> was a tag

  7. What is “Well Formed” XML? • Elements MUST be closed • Tags may be opening or closing tags of elements • Alternatively, single tags may be closed by a slash, eg <img src=“picture.gif” /> • Elements may also be empty

  8. What is “Well Formed” XML? • Tags have Names and Attributes <p font=“ariel”> (p was a name; font was an attribute) • XML is case sensitive, so the name “BR” is regarded as different to “br” • XML must be well nested: <b><i> Horrors!!! </b></i>

  9. What is “Well Formed” XML? Names and attributes may contain: • A…Z, a…z or the characters of ANY alphabet (eg: א...ي) • Numbers 0…9 • Underscore_ • Hyphen- • Period. • That’s it.

  10. What is “Well Formed” XML? • Tags must be closed. • Elements may contain elements - nesting must "proper". • Tags may contain attributes. • Characters such as < and & must be "escaped" as &lt; and &amp; - they have a special significance in XML and may not appear in data unescaped

  11. What is “Well Formed” XML? • Must begin with the XML declaration • Must have one unique root element • All start tags must match end-tags • XML tags are case sensitive • All elements must be closed • All elements must be properly nested • All attribute values must be quoted • XML entities must be used for special characters

  12. What is “Well Formed” XML? • Well-formedness is not the same as Validity (see later) Amazingly strict rule: • If a parser encounters a well-formedness violation while parsing a document, it MUST STOP (usually with a useful error message)

  13. Pop Quiz 5 Minutes Maximum!

  14. Pop Quiz Truth is relative. Let’s vote on the answers.

  15. What is “Valid” XML? If an XML document is well-formed we may ask if it is valid. A valid XML document is one that agrees with the additional rules set out in a DTD (document type definition). The DTD includes: • ELEMENT: These dictate what kind of child nodes each element is permitted. • ATTLIST: This indicates what kind of attributes are permitted.

  16. Scalable Vector Graphics (SVG) • (In bit-map graphics we specify the colour of each pixel in a grid). This isn’t it. • Instead, we describe objects to be rendered. • Allows us to produce graphics (boxes, lines, curves, text) in a scalable format. • Arbitrarily high resolution with constant file size. • Similar to Flash (but Flash has binary format) • Designed and controlled by W3C

  17. An Easy Example (SVG) <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "../../svg11-flat.dtd"> <svg width="12cm" height="4cm" viewBox="0 0 1200 400" xmlns="http://www.w3.org/2000/svg" version="1.1"> <circle cx="600" cy="200" r="100" fill="red" stroke="blue" stroke-width="10" /> <rect width="20" height="10"/> <text>Kilroy was here.</text> </svg>

  18. Scalable Vector Graphics (SVG) • Good example of an XML application. • Standard defined by www.w3.org • W3C supply a DTD and a description of how each element should be interpreted • Anyone can produce a processor for the language • Anyone can produce content.

  19. Narrative and Record Documents • XML documents normally fall into two categories: • An XHTML description of a web page starts at the beginning of the document and works its way down to the end • An XML description of a spreadsheet simply describes the data (there isn’t a beginning or an end)

  20. Narrative and Record Documents • An XHTML web page is an example of a Narrative document • A spreadsheet in Microsoft Office Open XML (OOXML) is an example of a record document.

  21. XML in 10 Points 1. XML lets you put structured data in a text file 2. XML looks like HTML but isn't HTML 3. XML is text, but isn't meant to be read 4. XML is a family of technologies 5. XML is verbose, but that is not a problem

  22. XML in 10 Points 6. XML is new, but not that new 7. XML is license-free 8. XML is platform-independent 9. XML is well-supported 10. XML is a W3 standard 11. For what it does, there are no competitors

  23. Recap of Unit • What is XML? • What is “Well Formed” XML? • What is “Valid” XML? • Document Type Definitions • Scalable Vector Graphics (SVG) • XML in 10 Points • Some Questions for You

More Related