XML: Visual Quickstart Guide to Be an Excellent Tutorial for Learning All About XML

XML: Visual Quickstart Guide to Be an Excellent Tutorial for Learning All About XML

VISUAL QUICKSTART GUIDE XML SECOND EDITION KEVIN HOWARD GOLDBERG Peachpit Press Visual QuickStart Guide XML, Second Edition Kevin Howard Goldberg Peachpit Press 1249 Eighth Street Berkeley, CA 94710 510/524-2178 510/524-2221 (fax) Find us on the Web at: www.peachpit.com To report errors, please send a note to [email protected] Peachpit Press is a division of Pearson Education Copyright © 2009 by Elizabeth Castro and Kevin Howard Goldberg Production Editor: David Van Ness Tech Editors: Chris Hare and Michael Weiss Compositor: Kevin Howard Goldberg Indexer: Valerie Perry Cover Design: Peachpit Press Notice of Rights All rights reserved. No part of this book may be reproduced or transmitted in any form by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. For information on getting permission for reprints and excerpts, contact [email protected]. Notice of Liability The information in this book is distributed on an “As Is” basis without warranty. While every pre- caution has been taken in the preparation of the book, neither the author nor Peachpit shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the instructions contained in this book or by the computer software and hardware products described in it. Trademarks Visual QuickStart Guide is a trademark of Peachpit, a division of Pearson Education. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Peachpit was aware of a trademark claim, the designations appear as requested by the owner of the trademark. All other product names and services identified throughout this book are used in editorial fashion only and for the benefit of such companies with no intention of infringement of the trademark. No such use, or the use of any trade name, is intended to convey endorsement or other affiliation with this book. ISBN-13: 978-0-321-55967-8 ISBN-10: 0-321-55967-3 9 8 7 6 5 4 3 2 1 Printed and bound in the United States of America FOREWORD BY ELIZABETH CASTRO XML has come a long way since I wrote the first edition of this book in 2001. It is as widespread now as it was exotic then. Last year, I bumped into my friend Kevin Goldberg on a visit to California. We had known each other in college, and had played a lot of Boggle together in Barcelona. When he offered to help me revise this book, I jumped at the chance. Kevin has been working in the computer industry for more than twenty years. He started his career as a video game programmer and producer. Since 1997, Kevin has been serving as partner and chief technology officer at imagistic, an award-winning, Web development and services company in Southern California. In this role, he is regularly called upon to help clients clarify their business needs, and to clearly communicate the nature and applicability of potential technology solutions—in a sense, demystify technology. Besides all of these apt credentials, Kevin is a great guy. He is smart, conscientious, cre- ative, and—not to mention—careful with details. In addition to updating the content and examples in the book, he added chapters on XSL-FO, recent W3C recommendations (XSLT 2.0, XPath 2.0 and XQuery 1.0), and a chapter devoted to real world examples called XML in Practice. I am most confident that you will find this second edition of XML: Visual QuickStart Guide to be an excellent tutorial for learning all about XML. Elizabeth Castro Author of XML for the World Wide Web: Visual QuickStart Guide ABOUT THE AUTHOR Kevin Howard Goldberg has been working with computers since 1976 when he taught himself BASIC on his elementary school’s PDP 11/70. Since then, Kevin’s career has included management consulting using commerce simulations, and lead software development for numerous video game titles in multi-million dollar divisions at Film Roman and Lionsgate (previously Trimark). In his current capacity, he runs technology operations for a world-class Internet Strategy, Marketing and Development company in Westlake Village, California. Kevin serves on the Santa Monica College Computer Science and Information Systems Advisory Board, and was invited to speak at the ACLU Nationwide Staff Conference as a Web development and production expert. Kevin holds a bachelor’s degree in Economics and Entrepreneurial Management from the Wharton School of Business at the University of Pennsylvania, and is a candidate for a master’s degree in Computer Science at the University of California, Los Angeles. DEDICATION This book is dedicated to my wife, Lainie; in exchange for harried weekends, night-time surrogates, and an overcrowded bedroom, she receives this book. I am truly blessed. THANK YOU Michael Weiss, my business partner (of more than eleven years), my brother-in-law, and my friend. His support throughout this process; uncanny ability to see things from a reader’s perspective; and willingness to do what it took to get the job done, while I was, at times, preoccupied, was invaluable to me. Chris Hare, my technical editor, for jumping into the XML deep-end and amazingly keeping everything else afloat; teaching me the subtleties of punctuation (colons, semi- colons, and parenthetical expressions, oh my!); and being so detailed that when a page came back with less than a dozen red marks, I was concerned. The staff at imagistic (Chris, Heidi, Robert, Sam, Tamara, and Will), who didn’t know what was coming, but nonetheless kept all the plates spinning with grace and humor. David Van Ness, Peachpit’s production editor extraordinaire, who was so incredibly helpful, resourceful, accommodating, available, and patient. Nancy Davis, editor-in-chief at Peachpit, for seeing all the possibilities and shepherd- ing this complex process through to completion. Finally, a very special thanks to Elizabeth Castro, whose openness, honesty, integrity, and first edition of this book made this second edition possible. IMAGE COPYRIGHTS ◆ Herodotus head in the Stoa of Attalus, Athens (Inv. S270), photograph by Samuel Provost. ◆ Depictions of The Seven Wonders of the Ancient World, as painted by 16th-century Dutch artist Marten Jacobszoon Heemskerk van Veen, reside within the public domain. TABLE OF CONTENTS Introduction . .xi What is XML? . xii Th e Power of XML . xiii Extending XML . xiv XML in Practice . xv About Th is Book . .xvi What Th is Book is Not . xviii of Contents Table Part 1: XML Chapter 1: Writing XML . 3 An XML Sample . .4 Rules for Writing XML . .5 Elements, Attributes, and Values . .6 How To Begin . .7 Creating the Root Element . .8 Writing Child Elements . .9 Nesting Elements . .10 Adding Attributes . .11 Using Empty Elements . .12 Writing Comments . .13 Predefi ned Entities – Five Special Symbols . .14 Displaying Elements as Text . .15 Part 2: XSL Chapter 2: XSLT . 19 Transforming XML with XSLT . .20 Beginning an XSLT Style Sheet . .22 Creating the Root Template . .23 Outputting HTML . .24 Outputting Values . .26 Looping Over Nodes . .28 Processing Nodes Conditionally . .30 v Table of Contents Adding Conditional Choices . .31 Sorting Nodes Before Processing . .32 Generating Output Attributes . .33 Creating and Applying Templates . .34 Chapter 3: XPath Patterns and Expressions . .37 Locating Nodes . .38 Determining the Current Node . .40 Referring to the Current Node . .41 Selecting a Node’s Children . .42 Selecting a Node’s Parent or Siblings . .43 Selecting a Node’s Attributes . .44 Conditionally Selecting Nodes . .45 Creating Absolute Location Paths . .46 Selecting All the Descendants . .47 Chapter 4: XPath Functions . 49 Comparing Two Values . .50 Testing the Position . .51 Multiplying, Dividing, Adding, Subtracting . .52 Counting Nodes . .53 Table of Contents Table Formatting Numbers . .54 Rounding Numbers . .55 Extracting Substrings . .56 Changing the Case of a String . .57 Totaling Values . .58 More XPath Functions . .59 Chapter 5: XSL-FO . 61 Th e Two Parts of an XSL-FO Document . .62 Creating an XSL-FO Document . .63 Creating and Styling Blocks of Page Content . .64 Adding Images . .65 Defi ning a Page Template . .66 Creating a Page Template Header . .67 Using XSLT to Create XSL-FO . .68 Inserting Page Breaks . .69 Outputting Page Content in Columns . .70 Adding a New Page Template . .71 Part 3: DTD Chapter 6: Creating a DTD . 75 Working with DTDs . .76 Defi ning an Element Th at Contains Text . .77 Defi ning an Empty Element . .78 vi Table of Contents Defi ning an Element Th at Contains a Child . .79 Defi ning an Element Th at Contains Children . .80 Defi ning How Many Occurrences . .81 Defi ning Choices . .82 Defi ning an Element Th at Contains Anything . .83 About Attributes . .84 Defi ning Attributes . .85 Defi ning Default Values . .86 Defi ning Attributes with Choices. .87 Defi ning Attributes with Unique Values . .88 Referencing Attributes with Unique Values . .89 Restricting Attributes to Valid XML Names . .90 Chapter 7: Entities and Notations in DTDs . 91 Creating a General Entity . .92 Using General Entities . .93 Creating an External General Entity . .94 of Contents Table Using External General Entities . .95 Creating Entities for Unparsed Content . .96 Embedding Unparsed Content . .98 Creating and Using Parameter Entities . .100 Creating an External Parameter Entity . .101 Chapter 8: Validation and Using DTDs . 103 Creating an External DTD . .104 Declaring an External DTD . .105 Declaring and Creating an Internal DTD . .106 Validating XML Documents Against a DTD . .107 Naming a Public External DTD . ..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    289 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