1 / 19

Introduction to XML BKF04

Introduction to XML BKF04. Brian Ciccolo. Agenda. XML revealed What is it and why should I care? Syntax semantics Elements and tags and attributes, oh my! Document validation Following the rules of the road. XML Revealed. What is it? eXtensible Markup Language Structured data.

dava
Télécharger la présentation

Introduction to XML BKF04

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. Introduction to XMLBKF04 Brian Ciccolo

  2. Agenda • XML revealed • What is it and why should I care? • Syntax semantics • Elements and tags and attributes, oh my! • Document validation • Following the rules of the road

  3. XML Revealed • What is it? • eXtensible Markup Language • Structured data Why should I care? • It’s used throughout Aspen • It’s easy to learn • It’s fun!

  4. Music Collection Example • A simple hierarchy: • Artists • Albums • Songs • Beatles • The White Album • Back in the U.S.S.R. • Helter Skelter • Abbey Road • Come Together • Oh! Darling

  5. Tags: The Building Blocks of XML <music-collection> This is my music collection. Not very impressive yet. </music-collection>

  6. XML Syntax Rule 1 • Every opened tag must be closed. Good Bad <example1> stuff </example1> <example2 /> <example3> more stuff

  7. Nested Tags <music-collection> <artist>Beatles</artist> <artist>Frank Sinatra</artist> <artist>U2</artist> </music-collection>

  8. XML Syntax Rule 2 • All children tags must be closed • before the parent tag is closed. Good Bad <parent> <child>hi!</child> </parent> <parent> <child>hi! </parent> </child>

  9. Tag Attributes <album title=“Abbey Road”year=“1969”> <song>Come Together</song> <song>Oh! Darling</song> </album>

  10. XML Syntax Rule 3 • Attributes must be located in the open tag, • and their values must be wrapped in quotation marks. Good Bad <pet name=“Lucky” /> <pet name=“Spot”> <type>Dog</type> </pet> <state name=MA /> <state> <city>NYC</city> </state name=“NY”>

  11. Other Syntax Tidbits • <?xml version="1.0"?> • <!-- comments --> • Special characters

  12. Validating with DTD • Document Type Definition • Defines the elements and attributes allowed within an XML document • Syntax based on the XML we just learned

  13. DTD Symbols

  14. Element Definition <!ELEMENT artist (comment?, member*, album+)> <!ELEMENT comment #PCDATA> <!ELEMENT member EMPTY> <!ELEMENT album (song+)> <!ELEMENT song EMPTY>

  15. DTD Example 1 Good Bad <artist> <member>...</member> <member>...</member> <album>...</album> <album>...</album> <album>...</album> </artist> <!-- snippet 1 --> <artist> <member>...</member> <comment>...</comment> </artist> <!-- snippet 2 --> <song>...</song>

  16. Attribute Definition <!ATTLIST album name CDATA #REQUIRED year CDATA #REQUIRED format (CD|MP3) "MP3">

  17. DTD Example 2 Good Bad <album name=“The White Album” year=“1968”> ... </album> <album year=“1969” format=“CD” name=“Abbey Road”> ... </album> <album name=“Abbey Road” format=“Vinyl”> ... </album>

  18. Extras • w3schools.com XML Tutorialhttp://www.w3schools.com/xml • W3C XML Specificationhttp://www.w3.org/TR/REC-xml • Notepad++ text editorhttp://notepad-plus.sourceforge.net

  19. Thank you. bciccolo@x2dev.com

More Related