xml why is xml so popular? –it’s flexible –it enables you to create your own documents with...

34

Post on 20-Dec-2015

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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: This is a
Page 2: 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: This is a

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?

Page 3: 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: This is a

XML

• What does the browser see?

<p>blah, blah, blah</p>

Page 4: 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: This is a

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>

Page 5: 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: This is a

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

Page 6: 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: This is a

XML

• XML documents may have three parts– Prolog– Body– Epilog

• Prolog– Comments & processing instructions– Version information– Reference to a specific XML DTD or schema

Page 7: 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: This is a

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

Page 8: 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: This is a

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

Page 9: 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: This is a

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?

Page 10: 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: This is a

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

Page 11: 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: This is a

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)

Page 12: 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: This is a

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

Page 13: 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: This is a

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

Page 14: 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: This is a

XML

• <script> and <style> elements must be marked as CDATA areas

<script language=”Javascript”><![CDATA[function clickalert() {

alert(“VSNET is cool!”)}]]>

</script>

Page 15: 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: This is a

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

Page 16: 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: This is a

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

Page 17: 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: This is a

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

Page 18: 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: This is a

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

Page 19: 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: This is a

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

Page 20: 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: This is a

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

Page 21: 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: This is a

.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

Page 22: 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: This is a

.NET Structures & Languages

• Communications protocols– VS.NET supports many– Necessary for networked environment

• Multiple computers• Multiple operating systems

• Encoding formats– ISO 8859-1– Unicode

Page 23: 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: This is a

.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 …

Page 24: 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: This is a

.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

Page 25: 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: This is a

.NET Structures & Languages

• Constants– Literals (simply a value): Const 19.95– Symbolic (includes name): Const TVPrice=19.95

• Comments– Begins with apostrophe

Page 26: 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: This is a

.NET Structures & Languages

• Data types– Boolean– String– Integer– Decimal– Date– Object– User-defined

Page 27: 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: This is a

.NET Structures & Languages

• Operators– Assignment

• =

– Arithmetic• + - / * ^

– Relational• < <= = <> >= >• Like

– Wild cards * and ?

Page 28: 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: This is a

.NET Structures & Languages

• Operators (cont.)– Logical

•and•or

– Concatenation•+ &

Page 29: 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: This is a

.NET Structures & Languages

• Control Structures– if…then– do– for…next– select case– while…wend– with

Page 30: 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: This is a

.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

Page 31: 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: This is a

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

Page 32: 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: This is a

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

Page 33: 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: This is a

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

Page 34: 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: This is a

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