Presentation is loading. Please wait.

Presentation is loading. Please wait.

Thayer School of Engineering Dartmouth Lecture 2 Overview Web Services concept XML introduction Visual Studio.net.

Similar presentations


Presentation on theme: "Thayer School of Engineering Dartmouth Lecture 2 Overview Web Services concept XML introduction Visual Studio.net."— Presentation transcript:

1 Thayer School of Engineering Dartmouth Lecture 2 Overview Web Services concept XML introduction Visual Studio.net

2 Thayer School of Engineering Dartmouth HTML is HyperTex Markup Language HTML is a “specialization” of SGML HTML is a language for describing how web pages should look. HTML has some constructions for forms, frames, etc that make it a bit more dynamic. HTML is very simple....we’re going to go over only the basics...other sources: - read the source of other pages - web HTML manuals and how-to’s HTML Primer

3 Thayer School of Engineering Dartmouth Basic syntax of an HTML HTML uses “tags” tags typically have a beginning and a closing version. example....every html page should start with the tag – and end with – Not essential but good style.

4 Thayer School of Engineering Dartmouth Basic structure of an HTML page Our first page!! Blah, blah, blah

5 Thayer School of Engineering Dartmouth Why Web Services? HTML describes the formatting of a web page Originally designed to let people read web pages easily via that formatting The structure of the page is not necessarily conveyed by HTML The meaning of a page is certainly not in the HTML If programs are to consume information on web pages, then HTML is not enough

6 Thayer School of Engineering Dartmouth What are Web Services? A language to define web resources’ structure/syntax - XML A transport protocol for moving XML - SOAP A language to describe a service – WSDL Directory-like services to locate XML described services - UDDI

7 Thayer School of Engineering Dartmouth Example of XML Mocha Java 11.95 Sumatra 12.50

8 Thayer School of Engineering Dartmouth XML Overview XML vs HTML –HTML is a presentation markup language –XML is a content markup language –both are derivatives of SGMLSGML –“elements”, “attributes”, “values” and content –syntax is more strict in XML than in HTML –large development activity underway –version 1.0

9 Thayer School of Engineering Dartmouth Examples DARPA Agent Markup Language (DAML) Genome information XML registries MathML

10 Thayer School of Engineering Dartmouth Example Created with a text editor and saved in file.xml Jane Smith AT&T (212) 555-4567

11 Thayer School of Engineering Dartmouth Example Jane Smith elementattributevalue content Elements can be nested interspersed with “text” Jane Smith works at AT&T.

12 Thayer School of Engineering Dartmouth XML Declaration All XML documents can optionally begin with an XML declaration. The XML declaration provides at a minimum the number of the version of XML in use: Currently, 1.0 is the only approved version of XML, but others may appear in the future. The XML declaration can also specify the character encoding used in the document:

13 Thayer School of Engineering Dartmouth Encodings All XML parsers: Unicode “UTF-8” and “UTF-16” encodings. the XML declaration is case sensitive: it may not begin with “<?XML” or any other variant; if the XML declaration appears at all, it must be the very first thing in the XML document: not even whitespace or comments may appear before it; and it is legal for a transfer protocol like HTTP to override the encoding value that you put in the XML declaration, so you cannot guarantee that the document will actually use the encoding provided in the XML declaration.

14 Thayer School of Engineering Dartmouth Elements “elements” are the logical units of information in an XML document. An element consists of a start tag, optional text or other complete elements, followed by an end tag. Tony Blair is Prime Minister of GreatBritain.

15 Thayer School of Engineering Dartmouth Parsing this example... the p element, that contains the entire example (the person element, the text “ is ”, the function element, the text “ of ”, and the location element); the person element, that contains the text “Tony Blair”; the function element, that contains the text “Prime Minister”; the location element, that contains the country element; and the country element, that contains the text “Great Britain”.

16 Thayer School of Engineering Dartmouth Element “tree”

17 Thayer School of Engineering Dartmouth Syntax errors President Habibe Tags must be nested properly. eg... President Habibe

18 Thayer School of Engineering Dartmouth Syntax.... An XML document must have only one “root” element.... The following example fixes the problem by including both the a and b elements within a new x root element:...

19 Thayer School of Engineering Dartmouth Syntax.... polar bear This example will cause a parser error because an XML processor considers a and A to be separate elements, so the start and end tags do not match. Case sensitive!!! XML has a special empty-element tag that represents both the start tag and the end tag: Stuff More stuff. In this example, “ ” represents both the start and the end of the hr element; equivalent to “ ”

20 Thayer School of Engineering Dartmouth Attributes In addition to marking the beginning of an element, XML start tags also provide a place to specify attributes. An attribute specifies a single property for an element, using a name/value pair. One very well known example of an attribute is href in HTML: Yahoo! In this example, the content of the a element is the text “Yahoo!”; the attribute href provides extra information about the element (in this case, the Web page to load when a user selects the link).

21 Thayer School of Engineering Dartmouth Attributes Every attribute assignment consists of two parts: the attribute name (for example, href), and the attribute value (for example, http://www.yahoo.com/). Some rules : Attribute names in XML (unlike HTML) are case sensitive: HREF and href refer to two different XML attributes. You may not provide two values for the same attribute in the same start tag. This is wrong:.... Attribute names should never appear in quotation marks, but attribute values must always appear in quotation marks in XML (unlike HTML) using the " or ' characters....

22 Thayer School of Engineering Dartmouth References A reference allows you to include additional text or markup in an XML document. References always begin with the character “&” (which is specially reserved) and end with the character “;”. XML has two kinds of references: entity references An entity reference, like “&”, contains a name (in this case, “amp”) between the start and end delimiters. The name refers to a predefined string of text and/or markup, like a macro in the C or C++ programming languages. character references A character references, like “&”, contains a hash mark (“#”) followed by a number. The number always refers to the Unicode code for a single character, such as 65 for the letter “A” or 233 for the letter “é”, or 8211 for an en-dash.

23 Thayer School of Engineering Dartmouth Predeclared References Character Predeclared Entities & & < < > > " " ' &apos;

24 Thayer School of Engineering Dartmouth DTD’s.... This the syntax of an XML document. The structure (elements, etc) of an XML document are specified by a “schema”. If an XML document adheres to a prespecified schema, it is valid....ie the syntax is compliant with the schema. Schemas are specified by DTD’s or XML Schema. We’ll look at both DTD’s and XML Schema next.

25 Thayer School of Engineering Dartmouth Different types of DTD’s Internal DTD - inside.xml file External DTD - file with.dtd extension “SYSTEM” (private) vs “PUBLIC” Local extensions,rules can be added to external reference and override the external DTD.

26 Thayer School of Engineering Dartmouth Using a DTD from within an.xml... Naming DTD’s using Formal Public Identifiers (FPI’s)..... Next class....structure of the DTD and XML Schema.

27 Thayer School of Engineering Dartmouth Defining elements Elements name and company must be defined elsewhere, before, after or externally. means name occurs at least once, company zero or more times. + means at least once, ? means zero or one, * means zero or more so (name,name,name+) means at least three time, etc.

28 Thayer School of Engineering Dartmouth XMl Tutorials and References Let’s find a few….. XML Parser in Visual Studio


Download ppt "Thayer School of Engineering Dartmouth Lecture 2 Overview Web Services concept XML introduction Visual Studio.net."

Similar presentations


Ads by Google