presentation 6
Download
Skip this Video
Download Presentation
Presentation 6:

Loading in 2 Seconds...

play fullscreen
1 / 29

Presentation 6: - PowerPoint PPT Presentation


  • 121 Views
  • Uploaded on

Presentation 6:. Introduction to XML and related technologies – for use with SOAP / WSDL = Web services. Outline. Why an XML presentation? W3C & legacy of XML – ultra short XML markup and Namespaces DTD’s XML Schemas DOM/SAX The SOAP connection. Why an XML presentation?.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Presentation 6:' - sema


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
presentation 6

Presentation 6:

Introduction to XML and related technologies – for use with SOAP / WSDL = Web services

outline
Outline
  • Why an XML presentation?
  • W3C & legacy of XML – ultra short
  • XML markup and Namespaces
  • DTD’s
  • XML Schemas
  • DOM/SAX
  • The SOAP connection
why an xml presentation
Why an XML presentation?
  • Because SOAP, WSDL & UDDI is based on XML technologies
  • Future “Home-brew” framework based on XML?
  • Important to understand how the API’s work
    • Parsing mechanisms
      • DOM
      • SAX
      • Why its slow ;)
w3c the legacy of xml
W3C & the legacy of XML
  • World Wide Consortium
    • Founded 1994
    • Standardizations on the Internet
    • First Chairman: Tim Berners-Lee
    • Boards of members submits proposals
    • Ensures standardization of WWW technologies
      • Like: XHTML, XML, XSL, CSS, SOAP, WAP etc.
      • Members: Microsoft, IBM, SUN, Oracle and many others
    • http://www.w3c.org
  • Legacy:
    • Standard Generalized Markup Language (SGML)
    • Same legacy as HTML
xml markup
XML markup
  • eXtended Markup Language
  • XML based on SGML (subset of)
  • Like SGML for data & structure not layout (as HTML)
  • XML targets the Internet – but is also being used for application exchange formats (Open Office, XMI) – CSVs
  • XML is an W3C Recommendation
  • Structure decided by DTD or Schema (more later)
  • Wide spread support for XML
presenting xml documents
Presenting XML documents
  • First standalone XML document and its component
  • Note: XML document are “Well-formed”
  • Please visit http://www.w3schools.com/default.asp for in-depth examples of XML usage
slide7
Element article is the root element.

Optional XML declaration.

Elements title, date, author, summary and content are child elements of article.

1

2

3

4

5

6

7

8 Simple XML

9

10 September 19, 2001

11

12

13 Tem

14 Nieto

15

16

17

XML is pretty easy.

18

19 Once you have mastered XHTML, XML is easily

20 learned. You must remember that XML is not for

21 displaying information but for managing information.

22

23

24

Article.xml

browser displaying xml unformatted
Browser displaying XML (unformatted)

IE5.5 displaying article.xml.

use of xml namespaces
Use of XML Namespaces
  • XML namespaces used to avoid naming conflicts
  • When several different elements are involved
  • isnt always a book
  • Keyword ”xmlns”
slide10
Keyword xmlns creates two namespace prefixes, text and image.

URIs (Uniform Resource Identifiers) ensure that a namespace is unique.

1

2

3

4

5

6

7 xmlns:image = "urn:deitel:imageInfo">

8

9

10 A book list

11

12

13

14 A funny picture

15

16

17

18

Namespace.xml

slide11
Default namespace.

Element file uses the default namespace.

Element file uses the namespace prefix image.

1

2

3

4

5

6

7 xmlns:image = "urn:deitel:imageInfo">

8

9

10 A book list

11

12

13

14 A funny picture

15

16

17

18

Defaultnamespace.xml

slide12
DTDs
  • Document Type Definition
  • Extended Backus-Naur Form
  • Defines how an XML document is structured
    • Required elements
    • Nesting of elements
    • Does not define types or behavior
  • If DTD is used – some parsers can decide if XML document is “valid” – which is more than just “wellformed”
slide13
The ELEMENT element type declaration defines the rules for element letter.

The plus sign (+) occurrence indicator specifies that the DTD allows one or more occurrences of an element. (2 contacts in our example)

The contact element definition specifies that element contact contains child elements name, address1, address2, city, state, zip, phone and flag—in that order.

1

2

3

4

5 closing, signature )>

6

7

8 zip, phone, flag )>

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

Letter.dtd

slide14
Keyword #IMPLIED specifies that if the parser finds a contact element without a type attribute, the parser can choose an arbitrary value for the attribute or ignore the attribute and the document will be valid.

Flag #PCDATA specifies that the element can contain parsed character data (i.e., text).

