Richards - Pro PHP XML and Web Services (Apress, 2006).pdf
(
8310 KB
)
Pobierz
133840339 UNPDF
THE EXPERT’S VOICE
®
IN OPEN SOURCE
Covers PHP
versions 5
and the
forthcoming 6
PHP XML
and
Web Services
Master working with XML and Web services using PHP
Robert Richards
Pro
Pro PHP XML and
Web Services
Robert Richards
Pro PHP XML and Web Services
Copyright © 2006 by Robert Richards
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13: 978-1-59059-633-3
ISBN-10: 1-59059-633-1
Library of Congress Cataloging-in-Publication data is available upon request.
Printed and bound in the United States of America 987654321
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Lead Editor: Matt Wade
Technical Reviewers: Christian Stocker, Adam Trachtenberg
Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Jason Gilmore,
Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft,
Jim Sumser, Matt Wade
Project Manager: Kylie Johnston
Copy Edit Manager: Nicole LeClerc
Copy Editor: Kim Wimpsett
Assistant Production Director: Kari Brooks-Copony
Production Editor: Kelly Gunther
Compositor: Linda Weidemann, Wolf Creek Press
Proofreader: Nancy Sixsmith
Indexer: Jan Wright
Artist: Kinetic Publishing Services, LLC
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail
orders-ny@springer-sbm.com
, or
visit
http://www.springeronline.com
.
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley,
CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail
info@apress.com
, or visit
http://www.apress.com
.
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution
has been taken in the preparation of this work, neither the author(s) nor Apress 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 information contained in this work.
The source code for this book is available to readers at
http://www.apress.com
in the Source Code section.
This book is dedicated to my wife and best friend, Julie.
Thank you for your patience, support, and encouragement
at the times I most needed it.
Contents
About the Author
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
About the Technical Reviewers
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
Acknowledgments
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
CHAPTER 1
Introduction to XML and Web Services
. . . . . . . . . . . . . . . . . . . . . 1
Exploring the History of XML
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Using XML in the Real World
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Introducing Service Oriented Architecture and Web Services
. . . . . . . . . . . 9
Defining Common Terms and Acronyms
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Conclusion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
CHAPTER 2
XML Structure
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Introducing Characters
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Understanding Basic Layout
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Understanding Basic Syntax
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Using Namespaces
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Using IDs, IDREF/IDREFS, and xml:id
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Using xml:space and xml:lang
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Understanding XML Base
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Conclusion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
CHAPTER 3
Validation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Introducing Validation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Introducing Document Type Definitions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Using XML Schemas
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Using RELAX NG
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Conclusion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
CHAPTER 4
XPath, XPointer, XInclude, and the Future
. . . . . . . . . . . . . . . . 123
Introducing XPath
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Introducing XPointer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
iii
■
■
■
■
iv
■
CONTENTS
Introducing XInclude
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Examining the Future of XML
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Conclusion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
CHAPTER 5
PHP and XML
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Introducing XML in PHP 5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Configuring libxml Support
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Introducing Encoding
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Figuring Out the libxml2 Version
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Introducing Parser Options
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Introducing PHP Streams
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Performing Error Handling
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Conclusion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
CHAPTER 6
Document Object Model (DOM)
. . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Introducing the DOM
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Using the DOM Extension
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Performing Validation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Using XPath
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Extending Classes
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Common Questions, Misconceptions, and Problems
. . . . . . . . . . . . . . . . 223
Migrating from domxml to the DOM Extension
. . . . . . . . . . . . . . . . . . . . . 228
Seeing Some DOM Examples
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Conclusion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
CHAPTER 7
SimpleXML
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Introducing SimpleXML
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Using SimpleXML
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Using Namespaces in SimpleXML
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Using XPath
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Seeing Some Examples in Action
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Conclusion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
CHAPTER 8
Simple API for XML (SAX)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Introducing SAX
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Using the xml Extension
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
Migrating from PHP 4 to PHP 5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
■
■
■
■
Plik z chomika:
walbo48
Inne pliki z tego folderu:
Cole - Planetary Science - Science of Planets Around Stars (IOP, 2002).pdf
(8299 KB)
Einstein's Space-Time - An Intro to Special and General Relativity - R. Ferraro (Springer, 2007) WW.pdf
(8617 KB)
Frolov - Black Hole Physics - Basic Concepts and New Developments (Kluwer, 1997).pdf
(26556 KB)
Falcke - The Galactic Black Hole (IOP, 2003).pdf
(19940 KB)
Elements of Space Technology - R. Meyer (AP, 1999) WW.djvu
(2924 KB)
Inne foldery tego chomika:
ksiazki
Schematy spawarek
Amaterske Radio_2009.rar
))) Przyśpiewki weselne
@Excel
Zgłoś jeśli
naruszono regulamin