340 likes | 450 Views
XML. Why is XML so popular? It’s flexible It enables you to create your own documents with elements (tags) that you define Non-XML example: <p>This is a paragraph of text</p> What does this tell you? What does it tell a program?. XML. What does the browser see? <p> blah, blah, blah </p>.
E N D
XML • Why is XML so popular? • It’s flexible • It enables you to create your own documents with elements (tags) that you define • Non-XML example: <p>This is a paragraph of text</p> • What does this tell you? • What does it tell a program?
XML • What does the browser see? <p>blah, blah, blah</p>
XML • XML example: <pets> <pet> <type>Dog</type> <name>Rover</name> <age>12</age> <owner>Dave</owner> </pet> </pets> <html> <body> <p> <img…> <a href=…> <script…> <form…> </body> </html>
XML • XML tags provide meaning or context • Programs can interpret these meanings • XML is ideal for sharing data between programs • One user can encode data using XML and share it with others • A different user can interpret that data
XML • XML documents may have three parts • Prolog • Body • Epilog • Prolog • Comments & processing instructions • Version information • Reference to a specific XML DTD or schema
XML • Epilog • Comments & processing instructions • Body • One or more elements • Defined by the DTD or schema • Forms a hierarchical tree structure • One top-level element • All others below it in the hierarchy
XML • Why is XML important? • Forms the basis for web services • How is XML different from HTML? • HTML is fairly forgiving of errors <p>This is a paragraph will probably work OK • You can mix upper and lower case • Attribute values don’t have to be enclosed in quotes
XML • Bottom line: • Poorly-formed HTML documents are no big deal • XML does not provide that level of informality • You have to follow the rules • What are the rules to remember?
XML • XHTML documents must have a DOCTYPE declaration <!DOCTYPE html PUBLIC ¬ “-//W3C//DTD XHTML 1.0 Transitional//EN” ¬ http://www/w3/org/TR/xhtml/11/DTD/xhtml1- transitional.dtd> • Must occur before the root element
XML • Root element • Top of the hierarchy of elements (<html>) • Only one element at this level • No other elements before it • No other elements after the ending tag (</html>) • Lowercase only (XML is case sensitive)
XML • Attribute values must be encased in quotes • HTML: <img … width=72> • XML: <img … width=“72”> • Attribute values must not be minimized • That is, the name entered without a value • That’s why selected=“selected” • Spaces in attribute values will be removed
XML • Only the id attribute is used to uniquely identify an element • The name element is not recognized • Both starting and ending tags are required • HTML: <br> • XML: <br/> • Elements must be nested, not overlapping
XML • <script> and <style> elements must be marked as CDATA areas <script language=”Javascript”> <![CDATA[ function clickalert() { alert(“VSNET is cool!”) } ]]> </script>
Object-Oriented Concepts • Object-oriented programming • Certain block of code treated as reusable objects • Accept certain inputs • Produce certain outputs • Programmer doesn’t have to know how the output is produced, only how to manipulate the object • Programmer has to know what parts of an object can be manipulated
Object-Oriented Concepts • Properties • Contain values • Addressable • That is, programmer has access to the property • Methods • Functions that the object can perform • Can supply data via arguments • Don’t have to know how they work
Object-Oriented Concepts • Events • Triggers that are activated in specific situations • Affects object without user intervention • Many objects are already part of the VS.NET environment • You don’t have to create them, only use them • You can build your own objects if you need to
Object-Oriented Concepts • Objects are derived from classes • Classes are basically templates • Human is a class • An object is an instance of a class • Creating an object is called instantiation • Making a baby is instantiating a human
Object-Oriented Concepts • Encapsulation • Objects can be used without knowing what goes on inside them • Inheritance • New classes can be created based on base classes • Each new derived class • Inherits the properties and methods of the base class • May have properties and methods not in the base class
Object-Oriented Concepts • Polymorphism • Properties and methods of both base and derived classes can have the same name and be used in the same way • This means that the output of a method may be produced by completely different internal processing methods • The user doesn’t care
.NET Structures & Languages • Common Language Runtime (CLR) • CLR is an intermediate state • Not source • Not object • Makes VS.NET applications machine independent • Code running within the CLR is called managed code
.NET Structures & Languages • Communications protocols • VS.NET supports many • Necessary for networked environment • Multiple computers • Multiple operating systems • Encoding formats • ISO 8859-1 • Unicode
.NET Structures & Languages • VS.NET supports • Visual Basic (VB.NET) • C# • J# • Others being added • We’ll be using VB.NET • It’s components are …
.NET Structures & Languages • Variables • Strongly typed • Name begins with alphabetic character • May contain alphabetic characters or digits • No special characters or punctuation symbols • No more than 255 characters in length • Cannot match a reserved word • Declared: dim SSN as String
.NET Structures & Languages • Constants • Literals (simply a value): Const 19.95 • Symbolic (includes name): Const TVPrice=19.95 • Comments • Begins with apostrophe
.NET Structures & Languages • Data types • Boolean • String • Integer • Decimal • Date • Object • User-defined
.NET Structures & Languages • Operators • Assignment • = • Arithmetic • + - / * ^ • Relational • < <= = <> >= > • Like • Wild cards * and ?
.NET Structures & Languages • Operators (cont.) • Logical • and • or • Concatenation • + &
.NET Structures & Languages • Control Structures • if…then • do • for…next • select case • while…wend • with
.NET Structures & Languages • Namespaces • Closed set of names that identifies elements from a DTD • Can be used to include classes of objects in an application • Scope • Local • Blobal
Example Application • What savings are needed to achieve a specific retirement goal? • Variables • Amount at retirement • Amount saved each month • Time until retirement • Interest rate
Example Application • Web page format • Welcome page with link to a form • Data entry form • Results shown in browser window • Validation on client side • Javascript • Processing on server side • Computations
Example Application • Server-side processing is a little different • Web form – web page in HTML with a form • Form written in HTML on client side • Comes to client from server • Page & form start on server • Contains HTML and other elements (XML) • Application also includes code behind the page • Web form and Code-Behind page automatically generated by VS.NET
Assignment • Complete the application described on pages 53 thru 63 • Follow the instructions exactly • You can check your code the same way I will • Through a browser: http://coit-ts2003.uncc.edu/ • Grade based on functionality