1. Trang chủ
  2. » Thể loại khác

John wiley sons java and xml (2002) bm ocr 7 0 2 6 lotb

322 412 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 322
Dung lượng 7,5 MB

Nội dung

3683-4 Cover Perfect bind 5/16/02 4:16 PM Page Trim: X Bleed: 25” 4-color process plus Pantone 2945 cv Matte layflat Development tools on CD-ROM! Welcome to the only guidebook series that takes a visual • Example code from the book approach to professional-level computer topics Open the • Java Platform, Standard Edition version 1.4 for Windows; Forte for Java, release 3.0 Community Edition; and Java Platform, Micro Edition, Wireless Toolkit 1.0.3 book and you’ll discover step-by-step screen shots that demonstrate over 120 key Java and XML programming techniques, including: • Creating a Java class file • Parsing an XML document with the SAX API • Importing a Java package • Verifying XML well-formedness • Working with nodes in the DOM • Declaring an XML DTD • Extracting CDATA sections • Preparing an XML Schema • Creating child elements in JDOM • UltraEdit shareware • Xerces Java Parser, Crimson Java XML Parser, and GNU JAXP • Plus a searchable e-version of Java and XML ™ the book • Detecting events in JAXP declaration • XML Spy evaluation version JavaXML Pro and JPad Pro demos ™ and XML “Apply It” and “Extra” sidebars highlight useful tips High-resolution screen shots demonstrate each task Succinct explanations walk you through step by step Two-page lessons break big topics into bite-sized modules ISBN 0-7645-3683-4 *85 -BAJHBb $26.99 USA $39.99 CAN £20.99 UK incl VAT Category: Web Development www.wiley.com System requirements: Pentium PC with Windows 98 or later; Macintosh with OS 8.6 or later; 64 MB RAM See the What’s on the CD-ROM Appendix for details and complete system requirements ,!7IA7G4-fdgida!:p;m;Q;t;T Whitehead Your visual blueprint for creating Java-enhanced Web programs Java and XML tools on CD-ROM • Java Platform, Standard Edition version 1.4 for Windows • Plus XML parsers, an e-version of the book, and more Visit us at www.wiley.com 013683-4 FM.F 5/24/02 8:58 AM Page i  Java and XML Your visual blueprint for creating Java-enhanced Web programs by Paul Whitehead, Dr Ernest Friedman-Hill, and Emily Vander Veer TM From ® & 013683-4 FM.F 5/24/02 8:58 AM Page i  Java and XML Your visual blueprint for creating Java-enhanced Web programs by Paul Whitehead, Dr Ernest Friedman-Hill, and Emily Vander Veer TM From ® & 013683-4 FM.F 5/24/02 8:58 AM Page ii JavaTM and XML: Your visual blueprint for creating Java-enhanced Web programs Published by Wiley Publishing, Inc 909 Third Avenue New York, NY 10022 Published simultaneously in Canada Copyright © 2002 by Wiley Publishing, Inc., Indianapolis, Indiana Certain designs and text Copyright © 1992-2002 maranGraphics, Inc., used with maranGraphics’ permission maranGraphics, Inc 5755 Coopers Avenue Mississauga, Ontario, Canada L4Z 1R9 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4744 Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, E-mail: permcoordinator@wiley.com Library of Congress Control Number: 2002102421 ISBN: 0-7645-3683-4 Manufactured in the United States of America 10 1V/RZ/QW/QS/IN Trademark Acknowledgments Wiley, the Wiley Publishing logo, Visual, the Visual logo, Simplified, Master VISUALLY, Teach Yourself VISUALLY, In an Instant, Read Less - Learn More and related trade dress are trademarks or registered trademarks of Wiley Publishing, Inc in the United States and other countries and may not be used without written permission The maranGraphics logo is a trademark or registered trademark of maranGraphics, Inc All other trademarks are the property of their respective owners Wiley Publishing, Inc and maranGraphics, Inc are not associated with any product or vendor mentioned in this book LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK, THEY MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUATION YOU SHOULD CONSULT WITH A PROFESSIONAL WHERE APPROPRIATE NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES FOR PURPOSES OF ILLUSTRATING THE CONCEPTS AND TECHNIQUES DESCRIBED IN THIS BOOK, THE AUTHOR HAS CREATED VARIOUS NAMES, COMPANY NAMES, MAILING, E-MAIL AND INTERNET ADDRESSES, PHONE AND FAX NUMBERS AND SIMILAR INFORMATION, ALL OF WHICH ARE FICTITIOUS ANY RESEMBLANCE OF THESE FICTITIOUS NAMES, ADDRESSES, PHONE AND FAX NUMBERS AND SIMILAR INFORMATION TO ANY ACTUAL PERSON, COMPANY AND/OR ORGANIZATION IS UNINTENTIONAL AND PURELY COINCIDENTAL Important Numbers For U.S corporate orders, please call maranGraphics at 800-469-6616 or fax 905-890-9434 For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S at 800-762-2974, outside the U.S at 317-572-3993 or fax 317-572-4002 Permissions maranGraphics Certain text and illustrations by maranGraphics, Inc., used with maranGraphics’ permission Originally built in 1803 with an addition in 1853, North Carolina’s Cape Hatteras Lighthouse stands 193 feet tall, making it the tallest brick lighthouse in the United States To find out more about the Cape Hatteras Lighthouse and the Cape Hatteras National Seashore, check out Frommer’s® The Carolinas & Georgia, 5th Edition, available wherever books are sold or at Frommers.com is a trademark of Wiley Publishing, Inc U.S Corporate Sales U.S Trade Sales Contact maranGraphics at (800) 469-6616 or fax (905) 890-9434 Contact Wiley at (800) 762-2974 or (317) 572-4002 013683-4 FM.F 5/24/02 8:58 AM Page iii  Java and XML Your visual blueprint for creating Java-enhanced Web programs 013683-4 FM.F 5/24/02 8:58 AM Page iv maranGraphics is a family-run business located near Toronto, Canada At maranGraphics, we believe in producing great computer books — one book at a time maranGraphics has been producing high-technology products for over 25 years, which enables us to offer the computer book community a unique communication process and organizing the content for each topic Our artists rebuild every screen shot to provide the best clarity possible, making our screen shots the most precise and easiest to read in the industry We strive for perfection, and believe that the time spent handcrafting each element results in the best computer books money can buy Our computer books use an integrated communication process, which is very different from the approach used in other computer books Each spread is, in essence, a flow chart — the text and screen shots are totally incorporated into the layout of the spread Introductory text and helpful tips complete the learning experience Thank you for purchasing this book We hope you enjoy it! maranGraphics’ approach encourages the left and right sides of the brain to work together — resulting in faster orientation and greater memory retention President Above all, we are very proud of the handcrafted nature of our books Our carefully chosen writers are experts in their fields, and spend countless hours researching Sincerely, Robert Maran maranGraphics Rob@maran.com www.maran.com 013683-4 FM.F 5/24/02 8:58 AM Page v CREDITS Acquisitions, Editorial, and Media Development Project Editor Maureen Spears Acquisitions Editor Jen Dorsey Product Development Supervisor Lindsay Sandman Copy Editor Marylouise Wiack Technical Editor Dr Ernest Friedman-Hill Editorial Manager Rev Mengle Permissions Editor Laura Moss Media Development Specialist Travis Silvers Manufacturing Allan Conley Linda Cook Paul Gilchrist Jennifer Guynn Production Book Design maranGraphics® Production Coordinator Dale White Layout Melanie DesJardins, LeAndra Johnson, Kristin McMullan, Laurie Petrone Screen Artists Mark Harris, Jill A Proll Cover Illustration David E Gregory Proofreader Christine Pingleton Quality Control John Bitter Indexer Johnna VanHoose Special Help Cricket Franklin, Jill Mazurcyzk, Jade Williams ACKNOWLEDGMENTS Wiley Technology Publishing Group: Richard Swadley, Vice President and Executive Group Publisher; Bob Ipsen, Vice President and Executive Publisher; Barry Pruett, Vice President and Publisher; Joseph Wikert, Vice President and Publisher; Mary Bednarek, Editorial Director; Mary C Corder, Editorial Director; Andy Cummings, Editorial Director Wiley Production for Branded Press: Debbie Stailey, Production Director 013683-4 FM.F 5/24/02 8:58 AM Page vi TABLE OF CONTENTS 1) INTRODUCING JAVA AND XML Introducing the Java Phenomenon Introducing XML Java and XML Combined 12 2) JAVA BASICS Install the Java SDK 14 Object-Oriented Programming Concepts 16 The Java Class Library 18 Java Conventions 20 Create a Source File 22 Create a Method 24 Create the Method Body 26 Compile a Java Program 28 Execute a Java Program 30 3) JAVA PROGRAMMING Create an Object 32 Work with Object Fields 34 Specify the Data Type for a Variable 36 Work with Strings 38 Call a Method 40 Using Return Values and Arguments 42 Using the if Statement 44 Using the for Statement 46 Using The While Or Do While Loop 48 Using the Switch Statement 50 Create an Array 52 Create a Package 54 Import a Package 56 Extend a Class 58 Create an Exception 60 Handle Errors 62 Understanding Variable Scope 64 4) XML BASICS Create an XML Document 66 Verify Well-Formedness 68 Create Elements 70 Add Attributes 72 Add a Comment 74 Include Special Processing Instructions 76 Using Predefined XML Entities 78 Include Nonstandard Text 80 vi 013683-4 FM.F 5/24/02 8:58 AM Page vii JavaBOOK and XML: TITLE: Your visual Yourblueprint visual blueprint for creating for Java-enhanced the rest of Web theprograms book title 5) XML DOCUMENT TYPE DEFINITIONS Declare a DTD 82 Create an External DTD File 84 Declare a Container Element 86 Define the Structure of Elements 88 Define Element Attributes 90 Declare Attributes as Words 92 Restrict Attributes to a List of Values 94 Create Internal General Entities 96 Create a Notation 98 Create External General Entities 100 Using Namespaces 102 Using the XML Namespace Attribute 104 6) XML SCHEMAS Introducing XML Schemas 106 Create an XML Schema Declaration 108 Declare an Element 110 Assign an XML Schema to an XML Document 112 Validate an XML Document 114 Declare a Container Element 116 Declare Optional Elements 118 Specify Data Types 120 Constrain Element Values 122 Constrain Element Values to a List 124 Declare an Attribute 126 Constrain the Values of an Attribute 128 Reference Predefined Elements 130 Create a Group of Attributes 132 Constrain Values Using Regular Expressions 134 7) THE SAX API An Introduction to the SAX API 136 Install the Xerces XML Parser 138 Set the CLASSPATH Environment Variable 140 Create an Event Handler Class 142 Parse an XML Document 144 Detect Elements in an XML Document 146 Extract Textual Element Content 148 Determine the Number of Element Attributes 150 Determine the Name of Attributes 152 Determine the Value of Attributes 154 Determine the Line Number Being Parsed 156 Determine Ignorable Whitespace in an Element 158 vii 013683-4 FM.F 5/24/02 8:58 AM Page viii TABLE OF CONTENTS Work with Processing Instructions 160 Parse Multiple XML Documents Using Multiple Event Handlers 162 Create an Error Handler 164 Create a Custom Error Message 166 Create an Entity Resolver 168 Using the Default Handler 170 Determine Feature and Property Settings 172 Detect Notation Declarations 174 Create a Declaration Handler 176 Create a Lexical Handler 178 Turn on Validation 180 Toggle Namespace and Prefix Usage 182 8) THE DOM Introducing the DOM 184 Retrieve the Root Element Name 186 Determine Node Type 188 Work with Nodes 190 Transverse All Element Nodes 192 Determine Names of Attributes 194 Determine the Values of Attributes 196 Work with Processing Instructions 198 Detect Entity References 200 Detect General Entities in the DTD 202 Retrieve DTD Information 204 Retrieve Text Information 206 Extract Comments 208 Extract CDATA Sections 210 Retrieve Notation Declarations 212 Navigate Nodes 214 Create an XML Document 216 Create a New DOM Tree with a Root Element 218 Add Attributes to an Element 220 Add a Child Element 222 Create a Text Node 224 Create Other Node Types 226 Copy Nodes 228 9) JDOM viii Introducing JDOM 230 Create the Root Element 232 Add Content to the Root Element 234 Create Child Elements 236 Read an XML Document 238 Extract Element Text Content 240 ... maranGraphics at ( 800 ) 469 -66 16 or fax ( 905 ) 8 90- 9434 Contact Wiley at ( 800 ) 76 2- 2 974 or (3 17) 5 72 - 400 2 01 368 3-4 FM.F 5 /24 / 02 8:58 AM Page iii  Java and XML Your visual blueprint for creating Java- enhanced... 4 62 5 6, (3 17) 5 72 -34 47, fax (3 17) 5 72 -44 47, E-mail: permcoordinator @wiley. com Library of Congress Control Number: 20 0 2 1 02 421 ISBN: 0 - 76 45- 368 3-4 Manufactured in the United States of America 10. .. tags 11 368 3-4 ch01.F 5 /24 / 02 8:58 AM Page 12 JAVA AND XML JAVA AND XML COMBINED side from the immense popularity that both Java and XML enjoy, you should consider combining the Java and XML technologies

Ngày đăng: 23/05/2018, 16:47