1 / 24

XML Technologies

XML Technologies. XML Basics What is XML? Why use XML? How to write XML?. Week 1: XML Basics > 1. What is XML?. 1. What is XML?. e X tensible Markup Language Markup: text + annotations <p> This is a sentence. </p> Extensible: A language for creating new markup languages

halima
Download Presentation

XML Technologies

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 Technologies XML Basics What is XML? Why use XML? How to write XML? XML Technologies - 2012 - David Raponi

  2. Week 1: XML Basics > 1. What is XML? 1. What is XML? • eXtensible Markup Language • Markup: text + annotations • <p>This is a sentence.</p> • Extensible: A language for creating new markup languages • <myTag>I can make up anything</myTag> XML Technologies - 2012 - David Raponi

  3. Week 1: XML Basics > 1. What is XML? An example: <?xml version=“1.0” encoding=“utf-8”?> <family> <parents> <parent gender=“male”>Romolo</parent> <parent gender=“female”>Silvia</parent> </parents> <children> <child gender=“male”>David</child> </children> </family> XML Technologies - 2012 - David Raponi

  4. Week 1: XML Basics > 1. What is XML? What it is and what it isn’t… • It is self-descriptive (commonsense tag names) • Focuses on STORING and DEFINING data • Focuses also on ORGANIZING data for easy manipulation • It does not handle displaying of data… that’s HTML’s job • It is not a processing “code” of any kind • It is not a version of XHTML XML Technologies - 2012 - David Raponi

  5. Week 1: XML Basics > 1. What is XML? Advantages of XML • Easily read by humans • Simple and lightweight • Bridges a gab between simple lists and overkill databases • Platform independent • Lots of technologies exist to work with XML • Anal-retentively dependable! XML Technologies - 2012 - David Raponi

  6. Week 1: XML Basics > 1. What is XML? Markup and so much more… To Summarize, XML is: - a markup language that allows for simple and contextualstorage of data that can be easily read and manipulated. - but on its own, it doesn’t actually DO anything. It’s just a bunch of information, like a grocery list. XML Technologies - 2012 - David Raponi

  7. Week 1: XML Basics > 1. What is XML? Markup and so much more… Another amazing aspect: XML can be used to create new markup languages This is because the tags are named however you wish, and then “definitions” (next week) can be made for those new tags. XML Technologies - 2012 - David Raponi

  8. Week 1: XML Basics > 1. What is XML? Example revisited: What do we notice? <?xml version=“1.0” encoding=“utf-8”?> <family> <parents> <parent gender=“male”>Romolo</parent> <parent gender=“female”>Silvia</parent> </parents> <children> <child gender=“male”>David</child> </children> </family> XML Technologies - 2012 - David Raponi

  9. Week 1: XML Basics > 1. What is XML? Initial observations: • Requires an initial declaration • <?xml version=“1.0” encoding=“utf-8”?> • Made up of elements (open + close tags) • Tags may contain attributes • There is a nesting structure • Can can create your own elements (only a very few naming restrictions apply) XML Technologies - 2012 - David Raponi

  10. Week 1: XML Basics > 1. What is XML? A quick comparison: <?xml version=“1.0” encoding=“utf-8”?> <family> <males> <person role=“father”>Romolo</person > <person role=“child”>David</person > </males> <females> <person role=“mother”>Silvia</person > </females> </family> Q: Is it all the same? Does it matter? Is there another way to write it out? XML Technologies - 2012 - David Raponi

  11. Week 1: XML Basics > 2. Why use XML? 2. Why use XML? • Since XML is… • Lightweight • Self-definable • Platform independent • Great for organizing information • … we can… XML Technologies - 2012 - David Raponi

  12. Week 1: XML Basics > 2. Why use XML? What can you do with XML? Create Twitter feeds Probably everything on Facebook Make scalable graphics (vector images) Run an entire website (no HTML files!) Host fun XML parties… ? Program Documents (get ready to have your minds blown…) Transfer data quickly (webservices) XML Technologies - 2012 - David Raponi

  13. Week 1: XML Basics > 2. Why use XML? What can you do with XML? Keep data and design separate (quick and simplified updates!) Quick storage of data (mini-database) Sending out and reading in info (RSS, podasts) Quick referencing (saving settings) Smaller scale CMSs Blogs XML Technologies - 2012 - David Raponi

  14. Week 1: XML Basics > 2. Why use XML? When NOT to use XML? When a dedicated database is warranted When display is most important factor Basically whenever another technology can get the job done faster. XML Technologies - 2012 - David Raponi

  15. Week 1: XML Basics > 2. Why use XML? When NOT to use XML? Please note: you will not use every technology you learn in this program on a daily basis. It very much depends on your future career. Making simple sites? Not much XML involved. Working for dedicated web services, data industries (banks, hospitals, etc) or in IT? Lots of XML! XML Technologies - 2012 - David Raponi

  16. Week 1: XML Basics > 3. How to write XML? 3. How to write XML Declaration and root Reserved words Special characters Elements and attributes Nesting Must be “Well-Formed” XML Technologies - 2012 - David Raponi

  17. Week 1: XML Basics > 3. How to write XML? Declaration Declaration and the root Reserved words Special characters Elements and attributes Nesting Must be “Well-Formed” • Each XML document must begin with a declaration. This tells the program (in our case, the browser) to interpret it as XML • <?xml version=“1.0”?> (no closing tag!) • Options include: • encoding=“utf-8” (or “ISO-8859-1”) • standalone=“yes” (or “no”) • Yes: the DTD is located internally • No: the DTD is external (default) XML Technologies - 2012 - David Raponi

  18. Week 1: XML Basics > 3. How to write XML? Declaration Declaration and the root Reserved words Special characters Elements and attributes Nesting Must be “Well-Formed” Each XML document must also have a root element within which everything else is found. <?xml version=“1.0”?><elementName> … </elementName XML Technologies - 2012 - David Raponi

  19. Week 1: XML Basics > 3. How to write XML? 3. How to write XML Declaration and the root Reserved words Special characters Elements and attributes Nesting Must be “Well-Formed” • There are no reserved words in XML! • However, you cannot: • Begin with a number • Begin with punctuation • Have any spaces • Begin with “xml” • Good: <fish> • Bad: <2fish> <a fish> <?fish> <xmlFish> XML Technologies - 2012 - David Raponi

  20. Week 1: XML Basics > 3. How to write XML? 3. How to write XML Declaration and the root Reserved words Special characters Elements and attributes Nesting Must be “Well-Formed” There are a few characters that should be replaced as follows: & &amp; <  &lt; >  &gt; ‘  &apos; “  &quote; (except for in attributes) I’m already lying to you: only the first two (& and <) are strict no-nos. Everything else is “good practice” to make life easier. XML Technologies - 2012 - David Raponi

  21. Week 1: XML Basics > 3. How to write XML? 3. How to write XML Declaration and the root Reserved words Special characters Elements and attributes Nesting Must be “Well-Formed” An element consists of an opening and closing tag (like in HTML) of the same case. An element can contain any number of attributes with values wrapped in matching quotes. Good: <tag attribute=“something”></tag> Bad: <tag attribute=“something’></Tag> Note: whenever possible, avoid attributes. They should be reserved for “metadata”. XML Technologies - 2012 - David Raponi

  22. Week 1: XML Basics > 3. How to write XML? 3. How to write XML Declaration and the root Reserved words Special characters Elements and attributes Nesting Must be “Well-Formed” • Open and close tags as you would in HTML, that is: In the proper order. • <section><title>My Title</section></title> • This causes kittens to explode  • <section><title>My Title</title></section> •  Kittens live another day  XML Technologies - 2012 - David Raponi

  23. Week 1: XML Basics > 3. How to write XML? 3. How to write XML Declaration and the root Reserved words Special characters Elements and attributes Nesting Must be “Well-Formed” • To be well-formed, XML must PHYSICALLY be written correctly. It may or may not live up to the pre-determined requirements (it will not validate), but it is at least an honest and true XML document: • Must include initial declaration • Must have a root element that captures everything else • All tags must be closed • All attribute values must be in quotes • No illegal characters present • No illegally named elements XML Technologies - 2012 - David Raponi

  24. Week 1: XML Basics > 3. How to write XML? Final remarks Remember, XML doesn’t just store data, it organizes it. The organizational approach of an XML document should be carefully considered since the structure itself can also be thought of as data. <course>HTML</course> <course>JS 1</course><course>JS 2</course><course>CSS</course> <course>PHP</course> <semester> <course>HTML</course> <course>JS 1</course> </semester> <semester> <course>JS 2</course> <course>CSS</course> <course>PHP</course> </semester> Technically, the data is the same, but the 2nd structure reveals more information! XML Technologies - 2012 - David Raponi

More Related