Using XML and XSL with IBM Websphere 3.0

Using XML and XSL with IBM Websphere 3.0

The XML Files: Using XML and XSL with IBM WebSphere 3.0 Luis Ennser, Christophe Chuvan, Paul Fremantle, Ramani Routray Jouko Ruuskanen International Technical Support Organization www.redbooks.ibm.com SG24-5479-00 SG24-5479-00 International Technical Support Organization The XML Files: UsingXMLandXSLwithIBMWebSphere3.0 March 2000 Take Note! Before using this information and the product it supports, be sure to read the general information in Appendix D, “Special notices” on page 221. First Edition (March 2000) This edition applies to IBM WebSphere Application Server V 3.0. Comments may be addressed to: IBM Corporation, International Technical Support Organization Dept. QXXE Building 80-E2 650 Harry Road San Jose, California 95120-6099 When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. © Copyright International Business Machines Corporation 2000. All rights reserved. Note to U.S Government Users – Documentation related to restricted rights – Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp. Contents Figures....................................................ix Tables....................................................xiii Preface...................................................xv The team that wrote this redbook. ..................................xv Commentswelcome............................................ xvii Part 1. Introduction to XML technology .....................................1 Chapter 1. Why XML?........................................3 1.1 Background .............................................3 1.2XML—auniversaldataformat..............................4 1.3 XML business benefits . ..................................5 1.3.1InformationSharing...................................6 1.3.2XMLinsideasingleapplication...........................6 1.3.3Contentdelivery......................................7 1.4 Technological benefits of XML . ............................7 1.4.1AnexampleofusingXML...............................7 1.4.2 Major benefits. .......................................8 1.5XMLhistory............................................10 1.6Real-lifeusesofXML.....................................11 1.6.1 SABRE and Wireless Markup Language. ................11 1.6.2 Chemical Markup Language . ...........................12 Chapter 2. XML overview ....................................13 2.1XMLconcepts..........................................13 2.1.1XMLandSGML.....................................13 2.1.2 Document validity and well-formedness . ................14 2.1.3DocumentTypeDefinition.............................15 2.1.4Namespaces.......................................20 2.1.5DTDversusXMLSchemas.............................22 2.2XMLLinking............................................23 2.3XPath.................................................25 2.4XPointer...............................................26 2.4.1TypesofXPointerlocators.............................27 2.5 eXtensible Stylesheet Language (XSL) . ......................28 2.5.1 Cascading Style Sheets ...............................28 2.5.2XSL=fo:+XSLT....................................29 2.5.3XSLTransformations.................................31 2.5.4RelationshipbetweenXSLandXPath....................31 © Copyright IBM Corp. 2000 iii 2.5.5AnXMLexample....................................32 Chapter 3. Processing XML using Java ........................35 3.1XMLapplications........................................35 3.2SAX..................................................36 3.2.1SAXclassesandinterfaces............................37 3.2.2SAXexample.......................................38 3.3DOM.................................................39 3.3.1DOMhierarchy......................................40 3.3.2DOMexample.......................................41 3.3.3DOMLevel2 .......................................41 3.4SAXorDOM?..........................................42 3.4.1 SAX advantages and disadvantages .....................42 3.4.2 DOM advantages and disadvantages .....................42 Part 2. Applying XML technology in IBM WebSphere..........................43 Chapter 4. Introduction to IBM WebSphere Application Server V3 ...45 4.1XMLforJavaParser......................................45 4.2LotusXSL..............................................46 4.3DTDCatalogs...........................................46 Chapter 5. XML Parser for Java ...............................47 5.1HowtoparseanXMLdocumentusingDOM...................48 5.2HowtocreateanXMLdocumentusingDOM...................53 5.3 Reading and querying DTD information . ......................53 5.4Usingnamespaces.......................................54 Chapter 6. LotusXSL .......................................55 6.1So,whatisanXSLTprocessor?.............................55 6.2XSLTbasics............................................56 6.2.1Accessingattributes..................................57 6.2.2 Conditional processing ................................58 6.2.3 Repetition..........................................59 6.2.4Creatingattributesandelements........................61 6.3LotusXSLAPI...........................................62 6.3.1IntegratingaparserwiththeXSLprocessor................63 6.3.2DefaultApplyXSL....................................63 6.3.3ConfiguringDefaultApplyXSL...........................63 6.3.4 Running DefaultApplyXSL . ...........................64 Chapter 7. WebSphere and XML approaches ....................65 7.1 WebSphere programming model . ...........................65 iv The XML Files: Using XML and XSL with IBM WebSphere 3.0 7.1.1Servlets...........................................65 7.1.2 Java Server Pages . .................................65 7.1.3 Servlets, JSPs, and JavaBeans . ......................66 7.2 Generating XML with WebSphere Application Server . ...........66 7.2.1Theprintlnmethod...................................67 7.2.2 The Document Object Model approach....................68 7.2.3TheJSPmethod.....................................70 7.2.4 Comparison of methods — generating XML ................71 7.3 Applying XSL to XML with WebSphere Application Server .........72 7.3.1UsingXSLwithinaservlet.............................72 7.3.2UsingXSLautomatically...............................78 7.3.3 XSLT Islands . ......................................79 7.4UsingXSLselectively.....................................82 7.4.1DefininganalternativeWebapplication...................82 7.4.2ApplyingXSLbasedonbrowsertype.....................83 7.5 Comparison of approaches.................................84 7.5.1ApplyingXSL.......................................84 7.5.2ComparisonofXML/XSLandServlet/JSP.................85 Part 3. ITSO XML application .............................................87 Chapter 8. XML application scenario ..........................89 8.1Applicationoverview......................................89 8.2 Database architecture . .................................91 8.3DocumentTypeDefinition.................................92 8.4Applicationarchitecture...................................96 Chapter 9. XML application implementation.....................97 9.1 Logon and user profile management . ......................97 9.1.1 User profile database .................................97 9.1.2Userprofileregistrationservlet.........................100 9.1.3 Logon servlet . .....................................101 9.1.4Userinterfaces.....................................101 9.2 Alternative — XSLT Islands ...............................109 9.3 Search engine .........................................114 9.3.1 Searching for products and adding to order ...............114 9.4 Implementation of shopping basket and ordering system .........118 9.4.1 Implementing the shopping basket as a JavaBean ..........119 9.4.2ProgramFlow......................................120 9.4.3Theorderbasket.jspfile..............................121 9.4.4BasketBeanimplementation...........................123 9.4.5 XSL stylesheet implementation — basket.xsl ..............131 9.5Ordertracking.........................................133 v 9.5.1Servletoverview....................................133 9.5.2 Displaying order reports ..............................134 9.5.3 Retrieving individual order information ...................136 9.5.4 Generating the HTML output ..........................139 9.6Supplier..............................................144 Chapter 10. Use and implementation of the DatabaseDom bean ...149 10.1 Use, limitations, and approach . ..........................149 10.1.1Thetemplatefile...................................149 10.1.2Definitionoftemplatefileelements.....................152 10.1.3Exampleoutput...................................154 10.1.4 Bean methods ....................................155 10.1.5 Updating the database ..............................155 10.2 The implementation of the DatabaseDom bean ...............155 10.2.1 Generating XML from the database ....................157 10.2.2 Updating the database from an XML DOM tree. ..........157 10.2.3 Creating the column to XML mapping ...................158 Chapter 11. Conclusions ...................................161 11.1Successes...........................................161 11.2 Lessons Learned . .....................................163 11.3Areasforfutureexploration..............................164 Appendix A. WebSphere Installation

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    258 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us