1. Trang chủ
  2. » Công Nghệ Thông Tin

o'reilly - building oracle xml applications

883 401 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 883
Dung lượng 4,59 MB

Nội dung

Building Oracle XML Applications Steve Muench Publisher: O'Reilly First Edition September 2000 ISBN: 1-56592-691-9, 810 pages Building Oracle XML Applications gives Java and PL/SQL developers a rich and detailed look at the many tools Oracle provides to support XML development. It shows how to combine the power of XML and XSLT with the speed, functionality, and reliability of the Oracle database. The author delivers nearly 800 pages of entertaining text, helpful and time-saving hints, and extensive examples that developers can put to use immediately to build custom XML applications. The accompanying CD-ROM contains JDeveloper 3.1, an integrated development environment for Java developers. Building Oracle XML Applications Copyright © 2000 O'Reilly & Associates, Inc. All rights reserved. Printed in the United States of America. Published by O'Reilly & Associates, Inc., 101 Morris Street, Sebastopol, CA 95472. The O'Reilly logo is a registered trademark of O'Reilly & Associates, Inc. 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 O'Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. Oracle®, JDeveloper™, and all Oracle-based trademarks and logos are trademarks or registered trademarks of Oracle Corporation, Inc. in the United States and other countries. Java™ and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. O'Reilly & Associates, Inc. is independent of Oracle Corporation and Sun Microsystems. While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. Table of Contents Preface Audience for This Book Which Platform and Version? Structure of This Book About the Examples About the CD-ROM Conventions Used in This Book Comments and Questions Acknowledgments I: XML Basics 1. Introduction to XML 1.1 What Is XML? 1.2 What Can I Do with XML? 1.3 Why Should I Use XML? 1.4 What XML Technologies Does Oracle Provide? 2. Working with XML 2.1 Creating and Validating XML 2.2 Modularizing XML 2.3 Searching XML with XPath II: Oracle XML Fundamentals 3. Combining XML and Oracle 3.1 Hosting the XML FAQ System on Oracle 3.2 Serving XML in Any Format 3.3 Acquiring Web-based XML Content 4. Using JDeveloper for XML Development 4.1 Working with XML, XSQL, and JSP Files 4.2 Working with Database Objects 4.3 Using JDeveloper with Oracle XDK Components 5. Processing XML with PL/SQL 5.1 Loading External XML Files 5.2 Parsing XML 5.3 Searching XML Documents with XPath 5.4 Working with XML Messages 5.5 Producing and Transforming XML Query Results 6. Processing XML with Java 6.1 Introduction to Oracle8 i JServer 6.2 Parsing and Programmatically Constructing XML 6.3 Searching XML Documents with XPath 6.4 Working with XML Messages 6.5 Producing and Transforming XML Query Results 7. Transforming XML with XSLT 7.1 XSLT Processing Mechanics 7.2 Single-Template Stylesheets 7.3 Understanding Input and Output Options 7.4 Improving Flexibility with Multiple Templates 8. Publishing Data with XSQL Pages 8.1 Introduction to XSQL Pages 8.2 Transforming XSQL Page Results with XSLT 8.3 Troubleshooting Your XSQL Pages 9. XSLT Beyond the Basics 9.1 Using XSLT Variables 9.2 The Talented Identity Transformation 9.3 Grouping Repeating Data Using SQL 9.4 Sorting and Grouping Repeating Data with XSLT 10. Generating Datagrams with PL/SQL 10.1 Programmatically Generating XML Using PL/SQL 10.2 Automatic XML Generation with DBXML 11. Generating Datagrams with Java 11.1 Generating XML Using Java 11.2 Serving XML Datagrams over the Web 11.3 Automatic XML from SQL Queries 12. Storing XML Datagrams 12.1 Overview of XML Storage Approaches 12.2 Loading Datagrams with the XML SQL Utility 12.3 Storing Posted XML Using XSQL Servlet 12.4 Inserting Datagrams Using Java 13. Searching XML with interMedia 13.1 Why Use interMedia? 13.2 What Is interMedia? 13.3 The interMedia Query Language 13.4 Handling Heterogeneous Doctypes 13.5 Handling Doctype Evolution 13.6 Advanced interMedia 14. Advanced XML Loading Techniques 14.1 Storing Datagrams in Multiple Tables 14.2 Building an XMLLoader Utility 14.3 Creating Insert Transformations Automatically III: Oracle XML Applications 15. Using XSQL Pages as a Publishing Framework 15.1 Overview of XSQL Pages Facilities 15.2 Additional XML Delivery Options 16. Extending XSQL and XSLT with Java 16.1 Developing Custom XSQL Actions 16.2 Integrating Custom XML Sources 16.3 Working with XSLT Extension Functions 17. XSLT-Powered Portals and Applications 17.1 XSLT-Powered Web Store 17.2 Building a Personalized News Portal 17.3 Online Discussion Forum IV: Appendixes A. XML Helper Packages A.1 Installing the XML Helper Packages A.2 Source Code for the XML Helper Packages B. Installing the Oracle XSQL Servlet B.1 Supported Configurations B.2 Prerequisites B.3 Downloading and Installing the XSQL Servlet C. Conceptual Map to the XML Family D. Quick References Colophon Preface This book is a hands-on, practical guide that teaches you the nuts and bolts of XML and the family of Internet standards related to it and shows how to exploit XML with your Oracle database using Java™, PL/SQL, and declarative techniques. It’s a book for Oracle developers by an Oracle developer who has lived the technology at Oracle Corporation for over ten years and has directly catalyzed the company’s XML technology direction and implementation. As you read this book, I hope you will come to appreciate the wide variety of tools Oracle provides to enable you to combine the best of XML with the best of Oracle to build flexible, database-powered applications for the Web. This book abounds with tested, commented, and fully explained examples because—in the unforgettable words of a high school mentor of mine—“you only get good at something by working through an ungodly number of problems." The examples include a number of helper libraries and utilities that will serve to jump-start your own Oracle XML development projects (see “About the Examples" later in this Preface for details). If this book has one main goal, it is to educate, excite, and thoroughly convince you that by combining: • The speed, functionality, and reliability of the Oracle database • The power of XML as a universal standard for data exchange • The flexibility to easily transform XML data into any format required we can accomplish some pretty amazing things, not to mention saving ourselves a lot of work in the process. Audience for This Book This book is aimed mainly at Java and PL/SQL developers who want to use the XML family of Internet standards in conjunction with their Oracle databases. I also expect that this book may catch the eye of existing Oracle database administrators who want to update their skills to learn how to apply Java, PL/SQL, and XML to their daily work. In addition, the in-depth coverage of Oracle’s template-driven XSQL Pages technology should prove useful to non-programmers as well. This book assumes no prior knowledge of XML on your part, but it does assume a basic working knowledge of SQL and familiarity with either Java or PL/SQL as a programming language. Which Platform and Version? Much of this book applies to Oracle8 and Oracle8i (and even Oracle7 in some cases). In general, if you want to use XML outside the database, you can use any Oracle version. However, if you want to use XML features inside the database (and take full advantage of the features I describe here), you must use Oracle8i. Wherever relevant, I note whether a particular XML feature is specific to Oracle8i or can be used with earlier Oracle versions as well. The examples for this book were developed and tested on a Windows NT 4.0 platform using JDeveloper 3.1 as a development environment and Oracle8i Release 2 Enterprise Edition for NT (version 8.1.6 ) as the database. However, none of the examples, tools, or technologies covered in the book are Windows-specific. The JDeveloper 3.1 product—included on the CD-ROM that accompanies this book—is certified to run on Windows NT and Windows 2000. Structure of This Book This book is not divided strictly by individual tool and function. Instead, it begins in Part I with an overview of fundamental XML standards and concepts. Part II covers all core Oracle XML technologies, presenting increasingly detailed discussions of various Oracle XML capabilities. Part III describes combining the technologies we’ve learned to build applications and portals. Finally, Part IV includes four useful appendixes with installation and reference information. The book uses extensive examples—in both PL/SQL and Java—to present material of increasing sophistication. The following list summarizes the contents in detail. Part I , introduces the basics of XML and provides a high-level overview of Oracle’s XML technology. It consists of the following chapters: • Chapter 1, provides a gentle introduction to XML by describing what it is, what you can do with it, why you should use it, and what software Oracle supplies to work with it. • Chapter 2 , describes how to build your own “vocabularies" of tags to represent the information you need to work with, as well as how to use XML namespaces and entities to modularize your documents and XPath expressions to search them. Part II , describes the core development activities that Oracle XML developers need to understand when using XML with an Oracle database. It consists of the following chapters: • Chapter 3 , provides a typical “day-in-the-life" scenario illustrating the power of combining XML with an Oracle database. • Chapter 4 , describes how you can use Oracle’s JDeveloper product to help with XML development. • Chapter 5 , explains how you can use PL/SQL to load XML files, parse XML, search XML documents, post XML messages, and both enqueue and dequeue XML messages from queues. • Chapter 6 , explains how you can combine Java and XML both inside and outside Oracle8i to load XML files, parse XML, search XML documents, and post XML messages, as well as enqueue and dequeue XML messages from queues. • Chapter 7 , explains the fundamentals of creating XSLT stylesheets to carry out transformations of a source XML document into a resulting XML, HTML or plain text output. • Chapter 8 , explains how to build dynamic XML datagrams from SQL using declarative templates to perform many common tasks. • Chapter 9 , builds on the fundamentals from Chapter 7 and explores additional XSLT functionality like variables, sorting and grouping techniques, and the many kinds of useful transformations that can be done using a variation on the identity transformation. • Chapter 10 , gives Java developers a whirlwind introduction to PL/SQL and describes how to use PL/SQL to dynamically produce custom XML datagrams containing database information. • Chapter 11 , describes numerous techniques for programmatically producing XML datagrams using Java by using JDBC™, SQLJ, JavaServer Pages™, and the Oracle XML SQL Utility. • Chapter 12 , explains how to store XML datagrams in the database using the XML SQL Utility and other techniques, as well as how to retrieve them using XSQL pages and XSLT transformations. • Chapter 13 , describes how you can use Oracle8i ’s integrated interMedia Text functionality to search XML documents, leveraging their inherent structure to improve text searching accuracy. • Chapter 14 , describes the techniques required to insert arbitrarily large and complicated XML into multiple tables. It also covers using stylesheets to generate stylesheets to help automate the task. Part III , describes how to build applications using Oracle and XML technologies. It consists of the following chapters: • Chapter 15, builds on Chapter 8, explaining the additional features that make XSQL Pages an extensible framework for assembling, transforming, and delivering XML information of any kind. • Chapter 16 , describes how to extend the functionality of the XSQL Pages framework using custom action handlers, and how to extend the functionality of XSLT stylesheets by calling Java extension functions. • Chapter 17 , builds further on Chapter 11 and on earlier chapters, describing best-practice techniques to combine XSQL pages and XSLT stylesheets to build personalized information portal and sophisticated online discussion forum applications. Part IV , contains the following summaries: • Appendix A , provides the source code for the PL/SQL helper packages we built in Chapter 3: xml, xmldoc, xpath, xslt, and http. • Appendix B , describes how to install the XSQL Servlet that you can use with any servlet engine (Apache JServ, JRun, etc.). • Appendix C , graphically summarizes the relationships between key XML concepts and the family of XML-related standards that supports them. • Appendix D , provides “cheat sheets" on XML, XSLT, and XPath syntax. About the Examples This book contains a large number of fully working examples. Many are designed to help you build your own Oracle XML applications. To that end, I’ve included all examples on the O’Reilly web site (http://www.oreilly.com/catalog/orxmlapp ). The site includes full source code of all examples and detailed instructions on how to create the sample data required for each chapter. I’ll try to keep the code up to date, incorporating corrections to any errors that are discovered, as well as improvements suggested by readers. In order to run the complete set of examples yourself, you will need the following software: • Oracle 8i Release 2 (version 8.1.6) or greater • Oracle JDeveloper 3.1 or greater From the Oracle XML Developer’s Kit for Java: • Oracle XML Parser/XSLT Processor for Java, Release 2.0.2.9 or greater • Oracle XSQL Pages and the XSQL Servlet Release 1.0.0.0 • Oracle XML SQL Utility From the Oracle XML Developer’s Kit for PL/SQL: • Oracle XML Parser/XSLT Processor for PL/SQL Release 1.0.2 or greater All of this software is downloadable from the Oracle Technology Network (OTN) web site for Oracle developers at http://technet.oracle.com and is available free of charge for single-developer use. For information on runtime distribution of the Oracle XML Developer’s kit components, read the license agreement on the download page of any of the components. For your convenience, all of the software listed—with the exception of the Oracle8i database itself—is available on the CD-ROM accompanying this book and is automatically installed as part of the JDeveloper 3.1 installation. About the CD-ROM We are grateful to Oracle Corporation for allowing us to include the JDeveloper 3.1 for Windows NT software (developer version) on the CD-ROM accompanying this book. This product provides a complete development environment for Java developers working with Oracle and XML. Chapter 4 covers the details of significant JDeveloper 3.1 features that are of interest to XML application developers. You’ll find full product documentation and online help on the CD-ROM as well. Conventions Used in This Book The following conventions are used in this book: Italic Used for file and directory names and URLs, menu items, and for the first mention of new terms under discussion Constant width Used in code examples and for package names, XML elements and attributes, and Java classes and methods Constant width italic In some code examples, indicates an element (e.g., a filename) that you supply Constant width bold Indicates user input in code examples UPPERCASE Generally used for Oracle SQL and PL/SQL keywords lowercase [...]... to the XML standards we've discussed earlier Figure 1.11 Overview of key Oracle technologies for XML Using the Oracle XML Parser, you can parse XML documents into their infoset, manipulate their contents, and return the modified infoset back into XML format Using the Oracle XSLT processor, you can transform XML into XML, HTML, or text of another structure Both the Oracle XML Parser and the Oracle XSLT... SQL, XML, and XSLT is powerful stuff 1.4 What XML Technologies Does Oracle Provide? Now that we understand what the XML family of standards is, what we can do with it, and why it is interesting to apply to database-driven web applications, let's get an overview of the tools and technologies that Oracle provides to implement Oracle XML applications Figure 1.11 shows an example of the key Oracle XML components... package with tracking number 56789? < ?xml version="1.0"?> ... Queuing Creates, syntax-checks, and debugs Java, XML, XSLT, and XSQL Queues and dequeues XML messages PLSXML utilities Produce XML datagrams in Oracle7 [1] 6 4, 6 5, 6 10 In Oracle8 i Release 3, JServer has been renamed Oracle8 i JVM In the sections that follow, I will summarize the Oracle XML tools and technologies described in this book, noting which chapters describe them and which Oracle releases support... XML Using its companion support for the Simple API for XML (SAX), you can process XML datagrams of arbitrary size with low memory usage Using the supplied oraxml tool, you can parse and validate XML files from the command line or in scripts The parser supports integrated XPath searching on in-memory XML documents using the integrated Oracle XPath Engine, an embedded component shared by the Oracle XML. .. vendor-neutral, platform-neutral, language-neutral technology for web-based data exchange, the XML family of standards solves a key problem for these companies' customers In a nutshell, XML simplifies the task of connecting applications and services over the Web 1.3.1 XML Enables a Data Web of Information Services Proprietary data formats undoubtedly represent data in a more efficient way, but what XML. .. assembling XML data pages from multiple sources and transforming their information content for delivery using XSLT Table 1.1 provides a summary of key Oracle XML technologies and the chapters that cover each one Table 1.1 Key Oracle XML Technologies and Chapters That Cover Them Oracle Technology Description Chapter(s) XML Parser Parses, constructs, and validates XML documents 5, 6 XPath Engine Searches in-memory... Searches in-memory XML documents declaratively 2 XSLT Processor Transforms XML documents 3, 5, 6, 7, 8, 9, 12, 14, 16, 17 XML SQL Utility Produces XML from SQL and inserts XML into tables 5, 6, 11, 12 XSQL Pages interMedia Text Assembles XML data declaratively and publishes with XSLT Indexes and searches XML documents using their structure 3, 8, 12, 15, 17 13 Object views Serve rich XML- enabled views of... point out that XML is no magic bullet, noting that companies still need to agree on common XML vocabularies for application data exchange However, market forces are already quickly resolving these concerns Due to the tremendous opportunities presented by business-to-business e-commerce, a burgeoning sector whose key players are already leveraging this new XML- based data web, the number of XML- based standards... to understand, XML can seem like a strange new planet to the uninitiated, so let's walk before we run This chapter introduces "Planet XML" and the "moons" that orbit it, and provides a high-level overview of the tools and technology Oracle offers to exploit the combined strengths of XML and the Oracle database in your web applications 1.1 What Is XML? First, let's look at some basic XML definitions . Building Oracle XML Applications Steve Muench Publisher: O'Reilly First Edition September 2000 ISBN: 1-5 659 2-6 9 1-9 , 810 pages Building Oracle XML Applications gives. I Use XML? 1.4 What XML Technologies Does Oracle Provide? 2. Working with XML 2.1 Creating and Validating XML 2.2 Modularizing XML 2.3 Searching XML with XPath II: Oracle XML Fundamentals. XML and Oracle 3.1 Hosting the XML FAQ System on Oracle 3.2 Serving XML in Any Format 3.3 Acquiring Web-based XML Content 4. Using JDeveloper for XML Development 4.1 Working with XML,

Ngày đăng: 25/03/2014, 10:40

TỪ KHÓA LIÊN QUAN