ebook img

XML and Web services unleashed PDF

1173 Pages·2002·6.28 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview XML and Web services unleashed

00 0672323419 FM 3/15/04 11:14 AM Page i XML and Web Services Unleashed 00 0672323419 FM 3/15/04 11:14 AM Page ii XML and Web Services Unleashed EXECUTIVEEDITOR Rochelle J. Kronzek Copyright © 2002 by Sams Publishing DEVELOPMENTEDITOR All rights reserved. No part of this book shall be reproduced,stored in a Songlin Qiu retrieval system,or transmitted by any means,electronic,mechanical,photo- copying,recording,or otherwise,without written permission from the publish- MANAGINGEDITOR er. No patent liability is assumed with respect to the use of the information Matt Purcell contained herein. Although every precaution has been taken in the preparation PROJECTEDITOR of this book,the publisher and author assume no responsibility for errors or George E. Nedeff omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein. COPYEDITOR Bart Reed International Standard Book Number:0-672-323419 Library of Congress Catalog Card Number:2001097282 INDEXER Kelly Castell Printed in the United States of America First Printing:February 2002 PROOFREADER Karen Whitehouse 05 04 03 02 4 3 2 1 TECHNICALEDITOR Trademarks Mike Farley All terms mentioned in this book that are known to be trademarks or service INTERIORDESIGNER marks have been appropriately capitalized. Sams Publishing cannot attest to Anne Jones the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. COVERDESIGNER Aren Howell Warning and Disclaimer PAGELAYOUT Every effort has been made to make this book as complete and as accurate as D&G Limited,LLC possible,but no warranty or fitness is implied. The information provided is on an “as is”basis. 00 0672323419 FM 3/15/04 11:14 AM Page iii Contents at a Glance Part I Essentials of XML 5 1 XML in Context 7 2 The Fundamentals of XML 35 3 Validating XML with the Document Type Definition (DTD) 67 4 Creating XML Schemas 107 5 The X-Files:XPath,XPointer,and XLink 169 6 Defining XML Using Alternate Schema Representations 223 Part II Building XML-Based Applications 265 7 Parsing XML Using Document Object Model 267 8 Parsing XML Using SAX 309 9 Transforming XML with XSL 345 10 Integrating XML with Databases 405 11 Formatting XML for the Web 439 12 Interactive Graphical Visualizations with SVG 499 13 XML and Content Management 545 14 Architecting Web Services 591 15 Web Services Building Blocks:SOAP 629 16 Web Services Building Blocks:WSDL and UDDI 677 17 Leveraging XML in Visual Studio .NET 719 18 Using XML in the .NET Enterprise Servers 769 Part III Applied XML 811 19 Understanding XML Standards 813 20 Implementing XML in E-Business 847 21 Delivering Wireless and Voice Services with XML 889 22 Applied XML in Vertical Industry 941 00 0672323419 FM 3/15/04 11:14 AM Page iv Part IV The Semantic Web 995 23 RDF for Information Owners 997 24 The Semantic Web for Information Owners 1039 Part V Appendix 1069 A Extensible Markup Language (XML) 1.0 (Second Edition) Specification 1071 Index 1133 00 0672323419 FM 3/15/04 11:15 AM Page v Contents PART I Essentials of XML 5 1 XML in Context 7 XML:A Brief Glimpse ..........................................................................9 The Time Is Right ..................................................................................9 How We Got Here ................................................................................11 Standard Generalized Markup Language (SGML) ........................11 Hypertext Markup Language (HTML) ..........................................15 Electronic Data Interchange ............................................................16 The Beginnings of XML ......................................................................19 The Promise of XML ............................................................................20 Benefits of XML ............................................................................20 Advantages of XML over SGML ....................................................23 Advantages of XML over HTML ..................................................23 Advantages of XML over EDI ........................................................24 Advantages of XML over Databases and Flat Files ......................25 Drawbacks to XML ........................................................................26 XML-Based Standards ....................................................................27 Where Is XML Heading? ....................................................................28 E-Business and E-Commerce ..........................................................28 Content Management ......................................................................29 Web Services and Distributed Computing ......................................30 Peer-to-Peer Networking and Instant Messaging ............................31 Getting More Meaning out of the Web:The Semantic Web ..........32 Summary ..............................................................................................33 00 0672323419 FM 3/15/04 11:15 AM Page vi 2 The Fundamentals of XML 35 Introduction to XML Syntax ................................................................36 Markup Languages and Self-Describing Data ................................37 A Simple XML Document ..............................................................38 XML Document Structure ....................................................................39 XML Declaration ............................................................................40 Document Type Declaration ............................................................41 Markup and Content ........................................................................43 Elements ..........................................................................................43 Attributes ........................................................................................45 Entity References ............................................................................47 Comments ........................................................................................48 Processing Instructions ....................................................................49 Marked CDATA Sections ................................................................49 Document Type Definitions ............................................................50 XML Content ..................................................................................50 XML Content Models ..........................................................................51 Handling Whitespace in XML ........................................................52 Rules of XML Structure ......................................................................53 All XML Elements Must Have a Closing Tag ................................53 XML Tags Are Case Sensitive ........................................................54 All XML Elements Must Have Proper Nesting ..............................54 All XML Documents Must Contain a Single Root Element ..........54 Attribute Values Must Be Quoted ..................................................55 Attributes May Only Appear Once in the Same Start Tag ..............55 Attribute Values Cannot Contain References to External Entities ..........................................................................................56 All Entities Except amp,lt,gt,apos,and quotMust Be Declared Before They Are Used ..................................................56 Other Rules of XML Structure ........................................................56 Well-Formed and Valid Documents ......................................................56 Well-Formed Documents ................................................................56 Valid Documents ............................................................................57 Linking XML Documents Together ....................................................57 Namespaces in XML ............................................................................58 Declaring Namespaces ....................................................................60 Identifying the Scope of Namespaces ............................................61 Applying Style to XML ........................................................................61 Basics of Reading and Processing XML ..............................................62 Parsers ..............................................................................................62 The Document Object Model (DOM) ............................................64 The SAX API ..................................................................................64 00 0672323419 FM 3/15/04 11:15 AM Page vii International Language Support in XML ............................................65 Unicode ............................................................................................65 Summary ..............................................................................................66 3 Validating XML with the Document Type Definition (DTD) 67 Document Type Definitions ..................................................................68 Some Simple DTD Examples ..............................................................70 Structure of a Document Type Definition ............................................72 The Document Type Declaration ....................................................72 DTD Attributes ................................................................................85 DTD Entities ....................................................................................92 More DTD Directives ....................................................................101 DTD Drawbacks and Alternatives ......................................................103 Summary ............................................................................................105 4 Creating XML Schemas 107 Introduction to the W3C XML Schema Recommendation ................108 Sample XML Document ..............................................................109 Schema for XML Document ........................................................112 Creating XML Schemas ....................................................................116 Declaring Attributes ......................................................................118 Declaring Elements ......................................................................125 Declaring Complex Elements ........................................................128 Declaring Simple Types ................................................................130 Refining Simple Types Using Facets ............................................131 Anonymous Type Declarations ....................................................138 Specifying Mixed Content for Elements ......................................140 Annotating Schemas ......................................................................141 Model Groups ................................................................................142 Attribute Groups ............................................................................148 Targeting Namespaces ..................................................................149 ”Inheriting”from Other Schemas ................................................159 Summary ............................................................................................168 5 The X-Files: XPath, XPointer, and XLink 169 XPath ..................................................................................................171 Operators and Special Characters ................................................171 XPath Syntax ................................................................................172 XPointer ..............................................................................................207 Points ............................................................................................209 Ranges ..........................................................................................213 Abbreviating XPointer Notation ..................................................214 00 0672323419 FM 3/15/04 11:15 AM Page viii XLink ..................................................................................................215 Simple Links ..................................................................................219 Extended Links ..............................................................................219 Summary ............................................................................................221 6 Defining XML Using Alternate Schema Representations 223 A Brief Review of XML Schemas ....................................................224 Dead Formats:XDR,DSD,and DCD ................................................229 XML Data Reduced (XDR) Schema ............................................230 Document Structure Description (DSD) Schema ........................233 Document Content Description (DCD) Schema ..........................237 Schema for Object-Oriented XML (SOX) ........................................240 RELAX NG Schema ..........................................................................243 RELAX ..........................................................................................244 TREX ............................................................................................247 Combining RELAX and TREX ....................................................249 Schematron ........................................................................................253 Summary ............................................................................................262 PART II Building XML-Based Applications 265 7 Parsing XML Using Document Object Model 267 What Is DOM,Anyway? ....................................................................269 What DOM Is Not ..............................................................................269 Why Do I Need DOM? ......................................................................270 Disadvantages of Using DOM ............................................................270 DOM Levels ......................................................................................271 DOM Core ..........................................................................................271 Parents,Children,and Siblings ....................................................272 DOM Interfaces ............................................................................273 Java Bindings ................................................................................274 Walking Through an XML Document ..........................................275 Creating an XML Document ........................................................281 DOM Traversal and Range ................................................................284 Traversal ........................................................................................284 Range ............................................................................................288 Other DOM Implementations ............................................................291 JDOM ............................................................................................291 Small DOM-like Implementations ................................................294 Java Architecture for XML Binding (JAXB) ....................................294 Data Binding ..................................................................................295 JAXB Example ..............................................................................296 Summary ............................................................................................307 00 0672323419 FM 3/15/04 11:15 AM Page ix 8 Parsing XML Using SAX 309 What Is SAX,Anyway? ......................................................................310 What SAX Is Not ................................................................................311 Why Do I Need SAX? ........................................................................311 SAX vs. DOM ....................................................................................312 Disadvantages ....................................................................................312 SAX Versions ......................................................................................313 SAX Basics ........................................................................................314 SAX Packages ..............................................................................314 SAX Implementations ..................................................................316 Working with SAX ............................................................................317 Walking Through an XML Document ..........................................317 Validation ......................................................................................321 Handling Errors ............................................................................325 Entity References ..........................................................................328 Lexical Events ..............................................................................331 Summary ............................................................................................344 9 Transforming XML with XSL 345 XSL Technologies ..............................................................................346 XSLT for Document Publishing ........................................................347 Getting Started with XSLT ............................................................349 The Missing Piece:The XSLT Processor ....................................352 Advanced Features of XSLT ........................................................360 XSL for Business-to-Business (B2B) Communication ......................371 Creating the XSL Style Sheet ......................................................373 Using the XSLT Processor ............................................................374 Running the Example ....................................................................376 XSL Formatting Objects ....................................................................377 XSL-FO Formatting Engines ........................................................377 Basic Document Structure ............................................................379 Generating a PDF Document ........................................................386 Page Headers and Footers ............................................................387 Graphics ........................................................................................390 Tables ............................................................................................391 Web Application Integration:Java Servlets,XSLT,and XSL-FO ............................................................................................399 Developing the Java Servlet ..........................................................400 Testing the Example ......................................................................403 Summary ............................................................................................403 00 0672323419 FM 3/15/04 11:15 AM Page x 10 Integrating XML with Databases 405 XML Database Solutions ....................................................................407 XML Database Mapping ..............................................................407 Native XML Support ....................................................................408 Modeling Databases in XML ............................................................409 JAXB Solution ..............................................................................410 Reviewing the Database Schema ..................................................411 Constructing the Desired XML Document ..................................412 Defining a Schema for the XML Document ................................413 Creating the JAXB Binding Schema ............................................414 Generating the JAXB Classes Based on Schemas ........................416 Developing a Data Access Object (DAO) ....................................419 Developing a Servlet for HTTP Access ........................................429 Testing the Application ..................................................................432 Converting the XML Data to HTML with XSLT ........................435 Testing the JSP Page ....................................................................437 Summary ............................................................................................437 11 Formatting XML for the Web 439 A Brief History of DSSSL ..................................................................440 A Brief History of CSS ......................................................................443 XML Presentation Using CSS ............................................................448 An Overview of XHTML ..................................................................454 XHTML 1.0:The Transition ........................................................454 XHTML 1.1:Modularization ........................................................470 An Overview of XForms ....................................................................487 Introduction to XForms ................................................................488 Next Generation of Web Forms ....................................................488 XForms:Three Layers ..................................................................491 Instance Data Tracking ..................................................................493 Rich Data Type and Form Validation ............................................495 Multiple Form Documents ............................................................496 Summary ............................................................................................497 12 Interactive Graphical Visualizations with SVG 499 Vector Graphics to Complement Bitmap Graphics ............................500 Bitmap Graphics ............................................................................501 Vector Graphics ............................................................................501 Complementary Bitmap and Vector Graphics ..............................503 SVG:An XML Standard for Vector Graphics ....................................503 The SVG Standard ........................................................................504 XML Technologies Related to SVG ............................................504

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.