1 / 89

XML & Java for Dot Com

XML. DTD. ejb. XSL. XML & Java for Dot Com. Raymond Gao http://raygao.com E-Commerce Architect Sun Microsystems, Inc. WWW. E - Commerce. ASP. B2B. B2C. The Internet Phenomenon. By 2003, 52 million U.S. household will be online

midori
Download Presentation

XML & Java for Dot Com

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. XML DTD ejb XSL XML & Java for Dot Com Raymond Gao http://raygao.com E-Commerce Architect Sun Microsystems, Inc.

  2. WWW E-Commerce ASP B2B B2C The Internet Phenomenon • By 2003, 52 million U.S. household will be online • By 2003, the market for packaged E-Commerce software will reach $14.5 billion • By 2004, Worldwide Net-Commerce will approach $6.8 trillion Source: Forrester Research

  3. Computing In The Age Of Internet • Heterogeneous environment and the portability factor • Open standards & non-proprietary technology • Support for distributed computing • Component architecture and code reuse • Flexibility and adaptability to the changing business requirements

  4. The Internet’s 4-As & 8-abilities • The 4 As • Anytime, Anywhere, Any device, and Anyone • The 8-abilities • Scalability, Availability, Manageability, Compatibility, Security, Stability, Portability, and Flexibility.

  5. HTML Web Server Model PCs <html>

  6. HTML’s Deficiency • One tag set is used for all applications • Tags’ semantics cannot be changed • Data structure is lost during the HTML translation process • Data validation is not supported - i.e. broken <a href > links • HTML document cannot be directly mapped backend to a database

  7. HTML Web Server Model Has Deficiencies • Inflexible - • Serves up only HTML pages. • No content validation - broken links. • Mainly PC clients and does not support PDA and Wireless devices. • Difficult to find useful information • 4 Billion pages by January - only 0.01% is useful for a person (USA Today, July 11)

  8. Content Servers (i.e. http://) <xml> & <html> Business Service Provider EIS XML Document Server Model

  9. What Is XML? • eXtensible Markup metaLanguage • A method for structuring portable data • A subset of SGML (ISO 8879) • A meta-language - supports unlimited numbers of context-relevant tags and attribute names. • Support data validation • Current version is XML 1.0

  10. XML <book> <bookname> A Tale of Two Cities </bookname> <Author> Charles Dickens </Author> <Type> Fiction </Type> </book> XML vs. HTML HTML <html> <head> book </head> <body> &nbsp; A Tales of Two Cities <br>&nbsp; Charles Dickens <br>&nbsp; Fiction </body> </html>

  11. XML’s Philosophy XML derives from the philosophy that data belongs to its creators and that content providers are best served by data format that does not bind them to any particular script languages, authoring tools, and delivery engines but provides a standardized, vendor-independent, level playing field… Jon Bosak, “XML, Java, and the Furture of the Web”

  12. XML - The Ideal Data Format • Extensible - Allowing user to define new tags and schemas (DTD) that are context-relevant • Reusable - Switching between different views without the need for new downloads • Structured - Providing a hierarchical model that facilitates Object-Orient Programming and resembles the database • Validation & well formed - Content and syntax checking

  13. Data Needs An Operator • XML is data; and data does not have behaviors • XML has no legs - XML did not specify which transport protocol to use • XML presentation is dependent on the OS platform - different platforms use different encoding schemes <CR><LF> on unix, dos, & mac • Security & Lifecycle - Schema will evolve

  14. Java - The New Programming Paradigm • Platform-neutral - Byte Code: 80% compiled, 20% interpreted • Object-Oriented Programming language • Virtual Machine - Buffers the application from the OS • Garbage Collection - Almost no memory leak • Reusable components and Interface driven

  15. Software Engineering Meets Business Domain • Can you buy a car with a Java object? - Exchange Java objects can be inefficient • The world is not made up entirely of JVMs - Legacy applications, native code programs, … • Distributed computing & security • Send messages that everyone can understand

  16. Common Points Between Java And XML • New & maturing fast • Portable • Polymorphic - Java is an OO Language, XML allows introduction of new tags and schemas. • Emerging Standards - • XML = Lingua Franca for i-Document • Java = Synonym for E-Commerce

  17. Is Your Application Really Portable? • True && False => False (XML + native code) • False && True => False (HTML + Java) • True && True => True (XML + Java)

  18. Why Java And XML Complement Each Other? • Portable data; Portable code • N-Tier architecture • Distributed computing • Security model • Growth of the smart internet - agent technology • Realization for wireless devices • Programming concept vs. computing in the real world

  19. Plan For Presentation • XML • XML Review - Syntax, DTD, XSL • 3-Tiered XML Model • Java • J2EE Blueprint • EJB Transaction • JSP, JMS

  20. XML Quick Overview • All XML documents must begin with the prolog<?xml version = “1.0”?><?XML version = “1.0”?> • XML must be Well-Formed - A document that is not well-formed is not XML. • Use optional DTD for document validation. • XML is case sensitive.

  21. XML Element Should Be Well-Formed • Explicit start and end tags for every elements including empty tags. <tag>text</tag>or<tag/>not <stuff><tag-a></stuff> • An XML document can have only one root element (/). • No element overlap allowed.<a>A<b>B</a></b>

  22. XML Element Attribute Should Also Be Well-Formed • Attributes are separate by space(s) • From element name • From each other<apple color=“red” taste=“sweet”><apple_color=“green”,taste=“sour”> • Each attribute must have a valid name.<apple color=“” taste=“sweet”><apple “green” the taste=“sour”> • Equal-sign and quotes are required.

  23. An Example XML Document <?xml version=“1.0” standalone=“no” ?> <!DOCTYPE play SYSTEM “play.dtd”> <play location = “Broadway”> <playname> Hamlet </playname> <author> Shakespare </author> <type> Tragedy </type> </play>

  24. Validating Your XML Document • Link DTD to your XML document.<?xml version=“1.0” standalone=“yes|no” ?><!DOCTYPE mydtd SYSTEM “MY.DTD”>or<!DOCTYPE mylocaldtd [ ….] > • Using Element declaration<!ELEMENT name (content model) >i.e. <!ELEMENT play (playname, author, type?)>or <!ELEMENT playname (#PCDATA)>where

  25. Use Attribute To Add Flavor To Element • If element is the noun, then attribute is the adjective. • Syntax:<!ATTLIST element_name attribute value default> • Usage:<!ELEMENT play (playname, author, type?)> <!ATTLIST play date CDATA #IMPLIED location CDATA #REQUIRED time (weekday | weekend) “weekend”>

  26. An Example of DTD <!-- This is the DTD for the play example --> <!ELEMENT play (playname, author, type?)> <!ATTLIST play date CDATA #IMPLIED location CDATA #REQUIRED time (weekday | weekend) “weekend”> <!-- Information about a play --> <!ELEMENT playname (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT type (Tragedy | Comedy | Drama)>

  27. XML Reference Card

  28. XSL Info • XSL is itself a XML document. • XSL has two parts: • 1. XSLT - XML Transformation. Takes an XML document and outputs into a HTML, WML, or XML document. (now in W3C recommendation stage) • 2. XSLFO - XML formatting. XML equivalent of CSS (Cascading StyleSheet) - (In Work?)

  29. An Example XSLT <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="UTF-8"/> <xsl:template match="/"> <HTML> <HEAD> <TITLE><xsl:value-of select="message"/></TITLE> </HEAD> <BODY> <xsl:apply-templates/> </BODY> </HTML> </xsl:template> <xsl:template match="message"> <H1><xsl:apply-templates/></H1> </xsl:template> </xsl:stylesheet>

  30. XML & The 3-Tier Notion • Why? • What? • How?

  31. 3-Tier Architecture Presentation (View) Business Logic (Controller) Persistence (Model)

  32. Justifications For 3-Tier Architecture • Scalable - Difficult to forecast web-site load & dynamic system capacity adjustment according to demand • Adaptable - Business process can change • Reusable - Component architecture • Maintenance & Improvement • Cycle Time & Cost

  33. Why Should You Apply The 3-Tier Concept To XML Programming? • Model after MVC (Model, View, Controller). • Make better architecture sense. • More adaptable - evolve according to changes in the business process. • Integrate with other languages - Java, UML, C++. (S/W Methodolgy) • Distributed Computing. • Increase portability.

  34. What Are The 3 XML Tiers? • Content • Structure • Exchange

  35. The Content • Purpose: contain the “instance” information about the data to be consumed by the end-user. • Usage: Holds the actual data content. • Examples: XML documents and XHTML.

  36. The Structure • Purpose: hold the schema information about a group of XML document(s). • Usage: abstract & high-level. i.e. for document validation and binds to the content. • Examples: DTD, XML Schema, RDF, Namespaces, ebXML, SOAP, fpML, JSP spec, etc.

  37. The Exchange Layer • Purpose - formatting & translating the XML data into appropriate views for the end-user’s application and connecting XML documents. • Usage: Displaying appropriate view, linking, and transforming documents, etc. • Examples: XSL, XSLT, XPath, XFormat, XPointer, XLink.

  38. Where To Get More Information • http://www.xml.com • http://www.xmlinfo.com • http://www.oasis-open.org/Cover/ • http://www.wrox.com • http://www.mulberrytech.com • http://www.w3.org/XML/ • http://www.javasoft.com/XML

  39. The Current Relationship Betwen XML And J2EE • EJB already uses XML for deployment descriptor. • JSP offers Tag library - observes XML convention, (Pipelines.) • JTA, JTS, and EJB 2.0 will be able to make transactions based on asynchronous message. • J2EE includes JMS, JAXP, JAXM.

  40. HTML, CSS, Javascripts, JSPs, Servlets, and Applets Web Server Java Beans, JMS, EJB (Session Beans) Application Server JDBC, EJB (Entity Beans) EIS Java In The 3-Tier Web Architecture <html> …. </html>

  41. J2EE Blueprint

  42. JDK 1.3 Layout

  43. EJB Overview • Different Types of EJB • EJB and Application Performance • EJB Transaction

  44. Classifying The EJB • Entity Bean - Maps to the row(s) in a database and is persistent • Session Beans - Services the client’s request but is not persistent • Stateless - service many clients • Stateful - service a single client • Message Driven Bean - (EJB 2.0) JSR-000019

  45. Making EJB More Scalable • Problem: • Stateful Session Bean - can hold the users’s session but is a heavyweight. (It generates high overhead ) • Stateless Session Bean - is lightweight but cannot hold users’ session information. • Solution: Use HttpSession object with stateless session bean.

  46. EJB Transaction Should Be ACID • Atomic - Transaction is “all or nothing” • Consistent - Transaction always leave the system in a consistent state • Isolated - Transaction is thread-safe and won’t affect other transactions • Durable - Transaction survives the system failure

  47. A Simple Example of EJB Transaction

  48. Where To Get More Information On EJB • http://www.javasoft.com/ejb • http://www.javasoft.com/j2ee • http://www.ejbportal.com/ • http://www.gamelan.com

  49. What is JSP? • Separates the presentation from the business logic • Extends the Java servlet technology • Dynamic page reloading

  50. JSP Extends The Java Servlet Technology • Includes 2 main packages • javax.servlet.jsp.* • javax.servlet.jsp.tagext.* • Lifecycle of JSP • Precompiling --> Dynamic Reloading • jspInit() --> _jspService() --> jspDestroy()

More Related