xml for java developers g22.3033-002...e.g., altova’s xml spy , corel’s xmetal, vervet logic’s...

34
1 1 XML for Java Developers G22.3033-002 Session 1 - Main Theme Markup Language Technologies (Part I) Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical Sciences 2 Course Roadmap Consider the Spectrum of Applications Architectures Distributed vs. Decentralized Apps + Thick vs. Thin Clients J2EE for eCommerce vs. J2EE/Web Services, JXTA, etc. Learn Specific XML/Java “Patterns” Used for Data/Content Presentation, Data Exchange, and Application Configuration Cover XML/Java Technologies According to their Use in the Various Phases of the Application Development Lifecycle (i.e., Discovery, Design, Development, Deployment, Administration) e.g., Modeling, Configuration Management, Processing, Rendering, Querying, Secure Messaging, etc. Develop XML Applications as Assemblies of Reusable XML- Based Services (Applications of XML + Java Applications)

Upload: others

Post on 10-Aug-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

1

1

XML for Java Developers G22.3033-002

Session 1 - Main ThemeMarkup Language Technologies (Part I)

Dr. Jean-Claude Franchitti

New York UniversityComputer Science Department

Courant Institute of Mathematical Sciences

2

Course RoadmapConsider the Spectrum of Applications Architectures

Distributed vs. Decentralized Apps + Thick vs. Thin ClientsJ2EE for eCommerce vs. J2EE/Web Services, JXTA, etc.

Learn Specific XML/Java “Patterns” Used for Data/Content Presentation, Data Exchange, and Application Configuration

Cover XML/Java Technologies According to their Use in the Various Phases of the Application Development Lifecycle (i.e., Discovery, Design, Development, Deployment, Administration)

e.g., Modeling, Configuration Management, Processing, Rendering, Querying, Secure Messaging, etc.

Develop XML Applications as Assemblies of Reusable XML-Based Services (Applications of XML + Java Applications)

Page 2: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

2

3

AgendaXML GenericsCourse Logistics, Structure and ObjectivesHistory of Meta-Markup LanguagesXML Applications: Markup LanguagesXML Information Modeling ApplicationsXML-Based ArchitecturesXML and JavaXML Development ToolsSummaryClass ProjectReadingsAssignment #1a

4

Part I

Introduction

Page 3: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

3

5

XML Generics

XML means eXtensible Markup LanguageXML expresses the structure of information (i.e., document content) separately from its presentationXSL style sheets are used to convert documents to a presentation format that can be processed by a target presentation device (e.g., HTML in the case of legacy browsers)

Need a “viewer” or a “renderer” to obtain a “presentation” of the “rendition”

Document Type Definitions (DTDs) or XML schemas are used to describe and validate content

6

Course LogisticsCourse Web Site

http://cs.nyu.edu/courses/summer03/G22.3033-003/index.htmhttp://www.nyu.edu/classes/jcf/g22.3033-002/Password: xmljava (not active)Review syllabus, references (being updated as of 5/21/03)

TextbooksXML and Java, Developing Web Applications, 2nd EditionProcessing XML with Java: A Guide to SAX, DOM, JDOM, JAXP, and TrAXDeveloping Java Web Services: Architecting and Developing Secure Web Services Using Java

Page 4: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

4

7

Knowledge Required

Web DevelopmentKnow how to ftp files, send e-mail, and load URLs into a Web browserReasonable knowledge of HTMLBe able to write a basic HTML page including links, images, and text using a text editorBe able to place a page on a web server

Application DevelopmentAdvanced Java programming experience

8

Knowledge Not Required

SGMLProgramming in Perl, or any language other than JavaCascading Style Sheets and other HTML advanced features

Page 5: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

5

9

Other Useful Knowledge

Web server configuration and the HTTP protocolJavaScriptC programmingDatabase theory (normalization rules)SGML (basic knowledge)Some knowledge of international character sets

10

Part II

The XML Family of Technologies

Page 6: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

6

11

