Presentation is loading. Please wait.

Presentation is loading. Please wait.

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!

Similar presentations


Presentation on theme: "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!"— Presentation transcript:

1 Introduction to XML BKF04 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 o Albums  Songs Beatles o The White Album  Back in the U.S.S.R.  Helter Skelter o Abbey Road  Come Together  Oh! Darling

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

6 XML Syntax Rule 1 Every opened tag must be closed. stuff more stuff GoodBad

7 Nested Tags Beatles Frank Sinatra U2

8 XML Syntax Rule 2 All children tags must be closed before the parent tag is closed. hi! hi! GoodBad

9 Tag Attributes Come Together Oh! Darling

10 XML Syntax Rule 3 Attributes must be located in the open tag, and their values must be wrapped in quotation marks. Dog NYC GoodBad

11 Other Syntax Tidbits Special characters CharacterRepresentationMeaning >>Greater than <<Less than “"Quote &&Ampersand

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 SymbolDefinition () The items within the parentheses define the contents of the element or attribute ? Either 0 or 1 instances of an element is allowed (i.e., the element is optional) + 1 or more instances of an element is allowed (i.e., the element is required) * 0 or more instances of an element is allowed (i.e., the element is not required) | The items separated by the pipe define the allowed values for an element EMPTY The element cannot contain body content CDATA Character data that is not parsed #PCDATA Character data that is parsed #REQUIRED The attribute is required, a value must be specified #IMPLIED The attribute is optional; if a value is not specified, then some default value will be used

14 Element Definition <!ELEMENT artist (comment?, member*, album+)>

15 DTD Example 1......... GoodBad

16 Attribute Definition <!ATTLIST album nameCDATA#REQUIRED yearCDATA#REQUIRED format(CD|MP3)"MP3">

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

18 Extras w3schools.com XML Tutorial http://www.w3schools.com/xml http://www.w3schools.com/xml W3C XML Specification http://www.w3.org/TR/REC-xml http://www.w3.org/TR/REC-xml Notepad++ text editor http://notepad-plus.sourceforge.net http://notepad-plus.sourceforge.net

19 Thank you. bciccolo@x2dev.com


Download ppt "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!"

Similar presentations


Ads by Google