The ATTLISTelement type declaration defines an attribute (i.e., type) for the contact element.

1

2

3

4

5 closing, signature )>

6

7

8 zip, phone, flag )>

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

Letter.dtd

  • Assignment: 5 min. – make a Letter XML document that is:
  • Well-formed (how would an XML Validator check this?)
  • Valid (how would an XML Validator check this?)
slide15
1

2

3

4

5

6

7

8

9

10

11 John Doe

12 123 Main St.

13

14 Anytown

15 Anystate

16 12345

17 555-1234

18

19

20

21

22 Joe Schmoe

23 Box 12345

24 15 Any Ave.

25 Othertown

26 Otherstate

27 67890

28 555-4321

29

30

31

Letter.xml

slide16
32 Dear Sir:

33

34 It is our privilege to inform you about our new

35 database managed with XML. This new system allows

36 you to reduce the load of your inventory list server by

37 having the client machine perform the work of sorting

38 and filtering the data.

39 Sincerely

40 Mr. Doe

41

42

Letter.xml

xml schema
XML Schema
  • DTD works OK – but
    • Is in Ex. Backus-Naur Form – why not use XML?
    • Cannot declare the type of an element
    • hundrede kr
      • Could give problems
    • Several other problems
  • W3C XML Schema
    • Use XML to describe the structure of XML documents …
    • Possible to give type information to XML definitions
  • Not supported by all parsers yet
  • Will live besides DTDs for a while
slide18
1

2

3

4

5

6

7 xmlns:deitel = "http://www.deitel.com/booklist"

8 targetNamespace = "http://www.deitel.com/booklist">

9

10

11

12

13

14 minOccurs = "1" maxOccurs = "unbounded"/>

15

16

17

18

19

20

21

Element element defines an element to be included in the XML document structure.

Book.xsd

A BookType has an Element named Title of Type “xsd:string”– which is defined at “http://www.w3.org/2000/10/XMLSchema”

how to use xml
How to use XML?
  • Need a parser (or a parser API) to access XML (as with CSV)
  • Two commonly used methods:
    • DOM (Document Object Model)
      • W3C Recommendation
      • Makes a tree structure representation of an XML document in memory
    • SAX (Simple API for XML)
      • Supported by diff. vendors
      • Parses document line by line and sends events to subscribers
      • Needs to parse every time access to XML document is needed
  • DOM is better for
    • Slow to load XML document (need all)
    • Quick access to random read or update of XML (like WWW browser - BOM)
    • Requires a lot of memory (need to hold entire XML in mem)
  • SAX is better for
    • Applications subscribing to certain parts of XML (event subscription)
    • Slow for random access to XML document (must parse every time)
what is dom
What is DOM
  • DOM: Document Object Model
    • http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/
  • W3C definition:
    • Standard for accessing structured documents
    • Core DOM used with XML
    • HTML DOM used with HTML
    • Representation of an object as an object tree structure
    • Provides a uniform interface for programming and scripting languages
    • API’s available for JavaScript, Java, C++, C# etc.
dom tree structure
DOM Tree Structure
  • Tree structure of an XML document (left)
  • … or HTML (right)

….

document

table

tbdoy

tr

tr

tr

td

td

td

tekst

example using dom on article xml
Example – using DOM on Article.xml
  • We have looked at Article.xml
  • We Will:
    • Look at the Article.xml document again
    • Look at the Tree Structure formed by loading it into a DOM
    • Use JavaScript to work on it
slide24
1

2

3

4

5

6

7

8 Simple XML

9

10 September 19, 2001

11

12

13 Tem

14 Nieto

15

16

17

XML is pretty easy.

18

19 XML is easily

20 learned. You must remember that XML is not for

21 displaying information but for managing information.

22

23

24

XML document – Article.XML

slide25
DOM Methods

article

title

date

author

firstName

summary

lastName

contents

Tree structure for article.xml.

slide26
Instantiate a Microsoft XML Document Object Model object and assign it to reference xmlDocument.

method load loads article.xml (Fig. 20.1) into memory.

Property documentElement corresponds to the root element in the document (e.g., article).

1

2

3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

4

5

6

7

8

9

10 A DOM Example

11

12

13

14

15

64

65

66

DOMExample.html

the soap connection
The SOAP Connection
  • SOAP, WSDL, UDDI uses:
    • XML
    • Namespaces
    • and Schemas
  • Original idea behind Web services
    • Connection through the Internet
    • Good sense to use XML – W3C child
    • Everyone loves W3C
      • practical solutions “that work”
ad

tekst