History of Meta-Markup LanguagesSGML (see http://www.w3c.org)

Complex and expensiveISO Standard (ISO 8879:1986)

http://xml.coverpages.org/sgml.html

DSSSL (style sheets), HyTime (linking)HTML

Tim Berners-Lee (Cern), 1990Simple replacement to SGMLLacked the flexibility and adaptability of XML

W3C XML working groupJon Bosak (Sun), 1996SGML strengths + HTML simplicity

12

History of Meta-Markup Languages(continued)

XML 1.0 SpecificationTim BrayLanguage simple enough for programmers to implementLanguage not limited to EnglishDocuments easy for search engine

CML, Jumbo, MathMLXLL (1997), CDF (1997), XSL (1997), MSXSL (1998), XML-Data, Mozilla, etc.

Page 7: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

7

13

Why XML?

Domain specific markup languageCommon data format

Simple, pure Unicode text

Well-documentedData interchange

Open Financial Exchange (OFX)XML non copyrighted

Support of portable structured text data as most electronic information is text-based

14

Related TechnologiesJavaSoft’s Java API for XML parsing (JAXP)Java bindings to SAX, and DOM APIsHTMLCSS, CSS2, and CSS3XSLXML Schemas / DTDs

“well formed” XML documents vs. “valid” documentsURLs and URIs

resource vs. locationLinking (XLL)Unicode

Page 8: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

8

15

Applications of XML:Markup Languages

XML helps define sets of rules for forming semantic tags that break documents into partsXML is a Metamarkup language

Not a markup language restricted to a fixed set of tagsCan make up tags as you go along

XML Tags can be documented in a DTD/Schemai.e., a domain specific syntax and vocabulary (e.g., CML, MathML, etc.)

16

HTML Example

<dt>Java<dd>by Sun MicroSystem<ul><li>Publisher: O’Reilly<li>ISBN: 0-777-88888-9<li>Pages: 900</ul><P>The complete documentation.<P>

Page 9: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

9

17

XML Corresponding Structure

<book><title>Java</title><author>Sun Microsystems</author><publisher>O’Reilly</publisher><isbn>0-777-88888-9</isbn><pages>900</pages><blurb>The complete documentation</blurb>

</book>

18

XML Enables Semantic/Structured Markup Languages

XML describes a document’s structure and meaningXML does not describe the formatting of the elementsFormatting is added through style sheetsXML document only contains tags describing the content (not the appearance) of the document

Page 10: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

10

19

XML Information Modeling Applications(Focus on Complex Structured Document Specification)

Custom and Industry specific Markup Languages with own syntax and vocabularyCML (Chemical Markup Language)MathML (Mathematical Markup Language)CML (Channel Definition Format)Classic LiteratureSMIL (Synchronized Multimedia Integration LanguageOSD (Open Software Description)X3D (eXtensible 3D)Web Services Protocol Stack (www.ws-i.org)

20

XML & DBMSs ComparisonBoth separate data from rendition/presentation infoSimilar languages

DBMSs: Forms and Reporting, DDL, DQL, DCLXML: XSL, XQL, and processing instructions

No DML in XMLXML is paired with a scripting or programming language

Validation capabilitiesDBMSs: datatyping, relationship constraintsXML: data type validity and semantic consistency checks

XML can handle data too complex for some databasesXML interchangeable form of data vs. multidatabases

Page 11: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

11

21

XML-Based Architectures

Presentation-Oriented Publishing FrameworksXML-Based Application ServersMessage-Oriented Middleware FrameworksService Oriented Frameworks

Web Services Frameworks and derivativesXML-Based eServices Protocols and Architectures

NG FrameworksPeer to Peer (P2P) Computing FrameworksGrid Computing FrameworksBrick-by-Brick Computing Frameworksetc.

22

XML POP Frameworks(Focus on Content Management and Publishing)

Requirements:XML parser (e.g., Xerces)XSL processor (e.g., Cocoon)Document repositoryCollection of document DTDs or schemaCollection of XSL style sheets

Parsing & processing can be client or server-basedSamples server-side XML technology:

Perl & CGI (http://www.perl.com/CPAN)Java servlets (http://www.alphaworks.ibm.com, www.apache.org)ASPs (e.g., Rocket POP framework)

Page 12: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

12

23

XML POP Packaged SolutionsEnterprise Information Portal (EIP) toolkits

e.g., IBM WebSphere Portal Express, Hummingbird EIP, etc.http://www.capterra.com/enterprise-information-portals-solutions

Structured content management and retrieval systems

e.g., Vignette’s StoryServerGauss Interprise’s VIP’XML-GatewayPoet’s Content Management Suite (CMS)Chrystal Software’s Astoria

24

XML MOM ApplicationsComponent-based modeling

e.g., XML Metadata Interchange (XMI)

Business-to-Customer (B2C) Applicationse.g., e-Commerce

Business Process Management (BPM)Enterprise Application Integration (EAI) Business-to-Business Integration (B2Bi)

e.g., WebMethods, Bluestone (older), eXcelon, XMLSolutions’ ExeterXML server, etc.

Enterprise Information Integration (EII)Legacy Extension (LE)

Page 13: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

13

25

XML Development Tools

Read and write XML documentsXML Editors

e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc.

XML well-formedness and/or validation Processorse.g., Apache’s XercesJ, IBM’s XML4J, Oracle Parser, Java Project X processor, James Clark’s Expat parser, Microsoft MSXML4

XML Browserse g IE5+

26

Part III

Java and XML

Page 14: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

14

27

XML and Java Standards(continued)

Java XML PackJava Architecture for XML Binding (JAXB)Java API for XML Messaging (JAXM)Java API for XML Processing (JAXP)Java API for XML Registries (JAXR)Java API for XML-based RPC (JAX-RPC)

Java Web Services Developer Pack (WSDP 1.1)Java XML PackJSP Standard Tag Library (JSTL) 1.0.3Ant Build Tool 1.5.1Java WSDP Registry Server 1.0_04Web Application Deployment ToolApache Tomcat 4.1.2 Container

28

Java & XML Frameworks

XML Parsers Xerces-JCrimsonOracle XML parser

XML Server-Side POP FrameworksCocoon

XML P2P/B2Bi/EAI (MOM) FrameworksJXTA, WebMethods, etc.

Page 15: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

15

29

Java and Web Services

Java Web Services Developer Pack (WSDP 1.1)Java XML Pack JavaServer Pages Standard Tag Library (JSTL) 1.0.3Ant Build Tool 1.5.1Java WSDP Registry Server 1.0_04Web Application Deployment ToolApache Tomcat Container 4.1.2

30

Java-enabled XML TechnologiesXML provides a universal syntax for Java semantics (behavior)

Portable, reusable data descriptions in XMLPortable Java code that makes the data behave in various ways

XML standard extensionBasic plumbing that translates XML into Java

parser, namespace support in the parser, simple API for XML (SAX), and document object model (DOM)

XML data binding standard extension (JAXB)

Page 16: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

16

31

XML and Java StandardsXML is a family of technologies

XSL, XML Schema, XML Query, XPath, XPointer, XLink, XML Base, DOM, CSS, XSL/XSLT, XHTML, XForms, XML Encryption, XML Key Management, XML Signature, RDF, MathML, SMIL, SVG, X3D, etc.

Review the current state of the XML standards at http://www.w3c.org/XMLReview the current state of Java Technology and XML (JAXP) standards at http://java.sun.com/XMLReview the Java binding to DOM 2.0 at http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/java-binding.zip

DOM Level 3 still at the specification stage

32

Part IV

XML and Java Connected Devices Support

Page 17: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

17

33

XML Tools for Information AppliancesSee http://www.topxml.com/java/articles/javaxml/3.aspJava Soap library

KVM kSOAP (http://ksoap.enhydra.org/)J2ME Web Service Spec. (JSR 172: http://jcp.org/jsr/tech/j2me.jsp)

Environment Needed to Run XML-Based Java ApplicationsJava KVM for J2ME

Java Kilobyte Virtual Machine (KVM) designed to operate with as little as 160 to 512 KB of memory

NanoXMLLightweight DOM-style XML parser and document generator

Palm OS Emulator (POSE)Software that emulates the hardware of different Palm devices (Palm III, Vx, VII, etc.)Can be used as a unit testing platform

Also See http://webdev.apl.jhu.edu/~rbe/kvm/ (older thin-client support ala WML/WAP)

34

XML on Lightweight Clients

Lightweight client-side developmentProcess and generate XML documents

Client-side transformation of generic XMLPeer-to-peer networkingInformation appliance interoperabilityPowerful lightweights leveraging

Page 18: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

18

35

Key Java XML Technologies forLightweight Clients

Lightweight parsers and document generatorsXSLT compilersCLDC and KVM

36

Myriads of Client Formats

Compact HTML (cHTML)Used in NTT DoCoMo iNode network in Japanhttp://www.w3.org/TR/1998/NOTE-compactHTML-19980209

Wireless Markup Language and WMLScript for WAP networks HTML

HTML 4.0 Guidelines for Mobile Accesshttp://www.w3.org/TR/1999/NOTE-html40-mobile-19990315

Page 19: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

19

37

Myriads of Client Formats(continued)

Handeld Device Markup Language (HDML)Created by Unwired Planet (Phone.com /Openwave -http://www.openwave.com) in 1995Scripting capabilities similar to WMLScriptOpenwave WAP Edition browser displays WML/WMLScript as well as HDMLOpenwave Universal Edition browser displays WML/WMLScript, xHTML, and cHTML

Proprietary Format (e.g., Xircom Rex)XHTML Basic

http://www.w3.org/TR/2000/REC-xhtml-basic-20001219

38

XML Document ServersConjecture:

Publish content and data in HTML, cHTML, WML and WMLScript, HDML, Web Clipping Application format, etc.

Alternative 1: Publish content data in one format (e.g., WML)

Relies on infrastructure providers for upgrade path (WAP server)

Alternative 2: Publish content data in XML with an associated DTD or XML Schema

Transformation process belongs to client

Page 20: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

20

39

Peer to Peer NetworksSample Networks

Napster / Jabber (have centralized directory svc.)GnuTella (no centralized directory svc.)

P2P Networks are supported by Jini and the JXTA project (http://www.jxta.org) in the information appliance world

Jini connects distributed services via a directory serviceJXTA connects distributed services without requiring a directory service

Based on generic XML data referred to as “codat”Provides InstantP2P for instant messaging with “peer groups” andP2P file sharingNot very well supported by single threaded device OSs

40

Information Appliance InteroperabilityExample

Mobile phone application dialing a number stored in a PDA

Typical SolutionBoth devices are Bluetooth-enabledMobile phone application uses the Java API for Bluetooth (JSR-000082, http://java.sun.com/aboutJava/communityprocess/jsr/jsr_082_bluetooth.html)PDA address book application exposes directory services in a standard wayWould be great is the PDA could generate XML as common message format ...

Page 21: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

21

41

Powerful LightweightsCompaq iPaq 3670, 3850, 5450, etc. !!!

64MB RAM expandable to 128MB with an optional CompactFlash cardBuilt-in microphone, speaker, and light sensorOptional IBM Microdrive for up to 1GB storageDual-Slot PC Card Expansion Pack for up to two Type-II PCMCIA cards

Novatel Wireless Merlin for Ricochet enables128 kbps wireless Internet accessOther slot can be used for another 16MB of RAM or perhaps a GPS receiver

42

Available VMs(not all J2ME-compliant)

IBM J9 (http://www-3.ibm.com/software/wireless/wsdd/)Kada Mobile (http://www.kadasystems.com/)Esmertec Jbed (http://www.esmertec.com/)SuperWaba (http://www.superwaba.org/)Waba (http://www.wabasoft.com/) Symbian (http://www.symbian.com/)

includes both an operating system and VM Sun KVM (http://java.sun.com/products/cldc/)

Page 22: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

22

43

J2ME Compliance(review)

Configuration LayerClass of information appliance

Device Profile LayerPDA Profile for CLDC Mobile Information Device Profile for CLDC Foundation Profile for CDC Personal Profile for CDC

Application Layer

44

XML Parsers

NanoXML 2.2.3http://web.wanadoo.be/cyberelf/nanoxml/Parser with a DOM-style interface that offers document generation and SAX 2.0 support

MinML (http://www.wilson.co.uk/xml/minml.htm)Lean, fast SAX 1.0 parser without support for document generation

kXML (http://kxml.enhydra.org/)TinyXML (http://www.grinninglizard.com/tinyxml/)XPP (http://www.extreme.indiana.edu/soap/xpp/)

Page 23: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

23

45

Different Types of XML ParsersPush parsers (SAX)

publish a set of interfaces, implemented by applications, through which the parser relays document information.application code must maintain state within callback class(es), and to evaluate that state at each event.

Object model parsers (DOM)build in-memory representations of XML documents using tree-like data structures Either all-at-once or lazy parsers

Pull parsers (similar to java.io.Reader)Parsing is based on application needsExamples: kXML and XPP

46

Sample Palm ApplicationBeaming contact information from a custom Palm database

Page 24: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

24

47

Part V

XML and JavaJ2EE Support

48

J2EE Web-Enabling Component Models(revisited)

Thick-Client Support / Client-ContainerJava Web Start / XUL / Thinlets, etc.

http://www.javasoft.com/products/javawebstart/index.html

Javasoft’s Applet Tutorial:http://java.sun.com/docs/books/tutorial/applet/TOC.html

Swing Applets:http://java.sun.com/docs/books/tutorial/uiswing/start/swingApplet.html

Connected Devices: MIDP, PDAP

Thin-Client SupportServlets, Servlet filters, Cocoon/XSPsConnected Devices (http://webdev.apl.jhu.edu/~rbe/kvm/)

Page 25: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

25

49

Java Servlets & Java Server Pages

See Javasoft’s Documentation on Servlets:http://java.sun.com/products/servlet/index.html

See Javasoft’s Documentation on JSPs:http://java.sun.com/products/jsp/

Servlet Example: Cocoonhttp://xml.apache.org

Need Domain Boundary Controllers e.g., www.xtradyne.comUntil HTTP-NG / CORBA 3 firewall spec. gets implemented

50

Introduction to Servlets and JSPsSee http://www.java-shop.com/jsp.htmServlets (http://java.sun.com/products/servlet/)

Java’s standard mechanism for writing code that runs and extends the functionality of a servlet engineA servlet is to a server what an applet is to a browserHTTP servlets

Replacement for CGIStandard mechanisms for handling cookies, sessions, session/application contextsAdvantages over CGI: performance, platform and web-server independence

Servlet filters are new in the Java Servlet Specification 2.3

Java Server Pages (http://java.sun.com/products/jsp/)Answer to Microsoft’s Active Server PagesProvide mechanism for including tags/scriptlets into an HTML or XML pageJSPs have .jsp extension and are processed using a special servlet

JSP page is compiled into a servlet upon first access or after each modificationAbility to instantiate and access JavaBeans within JSP pages

Page 26: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

26

51

MVC or Model 2 Design Pattern Used to implement Modern Web Applications as a combination of

Servlets/Servlet filtersController receiving/filtering requests from the userUpdates the application’s model composed of JavaBeansPasses the page request to a view JSP

Java Server PagesDisplay information based on the current state of the application’s model

JavaBeansEnable component reuse

Custom Tag LibrariesMake it possible to move source code out of the JSP where it is difficult to maintain and into reusable JavaBeans

Rich array of Java APIs

See http://www.mhsoftware.com/resources/iisjserv.html for a comparison of IIS/ASP and Servlet/JSP technology

52

Servlets and JSPs Examples JSP displaying a banner image based on who is referring the user to the site:

<%@ page import="com.ibm.jspredbook.*;” errorPage="error.jsp" %>

<body bgcolor="#FFFFFF">

<!--the referrer header is used to trap the url the user is coming from -->

<IMG SRC="/servlets/ImgServlet?from=<%=request.getHeader("Referer")%>">

</body>

</html>

Page 27: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

27

53

Servlets and JSPs Examples(continued)

Servlet referenced in the IMG tag of the previous slide (partial):package com.ibm.projsp;import javax.servlet.*;import javax.servlet.http.*;import java.util.*;import java.io.*;public class ImageServlet extends HttpServlet {

private String docHome = ".";public void service( HttpServletRequest request,

HttpServletResponse response)throws ServletException, IOException {

HttpSession session = request.getSession(true);ServletConfig config = getServletConfig();ServletContext application = config.getServletContext();File file = findFile(request, response);if (file == null) { return; } else {

response.setContentType(application.getMimeType(file.getName()));response.setContentLength((int) file.length());sendFile(file, response);} }

54

Architectural ConsiderationsPage-Centric v.s. Dispatcher Type

Page-Centric architectures have a JSP handling the request directlyDispatcher architectures include a Servlet that handles the request and delegates to a JSPSample architectural patterns:

Page-View (Page-Centric)Page-View with Bean (Page-Centric)Mediator-View (Dispatcher)Mediator-Composite View (Dispatcher)Service-to-Workers (Dispatcher)

Page 28: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

28

55

Cocoon 2Web Publishing framework implemented as a servletRequires a servlet engine to operateCocoon 2 has been rearchitected to truly support the MVC patternCocoon processor:

Cocoon Java type that takes a DOM tree as an input and produces another

Cocoon producer:Cocoon Java type used to feed the initial XML content to the Cocoon processing pipelinee.g., Cocoon serves static XML documents using its built-in FileProducer

Cocoon processing instructions act upon a whole document, which generates a result document

<?cocoon-process type="xsp"?>Result document is passed to the next Cocoon processorSimilar to servlet chaining

Alternatives: Rocket, CPan’s

56

Introduction to XSPsSee:

Apache Cocoon technology: http://cocoon.apache.org/2.0/XSP / JSP differences: http://www.onjava.com/lpt/a/620Publishing Frameworks:http://www.oreilly.com/catalog/javaxml/chapter/ch09.html#69379

XSP:Core technology available in Apache Cocoon 2Approach separates content, style, and logic as XML files and uses XSL to merge them

XSP engine Implemented as a Cocoon processor that accepts an XSP as inputTranslates XSP into equivalent source program, compiles, loads and executes itXSP generates producers while JSP technology generates servletsAll XSP producers are derived from an abstract base class XSPPage

Page 29: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

29

57

Minimal XSP PageXML document that has the following characteristics:

Processing instruction invoking the XSP processor:<?cocoon-process type="xsp"?>

Document root element must be:<xsp: page>

All language and Taglib declarations must appear as attributes in the root element tag:

e.g., <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core”>

Optional elements:<xsp:logic> (procedural logic embedding) and <xsp:expr> (programexpression inlining)

Optional processing of the resulting page via a style sheet for viewing purpose

<?cocoon-process type="xslt"?><?xml-stylesheet href="sample.xsl" type="text/xsl"?>

Note: Minimal JSP page is an HTML document

58

XSP Example XSP logic tag:. . .<p>

Good<xsp:logic>String timeOfDay = (new SimpleDateFormat("aa")

).format(new Date());

if (timeOfDay.equals("AM")) {<xsp:content>Morning</xsp:content>

} else {<xsp:content>Afternoon</xsp:content>

}</xsp:logic>!

</p>. . .

May be rephrased using a library tag as: ...<p>Good <util:time-of-day/>!</p>...

Page 30: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

30

59

XSP v.s. JSP XSP

Tailored to maximize code reuse

Allows separation of content from presentationDevelopers handle content generation (content can be static or generated via servlets or Java code)

XML/XSL authors handle style/presentation via style sheet modifications

As XSP processing occurs prior to styling, the content can be presented in various waysKeep development teams well isolatedCan use IBM's Bean Scripting Framework (BSF) to support other scripting languages in addition to Java

JSPPopular and widely understoodRequires tight collaboration between application developers and presentation designersAt best presentation designers must understand how to use tag libraries

60

Summary

XML is a metamarkup languageXML tags describe the structure and semantics of a document’s content (not the format of the content)XML addresses SGML’s complexity and HTML’s inadequacies Applications of XML for information modeling exist in various domains (chemistry, math, multimedia, etc.)

Page 31: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

31

61

Summary (continued)

XML supports MOM and POP applicationsXML supports the Web Services InfrastructureXML and Java complements each otherJava-enabled XML technology is available in the market todayStandards for integrating XML and Java are being developed

62

Class ProjectProject Description

The project will consist of providing custom XML-based services to support the various aspects of your own selected portable application. The application can be targeted to end-users (B2C), businesses (B2B), developers (toolkit). As an example, you could implement and XML-based training studio supporting VoiceXML, and application-sharing capabilities. Sample applications used in the past fell in the category of “multi-channel online community platforms”, and included applications such as “community-based shopping”. In that context, examples of useful XML-based services to support these platforms may include synchronized multimedia presentation viewing, and “offline” chatcapabilities. A sample specification of the online community platform for a virtual university eBusiness application that was used in the past for this course will be provided for illustration purpose.

Page 32: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

32

63

Generic Architecture Blueprint+ Architecture Design Methodology + Mgmt

XML Application Infrastructure(logic)

XML Application Services(logic)

Applications of XML(structured content/object data, style information)

Technology Infrastructure(hardware platforms)

XML Applications(logic) Logical View Implementation View

Process View Deployment View

Use CaseView

Use CaseView

Applications of

XML

Structure

Style

XMLApplications

Content

Management

Processing

Querying

Rendering

Applicationand

Technology Infrastructure

Additional Services

64

Sample Conceptual Architecture Diagram(e.g., virtual classroom environment)

Technology Infrastructure (OS and hardware)

XML Application (logic )

XML Application Infrastructure (logic)

Applications of XML (content/style) XML Application Services (logic )

Legend

Presentation Enabling(posting, querying, locating, viewing)

SMIL

JSP Engine / SMIL Viewer (processing, rendering)

Web Community Avatar-Based Chat Platform

Web-Based Infrastructure(lightweight client machines, server platforms)

Q&A Enabling (questions capture, integration, viewing)

XLF

3rd Party Tool

SMILAuthoring

Tool

XLF Processing/Rendering

XML POP Framework (processing, rendering)

XMLAuthoring

Tool

Page 33: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

33

65

Structured Applications Design TipsReuse: should focus on Domain Models/System Family ArchitecturesApplications should separate the various information elements (i.e., content, logic, style, and architecture/handling schemes)Various content formats: presentation, message, storage, etc.Application architecture supports:

Web Enabling (WE), XML Enabling (XE), Data Enabling (DE), Enterprise System Assurance Enabling (ESAE)

Various application support services to support:Interactions with users via content (content + logic) - WEEncoding of user requests as secure (portable) messages (content generation) -XE/ESAEProcessing of user requests via logic (content + logic) - XERendering of content via logic using style (content + style + logic) - WE/XEQuerying information via logic (content + logic) - XE/DEInteractions with back office via content (content + logic) - XE/ESAE

66

ReadingsReadings

XML and Java: Chapter 1, Appendices A, B, CProcessing XML with Java: Chapter 1Developing Java Web Services: Chapter 1Handouts posted on the course web siteExplore brief review of XML at XML in 10 pointsRead article at XMLJ2EEReview XML 1.0 (Second edition), Namespaces, and the XML activity statement at W3C

Project Frameworks Setup (ongoing)Apache’s Web Server, TomCat, and CocoonApache’s Xerces, Xalan

Page 34: XML for Java Developers G22.3033-002...e.g., Altova’s XML Spy , Corel’s Xmetal, Vervet Logic’s XML Pro, Sonic Stylus Studio, Wattle Software’s XMLWriter, etc. XML well-formedness

34

67

Assignment

Assignment #1a:Explore the textbooks’ CDs, and the textbook references to XML toolsInstall and experiment with XML and Java tools (i.e., modeling tools, and IDEs). Settle on a combination of tools you feel comfortable using, and come up with a small XML application that demonstrates the use of your selected XML tools. Write a short report that uses your sample application to document your findings and recommendations with respect to selection criteria in support of XML IDEs

68

Next Session:Markup Language Technologies (Part II)

Current state of the XML standardAdvanced XML applicationsXML Style Specification Languages