Introduction to Server-Side Web Development Introduction to Server-Side Web Development using JSP and XML Session V: Further JSP and integration with XML.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

CSE 190: Internet E-Commerce Lecture 17: XML, XSL.
XML Study-Session: Part IV Transforming XML Documents Copyright Quddus Chong 2001.
XML A brief introduction ---by Yongzhu Li. XML --- a brief introduction 2 CSI668 Topics in System Architecture SUNY Albany Computer Science Department.
Creating a Well-Formed Valid Document. 2 Objectives Introducing XHTML Creating a Well-Formed Document Creating a Valid Document Creating an XHTML Document.
XML Introduction What is XML –XML is the eXtensible Markup Language –Became a W3C Recommendation in 1998 –Tag-based syntax, like HTML –You get to make.
CS 898N – Advanced World Wide Web Technologies Lecture 22: Applying XML Chin-Chih Chang
XML(EXtensible Markup Language). XML XML stands for EXtensible Markup Language. XML is a markup language much like HTML. XML was designed to describe.
Introduction to XML Extensible Markup Language
COS 381 Day 16. Agenda Assignment 4 posted Due April 1 There was no resubmits of Assignment Capstone Progress report Due March 24 Today we will discuss.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Introducing XHTML: Module B: HTML to XHTML. Goals Understand how XHTML evolved as a language for Web delivery Understand the importance of DTDs Understand.
Technical Track Session XML Techie Tools Tim Bornholt.
By: Shawn Li. OUTLINE XML Definition HTML vs. XML Advantage of XML Facts Utilization SAX Definition DOM Definition History Comparison between SAX and.
XP Tutorial 9New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
Scientific Markup Languages Birds of a Feather A 10-Minute Introduction to XML Timothy W. Cole Mathematics Librarian & Professor of.
XML eXtensible Markup Language by Darrell Payne. Experience Logicon / Sterling Federal C, C++, JavaScript/Jscript, Shell Script, Perl XML Training XML.
1 XML at a neighborhood university near you Innovation 2005 September 16, 2005 Kwok-Bun Yue University of Houston-Clear Lake.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.
School of Computing and Management Sciences © Sheffield Hallam University To understand the Oracle XML notes you need to have an understanding of all these.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
SAX Parsing Presented by Clifford Lemoine CSC 436 Compiler Design.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
Advanced Java Session 9 New York University School of Continuing and Professional Studies.
Introduction to XML Extensible Markup Language. What is XML XML stands for eXtensible Markup Language. A markup language is used to provide information.
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Electronic Commerce COMP3210 Session 4: Designing, Building and Evaluating e-Commerce Initiatives – Part II Dr. Paul Walcott Department of Computer Science,
Intro to XML Originally Presented by Clifford Lemoine Modified by Box.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
XML Extensible Markup Language
Web Services for Satellite Emulation Development Kathy J. LiszkaAllen P. Holtz The University of AkronNASA Glenn Research Center.
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development using JSP and Web Services JSP and Web Services 18 th March 2005.
Web Technologies COMP6115 Session 4: Adding a Database to a Web Site Dr. Paul Walcott Department of Computer Science, Mathematics and Physics University.
1 Overview of XSL. 2 Outline We will use Roger Costello’s tutorial The purpose of this presentation is  To give a quick overview of XSL  To describe.
XML and Its Applications Ben Y. Zhao, CS294-7 Spring 1999.
XML Study-Session: Part III
XML and SAX (A quick overview) ● What is XML? ● What are SAX and DOM? ● Using SAX.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Web Technologies Lecture 4 XML and XHTML. XML Extensible Markup Language Set of rules for encoding a document in a format readable – By humans, and –
Introduction to Server-Side Web Development Introduction to Server-Side Web Development using JSP and XML Further JSP and integration with XML 17 th March.
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
1 Introduction JAXP. Objectives  XML Parser  Parsing and Parsers  JAXP interfaces  Workshops 2.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
XML Technology. Emerging Importance of XML –HTML-tagging is display oriented. –XML-based content tagging has important uses: data mining role-oriented.
Martin Kruliš by Martin Kruliš (v1.1)1.
XML Tools (Chapter 4 of XML Book). What tools are needed for a complete XML application? n Fundamental components n Web infrasructure n XML development.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
7-Mar-16 Simple API XML.  SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files  DOM is a W3C standard  SAX is an.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML Extensible Markup Language
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
1 Introduction to XML Babak Esfandiari. 2 What is XML? introduced by W3C in 98 Stands for eXtensible Markup Language it is more general than HTML, but.
Unit 4 Representing Web Data: XML
Java XML IS
XML in Web Technologies
Database Processing with XML
Chapter 7 Representing Web Data: XML
Presentation transcript:

