Xem mẫu

PUBLISHED BY Microsoft Press A Division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399 Copyright © 2002 by Michael J. Young All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. Library of Congress Cataloging-in-Publication Data Young, Michael J. XML Step By Step / Michael J. Young.--2nd ed. p. cm. Includes index. ISBN 0-7356-1465-2 1. XML (Document markup language) I. Title. QA76.76.H94 Y68 2001 005.7`2--dc21 2001044924 Printed and bound in the United States of America. 1 2 3 4 5 6 7 8 9 QWT 6 5 4 3 2 Distributed in Canada by Penguin Books Canada Limited. A CIP catalogue record for this book is available from the British Library. Microsoft Press books are available through booksellers and distributors worldwide. For further informa-tion about international editions, contact your local Microsoft Corporation office or contact Microsoft Press International directly at fax (425) 936-7329. Visit our Web site at www.microsoft.com/mspress. Send comments to mspinput@microsoft.com. ActiveX, JScript, Microsoft, Microsoft Press, MSDN, Visual Basic, Visual Studio, and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Other product and company names mentioned herein may be the trademarks of their respective owners. The example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. Acquisitions Editor: David J. Clark Project Editor: Jean Cockburn Body Part No. X08-24444 iii Contents Preface ............................................................................................. vii Introduction ...................................................................................... xi Why Another XML Book? xi � What You’ll Learn in This Book xii • XML Step by Step, Internet Explorer, and MSXML xiv • Using the Companion CD xvi • Requirements xviii • How to Contact the Author xix • Microsoft Press Support Information xix PART 1 Getting Started 1 Chapter 1 Chapter 2 Why XML?.........................................................................................3 The Need for XML 4 • Displaying XML Documents 10 • SGML, HTML, and XML 11 • The Official Goals of XML 12 • Standard XML Applications 14 • Real-World Uses for XML 15 • XML Applications for Enhancing XML Documents 19 Creating and Displaying Your First XML Document ........................21 Creating an XML Document 21 • Displaying the XML Document 29 PART 2 Creating XML Documents 43 Chapter 3 Chapter 4 Creating Well-Formed XML Documents..........................................45 The Parts of a Well-Formed XML Document 46 • Adding Elements to the Document 50 • Adding Attributes to Elements 62 • Using Namespaces 69 Adding Comments, Processing Instructions, and CDATA Sections ...................................................81 Inserting Comments 81 • Using Processing Instructions 83 • Including CDATA Sections 86 iv Chapter 5 Chapter 6 Chapter 7 Contents Creating Valid XML Documents Using Document Type Definitions...................................................91 The Basic Criteria for a Valid XML Document 92 • The Advantages of Making an XML Document Valid 93 • Adding the Document Type Declaration 95 • Declaring Element Types 98 • Declaring Attributes 107 • Using Namespaces in Valid Documents 117 • Using an External DTD Subset 120 • Converting a Well-Formed Document to a Valid Document 125 Defining and Using Entities...........................................................131 Entity Definitions and Classifications 131 •Declaring General Entities 135 • Declaring Parameter Entities 143 • Inserting Entity References 148 • Inserting Character References 153 • Using Predefined Entities 156 • Adding Entities to a Document 157 Creating Valid XML Documents Using XML Schemas......................................................................163 XML Schema Basics 165 • Declaring Elements 167 • Declaring an Ele-ment with a Simple Type 169 • Declaring Attributes 182 • Creating an XML Schema and an Instance Document 186 PART 3 Displaying XML Documents on the Web 193 Chapter 8 Chapter 9 Displaying XML Documents Using Basic Cascading Style Sheets ..............................................195 The Basic Steps for Using a Cascading Style Sheet 197 • Cascading in Cascading Style Sheets 211 • Setting the display Property 215 • Set-ting Font Properties 221 • Setting the font-variant Property 231 • Set-ting the color Property 232 • Setting Background Properties 235 • Setting Text Spacing and Alignment Properties 246 Displaying XML Documents Using Advanced Cascading Style Sheets .......................................257 Setting Box Properties 258 • Using Pseudo-Elements (Internet Explorer 5.5 through 6.0 Only) 285 • Inserting HTML Elements into XML Documents 286 • Creating and Using a Full-Featured Cascading Style Sheet 291 Contents v Chapter 10 Chapter 11 Chapter 12 Appendix Displaying XML Documents Using Data Binding .......................................................................297 The Main Steps 298 • The First Step: Linking the XML Document to the HTML Page 299 • The Second Step: Binding HTML Elements to XML Elements 303 • Using Paging 309 • Using Scripts with the DSO 350 Displaying XML Documents Using Document Object Model Scripts .........................................357 Linking the XML Document to the HTML Page 359 • The Structure of the DOM 360 • Accessing and Displaying XML Document Elements 367 • Accessing and Displaying XML Document Attribute Values 384 • Accessing XML Entities and Notations 388 • Traversing an Entire XML Document 392 • Checking an XML Document for Validity 398 Displaying XML Documents Using XML Style Sheets.................................................................409 Using an XSLT Style Sheet—the Basics 411 • Using a Single XSLT Template 412 • Using Multiple Templates 432 • Using Other Select and Match Expressions 435 • Filtering and Sorting XML Data 440 • Accessing XML Attributes 451 • Referencing Namespaces in XSLT 457 • Using Conditional Structures 459 Web Addresses for Further Information.........................................461 General Information on XML 461 • Internet Explorer and MSXML 462 • XML Applications 462 • Namespaces 462 • URIs and URNs 462 • XML Schemas 463 • Cascading Style Sheets (CSS) 463 • Data Binding and the Data Source Object (DSO) 464 • ActiveX Data Objects (ADO) and the ADO recordset Object 464 • HTML and Dynamic HTML (DHTML) 464 • Microsoft JScript 464 • The Document Object Model (DOM) 465 • Extensible Stylesheet Language Transformations (XSLT) and XPath 465 • Author’s Web Site 465 Index..............................................................................................467 ... - tailieumienphi.vn
nguon tai.lieu . vn