1 / 28

Lecture 2 Overview

Lecture 2 Overview. Web Services concept XML introduction Visual Studio .net. HTML Primer. 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

lesley
Download Presentation

Lecture 2 Overview

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 2 Overview • Web Services concept • XML introduction • Visual Studio .net

  2. HTML Primer 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

  3. 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 • <html> and end with • </html> Not essential but good style.

  4. Basic structure of an HTML page <html> <head> <title> Our first page!! </title> </head> <body> Blah, blah, blah </body> </html>

  5. 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. 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. Example of XML <priceList>    <coffee>      <name>Mocha Java</name>      <price>11.95</price>    </coffee>    <coffee>      <name>Sumatra</name>      <price>12.50</price>    </coffee> </priceList>

  8. XML Overview • XML vs HTML • HTML is a presentation markup language • XML is a content markup language • both are derivatives of SGML • “elements”, “attributes”, “values” and content • syntax is more strict in XML than in HTML • large development activity underway • version 1.0

  9. Examples • DARPA Agent Markup Language (DAML) • Genome information • XML registries • MathML

  10. Example Created with a text editor and saved in file.xml <?xml version="1.0"?> <contact-info> <name format=“FNLN”>Jane Smith</name> <company>AT&amp;T</company> <phone>(212) 555-4567</phone> </contact-info>

  11. Example <name format=“FNLN”>Jane Smith</name> element attribute value content Elements can be nested interspersed with “text” <people> <name format=“FNLN”>Jane Smith</name>works at <company>AT&amp;T</company>. </people>

  12. 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: <?xml version="1.0"?> 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: <?xml version="1.0" encoding="UTF-8"?>

  13. 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. 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. <p><person>Tony Blair</person> is <function>Prime Minister</function> of <location> <country>GreatBritain</country></location> </p>.

  15. 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. Element “tree”

  17. Syntax errors <!-- WRONG! --> <function><person>President</function> Habibe</person> Tags must be nested properly. eg... <!-- RIGHT--> <person><function>President</function> Habibe</person>

  18. Syntax.... An XML document must have only one “root” element. <!-- WRONG! --> <a>...</a> <b>...</b> The following example fixes the problem by including both the a and b elements within a new x root element: <x> <a>...</a> <b>...</b> </x>

  19. Syntax.... <!-- WRONG! --> <a href="pbear.html">polar bear</A> 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: <p>Stuff<hr/> More stuff.</p> In this example, “<hr/>” represents both the start and the end of the hr element; equivalent to “<hr></hr>”

  20. 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: <a href="http://www.yahoo.com/">Yahoo!</a> 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. 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: <!-- WRONG! --> <a b="x" c="y" b="z">....</a> 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. <!-- WRONG! --> <a b=x>...</a>

  22. 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 “&amp;”, 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 “&#38;”, 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. Predeclared References Character Predeclared Entities & &amp; < &lt; > &gt; " &quot; ' &apos;

  24. 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. Different types of DTD’s Internal DTD - inside .xml file <?xml version=“1.0”?> <!DOCTYPE people [ .... ]> <people> </people> External DTD - file with .dtd extension <!ELEMENT ......> “SYSTEM” (private) vs “PUBLIC” Local extensions,rules can be added to external reference and override the external DTD.

  26. Using a DTD from within an .xml <?xml version=“1.0” standalone=“no”?> <!DOCTYPE people SYSTEM “http://www.dartmouth.edu/~gvc/..”> <people> ... </people> Naming DTD’s using Formal Public Identifiers (FPI’s)..... Next class....structure of the DTD and XML Schema.

  27. Defining elements <!ELEMENT people(name,company)> Elements name and company must be defined elsewhere, before, after or externally. <!ELEMENT people(name+, company*)> means name occurs at least once, company zero or more times. <!ELEMENT nameandcomp(name|company)> <!ELEMENT people(name|nameandcomp*)> + means at least once, ? means zero or one, * means zero or more so (name,name,name+) means at least three time, etc.

  28. XMl Tutorials and References • Let’s find a few….. • XML Parser in Visual Studio

More Related