260 likes | 333 Views
CSE 3345 - Graphical User Interfaces. Chris Raley craley@smu.edu Lecture 1 – HTML Warmup. HTML Warm-up. H – hyper T – text M – markup L – language . Markup Language. Used to give structure to a document Composed of tags to ‘mark ’ the data inside a document
E N D
CSE 3345 - Graphical User Interfaces Chris Raley craley@smu.edu Lecture 1 – HTML Warmup
HTML Warm-up H – hyper T – text M – markup L – language CSE 3345
Markup Language • Used to give structure to a document • Composed of tags to ‘mark’ the data inside a document • Tags encapsulate and classify data • Tags provide semantic markup or meaning to the data CSE 3345
Markup Language Example <class> <teacher>Professor X</teacher> <students> <student age=“17”>Jean Grey</student> <student age=“16”>Scott Summers</student> </students> </class> CSE 3345
Tags <class> <teacher>Professor X</teacher> <students> <student age=“17”>Kitty Pride</student> <student age=“16”>Scott Summers</student> </students> </class> CSE 3345
Data <class> <teacher>Professor X</teacher> <students> <student age=“17”>Kitty Pride</student> <student age=“16”>Scott Summers</student> </students> </class> CSE 3345
Tags Three types of tags Opening: <tag> Closing: </tag> Solo: <tag/> <tag>Data</tag><tag data=“”/> Opening Closing Solo CSE 3345
Elements • Tags are also called elements • Can contain attributes, child elements, and data • An opening element must have a closing element • An element’s opening and closing tag must have the same name (case counts). GoodBad <element></element> <element></tron> CSE 3345
Elements All information that belongs to an element must be contained between its opening and closing tags. CSE 3345
A Bad example <friend> <name>Sally</name> <age>21</age> </friend> <gender>F</gender> CSE 3345
A Good example <friend> <name>Sally</name> <age>21</age> <gender>F</gender> </friend> CSE 3345
Attributes • Specify additional information about an element • Appears within the opening or solo tag <friend age=“21”>Sally</friend> <friend age=“21” name=“Sally”/> CSE 3345
Root Element <class> <teacher>Professor X</teacher> <students> <student age=“17”>Jean Grey</student> <student age=“16”>Scott Summers</student> </students> </class> CSE 3345
Root Element • There can only be ONE • Must be the first element • Describes what the document is composed of CSE 3345
Dissecting the Document <dinner begins=“5:00pm” ends=“9:30pm” > <entrées> <entrée price=“4.95”>Hamburger</entrée> <entrée price=“1.95”>French Fries</entrée> </entrées> <drinks> <drink price=“1.95”>Milk Shake</drink> <drink price=“0.00”>Water</drink> </drinks> <desserts> <dessert price=“0.75”>Apple Pie</dessert> </desserts> </dinner> Find the root, elements, and attributes. How many unique elements are there? What is the data? What story does the document tell us? CSE 3345
XML <?xml version="1.0" encoding="ISO-8859-15"?> <!DOCTYPE note SYSTEM "Note.dtd"> <class> <teacher>Professor X</teacher> <students> <student age=“17”>Kitty Pride</student> </students> </class> CSE 3345
XML - Prolog <?xml version="1.0" encoding="ISO-8859-15"?> • Specifies version of document • Encoding type • DTD • Is optional (not needed) CSE 3345
XML - DTD <!DOCTYPE note SYSTEM "Note.dtd"> DTD – Document Type Definition • Specifies the rules the document conforms to CSE 3345
The XML Tree CSE 3345
XML Trees • A computer represents an xml document in memory as a tree. CSE 3345
Family Tree Dad Mom Brother Me Sister CSE 3345 CSE 3345
XML Tree <class> <teacher>Professor X</teacher> <students> <student age=“17”>Jean Grey</student> <student age=“16”>Scott Summers</student> </students> </class> Class Teacher: Professor X Students Student: Scott Summers Student: Jean Grey CSE 3345
XML Family Tree <dinner begins=“5:00pm” ends=“9:30pm” > <entrées> <entrée price=“4.95”>Hamburger</entrée> <entrée price=“1.95”>French Fries</entrée> </entrées> <drinks> <drink price=“1.95”>Milk Shake</drink> <drink price=“0.00”>Water</drink> </drinks> <desserts> <dessert price=“0.75”>Apple Pie</dessert> </desserts> </dinner> CSE 3345
XML Family Tree Legend element data dinner drinks desserts entrees drink Water entrée Hamburger entrée French Fries drink Milk Shake dessert Apple Pie CSE 3345
Family Tree Terms • Ancestor – Anyone that comes before you • Descendant – Anyone that comes after you • Parent – An element’s direct ancestor • Child – An element contained one level below another element • Sibling – When elements share the same parent CSE 3345
Dissect the Family Tree Legend element data dinner drinks desserts entrees drink Water entrée Hamburger entrée French Fries drink Milk Shake dessert Apple Pie CSE 3345