890 likes | 1.07k Views
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
E N D
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 • 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
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
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.
HTML Web Server Model PCs <html>
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
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)
Content Servers (i.e. http://) <xml> & <html> Business Service Provider EIS XML Document Server Model
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
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> A Tales of Two Cities <br> Charles Dickens <br> Fiction </body> </html>
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”
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
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
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
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
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
Is Your Application Really Portable? • True && False => False (XML + native code) • False && True => False (HTML + Java) • True && True => True (XML + Java)
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
Plan For Presentation • XML • XML Review - Syntax, DTD, XSL • 3-Tiered XML Model • Java • J2EE Blueprint • EJB Transaction • JSP, JMS
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.
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>
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.
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>
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
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”>
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)>
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?)
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>
XML & The 3-Tier Notion • Why? • What? • How?
3-Tier Architecture Presentation (View) Business Logic (Controller) Persistence (Model)
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
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.
What Are The 3 XML Tiers? • Content • Structure • Exchange
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.
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.
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.
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
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.
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>
EJB Overview • Different Types of EJB • EJB and Application Performance • EJB Transaction
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
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.
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
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
What is JSP? • Separates the presentation from the business logic • Extends the Java servlet technology • Dynamic page reloading
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()