Download presentation
Presentation is loading. Please wait.
Published byClaude Fletcher Modified over 8 years ago
1
XML 1.Introduction to XML 2.Document Type Definition (DTD) 3.XML Parser 4.Example: CGI Gateway to XML Middleware
2
1. Introduction to XML CGI Middleware can perform sophisticated processes on several data sources that itself becomes a data source. XML provides an industry standard way of describing data from different data sources. CGI programs that speak XML will be able to deliver to and retrieve data from any XML- compliant Perl script or Java applet.
3
Introduction to XML HTML was deigned for the data presentation language (display the content for human to read), it lacks of the data description capability (can’t interpret the data for machine to understand.) –Example: White XML was designed to make up many of HTML’s limitations. It is a data description language that is useful as a mechanism for transporting data from program to program on different platforms. –Example: White
4
XML Features 1.New tags and tag hierarchies can be defined to represent data specific to your application. For instance, a quiz can contain and tags. 2.Document type definitions can be defined for data validation. You can require, for instance, that every be associated with exactly one. 3.Data transport is Unicode-compliant, which is important for non-ASCII character sets. 4.Data is provided in a way that makes it easily transportable via HTTP. 5.Syntax is simple, allowing parsers to be simple.
5
Example All of the following players won the regular season MVP and playoff MVP in the same year, except for: B West was awesome, but they did not have a playoff MVP in his day. How could you choose Bird, Magic, Michael, or Hakeem?
6
Example (Cont.) Who is the only NBA player to get a triple- double by halftime? Larry Bird You got it! He was quite awesome! Sorry. Magic was just as awesome as Larry, but he never got a triple-double by halftime. I guess you are not a Celtics Fan.
7
XML Document All XML documents must present the data with at least one root structure surrounding the whole document. XML accept all HTML tags, but it requires closed tag for all the tags. XML parser converts the XML document into standard HTML. It uses the a dtd file to define how the XML document is structured and what the tags mean in relation to another –Example: quiz.dtd (next page) XSL (Extensible Style sheet Language) defines the standard stylesheet language for XML. It takes the original document tree and creates a new one based on the instructions that the developer provide.
8
2. Document Type Definition: quiz.dtd –<!ATTLIST QUESTION – TYPE CDATA #REQUIRED> –<!ATTLIST CHOICE – VALUE CDATA #REQUIRED – TEXT CDATA #REQUIRED> –<!ATTLIST RESPONSE – VALUE CDATA – STATUS CDATA>
9
DTD The DTD file is optional. XML document with the DTD file is called valid XML document. (without DTD is called well-formed document) The tags describe the actual tags that are valid in the XML document. The parentheses after the name of the element show what tags it can contain. The * symbol is a quantity identifier. It follows the same basic rules as regular expression matching. After each element is defined, its attributes need to be laid out. –Example: Questions have a type attribute that takes a string of character data. Furthermore, the #REQUIRED keyword indicates that this data is required in the XML document.
10
3. XML Parser XML parsers parse data in two different ways. –To have the XML parser take the entire document and simply return a tree of objects that represents the XML document hierarchy. Perl supports this concept via the XML::Grove module. (Similar with Java DOM (Document Object Model) API) –To parse XML documents is using a SAX (Simple API for XML) style of parser. This type of parser is event- based and is the one that XML::Parser is based on. CGI Perl XML::Parser is an interface to a library written in C called expat. (Similar with Java SAX API)
11
4. Example: CGI Gateway to XML Middleware CGI gateway script parsing the XML from the Netscape “What’s Related” XML middleware server.
12
Example: CGI Gateway to XML Middleware User provides a URL: whats_related.htmlwhats_related.html whats_related.cgi:whats_related.cgi –get(“http://www-rl.netscape.com/wtgn?, &url) returns the directly related URL in a XML data document (without DTD).XML data document –XML::Parser parse XML data document into a HTML document. –sub get_whats_related_to_whats_related will iterate through the directly related urls to get next level related urls.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.