Introduction to Server-Side Web Development Introduction to Server-Side Web Development using JSP and XML Session V: Further JSP and integration with XML 18 th March 2004 Bogdan L. Vrusias

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Introduction One of the most important concepts in building any application is the concept of data. XML is a specification that gears data. Data is stored in databases. JSP and XML… a great way to access a database!

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Session V What is XML? History of XML Introducing JSP and XML together Example using DOM Example using SAX Example using XSL

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © What is XML? "The eXtensible Markup Language (XML) is the universal format for structured documents and data on the Web" (W3C) XML is not a markup language like HTML, it is a language used to describe a markup language (metalanguage).

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Applications of XML The applications which XML can be applied to fall into four distinct groups: –Those where a distributed program has to interact with two or more sources of data, where the sources are expressed in different formats. –Applications which attempt to move a large amount of processing onto client computers. –Applications which require different users to have different views of the same data. –Applications in which objects are allowed to wander around a network carrying out specific functions.

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © History of XML The roots of XML can be found in the explosive growth of the World Wide Web in the mid-1990s and in the browser wars that took place between the Microsoft Corporation and the Netscape Corporation, where each strived for dominance over the other with their respective browsers. As the Web became larger and more and more users accessed it a number of problems were discovered by designers who used HTML: –The fact that a similar HTML source was displayed in different ways depending on what browser was used. –Some browser manufacturers developed HTML facilities which were not recognised by other browsers. –It was almost impossible to discern any semantics within a Web page: nowhere was this more apparent than in the use of search engines.

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © History of XML W3C decided in 1996 to develop a markup language which would eventually supersede HTML. The major goals of the language are: –That it should be easy to use in the Internet. –That it should be capable of supporting a large number of applications ranging from browsers to search engine databases. –That it should be compatible with SGML, the text processing language which was the inspiration for HTML. –That it should not be a complicated process to develop processors for documents written in languages defined in XML, for example it should be easy to write a program to check that a source text reflects its definition. –That the number of optional facilities of the language should be very low. –That XML documents should be easy to read and understand. –That documents written using a language defined by XML should be easy to develop using simple editors. In 1998 the language, XML, was presented to the world as a final recommendation of the W3C; in effect it became an Internet standard.

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © XML and Other Storage Media

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Server-side XML One of the most aspiring aspects of XML is its simplicity. Benefits: –XML simplifies data communications because it is self-describing. This makes it simple and easy to share XML data between people and applications. –Data storage and organisation is customisable. –XML supports Unicode therefore documents can be created in nearly any language. –XML is based on simple character set, therefore it makes it easy to transport an XML document. –Document structure can be AUTOMATICALLY validated. –XML can be mixed with stylesheets. –Any type of data can be described in XML.

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © XML Example Dodo A dead bird Blackbird A thieving bird Peacock An attractive bird

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Defining XML-based Languages The first thing that is needed when developing an XML application is to define the structure of the language that is to be processed. The definition is known as a document type definition (DTD). An example of a simple DTD is shown below: <!DOCTYPE ENTRY[ ]>

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Processing XML-based Documents The main tool that has been used by XML developers has been a parser. A parser is a program which takes the source of a language and checks that it correctly matches its definition. An XML parser will check an XML document against its DTD. An XML parser can be a validating parser or a non-validating parser: –a validating parser checks an XML document adheres to every rule in its DTD; –a non-validating parser will make a smaller number of important checks such as the fact that a tag is matched by its end tag. Well-Formed and Valid Documents –XML documents that follow all the XML syntax rules are referred to as “well-formed” documents. –A “valid” XML document is one that conforms to the DTD or schema written to describe its structure.

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Example of a Parser (Aelfred) … public class XMLApplet extends Applet implements XmlHandler { public void init() { private XmlParser parser; parser = new XmlParser(); parser.setHandler(this);.. } public void start() {.. }

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Example of a Parser (Aelfred) public void startDocument() {…} public void endDocument() {…} public void startElement(String name) {…} public void endElement(String name) {…} public void charData (char[] strVal, int first, int last) {…} public void attribute (String aName, String aValue, boolean isSpecified) {…} … }

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Approaches to XML Processing One of the problems with XML-based parsers is the fact that there has been no standardisation effort. There are a number of parsers each of which is implemented in different ways with different sets of methods. In order to overcome this problem an API has been developed which calls a parser and then processes an internal form of the XML source that has been built up by it. One such API known as SAX (Simple API for XML) Another API is DOM (Document Object Model).

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © SAX The SAX API contains a number of methods which are similar to those found in Aelfred: –The method characters (char[] strVal, int first, int last) The first argument contains a string and the two integers delineate the string within the array. The second argument indexes its first character and the third argument indexes the last character. This method is the same as charData in Aelfred. –The method startDocument is executed when a document is first read. –The method endDocument is executed when the end of an XML document is encountered. –The method startElement( String name, AttributeList list) will be executed whenever a start tag is encountered. It has two arguments: the first is a string which holds the name of the tag and the second is an object defined by the SAX class AttributeList which holds a sequence of name/value pairs for each attribute. –The method endElement( String name) will be executed whenever an end tag is encountered. It is associated with one argument which is a string that represents the name of the tag.

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © DOM The DOM model involves the storage of the XML source that is to be processed as a tree within memory. –Adding the packages org.w3c.dom.*, org.apache.xerces.parsers.DOMParser –Create the DOMParser object DOMParser parser = new DOMParser(); –Parse the XML document and get the Document object parser.parse(xml); Document doc = parser.getDocument(); –Call the listNodes method and pass the NodeList object. listNodes(doc.getChildNodes(), out, ""); –Get necessary information from the NodeList object nlist.getLength() nlist.item(i).getNodeName() nlist.item(i).getNodeType() nlist.item(i).getNodeValue()

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © SAX vs DOM If you are writing Java programs which access XML <les you will be faced with the choice of what style of API to use: either the event- based SAX approach or the tree processing approach of DOM. There are a number of points to bear in mind when selecting which to use: –SAX is a conceptually simple way to program an XML application. It is based on events occurring when some element in an XML-defined source is encountered. –DOM is conceptually more difficult to program. It requires the programmer to develop code which traverses a tree made up of nodes and requires the use of recursion. –When an XML document is defined by a complex DTD, then programs using SAX can be very complex and somewhat unreadable. –DOM programs which access large DTDs are more readable and maintainable than SAX programs. –The memory demands of SAX are minimal. –The memory demands of DOM can be very high when the XML source is textually large.

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © XSL There is another popular way of processing source based on a concept known as XSL. XSL (eXtensible Style Language) is an XML-based language used for defining the type of processing (like SAX and DOM). The language is often referred to as XSLT (T for Transformations) and was developed by the W3C. XSL (eXtensive Stylesheet Language) is what we use to transform an XML document in HTML, XML or other. –Namespaces ( ) –Templates ( ) –Whitespace and Encoding (non-braking space is  ) –Entity Declaration ( ]>) –Trees, nodes and family –Xpath ( )

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © XSL Example The XML: <?xml-stylesheet type = “text/xml” href = “example.xsl” ?> An introduction to the saxophone E.J Wilson and R.Vitre Good introductory stuff but ignores recent history post 1955 …

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © XSL Example The XSL: Generated HTML for the book

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © The Relationship between XML and JSP JSP is about character based output (moving data). XML is about character based data (marking data). Scenarios: –The data is stored within an XML file. JSP imports the data and converts it to HTML. –The data is stored within a database. Java process converts the data to XML. Then either the XML is shipped to the user, or transformed to other formats (e.g. HTML) –The data is stored within an XML file. Java process stores the data to a database. JSP then is used to access and view the data. –Web application initialisation information is stored within an XML file. JSP reads the XML and changes application behaviour. –Data is transferred between two systems in an XML-formatted file. JSP is used as a front-end interface to initiate the process of sending or receiving data.

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © A Warning XML is not the most appropriate solution to all problems. If misused, XML will slow down Web applications, waste development time and cost money. XML does NOT replace a database. Do not use XML for XML’s sake

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Tools for XML Many tools exist for the processing and transformation of XML. We will evaluate the APIs that are most commonly used with JSP. –Xerces (XML Parser) Xerces is an XML parser and generator. It implements the W3C XML and DOM, as well as the SAX standard. –Xalan (XSLT Processor) Xalan is an XSLT stylesheet processor. It implements the W3C XSLT and XPath recommendations. –JAXP (Generic XML Processing) JAXP is technically an API for XML processing. It contains no parsing functionality (it’s an abstraction layer) It does not provide new functionality to XML processing, except that it provides a common way to use different XML processor implementations (such as DOM and SAX).

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Java XML / XSL APIs DOM (XML Document Object Model) –Easy to use, but requires lots of memory. SAX (XML Parser) –More complicated to use, but is more efficient. JDOM (XML Document Representation) (for Java Only) –JDOM has several classes that permit it to use SAX or the DOM. –Does not support XML parsing. dom4j (XML Document Representation) (for Java Only) –dom4j has a set of Java APIs used for handling XML, XSLT and XPath. –Similar to JDOM, however it also differs as it uses Java interfaces. JAXB (Parser and XML Document Representation) –Java Architecture for XML Binding (JAXB) is used to automate mapping between XML and Java. –It uses XML schema to build an optimised Java class to perform the parsing.

Introduction to Server-Side Web Development 18 th March 2004Bogdan L. Vrusias © Session V: Closing Questions??? Remarks??? Comments!!! Evaluation!