[Title will be auto-generated]

Page 1

www.GetPedia.com *More than 150,000 articles in the search database *Learn how almost everything works


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Back Cover Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Written by members of the Oracle XML group, this is a must-have reference for all IT managers, DBAs, and developers who PL/SQL want to learn the best practices for using XML with Oracle’s XML-enabled products. Includes real-world case studies based ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang on the authors’ experience managing Oracle’s XML Discussion Forum--a community of 20,000+ XML component users. McGraw-Hill/Osborne © 2004 (600 pages) About the XML Authors This comprehensive guide focuses on utilizing technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Mark V. Scardina is Oracle’s XML Evangelist for Server products and is the Group Product Manager for the CORE and XML Development Group tasked with providing the XML infrastructure components used throughout the Oracle product stack, Table of Contents including the Oracle XML Developer’s Kit. Mark chairs the Oracle XML Standards committee and is an editor on the W3C XSL Working Group. He is a frequent speaker atBuild industry trade shows and conferences, a writer for&industry Oracle Database 10g XML & SQL—Design, & Manage XML Applications in Java, C, C++ PL/SQL journals and is coauthor of Oracle9i XML Handbook and Oracle XML Handbook . Prior to joining Oracle, he worked at Socket Communications Introduction and ACE Technologies. He holds a B.S. in Information Systems Management from USF. Part I - Oracle and the XML Standards

Chapter 1 is- aIntroducing XML at Oracle Corp., where he heads the CORE and XML Development Group as Director. In Ben Chang 15-year veteran addition on Oracle6 to Oracle Database he served the longest tenure as Development Release Chapter to 2 working - Accessing XML with DOM, SAX, JAXB,10g andreleases, StAX Manager for Oracle 8.0, spanning five releases. He also served three years as chair of Oracle’s C Coding Standards Chapter 3 - Transforming XML with XSLT and XPath Committee, and he was a W3C DOM Working Group editor. He is co-author of Oracle9i XML Handbook and Oracle XML Chapter 4 Before - Validating with DTDs and XML Handbook. comingXML to Oracle, he worked atSchemas IBM Corp., Pacific Bell, Bellcore, and GE Corporate R&D. He holds an M.S. in Electrical (Computer Systems) from Stanford University and a B.S. in Electrical Engineering and Computer Chapter 5 Engineering - XML Operations with XQuery Science from the University of California at Berkeley. Chapter 6 - XML Messaging and RPC with SOAP Chapter 7 is - Putting All Together withfor XML Pipeline, andmanagement, XSQL Jinyu Wang a SeniorItProduct Manager Oracle XML JSPs, Product in charge of the Oracle XML Developer’s Kit, Part II - Oraclethe XML Management for components DBAs which provides XML infrastructure used across Oracle product stacks. As an Oracle Certified Professional with an extensive database background, she leads a variety of projects that successfully apply XML technologies to Chapter 8 - Getting Started with the Oracle XML Database enterprise business applications. While completing her master’s degree in computer science at the University of Southern Chapter 9 - Storing XML Data California and electrical engineering at Northern Jiaotong University, she worked on artificial intelligence and computer Chapter 10 - Generating Retrieving XML vision, focusing on motionand analysis. Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle Database 10g XML & SQL—Design, Build & PL/SQL Mark V. Scardina, Ben Chang and Jinyu Wang Manageby XML Applications in Java, C, C++ & PL/SQL ISBN:0072229527 McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Mark V. Scardina emphasis on XML standards, their usage and best practices. Ben Chang Jinyu Wang Table of Contents

McGraw-Hill/Osborne Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL 2100 Powell Street, 10th Floor Introduction Emeryville, California 94608 Part I - Oracle and the XML Standards U.S.A. 1 Chapter

- Introducing XML

Chapter 2

XML with DOM, SAX, JAXB, and StAX To arrange- Accessing bulk purchase discounts for sales promotions, premiums, or fund-raisers, please contact McGrawChapter 3 - Transforming with XSLT XPath on translations or book distributors outside the U.S.A., please Hill/Osborne at the aboveXML address. For and information Chapter 4 Validating XML with DTDs and XML see the International Contact Information pageSchemas immediately following the index of this book. Chapter 5

- XML Operations with XQuery

Copyright 2004 by The McGraw-Hill Companies, Inc. (Publisher). All rights reserved. Printed in the United States Chapter 6 -©XML Messaging and RPC with SOAP of America. Except ItasAllpermitted the Copyright Act of 1976, Chapter 7 - Putting Togetherunder with XML Pipeline, JSPs, and XSQLno part of this publication may be reproduced or distributed in any form or by any for means, Part II - Oracle XML Management DBAsor stored in a database or retrieval system, without the prior written permission Publisher. Chapter 8 - of Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

Oracle is a registered trademark of Oracle Corporation and/or its affiliates.

Chapter 10 - Generating and Retrieving XML

Chapter - Searching XML Data Oracle software programs have been reproduced herein with the permission of Screen11 displays of copyrighted Chapter Oracle 12 Corporation - Managing and/or the Oracle its affiliates. XML Database Part III - Oracle XML for Java Developers

1234567890 CUS CUS 01987654 Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

ISBN 0-07-222952-7

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter Publisher 16 - Developing an XML Gateway Application with SOAP and AQ

Brandon Nordin Chapter 17A. - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Vice President & Associate Publisher Scott Rogers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Acquisitions Editor Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Lisa McClain Part V - Oracle XML for C++ Developers

Project22Editors Chapter - Getting Started with Oracle XML and C++ LeeAnn23Pickrell, Chapter - Build an XML Database OCI C++ Application Lisa Wolters-Broder, Chapter 24 - Building an XML Data-Retrieval Application Emily Part VI Wolman - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

Acquisitions Coordinator Athena Honore

Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter Technical 28 - Editors Putting It All Together

Olivier Le -Diouris, Anjana Manian Appendix XML Standards Bodies and Open Specifications Glossary

Copy Editor William McManus

Index

List of Figures

List of Tables Proofreader List of Sidebars John Gildersleeve

Indexer Irv Hershman Composition Apollo Publishing Services, Jim Kussow Illustrators Kathleen Edwards,


Michael Mueller, Melinda Lytle Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

Series DesignPL/SQL Jani Beckwith by Mark V. Scardina, Ben Chang and Jinyu Wang Cover Series Design McGraw-Hill/Osborne © 2004 (600 pages) Damore Johann Design, Inc.

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

on XML standards, their ™ and best practices. This book was emphasis composed with Corel VENTURA usage Publisher.

Information has been obtained by Publisher from sources believed to be reliable. However, because of the possibility Table of Contents of human or mechanical by our sources, or others, Publisher does Oracle Database 10g XML &error SQL—Design, Build &Publisher, Manage XML Applications in Java, C, not C++guarantee & PL/SQL to the accuracy, adequacy, or completeness of any information included in this work and is not responsible for any errors or Introduction omissions or the obtained from the use of such information. Part I - Oracle andresults the XML Standards Chapter 1

- Introducing XML Oracle Corporation does not make any representations or warranties as to the accuracy, adequacy, or

Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAXand is not responsible for any errors or omissions. completeness of any information contained in this Work, Chapter 3

- Transforming XML with XSLT and XPath

To my family for their understanding, tolerance, and support through the late nights and lost weekends. To my Chapter 4 - Validating XML with DTDs and XML Schemas coworkers accepting without complaint my interruptions for technical help and advice. Chapter 5 -for XML Operations with XQuery —Mark6Scardina Chapter - XML Messaging and RPC with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

To my family for their support. —Ben Chang

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter - Storing I would9like to thankXML firstData and foremost my husband, Yong, for his support when I worked on this book. I’d also like Chapter - Generating Retrieving to thank10my colleaguesand on the Oracle XML XML development team who gave me invaluable help. Chapter —Jinyu11 Wang - Searching XML Data Chapter 12 - Managing the Oracle XML Database

About Authors Part III -the Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

Mark V. Scardina is Oracle’s XML Evangelist for Server products and is the Group Product Manager for the CORE

Chapter 14 Development - Building an XML-Powered and XML Group taskedWeb withSite providing the XML infrastructure components used throughout the Oracle Chapter - Creating a Portal Site with XMLDeveloper’s and Web Services product15 stack, including the Oracle XML Kit. Mark chairs the Oracle XML Standards committee and is Chapter 16on - Developing an XML Gateway Application SOAPspeaker and AQ at industry trade shows and conferences, a an editor the W3C XSL Working Group. He is a with frequent Chapter 17industry - Developing XML-Based Reusable of Components writer for journals and is co-author Oracle9i XML Handbook and Oracle XML Handbook. Prior to joining Part IV - Oracle XMLat forSocket C Developers Oracle, he worked Communications and ACE Technologies. He holds a B.S. in Information Systems

Chapter 18 - Getting Started with Oracle XML and C Management from USF. Chapter 19 - Building an XML-Managed Application

Mark lives Sanan Francisco with his wife and twin boys. His hobbies include DanceSport, high-end audio/video, and Chapter 20 -inBuild XML Database OCI Application working on his house.

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Ben Chang is a 15-year veteran at Oracle Corp., where he heads the CORE and XML Development Group as

Chapter 22In - Getting withon Oracle XML to and C++ Database 10g releases, he served the longest tenure as Director. additionStarted to working Oracle6 Oracle

Chapter 23 - Build an XML Database C++8.0, Application Development Release Manager forOCI Oracle spanning five releases. He also served three years as chair of Chapter 24C- Coding BuildingStandards an XML Data-Retrieval Application Oracle’s Committee, and he was a W3C DOM Working Group editor. He is co-author of Part VI - Oracle XML for PL/SQL Developers Oracle9i XML Handbook and Oracle XML Handbook. Before coming to Oracle, he worked at IBM Corp., Pacific Bell,

Chapter 25and - Getting Started with Oracle XML and PL/SQL Bellcore, GE Corporate R&D. He holds an M.S. in Electrical Engineering (Computer Systems) from Stanford Chapter 26 -and Building Web Services University a B.S.PL/SQL in Electrical Engineering and Computer Science from the University of California at Berkeley. Chapter 27 - Extending PL/SQL XML Functionality with Java

Jinyu Wang is a Senior Product Manager for Oracle XML Product management, in charge of the Oracle XML Chapter 28 - Putting It All Together

Developer’s Kit, which provides the XML infrastructure components used across Oracle product stacks. As an - XML Standards Bodies and Open Specifications Oracle Certified Professional with an extensive database background, she leads a variety of projects that Glossary successfully apply XML technologies to enterprise business applications. While completing her master’s degree in Index computer science at the University of Southern California and electrical engineering at Northern Jiaotong University, List of Figures she worked on artificial intelligence and computer vision, focusing on motion analysis. Appendix

List of Tables

List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Introduction PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

XML is now six years old, having been published as a W3C recommendation in February 1998. It was around that McGraw-Hill/Osborne © 2004 (600 pages) time that Oracle began to take a serious look at this new promising technology. In fact the Architectural Review on utilizing XML technologies within Oracle's XML-enabled products, with Board decidedThis that comprehensive XML was goingguide to befocuses of company-wide importance and handed down a development charter to emphasis on XML standards, their usage and best practices. the CORE Development group as follows: Table Deliver of Contents the best platform for developers to productively build and cost-effectively deploy reliable and scaleable

Internet applications exploiting XML. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

This charter has proven to be prescient as not only has XML become a dominant Internet technology, but also has spawned an entire family of standards that are becoming the foundation of electronic publishing, business, and Chapter 1 - Introducing XML application development. The impact of XML has been felt to no greater measure than within Oracle and has kept Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX the now CORE and XML Development group busy these many years. The authors are members of this group and Chapter 3 - Transforming XML with XSLT and XPath have had the opportunity to not only participate in the XML standards process and produce the implementations but Chapter 4 - Validating XML with DTDs and XML Schemas also work with over a hundred development groups across Oracle and countless customers in putting this family of Chapter 5 - XML Operations with XQuery technologies to work in a myriad of ways. Thus we hope to bring to you not only the means to put Oracle’s XML Chapter 6 XML Messaging and RPC withand SOAP technology to work, but also new ways new ideas for using XML in your applications. Part I - Oracle and the XML Standards

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Over years, theManagement XML dialog has changed. It used to be asked, when talking with new users or businesses Part II the - Oracle XML for DBAs contemplating XML,Started What iswith all this fuss about? Why would I want to exchange data in a bloated form having lost its Chapter 8 - Getting the Oracle XML Database binding? is theXML oneData killer XML application? Chapter 9 What - Storing Chapter 10 - Generating and Retrieving XML

These were tough questions, primarily because XML is not an end but a means. Its strength and its weakness are in its ability to be infinitely flexible and extensible. Fortunately, as companion standards such as XSL, XML Schema, Chapter 12 - Managing the Oracle XML Database Namespaces, XPath, and so on, were developed and rolled out businesses and their developers stopped asking Part III - Oracle XML for Java Developers Why XML? and started asking How XML? which leads us to why we wrote this book. Chapter 11 - Searching XML Data

Chapter 13 - Getting Started with Oracle XML and Java

Chapter You may 14be - Building surprised an to XML-Powered learn that Oracle Web Site does not have a research and development division. All development is

done in15 the- Creating context of a product. This XML can and make developing Chapter a Portal Site with Web Services new technologies difficult as these standards efforts evolve,16 have bugs, andan have years to stabilize. This canand be AQ seen in the years it took to publish XML Schema Chapter - Developing XMLtaken Gateway Application with SOAP and that Query is XML-Based in its fifth year and still not out the door. Nevertheless, Oracle has been an early adopter in all Chapter 17XML - Developing Reusable Components of these technologies, them to work within all Oracle products. Part IV - Oracle XML for putting C Developers Chapter 18 - Getting Started with Oracle XML and C

This situation gave birth to the Oracle XML Developer’s Kit in 1999 as a vehicle to expose implementations of these technologies to both the internal and external development community. This was desirable, as it would allow us to Chapter 20 - Build an XML Database OCI Application bring these implementations to production quicker using the beta facilities of the Oracle Technology Network (OTN), Chapter - Createfrom an XML-Configured High-Performance Transformation getting 21 feedback a broad spectrum of developers looking for XML Engine functionality. Productizing Oracle’s XML Part V - Oracle XML for C++ Developers infrastructure for external use meant that we had to develop a license. At that time the only Oracle licenses available Chapter 22 - Getting Started with Oracle XML and C++ were either a product license that limited usage to one’s own deployment or a development one that forbid Chapter 23 - Build an XML Database C++for Application deployment. Neither of these madeOCI sense a software development kit that we weren’t charging for and wanted Chapter - Building an XMLseriously. Data-Retrieval Application people 24 to develop against We were able to successfully navigate Oracle’s legal system to create a Part VI - Oracle XML for PL/SQLlicense Developers deployment and redistribution for the XDK that exists to this day. Chapter 19 - Building an XML-Managed Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL

The license wasn’t enough weServices were looking for serious enterprise-level development and deployments. We Chapter 26 - Building PL/SQL as Web needed27 support as well. Therefore we again successfully Chapter - Extending PL/SQL XML Functionality with Java negotiated to have the XDK be included as part of the

Oracle server support contracts for the database, application server, and tools at the same service level at no additional charge. Additionally, we were able to offer standalone support agreements for non-Oracle customers. Appendix - XML Standards Bodies and Open Specifications Finally, for those who could not afford or did not need formal support, we opened a support forum on OTN, which Glossary has rapidly grown to six forums that we directly support. Over the last five years we have released both beta and Index production XDKs at roughly three month intervals. Beta versions have a time-based development-only license but List of Figures the production releases have the full redistribution license. Chapter 28 - Putting It All Together

List of Tables

List Finally of Sidebars we come to this book. While this is the third book for two of us, it represents a totally different effort from the

previous Oracle XML Handbook and Oracle9i XML Handbook. Those previous editions provided a survey of Oracle and XML and in-depth discussions about the XDK. This edition is totally rewritten with almost all new content. While the previous editions came with CDs, this one does not for two very important reasons. First, all the code in the book will be downloadable from the Oracle Press web site. As distinct from a CD, this allows us to update it should any bugs appear. In the previous editions we provided Oracle software on the CD; however, it forced us to include only Oracle software, so we made most of the code available on OTN. This had the unanticipated effect of lessening the book’s value in some reader’s minds. This edition does not suffer under those limitations, so you will find more original and innovative content and all of the code available for download.


The book is divided into six parts and is organized to be accessible by managers, DBAs, and developers alike. Part I includesChapters 1 through 7 and focuses on the family of XML standards that are important to Oracle and that Oracle when Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ should be considered designing XML-enabled solutions. These not only discuss the common standards of & PL/SQL DOM, SAX, XSLT, and XML Schema, but venture into new standards, some of which are not complete, such as ISBN:0072229527 by Mark V. Scardina, Ben ChangThese and Jinyu Wangare not intended to be comprehensive in their XML Query, XML Pipeline, StAX, and JAXB. chapters McGraw-Hill/Osborne © 2004 (600 pages) coverage, as whole books have been written on many of them. They do intend to give you a good feel for the This comprehensive guide utilizing XML technologies withinguidance Oracle's XML-enabled products, with functionality offered and to compare andfocuses contrastonsimilar standards thus providing in their optimum usage. emphasis on XML standards, their usage and best practices.

Part II includes Chapters 8 through 12 and focuses on XML and the Oracle database. Beginning in Oracle9i Release 2, native XML support was introduced along with significant XML functionality integrated into other database features Table of Contents such as Oracle Text and Advanced Queuing. These chapters provide an in-depth look at this functionality and its Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL evolution into Oracle Database 10g. After getting started in Chapter 8, the chapters are arranged along task lines Introduction such as storing XML, retrieving and generating XML, searching and querying XML, and managing the Oracle XML Part I - Oracle and the XML Standards DB. These chapters are designed to be accessible to both developers and DBAs. Chapter 1

- Introducing XML

Chapter - Accessing XML with SAX,13 JAXB, and StAX Parts III2 through VI consists of DOM, Chapters through 28 and focus on how to use Oracle’s XML technology for real Chapter 3 - development. Transforming XML with XSLT and application These chapters areXPath split into Oracle’s major development languages of Java, C, C++, and Chapter 4 Each - Validating XMLbegins with DTDs XML Schemas PL/SQL. language with aand getting started chapter covering environment, IDE setup, runtime setup, and Chapter so on. The 5 - subsequent XML Operations chapters with XQuery in these parts discuss real-use case application scenarios. In many instances,

these were drawn from actual projects. While they include extensive source code, each example is Chapter 6 - XML Messaging andcustomer RPC with SOAP explained detail and code iswith available for download fromXSQL Oracle Press. Chapter 7 -inPutting It Allthe Together XML Pipeline, JSPs, and Part II - Oracle XML Management for DBAs

This book was written during the development of Oracle Database 10g and as such could not have been completed - Getting Started with the Oracle XML Database without the help of many within Oracle. The authors wish to especially thank the following:

Chapter 8 Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

K Karun Chapter 11 - Searching XML Data

Tomas Saulys

Chapter 12 - Managing the Oracle XML Database Bill Han Anjana Manian

Tim Yu Meghna Mehta

Part III - Oracle XML for Java Developers

Kongyi Stanley Chapter 13Zhou - Getting Started with Oracle XML and Guan Java

Ian Macky

Chapter 14Lenkov - Building an XML-Powered Web Site Novoselsky Dimitry Anguel

Mark Drake

Chapter 15 - Creating a Portal Site with XML and Web Services

Stephen Buxton

Asha Tarachandani

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter - Developing XML-Based Reusable Components Nipun17 Agarwal Jim Warner Part IV - Oracle XML for C Developers

Bhushan.Khaladkar

Ravi Murthy Olivier LeDiouris

Dan Chiba

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Part I: Oracle and the XML Standards PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Chapter List

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Chapter 1: Introducing XML

Table of Contents

OracleChapter Database XML & SQL—Design, Build & Manage in Java, C, C++ & PL/SQL 2: 10g Accessing XML with DOM, SAX, JAXB, XML and Applications StAX Introduction

Transforming XML with XSLT and XPath Part IChapter - Oracle 3: and the XML Standards Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 4: Validating XML with DTDs and XML Schemas

Chapter 3 - Transforming XML with XSLT and XPath Chapter 5: XML Operations with XQuery Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 6: XML Messaging and RPC with SOAP Chapter 5 - XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP Chapter 7: Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 1: Introducing XML PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Extensible Markup Language (XML) is a meta-markup language, meaning that the language, as specified by the McGraw-Hill/Osborne © 2004 (600 pages) World Wide Web Consortium’s (W3C) XML 1.0 specification, enables users to define their own markup languages to This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with describe and encapsulate data into XML files. These files can then be transformed into HTML (as well as into any emphasis on XML standards, their usage and best practices. other markup language) and displayed within browsers such as Netscape Navigator and Microsoft Internet Explorer, exchanged across the Internet between applications and businesses, or stored in and retrieved from databases. The Table of of Contents power XML comes from its simplicity, its being part of an open standard, and the incorporation of user-defined Oracle Database 10g XML & SQL—Design, Build & Manage markup tags that lend semantics to the embedded data.XML Applications in Java, C, C++ & PL/SQL Introduction

XML’s originsand come Standard Generalized Markup Language (SGML)—ratified by the International Part I - Oracle thefrom XMLthe Standards Standards (ISO) in 1986—on which Hypertext Markup Language (HTML), created in 1990, is based. Chapter 1 -Organization Introducing XML While SGML is still a widely used standard in theand document Chapter 2 - Accessing XML with DOM, SAX, JAXB, StAX world, and HTML is still widely used as the basis of millions3of -web pages on XML the World Wideand Web, XML is rapidly gaining widespread acceptance because of its Chapter Transforming with XSLT XPath

advantages in data exchange, storage, and description over the existing markup languages. Since the publication of - Validating XML with DTDs and XML Schemas its v1.0 specifications by the W3C in February 1998, XML has been widely seen as the language and data Chapter 5 - XML Operations with XQuery interchange of choice for e-commerce. Chapter 4 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

What Is an XML Document?

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

While this book is not meant to be a full XML tutorial, as with any standard, numerous concepts and technical terms Chapter 9 - Storing XML Data need to be explained. Because XML was developed to convey data, a relevant example is a data record of a book Chapter 10 - Generating and Retrieving XML listing from a standard database. A complex SQL query could return data in the following format: Chapter 11 - Searching XML Data

History of Interviews, Juan, Smith, 99999-99999, Oracle Press, 2003.

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

If XML is used as the output form, however, this record now has additional context for each piece of data, as

Chapter 13 -in Getting Started with Oracle XML and Java evidenced the following: Chapter 14 - Building an XML-Powered Web Site

<book> <title>History of Interviews</title> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <author> Chapter 17 - Developing XML-Based Reusable Components <firstname>Juan</firstname> Part IV Oracle XML for C Developers <lastname>Smith</lastname> Chapter 18 - Getting Started with Oracle XML and C </author> Chapter 19 - Building an XML-Managed Application <ISBN>99999-99999</ISBN> Chapter 20 - Build an XML Database OCI Application <publisher>Oracle Press</publisher> Chapter 21 Create an XML-Configured High-Performance Transformation Engine <publishyear>2003</publishyear> Part<price V - Oracle XML for C++ Developers type="US">10.00</price> Chapter </book> 22 - Getting Started with Oracle XML and C++ Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 23 - Build an XML Database OCI C++ Application

Certain24 items of noteaninXML this Data-Retrieval example are explored in detail later. Notice that the file has symmetry, and each piece of Chapter - Building Application dataVIhas its context enclosing in the form <context> … </context>. The angle brackets and text inside are called Part - Oracle XML for PL/SQLitDevelopers tags, and each set of tags and its enclosed data is called an element. This relationship can be thought of as similar to a column in a database table in which the text of the tag is the column heading and the text between the tags is Chapter 26 - Building PL/SQL Web Services the data from a row in that column. In the preceding example, title could be the name of the column and History of Chapter 27 - Extending PL/SQL XML Functionality with Java Interviews could be the data in a row. Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 28 - Putting It All Together

Appendix - XML Bodies and tags Openinstead Specifications Notice, too, that Standards several tags contain of data. This is a significant feature of XML, which permits nesting Glossary of data to define relationships better. Returning to the database metaphor, the <author> tag could be modeled as a Index table whose columns were <firstname> and <lastname>. In XML terminology, these column tags are referred to as

children of the parent <author> tag. List of Figures List of Tables

Now look at the <price> tag and you see that it includes text of the form name=“value”. These name-value pairs are called attributes, and one or more of these can be included in the start tag of any element. Attributes, however, are not legal in end tags (for example, </tagname=“foo”>). Notice that attribute values must be framed by quotes (single or double, as long as the closing and opening quotes are the same) as specified by SGML. HTML is much more permissive in this area.

List of Sidebars

One final terminology note: the entire XML example is enclosed by <book> … </book>. These tags are defined as theroot of the document, and only one may exist in any particular document. XML documents that follow these rules of having only one root and properly closing all open tags are considered well formed.


XML’s basic concepts and terminology are straightforward and are formalized in an open Internet standard. As the W3C XML 1.0 specification states, “XML documents are made up of storage units called entities, which contain either parsed data or unparsed data [or PCDATA] up of characters, someinofJava, whichC,form Oracle Databasedata. 10g Parsed XML & SQL: Design, Buildis&made Manage XML Applications C++ & character data,PL/SQL and some of which form markup. Markup encodes a description of the document’s storage layout and logical structure.” documents and logical structure. The physical structure of the XML ISBN:0072229527 by MarkXML V. Scardina, Ben have Changboth andphysical Jinyu Wang document simply refers to the XML file and(600 thepages) other files that it may import, whereas the logical structure of an XML McGraw-Hill/Osborne © 2004 document refers to comprehensive the prolog and guide the body of the This focuses ondocument. utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

The XML of the book example represents the body of an XML document, but it is missing important information that helps identify its nature. This information is in the prolog, discussed in the following section.

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

The Prolog

Introduction

Part I - Oracle and the XML Standards

Theprolog consists of the XML declaration (that is, the version number), a possible language encoding hint, other - Introducing XML attributes (name-value pairs), and an optional grammar or data model specified by either an XML Schema Definition Chapter 2 Accessing XML DOM, SAX, JAXB, and StAX (XSD) or a- Document Typewith Definition (DTD) referred to by a URL. The prolog may also contain the actual XSD or Chapter 3 example - Transforming XML with XSLT XPathDTD would look like the following: DTD. An with a reference to anand external Chapter 1

Chapter 4

- Validating XML with DTDs and XML Schemas

<?xml version="1.0" encoding="UTF-8" standalone="no" ?> - XML Operations with XQuery <!DOCTYPE book SYSTEM "book.dtd">

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7 a - Putting It All Together with Pipeline,of JSPs, and XSQL Note that line containing <? … ?> is XML an example an XML processing instruction (PI). In this example, xml is the Part II -ofOracle XMLPI. Management name the XML In addition,for theDBAs character set encoding supported in the example is a compressed version of

Chapter Unicode 8 called - Getting UTF-8. Started While with XML theprocessors Oracle XML usually Database detect the encoding from the first 3 bytes in the file, this

declaration be used as a hint to indicate the expected encoding. Finally, the standalone attribute refers to Chapter 9 - can Storing XML Data whether10the processor and needs to include or import other external files. Chapter - Generating Retrieving XML Chapter 11 - Searching XML Data

The second line of this prolog refers to a DOCTYPE. This is where the declaration of the grammar or data model for this XML document is done. Why is this important? Remember, an XML file has both physical and logical Part III - Oracle XML for Java Developers representations. In some applications, it may be sufficient to process the XML without knowing whether information Chapter 13 - Getting Started with Oracle XML and Java is missing, but most of the time, an application wants to validate the XML document it receives to confirm everything Chapter 14 - Building an XML-Powered Web Site is there. To do this, the application must know which elements are required, which ones can have children, which Chapter 15 have - Creating a Portal Site XML and Web Services ones can attributes, and sowith forth. In XML terms, the grammar or data model in this example is referred to as Chapter 16 -DTD Developing an XML Gateway Application SOAP be and AQ DTD. This can reside within the XML file itselfwith or simply referred to so that the processor can locate it, as in Chapter 17 - Developing XML-Based Reusable Components this example. Chapter 12 - Managing the Oracle XML Database

Part IV - Oracle XML for C Developers

The preceding example might as follows with Chapter 18 - Getting Started withlook Oracle XML and C an XML Schema declaration: Chapter - Building an XML-Managed Application <?xml 19 version="1.0"?> Chapter <xsd:schema 20 - Buildxmlns:xsd=http://www.w3.org/2001/XMLSchema an XML Database OCI Application

xmlns:bk="http://www.mypublishsite.com/books"> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

To begin note Started that thewith XMLOracle Schema Chapter 22with, - Getting XMLdeclaration and C++ has a prefix xsd:, which is associated with the XML Schema

namespace through the declaration xmlns:xsd=“http://www.w3.org/ 2001/XMLSchema”. This prefix is used on the names of the data types defined in the referenced XSD to differentiate them from others using the same name. Chapter 24 - Building an XML Data-Retrieval Application Thexsd:schemadeclaration denotes the beginning of this XML Schema incorporated in this XML document, along Part VI - Oracle XML for PL/SQL Developers with one other declaration, xmlns:bk=“http://www.mypublishsite.com/books”,whichdefines the namespace of Chapter 25 - Getting Started with Oracle XML and PL/SQL the prefix bk: so asto identify these types as defined by the author of this data model. Chapter 23 - Build an XML Database OCI C++ Application

Chapter 26 - Building PL/SQL Web Services

Chapter 27 -that Extending PL/SQL XML Functionality Java Note also the schema declaration is within with the <book> tag instead of in the prolog. This is a distinct difference Chapter 28XSDs - Putting All Together between andItDTDs. Thus, the XML schema declaration is an attribute of the root element of the document Appendix and is part- of XML theStandards body, which Bodies we discuss and Open next. Specifications Glossary

The Body

Index

List of Figures

List Theofroot Tables element, which contains the remainder of the XML document, follows the prolog and is called the body of

theofXML document. This part is composed of elements, processing instructions, content, attributes, comments, List Sidebars entity references, and so forth. As previously mentioned, elements must have start tags and corresponding end tags nested in the correct order; otherwise, the XML document is not well-formed, and XML parsers may signal errors because of this. Elements can also have attributes, or name-value pairs, such as <author firstname=“Juan” lastname=“Smith”>. Built-in attributes defined by the XML 1.0 specification also exist, such as xml:space=“preserve” to indicate that the whitespace between the elements be considered as data and thus preserved. Entity references, defined only in DTDs, are similar to macros in that entities are defined once, and references to


them, such as &nameofentity, can be used in place of their entire definitions. For example, in a DTD, <!ENTITY Copyright “Copyright 2000 by Smith, Jones, and Doe – All rights reserved”> could bedeclared, and then &Copyright could be Database used as a shortcut the XML document. An XML XMLApplications parser must recognize entities Oracle 10g XMLthroughout & SQL: Design, Build & Manage in Java, C, C++ & defined in DTDs, even though the validity check may be turned off and an additional XML Schema is specified. PL/SQL Again, built-in entities exist as defined by the specifications, such as those for the ampersand, & ISBN:0072229527 by Markalso V. Scardina, Ben Chang andXML Jinyu1.0 Wang apostrophe, ' less than, < and so (600 forth. Comments are recognized when they are enclosed in the <!-- --> McGraw-Hill/Osborne © 2004 pages) construct. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Within the body of the XML document instance, certain element and attribute names may have prefixes, which are XML namespaces identified by Uniform Resource Identifier (URI) references that qualify the names of these Table of Contents elements and attributes and locate resources that could be on different machines or XML documents. For example, Oracle 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, & PL/SQL if the Database declaration xmlns:bk=“http:// www.mypublishsite.com/books” is made in C++ a parent element, the prefix Introduction bk:title stands for http:// www.mypublishsite.com/books:title. You can use identical names for either elements Part I - Oracleifand Standards or attributes theythe areXML qualified with URIs to differentiate the names. For example, bk:hello is called a qualified Chapter 1 Introducing XML name; the namespace prefix bk is mapped to the URI, http://www.mypublishsite.com/books, and the local part is Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX hello. Note that URI references can contain characters not allowed in element names; that is why bk serves as a Chapter substitute 3 -for Transforming the URI. It isXML important with XSLT to mention and XPath that the bk prefix belongs to the document in which it is declared. Another4 document declaring theDTDs prefix book of bk but referencing the same URI would be considered Chapter - Validating XML with and XMLinstead Schemas equivalent parsed by with an XML parser. Chapter 5 -when XML Operations XQuery Chapter 6

- XML Messaging and RPC with SOAP

Finally, the body may contain character data (CDATA) sections to mark off blocks of text that would otherwise be - Putting It All Together with XML Pipeline, JSPs, and XSQL regarded as markup, comments, entity references, processing instructions, and so forth. The CDATA syntax is

Chapter 7

Part II - Oracle XML Management for DBAs

<![CDATA[ characters including /, ?, & not legal anywhere else]]> Chapter 8 - Getting Started with the Oracle <, XML>, Database Chapter 9

- Storing XML Data

These sections are simply skipped by XML parsers as if they were opaque. Later in the book, you will see how you use them to embed SQL statements in XML documents.

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

Chapter Thus, the 12 body - Managing of the the XML Oracle document XML Database contains the root element with its schema declarations, child and sibling Part nodes, III -elements, Oracle XML attributes, for Java Developers text nodes that represent the textual content of an element or attribute, and CDATA

sections. Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


OracleXML Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Well-Formed Documents PL/SQL

by Mark V. Scardina, Ben Changis and Wang As mentioned previously, an XML document wellJinyu formed if only one root exists and all start tags have ISBN:0072229527 © 2004nesting. (600 pages) corresponding McGraw-Hill/Osborne end tags, with the correct For example, the following is not well formed: This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <bookcatalog> emphasis on XML standards, their usage and best practices. <book> <title>History of Interviews</ti> Table <author> of Contents Oracle <firstname>Juan</firstname> Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <lastname>Smith</author></lastname> Introduction Part I -<ISBN>99999-99999</ISBN> Oracle and the XML Standards <publisher>Oracle Chapter 1 - Introducing XML Press</publisher> <publishyear>2003</publishyear> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <price type="US">10.00</price> Chapter 3 - Transforming XML with XSLT and XPath </book> Chapter 4 - Validating XML with DTDs and XML Schemas </bookcatalog> Chapter 5 - XML Operations with XQuery <bookcatalog2> Chapter 6 - XML Messaging and RPC with SOAP … Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL </bookcatalog2> Part II - Oracle XML Management for DBAs

Chapter 8 - Getting Started withwhy theitOracle The following are the reasons is not XML well Database formed: Chapter 9

- Storing XML Data

Two exists, bookcatalog bookcatalog2. Chapter 10roots - Generating and Retrievingand XML Chapter 11 - Searching XML Data

The<title> tagdoes not have a correct corresponding end tag, as in </title>.

Chapter 12 - Managing the Oracle XML Database

Part III - Oracle for Java is Developers The end tagXML </author> not nested correctly, because the </lastname> end tag is after it instead of before it.

Chapter 13 - Getting Started with Oracle XML and Java

XML parsers will reject this documentWeb without Chapter 14 - Building an XML-Powered Site further processing. Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Valid XMLOracle Documents PL/SQL

by Mark V. Scardina, Ben Chang Jinyu Wang DTD or XML Schema, meaning that theISBN:0072229527 A valid XML document is one that conforms to and either a specified elements, McGraw-Hill/Osborne © 2004 (600 pages)in the XML document are the same as the ones specified in the attributes, structural relationships, and sequences DTD or XML Schema. For example, the focuses following is valid respect towithin the DTD, which follows it: products, with This comprehensive guide onXML utilizing XMLwith technologies Oracle's XML-enabled emphasis on XML standards, their usage and best practices. <bookcatalog> <book> Table of Contents <title>History of Interviews</title> Oracle <author> Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <firstname>Juan</firstname> Introduction Part I<lastname>Smith</lastname> - Oracle and the XML Standards </author> Chapter 1 - Introducing XML <ISBN>99999-99999</ISBN> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <publisher>Oracle Press</publisher> Chapter 3 - Transforming XML with XSLT and XPath <publishyear>2003</publishyear> Chapter 4 - Validating XML with DTDs and XML Schemas <price type="US">10.00</price> Chapter 5 - XML Operations with XQuery </book> Chapter 6 - XML Messaging and RPC with SOAP </bookcatalog> Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part - Oracle is XML forthe DBAs TheIIfollowing theManagement DTD to which XML document conforms:

Chapter 8

- Getting Started with the Oracle XML Database

<!-- DTD bookcatalog may have a number of book entries --> Chapter 9 - Storing XML Data <!DOCTYPE bookcatalog [ Chapter 10 - Generating and Retrieving XML <!ELEMENT bookcatalog (book)*> Chapter - Searching XML Data has a title, 1 or more authors, etc. --> <!-- 11 Each book element Chapter 12 Managing the Oracle XML Database <!ELEMENT book (title, author+, ISBN, publisher, publishyear, price)> Part III Oracle XML for Java Developers <!ELEMENT title (#PCDATA)> Chapter 13 - Getting Started with Oracle XML and Java <!ELEMENT author (firstname, lastname)> Chapter 14 Building an XML-Powered Web Site <!ELEMENT firstname (#PCDATA)> Chapter 15 - Creating a Portal(#PCDATA)> Site with XML and Web Services <!ELEMENT lastname Chapter <!ELEMENT 16 - Developing ISBN (#PCDATA)> an XML Gateway Application with SOAP and AQ <!ELEMENT publisher (#PCDATA)> Chapter 17 - Developing XML-Based Reusable Components <!ELEMENT (#PCDATA)> Part IV - Oracle publishyear XML for C Developers <!ELEMENT price (#PCDATA)> Chapter 18 - Getting Started with Oracle XML and C <!ATTLIST price (US|CAN|UK|EURO) #REQUIRED> Chapter 19 - Building an type XML-Managed Application ]> Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

TheDOCTYPE declaration of the DTD specifies the root element—in this case, the <bookcatalog> element. An element simply consists of a start tag, for example, <title>; all of the text in between, History of Interviews; and the Chapter 22 - Getting Started with Oracle XML and C++ corresponding end tag, for example, </title>. Only one root element, however, may exist within an XML document. Chapter 23 - Build an XML Database OCI C++ Application The root element marks the beginning of the document and is considered the parent of all the other elements, which Chapter 24 - within Building XML are nested its an start tagData-Retrieval and end tag. Application For XML documents to be considered valid with respect to this DTD, the Part VI Oracle XML for PL/SQL root element bookcatalog mustDevelopers be the first element to start off the body of the XML document. Part V - Oracle XML for C++ Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Following are thePL/SQL element declarations, which stipulate the child elements that must be nested within the root Chapter 26 -this Building Web Services element27 bookcatalog, the content model for thewith rootJava element. Note that all the child elements of bookcatalog are Chapter - Extending PL/SQL XML Functionality explicitly out It in All its Together element declaration, and that author has a + as a suffix. This is an example of the Chapter 28called - Putting Extended -Backus-Naur Format (EBNF) thatSpecifications can be used to describe the content model. The allowed suffixes are Appendix XML Standards Bodies and Open Glossary

? For 0 or 1 occurrence

Index

List of Figures * For 0 or more occurrences List of Tables

+ For 1 or more occurrencesNo suffix means 1 and only 1. List of Sidebars Note also the use of #PCDATA to declare that the element text must not be marked-up text, and that price’s required attribute values are explicitly declared. The difference between CDATA and PCDATA is that CDATA sections are simply skipped by the parser and aren’t checked for well-formedness; hence, they can be viewed as “non-parsed character data.” Thus a validating XML parser, by parsing the XML document according to the rules specified in this DTD, tries to determine whether the document conforms to the DTD (is valid), meaning that all the required elements, attributes, structural relationships, and sequences are as declared.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XML Namespaces PL/SQL

ISBN:0072229527 by Markwe V. introduced Scardina, Ben Chang and Jinyu This WangW3C XML standard introduces the following Earlier in the chapter, XML namespaces. terms with © 2004 (600 pages) regard to XML McGraw-Hill/Osborne namespaces:

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Local name Represents thestandards, name of the element attribute without the prefix. In the previous example, book, emphasis on XML their usage or and best practices. title,author,ISBN, and so forth are considered local names. These are used whenever there is no concern over duplicate tag or attribute names. Local name is also used to refer to the name part of a qualified name.

Table of Contents

OracleQualified Databasename 10g XML & SQL—Design, & Manage C, C++ of & the PL/SQL Represents the fullyBuild prefixed name.XML For Applications example, asina Java, continuation previous examples, Introduction bk:title,bk:book, and so forth are considered qualified names. Qualified names are being used more often Part Ibecause - Oracle and XML Standards XMLthe Schemas are defining standard types, such as address, customer, purchase order, and so on,

Chapter - Introducing and1 there is a needXML to differentiate semantics. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Namespace prefix Represents the namespace Chapter 3 - Transforming XML with XSLT and XPath prefix declared using the special prefix, xmlns. The previous example defined one namespace prefix: Prefixes are scoped and thus must be unique within the children of Chapter 4 - Validating XML with DTDs and XMLbk. Schemas the parent element that declared the namespace, but prefixes may be overridden by a new declaration on a Chapter 5 - XML Operations with XQuery descendent element or attribute. Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7 - Putting It All Together with XML Pipeline, JSPs, XSQL Expanded name Represents the result of applying theand namespace defined by the namespace prefix to the Part II - Oraclename. XML Management DBAs qualified For example,for bk:booklist could be expanded to

Chapter 8 - Getting Started with the Oracle XML DatabaseThe expanded name is never seen in the XML document http://www.mypublishsite.com/books:booklist. Chapter 9 -but Storing XML Data important. itself, is conceptually Chapter 10 - Generating and Retrieving XML

Two kinds namespace exist: prefixed and default. A prefixed namespace attribute is of the form Chapter 11 -of Searching XMLattributes Data nsprefix:attr, where nsprefix the Database namespace prefix defined previously. Once a prefix has been declared, it can Chapter 12 - Managing the OracleisXML be used to specify namespace for any elements or attributes in the scope of the element where it was declared. Part III - Oracle XMLafor Java Developers You would, therefore, need to declare global prefixes—that is, prefixes you want to use everywhere in your document—as attributes of the root element.

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Webhas Services The default namespace attribute is xmlns. xmlns the effect of specifying a default namespace for the entire Chapter 16an - Developing an XML Gateway Application with default SOAP and AQnot apply to the attributes in the subtree, scope of element (including the element itself). This does Chapter 17 For - Developing Reusable Components however. example, XML-Based consider the following example: Part IV - Oracle XML for C Developers

<booklist xmlns="http://www.osborne.com/books>

Chapter 18isbn="1234-5678-1234"> - Getting Started with Oracle XML and C <book Chapter 19 - Building anXML XML-Managed Application <title>Oracle Handbook</title> Chapter 20 - Build an XML Database OCI Application <author>Oracle XML Team</author> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine </book> Part V - Oracle XML for C++ Developers <book isbn="24345-564478-1344234">

Chapter 22 - Getting with Oracle XML and C++ <title>The C Started programming language</title> Chapter <author>Kernighan 23 - Build an XML Database and Ritchie</title> OCI C++ Application

</book> Chapter 24 - Building an XML Data-Retrieval Application </booklist> Part VI - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

This root element declaration has the effect of specifying that all the elements under booklist (book,title,author) are in the http://www.osborne.com/books namespace. The attribute isbn, however, is not. Default namespaces Chapter 27 - Extending PL/SQL XML Functionality with Java can be specified at any level of the document and have the effect of overriding previous declarations. Setting Chapter 28 - Putting It All Together xmlns=““ has the effect of removing the default namespace declaration for a particular document subtree. Chapter 26 - Building PL/SQL Web Services

Appendix

- XML Standards Bodies and Open Specifications

Glossary Namespaces complicate the determination of attribute uniqueness. For example, consider the following example: Index <booklist xmlns:dollars="USA" xmlns:pounds="Britain"> List<book of Figures dollars:price="7.99" pounds:price="3.99"> List <title>The of Tables Code of the Woosters</title> List <author>P.G. of Sidebars Wodehouse </author>

</book> </booklist> The two price attributes should be considered different, even though they have the same local name, because their expanded names are different. The following document would not be considered well-formed, however: <booklist xmlns:dollars="USA" xmlns:currency="USA"> <book dollars:price="7.99" currency:price="3.99"> <title>The Code of the Woosters</title>


<author>P.G. Wodehouse </author> </book> </booklist>Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Here, even though dollars:price and currency:price have different qualified names, they have the same expanded McGraw-Hill/Osborne © 2004 (600 pages) name, which means they are, in fact, the same attribute declared twice on the book element. For a similar reason, This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with only one default namespace is allowed per document. emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XML and Oracle the Database PL/SQL

ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyufor Wang Databases andbyXML offer complementary functionality storing data. Whereas databases store data for efficient McGraw-Hill/Osborne © 2004exchange (600 pages) that enables interoperability between applications due to its retrieval, XML offers an easy information ability to encapsulate the data withguide the metadata. Oracle9i, and, to within an even largerXML-enabled extent, Oracle Database This comprehensive focuses onOracle8i, utilizing XML technologies Oracle's products, with on XML standards, their XML-enabled usage and best practices. Storing XML collections in databases 10g enable youemphasis to store XML natively and build applications. enables you to benefit from not only the full power of a SQL engine but also database administration, business intelligence, and recovery tools and procedures, such as Oracle Enterprise Manager, Discoverer, and RMAN. You Table of Contents can use them enforce about data and&security, block operations compromise Oracle Databaseto 10g XML &rules SQL—Design, Build Manage and XML to Applications in Java,that C, C++ & PL/SQLdata integrity by embedding rules and logic in a database. Also, converting database tables into XML documents enables you to take Introduction advantage of XML’s features while preserving SQL data types, indexes, and enterprise-level scalability. You can Part I - Oracle and the XML Standards present XML documents as HTML pages with XSLT stylesheets, search them using XML-based query languages, or Chapter 1 - Introducing XML use them as a data-exchange format.

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 object-relational - Transforming XML with have XSLT been and XPath Oracle’s features extended to support hierarchical storage thus enabling you to capture Chapter 4 - Validating withdata. DTDsYou andcan XMLoperate Schemas the complex structure XML of XML and manage XML data on a desired level of granularity which Chapter 5 - readily XML Operations withconstruct XQuery dynamic XML documents from the stored fragments. You can also store lends itself to efficiently Chapter 6 - XML Messaging and RPC with XML documents in a new XMLType dataSOAP type that supports storing XML as a single document in a virtually Chapter unbounded 7 - Putting text data It type All Together called Character with XML Pipeline, Large Object JSPs, (CLOB), and XSQLas data without tags distributed in object-relational Part tables II -or Oracle as both. XMLYou Management can use Oracle for DBAs Text to perform searches on XML documents stored in CLOBs.

Chapter 8

- Getting Started with the Oracle XML Database

Note A CLOB is one of the Oracle internal Large Objects (LOBs) whose value is composed of character data Chapter 9 - Storing XML Data and can store up to 4GB of data. Meanwhile, a VARCHAR2 column in a table has a limit of 4000 bytes, Chapter 10 - Generating and Retrieving XML and a VARCHAR2 in a PL/SQL variable has a limit of 32767 bytes (32K). Chapter 11 - Searching XML Data

Chapter - Managing thetoOracle CLOBs12 can be indexed searchXML theDatabase XML as plain text or as document sections for more precise searches. For Part III - Oracle XML forOracle Java Developers example, you can find WITHIN <title>, ignoring it elsewhere in the document. Oracle Text also provides full-

Chapter 13 - Getting Started with XML and text indexing of documents and Oracle the capability toJava do SQL queries over documents, along with XPATH-like searching. Chapter - Building an XML-Powered Web Site Finally,14 Oracle’s Advanced Queuing (AQ) now supports XML-based message queuing in the database, supporting Chapter both synchronous 15 - Creating and a Portal asynchronous Site with XML communications and Web Services of XML messages defined in the standard Simple Object

Access16 Protocol (SOAP) for both Application the server and Chapter - Developing anformat XML Gateway with client. SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML &Documents SQL: Design, Build & Manage XML Applications in Java, C, C++ & Database Oracle Schema and XML PL/SQL

by consist Mark V.ofScardina, Chang to and Jinyu Wang XML documents text thatBen conforms a hierarchy or tree structure specified by a DTD or XMLISBN:0072229527 Schema. © 2004 (600 pages)you can easily store this hierarchical data in an optimal internal As distinct fromMcGraw-Hill/Osborne other strictly relational databases, form using Oracle’s object-relational tables, which as XML the foundation forwithin the native XMLType storage. All the with This comprehensive guide focuses onserve utilizing technologies Oracle's XML-enabled products, emphasis on applications XML standards, andinformation best practices. existing and future internal cantheir workusage with the in the most efficient way possible. When you retrieve information, for sharing with partners or other applications, you can present the appropriate view of data and document content specific to the task at hand as integrated XML. These XMLType views enable you to present data Table of Contents in any number “logical” hiding& any details ofApplications their underlying physical storage. You can effectively Oracle Database of 10g XML & combinations, SQL—Design, Build Manage XML in Java, C, C++ & PL/SQL transform the structure of one or more underlying tables into a more useful or more appropriate structure for the Introduction demands of a specific application. When you link views of information with other views of related information, they Part I - Oracle and the XML Standards quite naturally form “trees” or “graphs” of related data. When you represent database information as XML, the Chapter 1 - Introducing XML previous related views provide the foundation for many different tree-structured XML documents. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 offer - Transforming XML withofXSLT XPath table would be expressed as an XML DTD: Here, we a simple example how and a database Chapter 4

- Validating XML with DTDs and XML Schemas

<!DOCTYPE table [ - XML Operations with XQuery <!ELEMENT table (rows)*> Chapter 6 - XMLrows Messaging and RPCcolumn2, with SOAP ...)> <!ELEMENT (column1, Chapter 7 Putting It All Together with <!ELEMENT column1 (#PCDATA)>XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs <!ELEMENT column2 (#PCDATA)> Chapter 8 Getting Started with the Oracle XML Database ...]> Chapter 5

Chapter 9

- Storing XML Data

Note, however, that theand actual data types Chapter 10 - Generating Retrieving XML in these columns remain unspecified. We can instead use an XML Schema following form: Chapter 11of- the Searching XML Data Chapter <xs:element 12 - Managing name="table"> the Oracle XML Database Part <xs:sequence> III - Oracle XML for Java Developers

<xs:element Chapter 13 - Gettingname="rows"> Started with Oracle XML and Java <xs:sequence > XML-Powered Web Site Chapter 14 - Building an <xs:element name="column1" type="xs:integer" xdb:SQLType="NUMBER"/> Chapter 15 - Creating a Portal Site with XML and Web Services <xs:element name="column2" xdb:SQLType="CLOB"/> Chapter 16 - Developing an XML Gatewaytype="xs:string" Application with SOAP and AQ . . . Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

This does provide us with the column data types through the type attribute which can further constrain the data as we will discuss later in the database chapters. However, a database provides even more capability to express rules Chapter 19 - Building an XML-Managed Application than does a DTD or an XML Schema. The database schema defines type information and constraints—not only Chapter - Build ansuch XML Database OCI Application simple 20 constraints, as permissible value ranges, but also constraints between columns and tables. A database Chapter 21 Create an XML-Configured High-Performance Transformation Engine schema enables you to define relationships or dependencies. For example, your e-commerce business might Part V Oracle XML for C++ Developers receive orders as XML documents. By using a database, you can link customer and order information, and define a Chapter 22 -not Getting Startedorders with Oracle XML and C++ In spite of the limitations in DTDs or XML Schemas, mapping rule about processing for closed accounts. Chapter 23 - Build an XML C++ Application a database schema to a Database DTD or anOCI XML Schema presents the database as a virtual XML document to the tools that Chapter 24 -documents Building an as XML Data-Retrieval Application need XML input. Chapter 18 - Getting Started with Oracle XML and C

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Mapping XML Documents to a Database Schema

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending PL/SQL XMLassociated Functionality with When mapping XML documents with an Java XML DTD or an XSD to a database schema for the purpose of Chapter - Putting It Allthree Together storing 28 XML in Oracle, basic strategies exist: Appendix

- XML Standards Bodies and Open Specifications

Map the complete XML document as a single, intact object, such as an XMLType CLOB. Glossary Index

Store the data in relational or object-relational tables and create XMLType views over the data to present it as

List ofan Figures XML document. List of Tables

XML documents to an Oracle Native XMLType. List ofMap Sidebars You can choose one of the previous approaches, depending on the structure of the XML document and the operations performed by the application. Each of these three approaches is described in turn next. You can also store the XML DTD or Schema in the database to validate the XML documents.

XML Documents Stored As XMLType CLOBs Storing an intact XML document in an XMLType CLOB is a good strategy if the XML document contains static


content that will only be retrieved as a whole or updated by replacing the entire document. Examples include written text such as articles, advertisements, books, legal briefs, and contracts. Applications that use a repository of this nature are known as document-centric and&operate on the stored outside theApplications database. Storing thisC,kind of& Oracle Database 10g XML SQL: Design, Build &XML Manage XML in Java, C++ document intact within OracleX gives you the advantages of an industry-proven database and its reliability over file PL/SQL system storage. XML documents checked Text can byUpon Mark insertion, V. Scardina, Ben Chang andare Jinyu Wang and only committed if well formed. OracleISBN:0072229527 provide both content and path indexes to search, but data retrievals need to be done by processing the whole McGraw-Hill/Osborne © 2004 (600 pages) document. TheThis Oracle XML Developer’s Kit (XDK) providesXML the technologies functionality within to use Oracle's standards-based interfaces to with comprehensive guide focuses on utilizing XML-enabled products, access, modify,emphasis transform, these documents. on and XML validate standards, their usage and best practices. XMLType CLOBs can also be used in conjunction with XMLType views and the Native XMLType described in the

Table of Contents following sections. In these cases, the XML is a well-formed fragment that is treated as a whole.

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction XML Documents Stored As XMLType Views Part I - Oracle and the XML Standards

When an is XML using XML merely as an encapsulation of its data, it is considered to be data-centric. Chapter 1 application - Introducing Typically, XML document elements and StAX attributes that have complex structures, but in reality this Chapter 2 the - Accessing XML withcontains DOM, SAX, JAXB, and structure simply metadata convey Chapter 3 is - Transforming XMLtowith XSLTthe andactual XPathdata of interest. Examples of this kind of document include sales orders,4invoices, and airline flight schedules. this case, there is value to maintaining the storage as SQL data Chapter - Validating XML with DTDs and XMLInSchemas

because the actual data types need to be exposed to the application. Oracle Database 10g, with its XMLType - XML Operations with XQuery object-relational extensions, has the capability to capture the structure of the data in the database present it in an Chapter 6 - XML Messaging and RPC with SOAP XMLType view while still you can easily update, query, rearrange, and reformat as needed using SQL. The important Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL distinction to remember is that this view cannot convey document order, comments, processing instructions, or the Part II - Oracle XML Management for DBAs whitespace between elements and attributes that are preserved in the CLOB type. Chapter 5

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 - Storing XMLisData Using XMLType views especially useful when you are XML-enabling existing applications or database schemas. Chapter 10 can - Generating Retrieving XML This view serve to and abstract the underlying database schema, thereby eliminating the need to modify it to support Chapter XML. In11fact, - Searching since youXML canData have multiple views of differing XML structure over the same database schema, you can

directly12 support a different XML schema for each view without the need to apply XSL to transform the documents to Chapter - Managing the Oracle XML Database a structure compatible database schema. Part III - Oracle XML forwith Javayour Developers Chapter 13 - Getting Started with Oracle XML and Java

Applications built against XMLType views have the flexibility of using SQL and SQL-XML interfaces to process within the database and using the XDK to process either in JServer, middle tier, or client.

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

XML Documents Stored As Native XMLTypes

Chapter 17 - Developing XML-Based Reusable Components

Part IV - you Oracle foran C Developers Finally, canXML store XML document as a NativeXMLType, where the underlying storage is dictated and created

Chapter 18 - schema. Getting Started with Oracle XML and C of the other two types together because it stores the XML as SQL by its XML This type has the advantages Chapter data and 19preserves - Building byte-for-byte an XML-Managed fidelity. Application Creating this native type is as simple as registering its XML schema, which

not only20creates underlying database schema but also creates a database resource that can be used for access Chapter - Buildthe an XML Database OCI Application and updates with the protocols HTTP,Transformation FTP, and WebDAV. Chapter 21 - Create an Internet-standard XML-Configured High-Performance Engine Part V - Oracle XML for C++ Developers

Applications that need both a document and data view can make full use of this type, because an extensive array of SQL, PL/SQL, Java, C, and C++ interfaces is available. Inserts, updates, and deletes are simplified due to Native Chapter 23 - Build an XML Database OCI C++ Application XMLType’s support for query rewrites, thereby eliminating the triggers needed by the XMLType views. The Native Chapter 24 - Building an XML Data-Retrieval Application XMLType can, however, be used in conjunction with these views to expose differing or subset XML documents. To Part VI - Oracle XML for PL/SQL Developers further support large documents, a “virtual” or “lazy” DOM is provided through the XDK to access only those Chapter 25 - Getting Started with Oracle XML and PL/SQL elements that are needed at any one time. Chapter 22 - Getting Started with Oracle XML and C++

Chapter 26 - Building PL/SQL Web Services

Chapter While the 27 native - Extending XMLType PL/SQL exposes XML Functionality broad functionality, with Javayou need to remember that the underlying storage is

intimately to theItXML schema that created it. Therefore, it will most likely not be the best choice for applications Chapter 28 -tied Putting All Together that need to support multiple schemas or a nontrivial evolving schema. Appendix - XML Standards Bodies and Open Specifications Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 byyou Mark V. differing Scardina,strategies Ben Chang Oracle provides with to and mapJinyu XMLWang documents into a database schema. Since XML is an McGraw-Hill/Osborne © 2004 (600 pages) enabling technology and not an application, there is no one strategy that will work optimally for all scenarios. XML is an abstraction This borncomprehensive from the need guide to exchange or data an interoperable XML’s cost isproducts, the focuses content on utilizing XML in technologies within manner. Oracle's XML-enabled with emphasis on XML its standards, and best increased overhead to process structuretheir andusage tags, thus yourpractices. correct selection of XML storage model will have a significant performance impact on your application. In later chapters, we will walk you through the process of using eachofofContents these strategies with appropriate example applications. Table

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 2: Accessing XML w ith DOM, SAX, JAXB, and PL/SQL ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang StAX by McGraw-Hill/Osborne © 2004 (600 pages) comprehensive guidetechnologies focuses on utilizing XML technologies Oracle's XML-enabled products, with The importanceThis of XML and its related being open standards is within that components, libraries, and emphasis on XML standards, their usage and best practices. applications built to these standards have the potential for a high level of interoperability and reuse. To parse and access XML documents, you can call upon a number of components and utilities. You can use the W3C-specified Table of Contents Document Object Model (DOM) APIs to query and manipulate a parsed document or create a new document from Oracle Database 10g XML SQL—Design, Manage XML Applications in Java, C, C++ & PL/SQL scratch. You can use the& Simple API forBuild XML&(SAX) event-based APIs for the same purpose without building a fullIntroduction blown DOM tree in memory. You can use the Sun Microsystems Java Extension standard Java Architecture for XML Part Binding I - Oracle (JAXB) and APIs the to XML generate Standards Java code from an XML Schema, which enables you to create and access a conformant XML document. Chapter 1 - Introducing XML Finally, the Sun Microsystems Java Extension standard Streaming API for XML (StAX)APIs enable you to with perform stream parsing onStAX an XML document in a manner that is similar to, yet simpler Chapter 2 - Accessing XML DOM, SAX, JAXB, and than, using SAX. The following sections discuss parsing and various accessor APIs and provide examples of how to Chapter 3 - Transforming XML with XSLT and XPath use them. Chapter 4 - Validating XML with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

Parsing - XML and Messaging Binding and RPC anwith XML SOAPDocument

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Application programs invoke the for parse function to read an XML document and provide access to its content and Part II - Oracle XML Management DBAs structure DOM orStarted SAX APIs. Usually, and termination functions must also be invoked in association Chapter 8 by - Getting with the Oracleinitialization XML Database

with the parse function. Note that various flags, such as to discard white space and to turn on validation, can be set - Storing XML Data with some initialization functions before the parse function is invoked by the application program. For example, Chapter 10 - Generating and Retrieving XML whereas some XML parsers are only nonvalidating, meaning they cannot check to see whether the XML document Chapter 11 - Searching XML Data conforms to the DTD or XML Schema, other parsers, such as those from Oracle, have optional validation, meaning Chapter 12 - Managing the Oracle XML Database users can specify validation or nonvalidation before invoking the parse function. In addition, the parse routine must Part III - Oracle XML for Java Developers be able to accept different language encodings as specified in the XML document. Chapter 9

Chapter 13 - Getting Started with Oracle XML and Java

Chapter 14 - XML Building an XML-Powered Web Site for Java programmers to extend their existing Java applications TheOracle Parser for Java makes it easy Chapter seamlessly 15 - Creating to support a Portal XML. It Site processes with XMLXML and Web documents Services and provides access to the information contained in them

through16a -variety of user-friendly APIs. The parser fully Chapter Developing an XML Gateway Application with supports SOAP andboth AQ the tree-based DOM and event-based SAX standards. also has aXML-Based built-in XSLT processor that makes transforming XML documents from one format to Chapter 17 - It Developing Reusable Components another extremely The parser can be used in any environment that supports JDK 1.2.x or higher, and it can Part IV - Oracle XMLsimple. for C Developers also be18 run- Getting inside the Oracle9i Oracle 10g OJVM. The parser is completely internationalized and Chapter Started with and Oracle XML Database and C supports character set supported by Java, in addition to numerous others. This support means that the parser Chapter 19every - Building an XML-Managed Application provides messages in nearly OCI every language supported by Oracle9i and Oracle Database 10g, making it an Chapter 20error - Build an XML Database Application invaluable tool if you’re writing XML applications for non–English- speaking users.

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

TheOracle XML Parser for C with its integrated XSLT processor is provided in two forms: as a stand-alone,

Chapter 22 - Getting Started and with as Oracle XML for andlinking C++ with applications. Most users write their own applications and command-line executable, a library Chapter - Build an XML OCI Application use the23 XML library. The Database executable is C++ provided as a quick way to familiarize new users with XML by parsing and Chapter 24 -their Building an XML Data-Retrieval validating own test documents, and it Application is also used to apply stylesheets to the XML document. Part VI - Oracle XML for PL/SQL Developers

The C library contains APIswith for initializing, a file or buffer, resetting and shutting down the parser, plus full Chapter 25 - Getting Started Oracle XMLparsing and PL/SQL DOM, SAX, and XSLT implementations. Chapter 26 - Building PL/SQL Web Services Typically, you would use the following sequence: initialize(), parse(), terminate(). If multiple PL/SQL documents to be parsed, the sequence would beinitialize(), parse(), parse(), …, Chapter 27 - Extending XML are Functionality with Java terminate(). All dataItpresented by a parse remains valid until termination or cleanup. If you need only the results on Chapter 28 - Putting All Together each parse- XML without retaining older data, the sequence would beinitialize(), parse(), clean(), parse(), clean(),…, Standards Bodies and Open Specifications terminate().To apply stylesheets to the XML documents, an additional call to xslprocess before terminate() or Glossary clean() would be necessary. See the C header, xml.h, in the XDK distribution for details on available functions. Appendix Index

List Figures TheofOracle XML Parser for C++ calls the C parser with a wrapper to make it accessible from C++, with both List of Tables interfaces provided in the same XML library, oraxml10.lib or libxml10.a. Everything about the C APIs holds true for List Sidebars theofC++ APIs, except that the C++ APIs are able to provide APIs in an object-oriented manner corresponding to the

class and method names in the DOM specification. See the C++ header, xml.hpp, for details on available functions. Finally, functionality exists by way of class generators in both Java and C++ to automate the mapping between XML documents and code, so that generated code can create, access, update, and validate XML documents against XML Schema. Among the advantages are speed (the generated code is easily generated from input schema), ease of use (application programmers can easily call these generated routines rather than code their own), and data conversion (XML document data can be converted to that language’s data types). Using this type of functionality makes marshalling and unmarshalling XML content back and forth into the language representation very easy and


facilitates the programming of XML applications. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database XMLDOM & SQL: Design, Build & Manage XML Applications in Java, C, C++ & AccessingOracle XML Using10g the PL/SQL

ISBN:0072229527 V. Scardina, Ben Chang andresembles Jinyu Wang DOM is based by onMark an object structure that closely the structure of the documents it models. For instance, McGraw-Hill/Osborne © 2004 (600 pages) consider the following XML document:

<booklist> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. <book isbn="0-07-213495-X"> <title>Oracle9i XML Handbook</title> Table of Contents <author>Chang, Scardina and Kiritzov</author> Oracle <publisher>Osborne</publisher> Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <price>49.99</price> Introduction </book> Part I - Oracle and the XML Standards </booklist> Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

In DOM, documents have a logical structure that is similar to a tree, also known as a structure model. In the Chapter 3 - Transforming XML with XSLT and XPath example document, you can see the root element booklist serves as the root of the DOM tree, as you would Chapter 4 - Validating XML with DTDs and XML Schemas expect. The root element contains one child, book, which has four children: title,author,publisher, and price; and Chapter 5 - XML Operations with XQuery one attribute, ISBN. The leaf nodes of the tree are simple text string values. The nodes in the DOM tree can be Chapter 6 - XML Messaging and RPC with SOAP reached by using tree-walking methods (this does not include attributes). One important property of DOM structure Chapter Putting Itisomorphism: All Together with XML JSPs, and XSQL are used to create a representation of the same models7is -structural if any twoPipeline, DOM implementations Part II Oracle XML Management for DBAs document, they create the same structure model. This means implementations are free to choose any data structure Chapter 8 - Getting Started with the Oracle Database (not necessarily a tree) to implement DOM.XML When the XML parser parses the XML document, such a representation Chapter - Storing XML Data can be 9formed in memory. Chapter 10 - Generating and Retrieving XML

W3C has a set of DOM Chapter 11 created - Searching XML Data APIs for accessing and navigating this structure. Again, the components of this structure the root the element ofXML the document; Chapter 12 are - Managing Oracle Database elements; attributes; text nodes that represent the textual content of an element or attribute; CDATA sections to mark off blocks of text that would otherwise be regarded as markup; Part III - Oracle XML for Java Developers comments; entity references; processing instructions; Chapter 13 - Getting Started with Oracle XML and Java and so forth. XML parsers that provide all the DOM APIs are considered to be compliant with the W3C DOM recommendation.

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services The following Java code sample demonstrates a simple use of the parser and DOM APIs. This sample Chapter 16 - Developing anparser XML Gateway and AQ demonstrates how to set options,Application parse the with XMLSOAP file given to the application, and print the element nodes Chapter 17 - Developing XML-Based Reusable Components and attribute values in the document. Part IV - Oracle XML for C Developers

import java.io.*; import java.net.*; Chapter 19org.w3c.dom.*; - Building an XML-Managed Application import Chapter 20 - Build an XML Database OCI Application import org.w3c.dom.Node; Chapter 21 - Create an XML-Configured High-Performance Transformation Engine import oracle.xml.parser.v2.*; Chapter 18 - Getting Started with Oracle XML and C

Part V - Oracle XML for C++ Developers

Chapter 22class - Getting Started with{Oracle XML and C++ public DOMSample Chapter 23 -public Build an XML OCI C++ Application static voidDatabase main(String[] argv){ Chapter try 24 { - Building an XML Data-Retrieval Application Part VI if- Oracle (argv.length XML for PL/SQL != 1){ Developers

// pass in the name XML of the XML file. Chapter 25Must - Getting Started with Oracle and PL/SQL System.err.println("Usage: Chapter 26 - Building PL/SQL Web Services java DOMSample filename"); System.exit(1); Chapter 27 - Extending PL/SQL XML Functionality with Java } 28 - Putting It All Together Chapter Appendix

- XML Standards Bodies and Open Specifications

// Get an instance of the parser DOMParser parser = new DOMParser();

Glossary Index

List of Figures

// Generate a URL from the filename. URL url = createURL(argv[0]);

List of Tables

List of Sidebars

// Set various parser options: validation on, // warnings shown, error stream set to stderr. parser.setErrorStream(System.err); parser.showWarnings(true); // Parse the document. parser.parse(url);


// Obtain the document. Document doc = parser.getDocument(); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

// PrintPL/SQL document elements System.out.print("The elements ");Wang by Mark V. Scardina, Ben Changare: and Jinyu printElements(doc); McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

// Printemphasis document element attributes on XML standards, their usage and best practices. System.out.println("The attributes of each element are: "); printElementAttributes(doc); Table of Contents } Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL catch (Exception e){ Introduction System.out.println(e.toString()); Part I - Oracle and the XML Standards } Chapter 1 - Introducing XML } Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 - Transforming XML with XSLT and XPathdoc) { static void printElements(Document Chapter 4 - Validating with DTDs and XML Schemas NodeList nl = XML doc.getElementsByTagName("*"); Chapter 5 -n; XML Operations with XQuery Node Chapter 6

- XML Messaging and RPC with SOAP

Chapter for 7 (int - Putting i=0; It Alli<nl.getLength(); Together with XML Pipeline, i++){ JSPs, and XSQL Part IIn- Oracle = nl.item(i); XML Management for DBAs

System.out.print(n.getNodeName() + " "); Chapter 8 - Getting Started with the Oracle XML Database } 9 Chapter

- Storing XML Data

System.out.println(); Chapter 10 - Generating and Retrieving XML } 11 - Searching XML Data Chapter Chapter 12 - Managing the Oracle XML Database

void Partstatic III - Oracle XMLprintElementAttributes(Document for Java Developers

doc){ NodeList nl = doc.getElementsByTagName("*"); Chapter 13 - Getting Started with Oracle XML and Java Element e; Chapter 14 - Building an XML-Powered Web Site Node n; Chapter 15 - Creating a Portal Site with XML and Web Services NamedNodeMap nnm; Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

String attrname; String attrval; Chapter 18i, - Getting int len; Started with Oracle XML and C Part IV - Oracle XML for C Developers

Chapter 19 - Building an XML-Managed Application Chapter 20=- Build an XML Database OCI Application len nl.getLength(); Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part Vfor - Oracle for C++ (intXML j=0; j <Developers len; j++){

Chapter Getting Started with Oracle XML and C++ e 22 = -(Element)nl.item(j); Chapter System.out.println(e.getTagName() 23 - Build an XML Database OCI C++ Application + ":");

nnm e.getAttributes(); Chapter 24 -=Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

if != Started null){ Chapter 25(nnm - Getting with Oracle XML and PL/SQL (i=0; PL/SQL i<nnm.getLength(); i++){ Chapter for 26 - Building Web Services n -=Extending nnm.item(i); Chapter 27 PL/SQL XML Functionality with Java attrname Chapter 28 - Putting It=Alln.getNodeName(); Together attrval = n.getNodeValue(); - XML Standards Bodies and Open Specifications System.out.print(" " + attrname + " = " + attrval); Glossary } Index } List of Figures System.out.println(); List of Tables } List } of Sidebars } Appendix


Oracle Database XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Introducing the DOM 10g APIs PL/SQL

by Mark Scardina, Ben Chang and Jinyu Wangto an in-memory structure representation ofISBN:0072229527 The power of the DOMV. lies in its capability to provide access the entire McGraw-Hill/Osborne © 2004 (600 can pages) XML document. Using the DOM, applications perform tasks such as searching for specific data in an XML document, adding deleting elements attributes in theXML XMLtechnologies document, within and transforming the DOM to an This or comprehensive guideand focuses on utilizing Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. entirely different document. Along with the org.w3c.dom interfaces provided by W3C, the Oracle Java XML parser comes with a set of classes that implement the DOM APIs and extend them to provide other useful features, such as printing a document fragment or retrieving namespace information. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

The following code demonstrates some of the DOM functionality in an XML parser:

Introduction

// IThis example demonstrates Part - Oracle and the XML Standards

a simple use of the DOMParser // An XML file is parsed and some information is printed out. Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 9

- Storing XML Data

import java.io.*; Chapter 3 - Transforming XML with XSLT and XPath import java.net.*; Chapter 4 - Validating XML with DTDs and XML Schemas import oracle.xml.parser.v2.DOMParser; Chapter 5 - XML Operations with XQuery import org.w3c.dom.*; Chapter 6 org.w3c.dom.Node; - XML Messaging and RPC with SOAP import Chapter 7 - Putting to It AllDOM Together with XML for Pipeline, JSPs, and XSQL // Extensions Interfaces Namespace support. Part II Oracle XML Management for DBAs import oracle.xml.parser.v2.XMLElement; Chapter 8 oracle.xml.parser.v2.XMLAttr; - Getting Started with the Oracle XML Database import Chapter 10class - Generating and Retrieving XML public DOMExample { Chapter public 11 -static Searching void XML Data main(String[] argv){

try 12 { - Managing the Oracle XML Database Chapter // - Generate a new stream Part III Oracle XML for Java input Developers

from given file

FileInputStream = new Chapter 13 - Getting Startedxmldoc with Oracle XML FileInputStream(argv[0]); and Java Chapter 14 - Building an XML-Powered Web Site

// 15 Parse the adocument using Chapter - Creating Portal Site with XML DOMParser and Web Services DOMParser parser = new DOMParser(); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ parser.parse(xmldoc);

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

// Obtain the document. Document doc = parser.getDocument();

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application

// Print some information regarding attributes of elements // in the document Part V - Oracle XML for C++ Developers printElementAttributes(doc); Chapter } 22 - Getting Started with Oracle XML and C++ Chapter 23 -(Exception Build an XML Database OCI C++ Application catch e){ Chapter 24 - Building an XML Data-Retrieval Application System.out.println(e.toString()); Part}VI - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL } Chapter 26 -void Building PL/SQL Web Services static printElementAttributes(Document doc){ Chapter NodeList 27 - Extending nl = doc.getElementsByTagName("*"); PL/SQL XML Functionality with Java Element e; It All Together Chapter 28 - Putting XMLAttr nsAttr; Appendix - XML Standards Bodies and Open Specifications String attrname, attrval, attrqname; NamedNodeMap nnm; Glossary Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Index

(int j=0; j < nl.getLength(); j++) { List for of Figures e = (Element) nl.item(j); System.out.println(e.getTagName() + ":"); List of Sidebars nnm = e.getAttributes(); List of Tables

if (nnm != null) { for (int i=0; i < nnm.getLength(); i++) { nsAttr = (XMLAttr) nnm.item(i); // Use the methods getQualifiedName(), getLocalName(), // getNamespace(), and getExpandedName() in NSName


// interface to get Namespace information. attrname = nsAttr.getExpandedName( Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & attrqname = nsAttr.getQualifiedName(); PL/SQL attrval = nsAttr.getNodeValue(); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

System.out.println(" " + attrqname + "(" + attrname + This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with ")" +emphasis " = " +attrval); on XML standards, their usage and best practices. } } Table of Contents System.out.println(); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL } Introduction } Part I - Oracle and the XML Standards }. Chapter 1

- Introducing XML

Chapter 2 -APIs, Accessing andonly StAX The DOM unlikeXML thewith SAXDOM, APIs,SAX, can JAXB, be used after the XML document is completely parsed. The downside Chapter of this is 3 that - Transforming large XML documents XML with XSLT can and occupy XPath a lot of memory, which could ultimately affect the performance of

your application. In pure functionality terms, however, Chapter 4 - Validating XML with DTDs and XML Schemasthe DOM APIs are definitely more powerful. The first thing you need to5do- before you beginwith using any of the DOM APIs is to parse your document using a new instance of Chapter XML Operations XQuery DOMParser: Chapter 6 - XML Messaging and RPC with SOAP Chapter 7

- Putting // Parse It All the Together document with XMLusing Pipeline, DOMParser JSPs, and XSQL

Part II - Oracle DOMParser XML Management parser for=DBAs new

DOMParser();

Chapter 8

parser.parse(xmldoc); - Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Then, you need to request the parser to return a handle to the root of the Document Object Model, which it has constructed in memory:

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

// Obtain the document. Chapter 12 - Managing the Oracle XML Database Document doc Developers = parser.getDocument(); Part III - Oracle XML for Java Chapter 13 - Getting Started with Oracle XML and Java

Using the preceding handle, you can access every part of the XML document you just parsed. The DOMExample class assumes you want to access the elements in the document and their attributes. To do this, you first need to Chapter 15 - Creating a Portal Site with XML and Web Services obtain a list of all the elements in the document. A DOM method called getElementsByTagName enables you to Chapter 16recursively, - Developing XML Gateway Application AQ a certain level. It also supports a special tag retrieve, allan elements that match a givenwith tagSOAP nameand under Chapter 17 Developing XML-Based Reusable Components named“*”, which matches any tag. Given this information, you need to invoke this method at the top level of the Part IV - Oracle XML for C Developers document via the handle to the root you obtained earlier in this section: Chapter 14 - Building an XML-Powered Web Site

Chapter 18 - Getting Started with Oracle XML and C

NodeList nl = doc.getElementsByTagName("*");

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build angenerates XML Database The preceding call a list OCI of allApplication the elements in the document. Each of these elements contains the Chapter 21 - Create an XML-Configured Transformation Engine information regarding its attributes. ToHigh-Performance access this information, you need to traverse this list: Part V - Oracle XML for C++ Developers

len = nl.getLength();

Chapter 22 - Getting with for (int Started j=0; j < Oracle len; XML j++)and{ C++ Chapter 23e- Build an XML Database OCI C++ Application = (Element) nl.item(j); Chapter 24 - Building an XML Data-Retrieval Application ... Part VI - Oracle XML for PL/SQL Developers }

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

To obtain attributes of each element in the loop, you can use a DOM method called getAttributes. This method Chapter 27 the - Extending PL/SQL XML Functionality with Java generates specialItkind of DOM list called NamedNodeMap. Once you obtain this list, traversing it to obtain Chapter 28 -aPutting All Together information- XML aboutStandards the attributes themselves is straightforward. Bodies and Open Specifications

Appendix Glossary

DOM Level 2

Index

List of Figures

As DOM evolved into Level 2, it became a modular specification, meaning that some of the new APIs can be standalone modules. Though the specifications are “Level 2,” they are actually 1.0 versions, which can be confusing, List of Sidebars especially when the same DOM Core names are reused. In addition to DOM Level 2 Core, there are Events, Style, HTML, Traversal and Range, and Views modules. References to these specifications can be found in the appendix of this book. List of Tables

The introduction of XML namespaces was the primary force behind the development of the DOM Core Level 2 specification, because all the element and attribute functions now had to accept or retrieve namespaces. The following snippet uses the Oracle XML Parser’s DOM 2.0 XML Namespace support to retrieve additional information regarding the attributes of each element:


for (int i=0; i < nnm.getLength(); i++){ nsAttr = (XMLAttr) nnm.item(i); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

// Use thePL/SQL methods getQualifiedName() and getExpandedName() // in NSName interface to Ben getChang Namespace by Mark V. Scardina, and Jinyuinformation. Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

attrname =This nsAttr.getExpandedName(); comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with attrqname emphasis = nsAttr.getQualifiedName(); on XML standards, their usage and best practices. attrval = nsAttr.getNodeValue(); Table of Contents

System.out.println(" " + attrqname + "(" + attrname + ")" + " = " + attrval);

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

}

Part I - Oracle and the XML Standards

Chapter 1 of - Introducing XMLif the XML document you have to parse has elements with many attributes that belong to This kind code is useful Chapter 2 namespaces. - Accessing XML DOM, suppose SAX, JAXB, StAX XML document from the preceding section looked like different Forwith example, theand booklist Chapter this: 3

- Transforming XML with XSLT and XPath

Chapter 4 - Validating XML with DTDs and XML Schemas <booklist xmlns:osborne="http://www.osborne.com" Chapter 5

- XML Operations with XQuery xmlns:bookguild="http://www.bookguild.com"

Chapter 6

- XML Messaging and RPC with SOAP xmlns:dollars="http://www.currency.org/dollars">

Chapter <book 7 osborne:isbn="0-07-213495-X" - Putting It All Together with XML Pipeline, title="Oracle9i JSPs, and XSQL XML Handbook" Part II - Oracle author="Chang, XML Management Scardina, for DBAs

and Kiritzov" bookguild:publisher="Osborne"

Chapter 8 dollars:price="49.99"/> - Getting Started with the Oracle XML Database

<book title="Emperor's New Mind" Chapter 9 osborne:isbn="1230-23498-2349879" - Storing XML Data Penrose" bookguild:publisher="Oxford Publishing Chapter 10author="Roger - Generating and Retrieving XML Company" Chapter 11 - Searching XML Data Chapter 12dollars:price="15.99"/> - Managing the Oracle XML Database

</booklist> Part III - Oracle XML for Java Developers Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

The generated output with namespaces would look like this:

Chapter 15 - Creating a Portal Site with XML and Web Services

xmlns:osborne(http://www.w3.org/2000/xmlnls/:osborne)=http://www.osborne.com xmlns:bookguild(http://www.w3.org/2000/xmlns/:bookguild)=http://www.bookguild.com Chapter 17 - Developing XML-Based Reusable Components xmlns:dollars(http://www.w3.org/2000/xmlns/:dollars=http://www.currency.org/dollars Part IV - Oracle XML for C Developers book: Chapter 18 - Getting Started with Oracle XML and C osborne:isbn(http://www.osborne.com:isbn) = 0-07-213495-X Chapter 19 - Building=anOracle9i XML-Managed title(title) XMLApplication Handbook Chapter 20 Build an XML Database OCI Application author(author) = Chang, Scardina, and Kiritzov Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part TheVDOM - Oracle Level XML 2 Traversal for C++ Developers and Range functionality includes methods that create Iterators and TreeWalkers to

traverse andStarted its children in document order. Chapter 22a-node Getting with Oracle XML and C++Objects using a TreeWalker to navigate a document tree or subtree23 use the view of the document by their whatToShow flags and filters. An example of such stub code Chapter - Build an XML Database OCI defined C++ Application would be following: Chapter 24 the - Building an XML Data-Retrieval Application Part - Oracle XML for PL/SQL everything Developers // VI This filter accepts

Chapter NodeFilter 25 - Getting n1 =Started new nf1(); with Oracle XML and PL/SQL

// Node doesn't allow expansion of entity references Chapter 26 -iterator Building PL/SQL Web Services NodeIterator ni =PL/SQL XML Functionality with Java Chapter 27 - Extending doc.createNodeIterator(elems[0],NodeFilter.SHOW_ALL,n1,false); Chapter 28 - Putting It All Together // Move -forward Appendix XML Standards Bodies and Open Specifications XMLNode nn =(XMLNode) ni.nextNode(); Glossary while (nn != null){ System.out.println(nn.getNodeName() + " " + nn.getNodeValue()); List of Figures nn = (XMLNode)ni.nextNode(); List of Tables } List of Sidebars // Move backward nn = (XMLNode)ni.previousNode(); while (nn != null){ System.out.println(nn.getNodeName() + " " + nn.getNodeValue()); nn = (XMLNode)ni.previousNode(); } Index

// Node iterator allows expansion of entity references


ni = doc.createNodeIterator(elems[0],NodeFilter.SHOW_ALL,n1,true); // Move forward nn =(XMLNode) ni.nextNode(); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & while (nn != null){ PL/SQL System.out.println(nn.getNodeName() " "Wang + nn.getNodeValue()); ISBN:0072229527 by Mark V. Scardina, Ben Chang and+Jinyu nn = (XMLNode)ni.nextNode(); McGraw-Hill/Osborne © 2004 (600 pages) } This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with // Move backward emphasis on XML standards, their usage and best practices. nn = (XMLNode)ni.previousNode(); while (nn != null){ Table of Contents System.out.println(nn.getNodeName() + " " + nn.getNodeValue()); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL nn = (XMLNode)ni.previousNode(); Introduction } Part I - Oracle and the XML Standards

Chapter 1 -filter Introducing XML // This doesn't accept expansion of entity references Chapter 2 Accessing XML DOM, SAX, JAXB, and StAX NodeFilter n2 = new with nf2(); Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4 -iterator Validating XML with DTDs and XML of Schemas // Node allows expansion entity references Chapter 5 - XML Operations with XQuery ni = doc.createNodeIterator(elems[0],NodeFilter.SHOW_ALL,n2,true); Chapter // Move 6 -forward XML Messaging and RPC with SOAP

nn =(XMLNode) Chapter 7 - Putting ni.nextNode(); It All Together with XML Pipeline, JSPs, and XSQL while (nn != null){ Part II - Oracle XML Management for DBAs System.out.println(nn.getNodeName() + " " + nn.getNodeValue()); Chapter 8 - Getting Started with the Oracle XML Database nn = 9(XMLNode)ni.nextNode(); Chapter - Storing XML Data } Chapter 10 - Generating and Retrieving XML // Move Chapter 11 -backward Searching XML Data nn = (XMLNode)ni.previousNode(); while (nn != null){ Part III - Oracle XML for Java Developers System.out.println(nn.getNodeName() + " " + nn.getNodeValue()); Chapter 13 - Getting Started with Oracle XML and Java nn = (XMLNode)ni.previousNode(); Chapter 14 - Building an XML-Powered Web Site } Chapter 12 - Managing the Oracle XML Database

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

// After detaching, all node iterator methods throw an exception

Chapter 17 - Developing XML-Based Reusable Components ni.detach(); Part tryIV{- Oracle XML for C Developers

Chapter - Getting Started with Oracle XML and C nn = 18 (XMLNode)ni.nextNode(); Chapter 19 - Building an XML-Managed Application } Chapter 20 - Build an XML Database OCI Application catch(DOMException e) { Chapter 21 - Create an XML-Configured High-Performance Transformation Engine System.out.println(e.getMessage()); Part } V - Oracle XML for C++ Developers

Chapter try { 22 - Getting Started with Oracle XML and C++

nn = 23 (XMLNode)ni.previousNode(); Chapter - Build an XML Database OCI C++ Application } Chapter 24 - Building an XML Data-Retrieval Application catch(DOMException e){ Developers Part VI - Oracle XML for PL/SQL System.out.println(e.getMessage()); Chapter 25 - Getting Started with Oracle XML and PL/SQL } Chapter 26 - Building PL/SQL Web Services // TreeWalker allows of entity Chapter 27 - Extending PL/SQLexpansion XML Functionality with Javareferences TreeWalker tw = doc.createTreeWalker(elems[0],NodeFilter.SHOW_ALL,n1,true); Appendix - XML Standards Bodies and Open Specifications nn = (XMLNode)tw.getRoot(); Glossary // Traverse in document order Index while (nn != null) { List of Figures System.out.println(nn.getNodeName() + " " + nn.getNodeValue()); Listnn of Tables = (XMLNode)tw.nextNode(); List } of Sidebars Chapter 28 - Putting It All Together

tw = doc.createTreeWalker(elems[0],NodeFilter.SHOW_ALL,n1,true); nn = (XMLNode) tw.getRoot(); // Traverse the depth left while (nn != null){ System.out.println(nn.getNodeName() + " " + nn.getNodeValue()); nn = (XMLNode)tw.firstChild(); }


tw = doc.createTreeWalker(elems[0],NodeFilter.SHOW_ALL,n2,true); nn = (XMLNode)tw.getRoot(); // TraverseOracle in document order Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & while (nn != null){ PL/SQL System.out.println(nn.getNodeName() " "Wang + nn.getNodeValue()); ISBN:0072229527 by Mark V. Scardina, Ben Chang and+Jinyu nn = (XMLNode)tw.nextNode(); McGraw-Hill/Osborne © 2004 (600 pages) } This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with tw = doc.createTreeWalker(elems[0],NodeFilter.SHOW_ALL,n2,true); emphasis on XML standards, their usage and best practices. nn = (XMLNode) tw.getRoot(); // Traverse the depth right Table of Contents while (nn != null) { Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL System.out.println(nn.getNodeName() + " " + nn.getNodeValue()); Introduction nn = (XMLNode)tw.lastChild(); Part I - Oracle and the XML Standards } Chapter ... 1 - Introducing XML Chapter - Accessing XML with DOM, SAX, JAXB, and StAX class 2nf1 implements NodeFilter { Chapter 3 -short Transforming XML with XSLT and XPath public acceptNode(Node node) { Chapter 4 - Validating XML with DTDs and XML Schemas return FILTER_ACCEPT; Chapter 5 - XML Operations with XQuery } Chapter } 6 - XML Messaging and RPC with SOAP class 7nf2 implements NodeFilter Chapter - Putting It All Together with XML { Pipeline, JSPs, and XSQL public short Part II - Oracle XML acceptNode(Node Management for DBAsnode) { short = Started node.getNodeType(); Chapter 8 -type Getting with the Oracle XML Database Chapter 9

- Storing XML Data if ((type == Node.ELEMENT_NODE) || (type == Node.ATTRIBUTE_NODE)) Chapter 10 - Generating and Retrieving XML

return FILTER_ACCEPT; Chapter 11 - Searching XML Data if ((type == Node.ENTITY_REFERENCE_NODE)) return FILTER_REJECT; Part III - Oracle XML for Java Developers return FILTER_SKIP; Chapter 13 - Getting Started with Oracle XML and Java } Chapter 14 - Building an XML-Powered Web Site } Chapter 12 - Managing the Oracle XML Database

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

DOM Level 3

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

As in Level 2, the DOM Level 3 W3C Working Draft consists of DOM Level 3 modules of Core, Load and Save, Validation, Events, and XPath, which provide further functionality identified by DOM users as useful and necessary Chapter 19 - Building an XML-Managed Application for their applications. References to these can be found in the Appendix. Chapter 18 - Getting Started with Oracle XML and C

Chapter 20 - Build an XML Database OCI Application

Chapter - Create an XML-Configured High-Performance Engine A DOM21 application can use the hasFeature() method ofTransformation the DOMImplementation object to determine whether the Part V - Oracle XML for A C++ Developers module is supported. DOMImplementation object can be retrieved from a Document using the

Chapter 22 - Getting Started withExamples Oracle XML C++ getImplementation() method. ofand these feature strings for their respective modules are XML,HTML, Chapter Events, 23and - Build Validation. an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

TheVI basis of the DOM, as previously stated, is a tree consisting of Node objects. Different kinds of Nodes are used Part - Oracle XML for PL/SQL Developers

to represent an XML document: Document,Element,Attr,Text,DocumentFragment,DocumentType, ProcessingInstruction,Comment,CDATASection,EntityReference, and Notation. The DOM also defines some Chapter 26 - Building PL/SQL Web Services other types that represent a list of nodes—NodeList and NamedNodeMap—and introduces a DOMString type, Chapter 27 - Extending PL/SQL XML Functionality with Java which is a string of UTF-16 encoded characters. Finally, DOM introduces an exception type, DOMException, which Chapter 28 - Putting It All Together is raised by the various DOM interfaces if an erroneous operation is performed or if some other error occurred during Appendix - XML Standards Bodies and Open Specifications execution. Chapter 25 - Getting Started with Oracle XML and PL/SQL

Glossary

Index Table 2-1 and Table 2-2 list the DOM types and the corresponding types supported by the Oracle XML parsers for

Java, PL/SQL, C and C++. List of Figures List of Tables

Table 2-1: DOM Types with Corresponding Java and PL/SQL Oracle Types List of Sidebars


DOM Type Node Document

Java

PL/SQL

DOMNode Oracle Database 10g XMLXMLNode & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XMLDocument

DOMDocument

Element

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004XMLElement (600 pages)

Attr

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with XMLAttr DOMAttr emphasis on XML standards, their usage and best practices.

Text Table of Contents

DocumentFragment

ISBN:0072229527

DOMElement

XMLText

DOMText

XMLDocumentFragment

DOMDocumentFragment

XMLPI

DOMPI

DTD

XMLDTD

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction ProcessingInstruction Part I - Oracle and the XML Standards

DocumentType

Chapter 1

- Introducing XML

Chapter 2 - Accessing XML with DOM, SAX,XMLEntityReference JAXB, and StAX EntityReference Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Comment

XMLComment

Chapter CDATASection 5 - XML Operations with XQuery XMLCDATA Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

NodeList

XMLNodeList

Part NamedNodeMap II - Oracle XML Management for DBAsN/A (private class)

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Notation

XMLNotation

DOMString Chapter 10 - Generating and Retrieving XMLjava.lang.String Chapter 11 - Searching XML Data

DOMException

XMLDOMException

Chapter 12 - Managing the Oracle XML Database

DOMEntityReference DOMComment DOMCDataSection DOMNodeList DOMNamedNodeMap DOMNotation VARCHAR2 EXCEPTION

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

Table 2-2: DOM Types with Corresponding C and C++ Oracle Types

Chapter 14 - Building an XML-Powered Web Site

DOM 15 Type Chapter - Creating a Portal Site with XMLCand Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Node

xmlnode

NodeRef

xmldocnode

DocumentRef

Chapter 17 - Developing XML-Based Reusable Components Part Document IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

Element

C++

xmlelemnode

Chapter 19 - Building an XML-Managed Application

Attr 20 - Build an XML Database OCI Application xmlattrnode Chapter

ElementRef AttrRef

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Text

Part V - Oracle XML for C++ Developers

xmltextnode

DocumentFragment xmlfragnode Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

ProcessingInstruction

xmlpinode

Chapter 24 - Building an XML Data-Retrieval Application

DocumentType xmldtdnode Part VI - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

EntityReference

Chapter 26 - Building PL/SQL Web Services

xmlentrefnode

TextRef DocumentFragmentRef ProcessingInstructionRef DocumentTypeRef EntityReferenceRef

Comment xmlcommentnode Chapter 27 - Extending PL/SQL XML Functionality with Java

CommentRef

Chapter 28 - Putting It All Together

xmlcdatanode

CDATASectionRef

NodeList Glossary

xmlnodelist

NodeListRef

Index NamedNodeMap

xmlnamedmap

NamedNodeMapRef

ListNotation of Tables

xmlnotenode

NotationRef

ListDOMString of Sidebars

oratext *

DOMString

N/A

N/A

CDATASection

Appendix

- XML Standards Bodies and Open Specifications

List of Figures

DOMException

Oracle DOM APIs in C Because the DOM is an object-oriented specification and the C language is not object oriented, some changes had to be made. In particular, the C function namespace is flat, so the names of DOM methods that are the same in


several different classes have been changed to make them unique, as detailed in Table 2-3. Table 2-3: Oracle DOM APIs in10g C XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle Database DOM Name

PL/SQL

C Name

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) Attr::getName, ... XmlDomGetAttrName, ...

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

CharacterData::getData, ... emphasis on... XML standards, their usage and XmlDomGetCharData, best practices. DocumentType::getName, ... Table of Contents

Entity::getPublicId, ...

XmlDomGetDocTypeName, ... XmlDomGetEntityPublicID, ...

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction NamedNodeMap::item Part I - Oracle and the XML Standards

NamedNodeMap::getLength

Chapter 1

- Introducing XML

XmlDomGetChildNode XmlDomGetNodeMapLength

Chapter NodeList::item 2 - Accessing XML with DOM, SAX, JAXB, and StAX XmlDomGetChildNode Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

NodeList::getLength

Notation::getPublicId, ... with XQuery Chapter 5 - XML Operations Chapter 6

XmlDomGetNodeMapLength XmlDomGetNotationPubID, ...

- XML Messaging and RPC with SOAP

The documentation is included with thePipeline, C XDK details each of these functions and can also be seen in the Chapter 7 - Putting Itthat All Together with XML JSPs, and XSQL parser file, xml.h. Part II - header Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & AccessingOracle XML with SAX PL/SQL

ISBN:0072229527 Mark V. Scardina, Ben Chang and for Jinyu Wang Simple API for by XML (SAX) is a standard interface event-based XML parsing. This means that notification of © during 2004 (600 pages) certain events McGraw-Hill/Osborne and data encountered the parsing of the XML document can be reported by callback functions to the application On notification of these events, XML the application program then must deal with them. For with Thisprogram. comprehensive guide focuses on utilizing technologies within Oracle's XML-enabled products, emphasis on XML standards, and best practices. example, the application program can havetheir datausage structures using callback event handlers. Finally, the types of information and notifications passed back by these callback functions are in the vein of such things as the start and end of of elements Table Contents and information related to an element’s content, such as CDATA, processing instructions, and subelements. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Introduction

SAX, initially developed by David Megginson, has become a W3C XML standard. One advantage of using SAX parsing over using the DOM is that an in-memory representation of the parse structure doesn’t have to be built, thus Chapter 1 - Introducing XML saving memory and resulting in better performance for certain types of operations, such as searching. On the other Chapter 2 - Accessing XML with SAX, JAXB, StAX operations may be made more efficient by using a DOM hand, modifying, updating, and DOM, performing other and structural Chapter parser.3 - Transforming XML with XSLT and XPath Part I - Oracle and the XML Standards

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery SAX Level 1 and Level 2 - XML Messaging and RPC with SOAP

Chapter 6

Chapter 7 API - Putting It AllofTogether XML Pipeline, JSPs, Some and XSQL The SAX consists a set of with interfaces and classes. of these interfaces are implemented by a SAX Part II - (such Oracleas XML DBAs parser theManagement Oracle XML for Parser for Java). Others need to be implemented/ extended by your application. In

Chapter 8 with - Getting Started the Oracle and XMLmethods Databasenow have namespace support, along with other functionality addition, SAX Level 2, with the interfaces Chapter - Storing XML Data because of the namespace support, some of the interfaces were deprecated and such as9 filters. Consequently, Chapter 10with - Generating and Retrieving XML replaced new ones. Chapter 11 - Searching XML Data

SAX interfaces and classes are XML classified into five groups: Chapter 12 - Managing the Oracle Database Part III - Oracle XML for Java Developers

Interfaces implemented by the parser

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Interfaces implemented by the application Chapter 15 - Creating a Portal Site with XML and Web Services

Standard SAX classes Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Optional Java-specific helper classes in the org.xml.sax.helpers package

Part IV - Oracle XML for C Developers

Chapter 18 demonstration - Getting Started with Oracle and C Java classes in the XML nul package Chapter 19 - Building an XML-Managed Application

However, an application writer, OCI you only need to focus on at most two of the interfaces, as described in Table 2Chapter 20 -asBuild an XML Database Application 4.

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Table 2-4: Interfaces Implemented by Applications

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 -Interface Build an XML Database OCI C++ Application SAX 1.0 SAX 2.0 Interface

Description

Chapter 24 - Building an XML Data-Retrieval Application

DocumentHandler ContentHandler Part VI - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services ErrorHandler ErrorHandler Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

DTDHandler

Appendix

Optional interface needed to work with notations and unparsed (binary) entities

EntityResolver

Optional interface needed to do redirection of URIs in documents

Glossary Index List of Tables List of Sidebars

Optional interface for special error handling

DTDHandler

- XML Standards Bodies and Open Specifications

ListEntityResolver of Figures

Receives notifications from parser

In addition to the application interfaces, most SAX parsers, including the Oracle XML Parser for Java, implement helper classes that provide static methods that are useful in integrating SAX parsers. These helper classes are described in Table 2-5. Table 2-5: Oracle SAX Helper Classes


SAX 1.0 Interface

SAX 2.0 Interface

Description

ParserFactoryOracle Database 10g XMLXMLReaderFactory ClassApplications to support loading SAX & SQL: Design, Build & Manage XML in Java, C, C++ & PL/SQL parsers dynamically by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

AttributeListImpl AtrributeImpl McGraw-Hill/Osborne © 2004 (600 pages)

Convenience class to make a persistent copy of an This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with AttributeList emphasis on XML standards, their usage and best practices.

LocatorImpl

LocatorImpl

Convenience class to make a persistent snapshot of a Locator's values at a specific Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL point in the parse Introduction

Table of Contents

Part I - Oracle and the XML Standards

N/A

NamespaceSupport

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

N/A 3 - Transforming XML with XSLT and XMLFilerImpl Chapter XPath Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6 - XML Messaging and RPC with SOAP HandlerBase DefaultHandler Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

Convenience class to add namespace support Base class to be subclassed when applications need to modify the event stream Base class with default implementations of all four SAX2 handler classes

- Getting Started with the Oracle XML Database

Chapter The following 9 - Storing code XML sample Data demonstrates a simple use of the parser and SAX API. The XML file given to the

application parsed and some XML information about the contents of this file. Sample code of various useful Chapter 10 - is Generating andprints Retrieving interfaces also provided. Chapter 11 -isSearching XML Data Chapter 12org.xml.sax.*; - Managing the Oracle XML Database import Part III - Oracle XML for Java Developers import java.io.*;

Chapter import 13java.net.*; - Getting Started with Oracle XML and Java

import Chapter 14oracle.xml.parser.v2.*; - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

public SAXSample extendsApplication DefaultHandler { AQ Chapter 16class - Developing an XML Gateway with SOAP and // Store the locator Chapter 17 - Developing XML-Based Reusable Components Locator locator; Part IV - Oracle XML for C Developers Chapter 18 - Getting Started with Oracle XML and C

static public void main(String[] argv) { try { Chapter 20 - Build an XML Database OCI Application if (argv.length != 1) { Chapter 21 - Create an XML-Configured High-Performance Transformation Engine // Must pass in the name of the XML file. Part V - Oracle XML for C++ Developers System.err.println("Usage: SAXSample filename"); Chapter 22 - Getting Started with Oracle XML and C++ System.exit(1); Chapter 23 - Build an XML Database OCI C++ Application } Chapter - Building Data-Retrieval Application // 24 Create a an newXML handler for the parser Part VI Oracle XML for PL/SQL Developers SAXSample sample = new SAXSample(); Chapter 19 - Building an XML-Managed Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter - Building PL/SQL Web // 26 Get an instance of Services the parser Chapter 27 - Extending Functionality with Java Parser parser PL/SQL = newXML SAXParser(); Chapter 28 - Putting It All Together Appendix // Set - XML Handlers Standardsin Bodies theand parser Open Specifications

parser.setDocumentHandler(sample); Glossary Indexparser.setEntityResolver(sample); List ofparser.setDTDHandler(sample); Figures List ofparser.setErrorHandler(sample); Tables List of Sidebars

// Convert file to URL and parse try { parser.parse(fileToURL(new File(argv[0])).toString()); } } } ////////////////////////////////////////////////////////////////////// // Sample implementation of ContentHandler interface.


////////////////////////////////////////////////////////////////////// public void setDocumentLocator (Locator locator) { Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & System.out.println("SetDocumentLocator:"); PL/SQL this.locator = locator; ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang } McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

public void startDocument(){ emphasis on XML standards, their usage and best practices. System.out.println("StartDocument"); }

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

public void endDocument() throws SAXException { System.out.println("EndDocument"); Part I - Oracle and the XML Standards } Chapter 1 -void Introducing XML public startElement(String namespaceURI, String localName, Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX String qName, AttributeList atts) Chapter 3 - Transforming XML with XSLT and XPath throws SAXException { Chapter 4 - Validating XML with DTDs and XML Schemas System.out.println("StartElement:"+name); Chapter - XMLi=0;i<atts.getLength();i++) Operations with XQuery for 5(int { Chapter String 6 - XML aname Messaging = atts.getName(i); and RPC with SOAP String type It=Allatts.getType(i); Chapter 7 - Putting Together with XML Pipeline, JSPs, and XSQL String = atts.getValue(i); Part II - Oraclevalue XML Management for DBAs System.out.println(" Chapter 8 - Getting Started with the "+aname+"("+type+")"+"="+value); Oracle XML Database } Chapter 9 - Storing XML Data } Chapter 10 - Generating and Retrieving XML public endElement(String namespaceURI, String localName, String qName) Chapter 11 -void Searching XML Data throws SAXException { Chapter 12 - Managing the Oracle XML Database System.out.println("EndElement:"+name); Part III - Oracle XML for Java Developers } Introduction

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

public void characters(char[] cbuf, int start, int len) { System.out.print("Characters:"); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ System.out.println(new String(cbuf,start,len)); Chapter } 17 - Developing XML-Based Reusable Components Chapter 15 - Creating a Portal Site with XML and Web Services

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C public void ignorableWhitespace(char[] cbuf, int start, int len) { Chapter 19 Building an XML-Managed Application System.out.println("IgnorableWhiteSpace"); Chapter } 20 - Build an XML Database OCI Application Chapter 21 - Create XML-Configured High-Performance Transformation Engine data) public void an processingInstruction(String target, String Part Vthrows - Oracle SAXException XML for C++ Developers {

Chapter System.out.println("ProcessingInstruction:"+target+" 22 - Getting Started with Oracle XML and C++ "+data);

} 23 - Build an XML Database OCI C++ Application Chapter Chapter 24 - Building an XML Data-Retrieval Application

////////////////////////////////////////////////////////////////////// Part VI - Oracle XML for PL/SQL Developers // Sample implementation of the interface. Chapter 25 - Getting Started with Oracle XML EntityResolver and PL/SQL ////////////////////////////////////////////////////////////////////// Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

public InputSource resolveEntity (String publicId, String systemId) throws SAXException { Appendix - XML Standards Bodies and Open Specifications System.out.println("ResolveEntity:"+publicId+" "+systemId); Glossary System.out.println("Locator:"+locator.getPublicId()+" "+ Index locator.getSystemId()+ List of Figures " "+locator.getLineNumber()+" " List of Tables +locator.getColumnNumber()); List ofreturn Sidebarsnull; } Chapter 28 - Putting It All Together

////////////////////////////////////////////////////////////////////// // Sample implementation of the DTDHandler interface. ////////////////////////////////////////////////////////////////////// public void notationDecl (String name, String publicId, String systemId) {


System.out.println("NotationDecl:"+name+" "+publicId+" "+systemId); } Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

public void unparsedEntityDecl (String name, String publicId, PL/SQL String notationName) { ISBN:0072229527 by Mark V. Scardina, Ben ChangString and JinyusystemId, Wang System.out.println("UnparsedEntityDecl:"+name + " "+publicId+" "+ McGraw-Hill/Osborne © 2004 (600 pages) systemId+" "+notationName); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with } emphasis on XML standards, their usage and best practices. …

Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Using SAX APIs

Introduction

Part I - Oracle and the XML Standards

Quite often, applications that require only SAX (Level 1 and Level 2) support do not want to be burdened with a - Introducing XML parser that always builds a full-blown DOM tree in memory. The Oracle XML SAX parser’s high-performance, eventChapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX based, run-time engine addresses this requirement. Using the SAX parser, applications can leverage the full power Chapter 3 - Transforming XML with XSLT and XPath of the SAX model to parse extremely large documents without incurring prohibitive memory costs. Chapter 1

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 - XML Operations with XQuery The following code demonstrates how the SAX APIs can be used to extract useful information from an XML Chapter 6 - XML Messaging and RPC with SOAP document: Chapter 7 -example Putting It All Together with XML Pipeline,use JSPs,of andthe XSQLSAXParser. // This demonstrates a simple Part XML Management DBAs // II An- Oracle XML file is parsedfor and some

information is printed out.

Chapter 8 org.xml.sax.*; - Getting Started with the Oracle XML Database import Chapter 9 java.io.*; - Storing XML Data import Chapter 10java.net.*; - Generating and Retrieving XML import Chapter import 11oracle.xml.parser.v2.*; - Searching XML Data Chapter 12 - Managing the Oracle XML Database

public classXML SAXHandler extends Part III - Oracle for Java Developers

DefaultHandler {

public void main(String[] argv) Chapter 13 -static Getting Started with Oracle XML and Java { try 14 { - Building an XML-Powered Web Site Chapter // 15 Get an instance of with theXML parser Chapter - Creating a Portal Site and Web Services Parser parser = SAXParser(); Chapter 16 - Developing an new XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

// Create a SAX event handler and register it with the parser SAXHandler handler = new SAXHandler(); Chapter 18 - Getting Started with Oracle XML and C parser.setContentHandler(handler); Part IV - Oracle XML for C Developers

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application

// Convert file to InputSource and parse InputSource xmldoc = new InputSource(new FileInputStream(argv[0])); Part V - Oracle XML for C++ Developers parser.parse(xmldoc); Chapter } 22 - Getting Started with Oracle XML and C++ Chapter 23 -(Exception Build an XML Database OCI C++ Application catch e) { Chapter 24 - Building an XML Data-Retrieval Application System.out.println(e.toString()); Part}VI - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL } Chapter - Building PL/SQL Web Services // 26 Sample implementation of DocumentHandler interface. Chapter public 27 - Extending void startElement(String PL/SQL XML Functionalityname, with Java Attributes atts) throws SAXException { Chapter 28 - Putting It All Together System.out.println("StartElement:"+name); Appendix - XML Standards Bodies and Open Specifications for (int i=0;i<atts.getLength();i++) { Glossary Index String aname = atts.getName(i); String type = atts.getType(i); List of Figures String value = atts.getValue(i); List of Tables System.out.println(" "+aname+"("+type+")"+"="+value); List of Sidebars } } Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

public void characters(char[] cbuf, int start, int len) { System.out.print("Characters:"); System.out.println(new String(cbuf,start,len)); } }


To use the Oracle XML parser’s SAX support, you need to use the SAXParser class to parse your XML document. The first thing to do, therefore, is to get an instance of this class: Parser parser = new SAXParser(); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

You then needby to Mark register your SAXBen event handler parser, so that it knows what methods to invoke when a ISBN:0072229527 V. Scardina, Chang and with Jinyuthe Wang particular eventMcGraw-Hill/Osborne occurs. Because not events may be of interest to you, make sure the handler you register © all 2004 (600 pages) extends the org.xml.sax.DefaultHandler class.on This class XML provides some default for handling events This comprehensive guide focuses utilizing technologies within behavior Oracle's XML-enabled products, with (typically theseemphasis do nothing). Youstandards, can then override the and methods for those events of interest to you. In the preceding on XML their usage best practices. example, the assumption is that the only events of interest are a subset of those specified by the org.xml.sax.ContentHandler interface, namely, startElement and characters. Arguably, these are the most Table of Contents important SAX events generated because XML documents typically consist of markup and text. This handler can be Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL registered with SAXParser with a simple API call: Introduction

parser.setContentHandler(handler); Part I - Oracle and the XML Standards Chapter 1

- Introducing XML

ThestartElement event is triggered every time a new element is encountered within the XML document by - Accessing XML with DOM, SAX, JAXB, and StAX SAXParser. When this event occurs, you can print the element name and its attributes:

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

public void startElement(String namespaceURI, String localName, String - Validating XML with DTDs and XML Schemas qName,Attribute Chapter 5 - XML Operations with XQuery throws SAXException { Chapter 6 - XML Messaging and RPC with SOAP ... Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL } Chapter 4

Part II - Oracle XML Management for DBAs

Chapter 8 - Getting Started with the Oracle XML Database text is encountered by SAXParser. This text is often the Thecharacters event is triggered every time unmarked-up Chapter - Storing XML Data “value” 9of an element and can be retrieved by listening for this event: Chapter 10void - Generating and Retrieving XML public characters(char[] cbuf, int start, int len) { Chapter 11 -... Searching XML Data Chapter 12 - Managing the Oracle XML Database } Part III - Oracle XML for Java Developers

Once the beenwith registered, all that is to parse an XML document using SAXParser: Chapter 13 handler - Gettinghas Started Oracle XML andremains Java Chapter 14 - Building an XML-Powered Web Site parser.parse(xmldoc); Chapter 15 - Creating a Portal Site with XML and Web Services

The input document contain Application a list of book data, such the following: Chapter 16 XML - Developing an could XML Gateway with SOAP andasAQ <booklist> Chapter 17 - Developing XML-Based Reusable Components <book isbn="0-07-213495-X"> Part IV - Oracle XML for C Developers <title>Oracle9i XML Handbook</title> Chapter 18 - Getting Started with Oracle XML and C <author>Chang, and Kiritzov</author> Chapter 19 - Building an Scardina XML-Managed Application <publisher>Osborne</publisher> Chapter 20 - Build an XML Database OCI Application <price>49.99</price> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine </book> Part V - Oracle XML for C++ Developers <book isbn="1230-23498-2349879"> <title>Emperor's New Mind</title> Chapter 23 - Build an XML Database OCI C++ Application <author>Roger Penrose</author> Chapter 24 - Building an XML Data-Retrieval Application <publisher>Oxford Publishing Company</publisher> Part VI - Oracle XML for PL/SQL Developers <price>15.99</price> Chapter 25 - Getting Started with Oracle XML and PL/SQL </book> Chapter 26 - Building PL/SQL Web Services </booklist> Chapter 22 - Getting Started with Oracle XML and C++

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix The following - XML output Standards would Bodies be generated: and Open Specifications Glossary StartElement:booklist Index StartElement:book List ofisbn(CDATA)= Figures 0-07-213495-X List StartElement:title of Tables

Characters: List of Sidebars Oracle9i XML Handbook StartElement:author Characters: Chang, Scardina and Kiritzov StartElement:publisher Characters: Osborne StartElement:price Characters:49.99 StartElement:book isbn(CDATA)=1230-23498-2349879


StartElement:title Characters:Emperor's New Mind StartElement:author Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Characters:Roger PL/SQL Penrose StartElement:publisher ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang Characters:Oxford Publishing Company McGraw-Hill/Osborne © 2004 (600 pages) StartElement:price This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Characters:15.99 emphasis on XML standards, their usage and best practices. Implementation of SAX Level 2 comes mainly in the form of support of XML namespaces, and querying or setting

Table of Contents features or properties in the parser. With namespace support, element and attribute names may now return an

Oracle Database 10g XML SQL—Design, Buildname, & Manage Applications in Java, C, C++ & PL/SQL optional namespace URI&followed by a local e.g.,XML <foo:bar xmlns:foo=“http://www.oracle.com/”/>, where Introduction http://www.oracle.com/ is the namespace URI and bar is the local name. In addition, the qualified name (or Part I - Oracle and the qName), foo:bar, mayXML alsoStandards be returned.Without namespace support, element and attribute names simply return a

Chapter 1 - Introducing XML 2 interfaces affected by namespace support are XMLReader, Attributes, and local name. The SAX Level Chapter 2 - Accessing with of DOM, SAX, JAXB, and StAX ContentHandler. An XML example SAX 2 namespace support, followed by code for the startElement and Chapter endElement 3 - Transforming callback methods XML with in the XSLT ContentHandler and XPath interface, might look like this: Chapter 4 -example Validating demonstrates XML with DTDs and XMLto Schemas // This how use SAX Level 2 Namespace Chapter 5 - XML followed Operations with // support, by XQuery how to use the callback Chapter 6 - XMLstartElement Messaging and RPC SOAP // methods andwith endElement. Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part import II - Oracle java.io.*; XML Management for DBAs

import Chapter 8 java.net.URL; - Getting Started with the Oracle XML Database import Chapter 9 java.net.MalformedURLException; - Storing XML Data import Chapter 10org.xml.sax.*; - Generating and Retrieving XML import Chapter 11org.xml.sax.helpers.*; - Searching XML Data import Chapter 12oracle.xml.parser.v2.SAXParser; - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

public class SAX2Namespace { static public void main(String[] args) { Chapter 14 - Building an XML-Powered Web Site String fileName; Chapter 15 - Creating a Portal Site with XML and Web Services //Get the file name Chapter 16 - Developing an XML Gateway Application with SOAP and AQ fileName = args[0]; Chapter 17 - Developing XML-Based Reusable Components try { Part IV - Oracle XML for C Developers // Create handlers for the parser Chapter - Getting Started with Oracle XML and use C // 18 For all the other interfaces the default provided by Chapter 19 Building an XML-Managed Application // Handler base Chapter 20 - Build an XMLdefHandler Database OCI Application DefaultHandler = new XMLDefaultHandler(); Chapter 21 Create an XML-Configured High-Performance Transformation Engine SAXParser parser = new SAXParser(); Part Vparser.setContentHandler(defHandler); - Oracle XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++ parser.setErrorHandler(defHandler); Chapter parser.setEntityResolver(defHandler); 23 - Build an XML Database OCI C++ Application parser.setDTDHandler(defHandler); Chapter 24 - Building an XML Data-Retrieval Application try { Part VI - Oracle XML for PL/SQL Developers parser.parse(createURL(fileName)); Chapter 25 - Getting Started with Oracle XML and PL/SQL } 26 - Building PL/SQL Web Services Chapter } 27 - Extending PL/SQL XML Functionality with Java Chapter } Chapter 28 - Putting It All Together static URL createURL(String fileName) { Appendix - XML Standards Bodies and Open Specifications URL url = null; Glossary try { Index url = new URL(fileName); List of Figures } catch (MalformedURLException ex) { List of Tables try { List ofFile Sidebars f = new File(fileName); url = f.toURL(); } catch (MalformedURLException e) { System.out.println("Cannot create url for: " + fileName); System.exit(0); } } return url; Chapter 13 - Getting Started with Oracle XML and Java


} } class XMLDefaultHandler extends DefaultHandler { Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & public void XMLDefaultHandler() { PL/SQL } ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang public void startElement(String uri, McGraw-Hill/Osborne © 2004 (600 pages)String localName, String qName, Attributes atts) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with throws SAXException { emphasis on XML standards, their usage and best practices. System.out.println("ELEMENT Qualified Name:" + qName); System.out.println("ELEMENT Local Name :" + localName); Table of Contents System.out.println("ELEMENT Namespace :" + uri); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

for (int i=0; i<atts.getLength(); i++) { qName = atts.getQName(i); Chapter 1 - Introducing XML localName = atts.getLocalName(i); Chapter 2 Accessing XML with DOM, SAX, JAXB, and StAX uri = atts.getURI(i); Part I - Oracle and the XML Standards

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4 - Validating XML with DTDs and XML Schemas System.out.println(" ATTRIBUTE Qualified Name Chapter 5 - XML Operations with XQuery System.out.println(" ATTRIBUTE Local Name Chapter System.out.println(" 6 - XML Messaging and RPC ATTRIBUTE with SOAP Namespace Chapter 7

:" + qName); :" + localName); :" + uri);

- Putting It All Together with XML Pipeline, JSPs, and XSQL

You XML can Management get the type and Part II// - Oracle for DBAs

value of the attributes either

// indexStarted or by the Name. Chapter 8 by - Getting with the Qualified Oracle XML Database Chapter 9

- Storing XML Data

String type =and atts.getType(qName); Chapter 10 - Generating Retrieving XML String value XML = atts.getValue(qName); Chapter 11 - Searching Data Chapter 12 - Managing the Oracle XML Database

System.out.println(" ATTRIBUTE Type System.out.println(" ATTRIBUTE Value Chapter 13 - Getting Started with Oracle XML and Java System.out.println(); Chapter 14 - Building an XML-Powered Web Site } Chapter 15 - Creating a Portal Site with XML and Web Services }

:" + type); :" + value);

Part III - Oracle XML for Java Developers

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusableuri, Components public void endElement(String String localName, Part IV - Oracle XML for C Developers String

qName) throws SAXException {

Chapter 18 - Getting Started with Oracle XMLQualified and C System.out.println("ELEMENT Name:" + qName); Chapter 19 Building an XML-Managed Application System.out.println("ELEMENT Local Name :" + localName); Chapter 20 - Build an XML Database OCI Application System.out.println("ELEMENT Namespace

:" + uri);

Chapter } 21 - Create an XML-Configured High-Performance Transformation Engine Part } V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

For SAX 2,an theXML additional parameters passed in are the namespace URI, the local name, and the Chapter 23Level - Build Database OCI C++ being Application qName. SAX an Level enhancementsApplication include the querying and setting of features and properties in the parser. Chapter 24Other - Building XML2 Data-Retrieval For VI example, methods such as getFeature,setFeature, getProperty, setProperty, are available Part - Oraclegetter/setter XML for PL/SQL Developers supporting namespaces as demonstrated in the following listing:

Chapter 25 - Getting Started with Oracle XML and PL/SQL

void process(String Chapter 26 - Building PL/SQLfilename) Web Servicesthrows SAXException, IOException{ URL url = createURL(filename); Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

// Validating, Namespace = true, NamespacePrefix = true - XML Standards Bodies and Open Specifications parser.setFeature("http://xml.org/sax/features/validation", true); Glossary parser.setFeature("http://xml.org/sax/features/namespaces", true); Index parser.setFeature("http://xml.org/sax/features/namespace-prefix", true); Appendix

List of Figures List of Tables

try {

List parser.parse(url.toString()); of Sidebars

} catch (XMLParseException e) { System.out.println(); System.out.println(e); } // Non-validating, NamespacePrefix = false parser.setFeature("http://xml.org/sax/features/validation", true);


parser.setFeature("http://xml.org/sax/features/namespace-prefix", true); try { Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & parser.parse(url.toString()); PL/SQL } ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

catch (XMLParseException e) { This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with System.out.println(); emphasis on XML standards, their usage and best practices. System.out.println(e); }

Table of Contents

}

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction For this code example, note that you can control namespace support in SAX Level 2 processing. In default Part I - Oracle and the XML Standards processing, namespace-prefix is false, meaning that qNames are optionally reported and namespace declarations

Chapter - Introducing XML (xmlns1attributes) are not reported. In our example, however, the code stub sets validation,namespaces, and Chapter 2 - Accessing with which DOM, SAX, namespace-prefix toXML be true, whenJAXB, givenand StAX Chapter 3 - Transforming XML with XSLT and XPath <foo:bar xmlns:foo="http://www.oracle.com/" foo1="bar1" foo:stock="wayout.com"/>, Chapter 4

- Validating XML with DTDs and XML Schemas

an element will have the namespace URI of http://www.oracle.com/, a local name of bar, and a qName of Chapter 5 - XML Operations with XQuery foo:bar; attribute will have no namespace Chapter 6 one - XML Messaging and RPC with SOAP URI, no local name, and a qName of xmlns:foo; another attribute will have namespace URI, a local and a qName of foo1; Chapter 7 no - Putting It All Together withname, XML Pipeline, JSPs, and XSQL and the last attribute will have the namespace URIII http://www.oracle.com/ andfor a DBAs local name of stock. Part - Oracle XML Management Chapter 8

- Getting Started with the Oracle XML Database

StoringAPIs XML Data Oracle- SAX in C

Chapter 9

Chapter 10 - Generating and Retrieving XML

To use11 the- Oracle SAX APIs, a set of callback functions is passed to xmlinit(). The parser then invokes these Chapter Searching XML Data functions the matching parts of a document Chapter 12 as - Managing the Oracle XML Database are encountered. Compare this to the DOM, in which the document is parsed and aXML nodefor tree is Developers constructed in memory, which can then be queried and modified through the DOM API. Part III - Oracle Java SAX functions are invoked document is parsed. Each SAX function returns a (sword) error code. If the code Chapter 13 - Getting Started as withthe Oracle XML and Java is nonzero, an error is indicated and parsing stops immediately.

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 callback - Creating a Portal (xmlsaxcb) Site with XML Webas Services The SAX structure is and defined follows: Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

struct xmlsaxcb { sword (*startDocument)(void *ctx); Part IV - Oracle XML for C Developers sword (*endDocument)(void *ctx); Chapter 18 - Getting Started with Oracle XML and C sword (*startElement)(void *ctx, const oratext *name, Chapter 19 - Building an XML-Managed constApplication struct xmlnodes *attrs); Chapter 20 Build an XML Database Application sword (*endElement)(void OCI *ctx, const oratext *name); Chapter 21(*characters)(void - Create an XML-Configured High-Performance Transformation Engine len); sword *ctx, const oratext *ch, size_t Part V Oracle XML for C++ Developers sword (*ignorableWhitespace)(void *ctx, const oratext *ch, Chapter 22 - Getting Started with Oracle XML and C++ size_t len); Chapter 23(*processingInstruction)(void - Build an XML Database OCI C++ Application sword *ctx, const oratext *target, Chapter 24 - Building an XML Data-Retrieval Application const oratext *data); Part sword VI - Oracle (*notationDecl)(void XML for PL/SQL Developers *ctx, const oratext *name, oratext *publicId, Chapter 25 - Getting Started withconst Oracle XML and PL/SQL const oratext *systemId); Chapter 26 - Building PL/SQL Web Services sword const oratext *name, Chapter 27(*unparsedEntityDecl)(void - Extending PL/SQL XML Functionality*ctx, with Java const oratext *publidId, Chapter 28 - Putting It All Together const oratext Appendix - XML Standards Bodies and Open Specifications *systemId, const oratext *notationName); Glossary sword (*nsStartElement)(void *ctx, const oratext *qname, Index const oratext *local, List of Figures const oratext *nsp, List of Tables const struct xmlnodes *attrs); List of Sidebars } Chapter 17 - Developing XML-Based Reusable Components

Any or all callback functions may be specified; none are required. An optional context pointer may be provided, and it will be passed to each callback function. Its use is entirely up to the user. The callback functions are described in detail in Table 2-6. Table 2-6: SAX Callback Functions


Callback Function

Description

startDocument before the parseinbegins. Oracle Database 10g XML & SQL: Design,Invoked Build &immediately Manage XML Applications Java, C, C++ & PL/SQL

endDocumentby Mark V. Scardina, Ben Chang and Jinyu Wang Invoked immediately after a successful parse ISBN:0072229527 ends. McGraw-Hill/Osborne © 2004 (600 pages) XML technologies within Oracle's XML-enabled with startElement This comprehensive guide focuses on utilizingInvoked when an element start-tag is found. If products, the emphasis on XML standards, their usage and namespace best practices. version of this callback is also supplied, it is called instead. Table of Contents

endElement

Invoked when an element end-tag is found.

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

characters Introduction

Invoked for each CDATA or #PCDATA.

Part I - Oracle and the XML Standards

ignorableWhitespace

Invoked for each run of ignorable white space, unless all white space is being retained (in which Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX case characters is invoked). Chapter 1

- Introducing XML

Chapter 3

- Transforming XML with XSLT and XPath

processingInstruction Chapter 4 - Validating XML with DTDs and XML Schemas

Invoked for each processing instruction.

Chapter 5 - XML Operations with XQuery notationDecl

Invoked for each NOTATION declaration in the DTD.

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

unparsedEntityDecl Part II - Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 - Storing XML Data nsStartElement Chapter 10 - Generating and Retrieving XML

Invoked for each unparsed entity (those with NDATA defined). Invoked when a namespace qualified start-tag is found returning the namespace, local part, etc.

Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

TheIII following show how to declare, register, and use the SAX callbacks: Part - Oracleprogram XML forfragments Java Developers Chapter /* declare 13 - Getting SAX Started callback with Oracle functions XML and */Java

sword 14 startdocument(void *ctx); Chapter - Building an XML-Powered Web Site sword 15 enddocument(void *ctx); Chapter - Creating a Portal Site with XML and Web Services sword 16 startelement(void *ctx, Application const oratext *name, Chapter - Developing an XML Gateway with SOAP and AQ const xmlnodes *attrs); Chapter 17 - Developing XML-Based Reusable Components sword endelement(void *ctx, Part IV - Oracle XML for C Developers

const oratext *name); sword characters(void *ctx, const oratext *ch, size_t len); Chapter 18 - Getting Started with Oracle XML and C sword whitespace(void *ctx, const oratext *ch, size_t len); Chapter 19 - Building an XML-Managed Application sword pi(void *ctx, const oratext *target, Chapter 20 - Build an XML Database OCI Application const oratext *data); Chapter 21 - Create an XML-Configured High-Performance Transformation Engine sword notation(void *ctx, const oratext *name, Part V - Oracle XML for C++ Developers const oratext *publicId, Chapter 22 - Getting Started with Oracle XML and C++ const oratext *systemId); Chapter 23 - Build an XML Database OCI C++ Application sword entity(void *ctx, const oratext *name, Chapter 24 - Building an XML Data-Retrieval Application const oratext *publidId, Part VI - Oracle XML for PL/SQL Developers const oratext *systemId, Chapter 25 - Getting Startedoratext with Oracle XML and PL/SQL const *notationName); Chapter 26 Building PL/SQL Web Services /* declare SAX callback context */ Chapter 27 -struct Extending PL/SQL XML Functionality with Java typedef saxcontext { Chapter 28 - Putting It All Together uword depth; /* nested element level, for indenting */ Appendix } sax_context; - XML Standards Bodies and Open Specifications Glossary

/* declare SAX callback structure */ Index xmlsaxcb List of Figuressax_callback = { enddocument, startelement, endelement, Liststartdocument, of Tables whitespace, pi, notation, entity Listcharacters, of Sidebars }; /* declare SAX context and initialize */ sax_context saxctx = { 0 }; /* depth = 0 */ /* initialize parser specifying SAX callbacks */ xmlinit(&ecode, NULL, NULL, NULL, NULL, &sax_callback, (void *) &saxctx, NULL, NULL); /* ----- SAX CALLBACKS ----- */


sword startdocument(void *context) { puts("StartDocument"); return 0; Oracle /* success */ Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & } PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

sword enddocument(void *context) { pages) McGraw-Hill/Osborne © 2004 (600 puts("EndDocument"); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with return 0; emphasis /* success on XML*/ standards, their usage and best practices. } Table of Contents

sword startelement(void *context, const oratext *name, const xmlnodes *attrs) { Introduction sax_context *saxctx = (sax_context *) context; Part I - Oracle and the XML Standards indent(saxctx->depth); Chapter 1 - Introducing XML printf("<%s", name); Chapter 2 Accessing XML with DOM, SAX, JAXB, and StAX if (attrs) { Chapter XML with XSLT and XPath for 3(i- Transforming = 0; i < numAttributes(attrs); i++) { Chapter 4 -=Validating XML with DTDs and XML Schemas attr getAttributeIndex(attrs, i); Chapter 5 - XML %s=\"%s\"", Operations with XQuery printf(" getAttrName(attr), getAttrValue(attr)); Chapter } 6 - XML Messaging and RPC with SOAP } Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL puts(">"); Part II - Oracle XML Management for DBAs saxctx->depth++; Chapter 8 - Getting Started with the Oracle XML Database return /* XML success Chapter 9 -0; Storing Data */ } Chapter 10 - Generating and Retrieving XML

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter 11 - Searching XML Data

sword endelement(void *context, const oratext *name) { sax_context *saxctx = (sax_context *) context; Part III - Oracle XML for Java Developers Chapter 12 - Managing the Oracle XML Database

Chapter 13 - Getting Started with Oracle XML and Java

indent(--saxctx->depth); printf("</%s>\n", name); Chapter 15 - Creating a Portal Site with XML and Web Services return 0; /* success */ Chapter 16 - Developing an XML Gateway Application with SOAP and AQ } Chapter 14 - Building an XML-Powered Web Site

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers sword characters(void *context,

const oratext *ch, size_t len) {

Chapter 18 - Getting Started with Oracle XML and C*) context; sax_context *saxctx = (sax_context Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application indent(saxctx->depth); Chapter 21 - Create an XML-Configured High-Performance Transformation Engine putchar('"'); Part V - Oracle XML for C++ Developers print_string((oratext *) ch,

(sword) len);

Chapter puts("\""); 22 - Getting Started with Oracle XML and C++

return */ OCI C++ Application Chapter 23 -0; Build/* an success XML Database } Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

sword 25 whitespace(void *context, oratext *ch, size_t len) Chapter - Getting Started with Oracle XML const and PL/SQL { Chapter 26 - Building PL/SQL Web Services sax_context *saxctx (sax_context *) Java context; Chapter 27 - Extending PL/SQL=XML Functionality with Chapter 28 - Putting It All Together

indent(saxctx->depth); - XML Standards Bodies and Open Specifications putchar('\''); Glossary print_string((oratext *) ch, (sword) len); Index puts("'"); List of Figures return 0; /* success */ List } of Tables Appendix

List of Sidebars

sword pi(void *context, const oratext *target, const oratext *data) { sax_context *saxctx = (sax_context *) context; indent(saxctx->depth); fputs("PI", stdout); if (target) printf(" target=\"%s\"", target);


if (data) printf (" data=\"%s\"", data); putchar('\n'); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & return 0; PL/SQL /* success */ }

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

sword notation(void *context, const oratext *name, This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with const oratext *publicId, emphasis on XML standards, their usage and best practices. const oratext *systemId) { sax_context *saxctx = (sax_context *) context;

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

indent(saxctx->depth); printf("NOTATION '%s'", name); Part I - Oracle and the XML Standards if (publicId) Chapter 1 - Introducing XML publicId); printf (" PUB:%s", Chapter 2 Accessing XML with DOM, SAX, JAXB, and StAX if (systemId) Chapter 3 - Transforming with XSLT and XPath printf(" SYS:%s",XML systemId); Chapter 4 - Validating XML with DTDs and XML Schemas putchar('\n'); Chapter 5 -0; XML /* Operations with*/ XQuery return success Chapter } 6 - XML Messaging and RPC with SOAP Introduction

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

sword entity(void *context, const Part II - Oracle XML Management for DBAs

oratext *name,

Chapter 8

const *publidId, - Getting Startedoratext with the Oracle XML Database

Chapter 9

const oratext *systemId, - Storing XML Data

const { Chapter 10 - Generating andoratext Retrieving*notationName) XML sax_context *saxctx = (sax_context *) context; Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

indent(saxctx->depth); printf("ENTITY '%s'", name); Chapter 13 - Getting Started with Oracle XML and Java if (publidId) Chapter 14 - Building an XML-Powered Web Site printf(" PUB:%s", publidId); Chapter 15 - Creating a Portal Site with XML and Web Services if (systemId) Chapter 16 - Developing an XML Gateway Application with SOAP and AQ printf(" SYS:%s", systemId); Chapter 17 - Developing XML-Based Reusable Components if (notationName) Partprintf(" IV - Oracle NAME:%s", XML for C Developers notationName); Chapter 18 Getting putchar('\n');Started with Oracle XML and C Chapter 19 -0; Building XML-Managed Application return /* an success */ Chapter 20 Build an XML Database OCI Application } Part III - Oracle XML for Java Developers

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

TheVfollowing is a sample document that includes an inline DTD: Part - Oracle XML for C++XML Developers Chapter - Getting Started with Oracle XML and C++ <?xml 22 version="1.0"?> Chapter <!DOCTYPE 23 - Build PLAY an XML [ Database OCI C++ Application

<!ELEMENT top an XML (second*)> Chapter 24 - Building Data-Retrieval Application <!ELEMENT (third*)> Part VI - Oracle second XML for PL/SQL Developers <!ELEMENT third (#PCDATA)*> Chapter 25 - Getting Started with Oracle XML and PL/SQL <!NOTATION note1 SYSTEM "foo.exe"> Chapter 26 - Building PL/SQL Web Services <!NOTATION note2PL/SQL PUBLIC "bar.ent"> Chapter 27 - Extending XML "bar" Functionality with Java <!ENTITY ent SYSTEM "http://www.w3.org/" NDATA n> Chapter 28 - Putting It All Together ]> - XML Standards Bodies and Open Specifications <?dummy this is a sample processing instruction?> Glossary <top> Index <second> List of Figures <third>third level</third> List of Tables </second> List of Sidebars </top> Appendix

This is the resulting output from the preceding sample program: StartDocument NOTATION 'note1' SYS:foo.exe NOTATION 'note2' PUB:bar SYS:bar.ent ENTITY 'ent' SYS:http://www.w3.org/ NAME:n PI target=dummy data=this is a sample processing instruction


<top> '\n ' <second> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & '\nPL/SQL ' <third> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang "third level" © 2004 (600 pages) McGraw-Hill/Osborne </third> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with '\nemphasis ' on XML standards, their usage and best practices. </second> '\n' Table of Contents </top> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL EndDocument Introduction

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & AccessingOracle XML with Java Binding PL/SQL

ISBN:0072229527 Mark V. Scardina, andXML Jinyu Wang to assist in programmatically creating valid The JAXB APIsbycreate Java sourceBen filesChang from an Schema document instances McGraw-Hill/Osborne 2004 (600an pages) useful when you want an application©to send XML message to another application according to an agreed-upon XML Schem to construct anThis XMLcomprehensive document. You canfocuses construct, optionally validate, and print XML documents that comply with the guide on utilizing XML technologies within Oracle's XML-enabled products, withinput XM emphasis on XML standards, theirJAXB usageAPIs and work best practices. applications using the generated classes. The in conjunction with the Oracle XML Parser for Java, which par passes the parsed XML Schema to the JAXB compiler.

Table of Contents

The JAXB APIs then query the XML Schema for all the elements. A Java class is generated for each of these elements. Thes set the attributes and add child nodes by the corresponding content model. The Java class corresponding to the root element Introduction and print the constructed XML document. The following subsections use an example to show how the JAXB APIs can be used Part I - Oracle and the XML Standards Schema and generate classes for the XML Schema’s elements. The example then shows how to use the methods of the elem Chapter 1 - Introducing XML programmatically construct a valid XML document. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

The Input XML Schema - Validating XML with DTDs and XML Schemas

Chapter 4 Chapter 5

- XML Operations with XQuery The following XML Schema for book data, bookcatalog.xsd, is used as the input to the JAXB Compiler. Here, the schema sp

Chapter 6 -root XMLisMessaging and RPC with SOAP document BOOKCATALOG. BOOKCATALOG consists of one or more BOOKs. Each BOOK contains a required ISBN

Chapter 7 as - Putting All Together with XML Pipeline, JSPs,elements, and XSQLsuch as TITLE for the book title, AUTHORNAME for the au identifier, well asItseveral optional attributes and child Part II - publisher, Oracle XML Management for DBAs for the and so on. Optional attributes and children are followed by a ? in the element definition.

Chapter 8

- Getting Started with the Oracle XML Database

<xsd:element name="PRICE" type="xsd:decimal"/> Chapter 9 - Storing XML Data </xsd:sequence> Chapter 10 - Generating and Retrieving XML </xsd:complexType> Chapter 11 - Searching XML Data </xsd:schema> Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Generating XML Classes

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

The following code sample processes an XML Schema and generates the corresponding classes for elements in the DTD. Th

Chapter - Creating a Portal with XML and Web Services DTD file15along with the nameSite of the root element. The JAXB APIs can also parse an XML document and use the DTD defined

Chapter 16 compiler - Developing an XML Gateway Application with SOAP andclasses AQ the JAXB on the preceding XML Schema creates Java for each element (BOOKCATALOG, BOOK, TITLE, a

Chapter 17 - can Developing XML-Based Reusable Components application then use the methods defined on these classes to create a valid XML document containing book data. The Ora Part IV compiler - Oracle XML Developers JAXB that for canCgenerate these classes with the following command line:

Chapter 18 - Getting Started with Oracle XML and C

java -classpath %CLASSPATH% oracle.xml.jaxb.orajaxb -schema bookcatalog.xsd

Chapter 19 - Building an XML-Managed Application -targetPkg generated Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Binding to an XML Instance

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

The following Java code shows how generated methods might be used. Here, two BOOK records are created: book1 and boo are enforced by adding them as parameters to the constructor. In this case, ISBN is a required attribute for the BOOK elemen Chapter - Building an XML Data-Retrieval are also24created (title1, authorname1, and Application so on). If an element has an enumerated attribute, a static constant is defined in the Part VI Oracle XML for PL/SQL Developers enumeration. To build an XML document tree, the various data elements are grouped by assigning them to each row element Chapter Getting Started and PL/SQL element25is-then added as awith nodeOracle to theXML document root element BOOKCATALOG. In this example, classes generated are in up Chapter 23 - Build an XML Database OCI C++ Application

Chapter 26 - Building PL/SQL Web Services

import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; Chapter 28java.util.List; - Putting It All Together import

Chapter 27 - Extending PL/SQL XML Functionality with Java Appendix

- XML Standards Bodies and Open Specifications

Glossary public class CreateBooksDemo { Index public static void main (String args[]) { List of Figures try { List of Tables // Instantiate the object factory

CreateBooks.ObjectFactory objFactory = new CreateBooks.ObjectFactory(); List of Sidebars // New Book Catalog CreateBooks.BOOKCATALOG bookCatalogue = objFactory.createBOOKCATALOG(); // New book book1 CreateBooks.BOOK book1 = objFactory.createBOOK(); book1.setISBN("7654"); book1.setTITLE("The Adventures of Don Quixote");


book1.setAUTHORNAME("Miguel Cervantes"); book1.setPUBLISHER("Oracle Press"); book1.setPUBLISHYEAR("2000"); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & book1.setPRICE(new java.math.BigDecimal("1.0")); PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

// Create new book book2 McGraw-Hill/Osborne © 2004 (600 pages) CreateBooks.BOOK book2 = objFactory.createBOOK(); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with book2.setISBN("7788"); emphasis on XML standards, their usage and best practices. book2.setTITLE("The Iliad"); book2.setAUTHORNAME("Homer"); Table of Contents book2.setPUBLISHER("Oracle Press"); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL book2.setPUBLISHYEAR("1000"); Introduction book2.setPRICE(new java.math.BigDecimal("2.0")); Part I - Oracle and the XML Standards

Chapter 1//- Introducing XML list Getting the Chapter 2List - Accessing XML with DOM, SAX, JAXB, and StAX bookList = bookCatalogue.getBOOK(); Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4//- Validating with DTDs Setting XML a book itemand XML Schemas Chapter 5bookList.add(book1); - XML Operations with XQuery Chapter 6bookList.add(book2); - XML Messaging and RPC with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

// Get the JAXB Context Part II - Oracle XML Management for DBAs = the JAXBContext.newInstance("CreateBooks"); Chapter 8JAXBContext - Getting Startedjc with Oracle XML Database Chapter 9

- Storing XML Data

//- Generating Print toand System.out Chapter 10 Retrieving XML Marshaller m =Data jc.createMarshaller(); Chapter 11 - Searching XML m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true)); m.marshal(bookCatalogue, System.out); Part III - Oracle XML for Java Developers System.out.println(); Chapter 13 - Getting Started with Oracle XML and Java System.out.println(); Chapter 14 - Building an XML-Powered Web Site } Chapter 15 - Creating a Portal Site with XML and Web Services catch (Exception e) { Chapter 16 - Developing an XML Gateway Application with SOAP and AQ e.printStackTrace(); Chapter 17 } - Developing XML-Based Reusable Components Part IV Oracle XML for C Developers } Chapter 18 Getting Started with Oracle XML and C } Chapter 12 - Managing the Oracle XML Database

Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

XML Document Created by Java Application

Part V - Oracle XML for C++ Developers

Chapter 22 for - Getting Started with XML and The input the preceding JavaOracle application canC++ be received from various sources, such as a web form, SAX parser, or JDBC

Chapter 23 - Build creates an XML Database OCI C++ Application Java application an XML document that can then be transformed or stored in the database. The XML document create Chapter 24 - Building an XML Data-Retrieval Application

<?xml version="1.0" encoding="UTF-8"?> <BOOKCATALOG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocati Chapter 25 - Getting Started with Oracle XML and PL/SQL <BOOK> Chapter 26 - Building PL/SQL Web Services <TITLE>The Adventures of Don Quixote</TITLE> Chapter 27 Extending PL/SQL XML Cervantes</AUTHORNAME> Functionality with Java <AUTHORNAME>Miguel Chapter 28 - Putting It All Together <ISBN>7654</ISBN> Appendix <PUBLISHER>Oracle - XML Standards BodiesPress</PUBLISHER> and Open Specifications Glossary <PUBLISHYEAR>2000</PUBLISHYEAR> Index <PRICE>50.00</PRICE> List </BOOK> of Figures List <BOOK> of Tables <TITLE>The Iliad</TITLE> List of Sidebars <AUTHORNAME>Homer</AUTHORNAME> <ISBN>5354</ISBN> <PUBLISHER>Oracle Press</PUBLISHER> <PUBLISHYEAR>1000</PUBLISHYEAR> <PRICE>5.00</PRICE> </BOOK> </BOOKCATALOG> Part VI - Oracle XML for PL/SQL Developers


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & AccessingOracle XML with StAX PL/SQL

ISBN:0072229527 Mark V. Scardina, and JinyuJava Wang Pull parsing or by StAX (Streaming APIBen for Chang XML) is a new standards effort to address some of the limitations of McGraw-Hill/Osborne © 2004 (600 pages) SAX parsing yet still maintain a streaming model. Defined under JSR-173 in the Java Community Process, XML Pull Parsing was designed with simplicity andfocuses performance in mind. This comprehensive guide on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

As in SAX parsing, StAX delivers events; however, these events are less granular and can be returned as objects. These events, listed next, are derived from XMLEvent:

Table of Contents

StartDocument, EndDocument Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL StartElement, EndElement Introduction Characters, Part I - Oracle andCDATA, the XMLComment Standards Processing Instruction - Introducing XML Entity Reference

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter - Transforming XMLtowith XSLT and XPath A StAX3parser has factories create readers, writers, and events. They consist of the following: Chapter 4

- Validating XML with DTDs and XML Schemas

javax.xml.stream.XMLInputFactory - XML Operations with XQuery javax.xml.stream.XMLOutputFactory Chapter 6 - XML Messaging and RPC with SOAP javax.xml.stream.XMLEventFactory Chapter 5 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II of - Oracle Management DBAs Each these XML factory instances for is obtained through the newInstance() static method. Specific implementations can

Chapter 8 - Getting Started with the Database be plugged into these interfaces as Oracle is doneXML in the Oracle version. Chapter 9

- Storing XML Data

As distinct SAX, you need to register handlers for every type of event that the parser will stream to you. Chapter 10 -from Generating anddon’t Retrieving XML Instead, once a reader in instantiated, you simply call the next() method on the reader to get the events. The following example shows this being done on the booklist.xml file:

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database

XMLStreamReader reader = Part III - Oracle XML for Java Developers XMLInputFactory.newInstance().createXMLStreamReader Chapter 13 - Getting Started with Oracle XML and Java (new 14 FileInputStream("booklist.xml")); Chapter - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

while(reader.hasNext()) { int eventType = reader.next(); Chapter 17 - Developing XML-Based Reusable Components if (eventType == XMLEvent.START_ELEMENT && Part IV - Oracle XML for C Developers reader.getLocalName().equals("\title")) { Chapter 18 - Getting Started with Oracle XML and C reader.next(); Chapter 19 - Building an XML-Managed Application System.out.println(reader.getText()); Chapter 20 - Build an XML Database OCI Application } Chapter 21 - Create an XML-Configured High-Performance Transformation Engine } Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Part V - Oracle XML for C++ Developers

Chapter Note that 22 the - Getting element Started to bewith searched Oraclefor XML could and be C++ “pulled” while the rest is ignored. This is the cursor style of pull

parsing23 and it provides access the document content. Chapter - Build an XMLfine-grained Database OCI C++ to Application Chapter 24 - Building an XML Data-Retrieval Application

There is a second style to StAX parsing that is more natural to Java programmers because it returns the events as objects with get and set type methods. The following is an example of this iterator styleperforming the same task:

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

XMLEventReader eventReader = Chapter 26 - Building PL/SQL Web Services XMLInputFactory.newInstance().createXMLEventReader Chapter 27 - Extending PL/SQL XML Functionality with Java (new FileInputStream("booklist.xml")); while(reader.hasNext()) { Appendix - XML Standards Bodies and Open Specifications XMLEvent event = reader.next(); Glossary if (event instanceof StartElement && Index ((StartElement)event).getLocalName().equals("book\title")) List of Figures { List of Tables System.out.println( ((Characters)reader.next()).getData()); List } of Sidebars } Chapter 28 - Putting It All Together

Note that the getLocalName() method had to be called on the event to pull the title, and the getData() method to extract the data to print it. As you can see in these examples, it is the application, not the parser, that controls the process. This type of parsing is excellent for filtering XML, especially when dealing in small fragments.


The StAX writer can be used for limited transformation when a single pass is all that is necessary creating a subset or derivative XML document. However, the inability to traverse the document bidirectionally makes it a poor replacement forOracle a DOM parser. 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Database PL/SQL

Pull parsing generally can be used wherever SAX parsing can be used—and in most cases with fewer lines of code. ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang Pull parsing really has application in situations in which namespaces need to be supported. As in the DOM, there is McGraw-Hill/Osborne © 2004 (600 pages) the concept of scope to namespaces, where children inherit their parent’s namespace even when it is not explicitly This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with declared. StAXemphasis supportson retrieving this namespace information from elements, whereas SAX does not. Finally, the XML standards, their usage and best practices. ability of StAX to support multiple data or input sources easily provides a uniform programming model that can produce more reliable XML processing in distributed environments. This reliability is due once again to the pull Table of Contents model, where a single parser can poll multiple data sources or inputs and merge their contents into a single context Oracle Database 10g & SQL—Design, Build & Manage XML in Java, C, C++for & PL/SQL without the need forXML multiple threads. This is why StAX is theApplications parsing method of choice web service Introduction specifications such as JAX-RPC(Java API for XML-based RPC). Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Best Practices PL/SQL

by demonstrated Mark V. Scardina, Ben Chang Jinyu Wang This chapter has various ways toand parse and programmatically access the content of XML ISBN:0072229527 documents. McGraw-Hill/Osborne 2004 weaknesses, (600 pages) Each method has different strengths© and as discussed in its respective section. However, as the following sections there are some particular features and solutions to common problems. Thisdiscuss, comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

DTD Caching

Table of Contents

Oracle WhenDatabase parsing a10g collection XML & SQL—Design, or batch of XML Build documents & Manage with XML the Applications same DTD, in Java, performance C, C++ &isPL/SQL improved significantly if

you cache the DTD, which eliminates its being parsed over and over again. While DTD caching is not enabled Introduction automatically, the the Oracle Parser for Java provides the validating/nonvalidating DTD caching through the Part I - Oracle and XMLXML Standards setDoctype() function. XML After you set the DTD using this function, the parser will cache this DTD for further XML Chapter 1 - Introducing parsing.2 This is illustrated theDOM, following Chapter - Accessing XML in with SAX, code JAXB,fragment: and StAX Chapter // Parse 3 - Transforming the first XML document with XSLT and andset XPath the DTD for caching

parser.setValidationMode(DOMParser.DTD_VALIDATION); Chapter 4 - Validating XML with DTDs and XML Schemas parser.setAttribute(DOMParser.USE_DTD_ONLY_FOR_VALIDATION,Boolean.TRUE); Chapter 5 - XML Operations with XQuery parser.parse("{XML_Document_URL}"); Chapter 6 - XML Messaging and RPC with SOAP DTD dtd Chapter 7 -=parser.getDoctype(); Putting It All Together with XML Pipeline, JSPs, and XSQL parser.setDoctype(dtd); Part II - Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

// loop of XML parsing Chapter 9 - Storing XML Data for(...) { Chapter 10 - Generating and Retrieving XML // XML Parsing with DTD Cached Chapter 11 - Searching XML Data }

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XMLshould for Java Note that you also setDevelopers the following if the cached DTD object is used only for validation:

Chapter 13 - Getting Started with Oracle XML and Java

parser.setAttribute(DOMParser.USE_DTD_ONLY_FOR_VALIDATION,Boolean.TRUE);

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - the Creating Portalcopies Site with Weband Services Otherwise, XML aparser theXML DTDand object adds it to the resultant DOM tree. While the preceding Chapter 16is- for Developing an DTD, XML Gateway Application SOAP and AQ DTDs. example an internal the same method iswith used for external Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Skipping the <!DOCTYPE> Tag

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - problem Building an XML-Managed A common when parsing an Application XML document that has an external DTD declaration is retrieving that DTD. In Chapter 20 - Build an not XMLbe Database OCI and Application many cases, it may necessary, frequently firewalls, permissions, etc., prevent retrieving it. Fortunately, Chapter this can21be- ignored Create an in XML-Configured the Java parserHigh-Performance in either of two ways. Transformation If you haveEngine write access to the document, you can add Part standalone=“yes” V - Oracle XMLas foran C++ attribute Developers to the DOCTYPE element. Alternatively, within the application, you can add

Chapter 22 - Getting Started with Oracle XML and C++ xmlparser.setAttribute(XMLParser.STANDALONE, Boolean.TRUE) Chapter 23 - Build an XML Database OCI C++ Application

which has same an effect. Chapter 24 -the Building XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Cutting and Pasting Across Documents

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Using the parserPL/SQL is the appropriate way towith modify Chapter 27 -DOM Extending XML Functionality Javaan XML document in most cases. However, when the modification needs It to All beTogether across different documents, as you would do when cutting and pasting, the approach is not Chapter 28 - Putting obvious. Fortunately, this has been made with the DOM 3.0 adoptNode() method. As distinct from Appendix - XML Standards Bodies and Openeasy Specifications importNode(), which simply copies the node from one document to another, adoptNode() actually removes it from Glossary one document and inserts it into the other document, as illustrated in the following code fragment: Index XMLDocument doc1 = new XMLDocument(); List of Figures XMLElement element1 = (XMLElement)doc1.createElement("foo"); List of Tables doc1.appendChild(element1); List of Sidebars XMLDocument doc2 = new XMLDocument(); XMLElement element2 = (XMLElement) doc2.createElement("bar"); doc2.appendChild(element2); ... // Using adoptNode() element2 = (XMLElement)doc1.adoptNode(element2); element1.appendChild(element2);


We will illustrate further parsing examples in the third part of the book when we illustrate actual applications that you can build. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 3: Transforming XML with XSLT and XPath PL/SQL

Overview

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

To continue theemphasis theme from on XML the standards, last chapter, their oneusage openand XML best standard practices. that has caught tremendous traction in the industry is the W3C Extensible Stylesheet Transformation (XSLT) specification. Many companies have built XSLT engines and applications according to this specification, which is traditionally embodied in an XSLT processor, to be Table of Contents generally invoked following the parsing and validating of the XML document. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Because XSLT is a function-based language, programmers who are used to procedure-based and object-oriented Part I - Oracle and the XMLmay Standards programming languages have difficulty picking it up. An XSLT stylesheet will include one or more templates

Chapter 1 -inIntroducing XML formatted XML that are applied to the entire input XML document. XSLT is a feature-rich language, and version Chapter - Accessing XML withinDOM, SAX,ofJAXB, and StAX 2.0 will2extend it considerably the area supporting XML Schema and data types. Whole books have been Chapter Transforming XML and XPath written 3on -the language, so wewith areXSLT not going to cover that here. Instead, we will focus on integrating the Oracle Chapter 4 - Validating DTDs and XML Schemas XSLT processors into XML yourwith applications. Chapter 5

- XML Operations with XQuery

Using an you RPC can with transform Chapter 6 XSLT - XML processor, Messaging and SOAP an XML document into another XML document, an HTML document, or a variety- Putting of otherIttext formats. The processor can be invoked either programmatically (using the given APIs) or All Together with XML Pipeline, JSPs, and XSQL from the command line, and takes, as input, the XML document (to be transformed) and the XSLT stylesheet that Part II - Oracle XML Management for DBAs operates on it. It performs the transformation specified by the XSLT stylesheet and generates either a result DOM Chapter 8 - Getting Started with the Oracle XML Database tree or a text output stream. The diagram shown in Figure 3-1 represents the architecture of the XSLT processor. Chapter 7

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting with Oracle XML and C Figure 3-1: TheStarted Java XSLT processor architecture Chapter 19 - Building an XML-Managed Application

As mentioned, the processorOCI operates on two inputs: the XML document to transform and the XSLT Chapter 20 - Build anXSLT XML Database Application stylesheet use. Itancalls out to an XPath engine whenever it needs to match Chapter 21 -to Create XML-Configured High-Performance Transformation Enginepatterns. The XPath engine often needs traverse XML Developers DOM tree to retrieve nodes; it passes these nodes back to the XSLT processor. Part V - to Oracle XML the for C++ Whenever XSLT processor generate a result node, it generates a special XSLT event. This event is Chapter 22 -the Getting Started with needs Oracle to XML and C++ handled23by- Build an XSLT event handler,OCI serving as a midtier caching agent, which waits for subsequent events that Chapter an XML Database C++ Application affect the result A simple example of this is when the result node to be built is an XMLElement. Multiple Chapter 24 same - Building annode. XML Data-Retrieval Application XSLT as one to create the element simply followed by several that depict its attributes, may be Part VI events, - Oracle such XML for PL/SQL Developers generated by the XSLT processor. Once the XSLT event handler gets complete information about a node, it generates an appropriate SAX event, which can then be processed by a registered SAX handler.

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Chapter 27 -two Extending PL/SQL XML Functionality with Currently, output mechanisms are supported by Java the XSLT Processor for Java: a DOM tree and a text output Chapter - Putting It Allmechanisms Together stream.28 Either of these can be invoked through appropriate API calls made using the XSLProcessor Appendix - XML BodiesDOM and Open class. If the API Standards to build a result tree isSpecifications invoked, a DOM tree builder is registered as the SAX event handler for Glossary XSLT. Similarly, if the API to output to a text stream is invoked, an OutputWriter is registered as the SAX event Index handler. The advantage of this architecture is that a DOM tree is not built as the result tree unless you require it. If

your application simply needs a text output (such as HTML), you can use the less memory-intensive List of XSLT Figures OutputWriter mechanism to do the processing. Remember, if your XSLT stylesheet contains xsl:output List of Tables instructions, List of Sidebarsyou must use the OutputWriter mechanism for these instructions to be interpreted correctly.


Oracle Database 10g XML SQL: Design, & Manage XML Applications in Java, C, C++ & Programmatic Invocation of& the XSLT Build Processor PL/SQL

by Mark V. Scardina, Ben Chang and Jinyu The XSLT processor exposes two Java classes that youWang need to use to perform an XSL transformation: ISBN:0072229527 © 2004 (600 pages) XSLProcessorMcGraw-Hill/Osborne and XSLStylesheet. An XSLStylesheet object holds all information about an XSLT stylesheet, such as its templates, keys, variables, and attribute sets. This once constructed, canXML-enabled be used multiple timeswith This comprehensive guide focuses on utilizing XMLobject, technologies within Oracle's products, emphasis on XML standards, their usagedocuments. and best practices. to apply the same transformation to a variety of XML It can also be “tweaked” periodically by setting suitable stylesheet parameter values from the outside. Table of Contents

The following code demonstrates how the XSLT APIs could be used:

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

import java.util.*; Introduction import java.io.*; Part I - Oracle and the XML Standards import java.net.*; - Introducing XML import org.w3c.dom.*; Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX import oracle.xml.parser.v2.*; Chapter 1 Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

/** XML Operations with XQuery * This -is a simple example of how to use the XSL processing Chapter 6 XML Messaging and Oracle RPC with XML SOAP Parser V2.0. An input XML document * capabilities of the Chapter 7 Putting It All Together with XML Pipeline,stylesheet JSPs, and XSQL * is transformed using a given input Part II Oracle XML Management for DBAs */ Chapter 8 class - Getting Started with the public XSLExample { Oracle XML Database Chapter 9 - Storing Datamain (String args[]) throws Exception { public staticXML void Chapter 10 - Generating and Retrieving XML DOMParser parser; Chapter XMLDocument 11 - Searching xmldoc, XML Data xsldoc, out; FileInputStream xmlstream, xslstream; Chapter 12 - Managing the Oracle XML Database try { XML for Java Developers Part III - Oracle //- Getting CreateStarted an instance Chapter 13 with Oracleof XMLthe and DOMParser Java parser = an newXML-Powered DOMParser(); Chapter 14 - Building Web Site parser.setPreserveWhitespace(true); Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 5

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

// parse input XML file xmlstream = new FileInputStream(args[0]); Part IV - Oracle XML for C Developers parser.parse(xmlstream); Chapter 18 - Getting Started with Oracle XML and C xmldoc = parser.getDocument(); Chapter 17 - Developing XML-Based Reusable Components

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application

// parse input XSL file xslstream = new FileInputStream(args[1]); Part V - Oracle XML for C++ Developers parser.parse(xslstream); Chapter 22 - Getting with Oracle XML and C++ xsldoc = Started parser.getDocument();

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 an XML Data-Retrieval Application //- Building instantiate a stylesheet Part VI - Oracle XML for PL/SQL XSLStylesheet xsl Developers = processor.newXSLStylesheet(xsldoc);

Chapter 25 with Oracle XML and PL/SQL //- Getting Apply Started stylesheet Chapter 26 - Building PL/SQL Web Services XSLProcessor processor = new XSLProcessor(); Chapter 27 XMLDocumentFragment - Extending PL/SQL XML Functionality result = with Java

processor.processXSL(xsl, xmldoc); Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications Glossary // print the transformed document

result.print(System.out); } catch (Exception e) { List of Figures e.printStackTrace(); List of Tables } List of Sidebars } } Index

The preceding example is fairly straightforward. It accepts as input, the XML input file, and the XSL stylesheet to apply. The first thing you need to do is to parse these using the DOMParser and to retrieve the roots of their respective DOM trees: // Create an instance of the DOMParser parser = new DOMParser();


parser.setPreserveWhitespace(true); // parse input XML file Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & xmlstream =PL/SQL new FileInputStream(args[0]); parser.parse(xmlstream); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang xmldoc = parser.getDocument(); McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

// parse input XSL onfile emphasis XML standards, their usage and best practices. xslstream = new FileInputStream(args[1]); parser.parse(xslstream); Table of Contents xsldoc = parser.getDocument();

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction The important thing to note is that the new parser is explicitly configured to preserve whitespace (by default, it is not Part I - Oracle the XML Standards unless a DTDand is present). This is crucial, as it allows XSLT whitespace rules to determine how white space should

Chapter - Introducing XML be dealt1 with. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

The next is to construct stylesheet object: Chapter 3 step - Transforming XML awith XSLT and XPath // instantiate a XML stylesheet Chapter 4 - Validating with DTDs and XML Schemas XSLStylesheet xslwith = XQuery processor.newXSLStylesheet(xsldoc); Chapter 5 - XML Operations Chapter 6

- XML Messaging and RPC with SOAP

This example, being extremely simple, assumes that the input stylesheet does not reference anything external, such - Putting It All Together with XML Pipeline, JSPs, and XSQL as included stylesheets, external entities, and so forth. Only in such a case can you get away with passing a null as Part II - Oracle XML Management for DBAs the second argument to the XSLStylesheet constructor. Otherwise, you need to create a URL to serve as a Chapter 8 - Getting Started with the Oracle XML Database reference point for resolving external references within the stylesheets. Chapter 7

Chapter 9

- Storing XML Data

Chapter 10step - Generating andaRetrieving XML The next is to create new XSLProcessor and use it to apply the stylesheet on the input XML document: Chapter 11 - Searching XML Data // Apply stylesheet Chapter 12 - Managing the Oracle=XML XSLProcessor processor newDatabase XSLProcessor(); Part III - Oracle XML forresult Java Developers DocumentFragment = processor.processXSL(xsl,

xml);

Chapter 13 - Getting Started with Oracle XML and Java

The transformed output is now available you as a document fragment, which can be further manipulated using the Chapter 14 - Building an XML-Powered WebtoSite regular15 DOM APIs. For the sake of simplicity, Chapter - Creating a Portal Site with XML andthis Webexample Servicesprints the results: Chapter 16 - Developing an XML Gateway Application with SOAP and AQ // print the transformed document Chapter result.print(System.out); 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

A simple powerful stylesheet is the XML identity Chapter 18yet - Getting Started with Oracle andstylesheet: C <?xml 19 version="1.0"?> Chapter - Building an XML-Managed Application <!–– Identity ––> Chapter 20 - Build antransformation XML Database OCI Application <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> Chapter 21 - Create an version="1.0" XML-Configured High-Performance Transformation Engine Part<xsl:template V - Oracle XML for match="*|@*|comment()|processing-instruction()|text()"> C++ Developers

<xsl:copy> Chapter 22 - Getting Started with Oracle XML and C++ <xsl:apply-templates select="*|@*|comment()|processingChapter 23 - Build an XML Database OCI C++ Application instruction()|text()"/> </xsl:copy> Part VI - Oracle XML for PL/SQL Developers </xsl:template> Chapter 25 - Getting Started with Oracle XML and PL/SQL </xsl:stylesheet> Chapter 24 - Building an XML Data-Retrieval Application

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending PL/SQL Functionality withyou Java If you apply this stylesheet to XML any XML document, get the same document back. You can test the preceding Chapter 28by - Putting Together to a file containing the identity stylesheet and (say) the booklist example from example passingItitAll a reference Appendix XML output Standards Bodies would and Open Specifications Chapter 2.- The generated be as expected: Glossary <booklist> Index <book isbn="0-07-213495-X"> List of Figures <title>Oracle9i XML Handbook</title> List of Tables <author>Chang, Scardina and Kiritzov</author> List of Sidebars <publisher>Osborne</publisher>

<price>49.99</price> </book> <book isbn="1230-23498-2349879"> <title>Emperor's New Mind</title> <author>Roger Penrose</author> <publisher>Oxford Publishing Company</publisher> <price>15.99</price> </book>


</booklist> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Navigating XML with 10g XPath PL/SQL

ISBN:0072229527 by Marklanguage V. Scardina, Ben Chang Jinyu Wang TheXML Path (XPath) provides a wayand to address parts of an XML document and some basic functionality McGraw-Hill/Osborne © 2004and (600Booleans. pages) for the manipulation of strings, numbers, XPath is also a W3C standard, currently at version 1.0 but soon to be 2.0.This However, as distinct fromfocuses other standards, is designed to be usedOracle's by hostXML-enabled languages. XSLT, comprehensive guide on utilizing itXML technologies within products, with emphasis on XMLstandards standards,use their and the bestuse practices. XPointer, and the new XQuery it.usage Because of XPath with XSLT is well documented in XSLT books, we do not provide an extensive discussion here. However, to help with the examples, we provide a brief summary. Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

XPath models an XML document as a tree of nodes. These nodes are of the following types: root nodes, element nodes, text nodes, attribute nodes, namespace nodes, processing instruction nodes, and comment nodes. As you Part I - Oracle and the XML Standards can see, these are the same nodes used by DOM. Introduction Chapter 1

- Introducing XML

Chapter 2 - Accessing XML with DOM,toSAX, JAXB,these and StAX XPath defines a declarative syntax navigate nodes to point to a document subtree or item. Referring to our Chapter sample3XML - Transforming document inXML the with previous XSLTsection, and XPath paths are expressed in a similar fashion to how files and URLs are

expressed: the XPath XML / refers the entire document, Chapter 4 - Validating withtoDTDs and XML Schemaswhere /booklist/book/title refers to the <title> element that is a child 5of the book element.with Attributes Chapter - XML Operations XQuerycan also be selected using the @ symbol prepended to their name. For example, to the id attribute on the book element. Chapter 6 /booklist/book[@id] - XML Messaging and refers RPC with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

XPath also defines a way to compute a string-value for each type of node. For some node types, the string-value is part of the node; for other types of node, the string-value is computed from the string-value of descendant nodes. Chapter 8 - Getting Started with the Oracle XML Database For nodes that have a name (for example, element nodes), XPath models these as an expanded name—that is, a Chapter 9 - Storing XML Data name-value pair, consisting of a local name and a namespace value. Part II - Oracle XML Management for DBAs

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

XPath Expressions

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

XPath expressions are the heart of XPath’s functionality and are used extensively in XSLT. When an XPath expression is evaluated, the result is an object of one of the types: node-set (an unordered collection of nodes Chapter - Building Boolean an XML-Powered Site without14 duplicates), (true or Web false), number (a floating-point number), or string (a sequence of UCS Chapter 15 - Creating a Portal Site with XML and Services characters). Expression evaluation occurs withWeb respect to a context, and according to a set of rules and the order in Chapter 16apply - Developing an XML Gateway Application SOAP and AQ XSLT and XPointer each specify how this which to them. Since XPath is dependent on with the host language, Chapter Developingrelative XML-Based Reusable context17 is -determined to their use in Components their respective languages. Chapter 13 - Getting Started with Oracle XML and Java

Part IV - Oracle XML for C Developers

The example paths Started in the previous sections areCactually expressions when used in an XSLT stylesheet. Taking a Chapter 18 - Getting with Oracle XML and look at 19 our- identity we seeApplication the following expression: Chapter Buildingstylesheet, an XML-Managed Match="*|@*|comment()|processing-instruction()|text()" Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

ThisVis- Oracle evaluated a set of all XML items where the | signifies “or.” Therefore, it matches elements as the Part XMLas formatching C++ Developers first*, attributes as @*, commentsas comment(),processing instructions as processing-instruction, and text as text().

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application

Chapter 24 - Building XML Data-Retrieval Application Expressions can be an constructed not only with path syntax but also by using a rich array of functions that support Part VI - Oracle XML for PL/SQL Developers operations on node sets, numbers, strings, and Booleans. Table 3-1 provides examples that could be used in a

Chapter 25 -that Getting Started Oracle XML stylesheet accepts our with booklist.xml fileand as PL/SQL input. Chapter 26 - Building PL/SQL Web Services Chapter 27 - Example ExtendingXpath PL/SQLExpressions XML Functionality with Java Table 3-1: Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Example //book

Description of the <book> elements inin theJava, C, C++ & Oracle Database 10g XML & SQL: Design,Selects Build &all Manage XML Applications PL/SQL document by Mark V. Scardina, Ben Chang and Jinyu Wang

//book[@id=”121”] McGraw-Hill/Osborne © 2004 (600 pages)

Selects the <book> element whose id is 121

ISBN:0072229527

This comprehensive guide focuses on utilizingSelects XML technologies within in Oracle's XML-enabled products, with Book[position()=1] the first <book> the document emphasis on XML standards, their usage and best practices.

//title | //author Table of Contents number sum(//book/price)

Selects all <title> and <author> elements Returns the sum of all <price> elements whose

Oracle Database 10g XML & SQL—Design, Build & Manage XML parent Applications is <book> in Java, C, C++ & PL/SQL Introduction

string concat (//book/title, //book/author)

Part I - Oracle and the XML Standards

Chapter 1

Returns a concatenated list of titles and authors

- Introducing XML

Count2(/booklist) Chapter - Accessing XML with DOM, SAX, JAXB, and StAX Returns a count of all books, which is 2 Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

ancestor::book

Selects the ancestor node of <book>, which is <booklist>

Chapter 6 - XML Messaging and with SOAP These expressions are used asRPC predicates within the XSLT language to activate a template or perform an operation Chapter 7 - Putting It All Together with XML as Pipeline, JSPs, and XSQLfunctions, which are distinct from XPath on selected XML content. They also serve parameters to XSLT Part II - Oracle XML Management for DBAs functions.

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Introducing XSLT Stylesheets PL/SQL

ISBN:0072229527 Mark V. rules Scardina, Ben Chang and Jinyu Wang XSLTis used tobydescribe for transforming a source tree into a result tree. The transformation is achieved by McGraw-Hill/Osborne 2004 (600 pages) associating patterns with templates ©contained within a stylesheet. An XSLT processor matches patterns against elements in theThis source tree and instantiates associated templates to create various parts ofXML-enabled the result tree. While with comprehensive guide focuses on utilizing XML technologies within Oracle's products, emphasis on XML standards, might their usage and reorder best practices. constructing the result tree, the processor filter and elements from the source tree and add arbitrary structure, as specified by the XSLT transformation. The result tree is separate from the source tree—that is, no nodes shared between the two—and its structure can be completely different from the structure of the source Table of are Contents tree. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Introduction

XSLT stylesheets are well-formed XML documents that contain elements and attributes in the XSLT namespace (http://www.w3.org/1999/XSL/Transform). These elements and attributes are used to provide instructions to an Chapter 1 - Introducing XML XSLT processor regarding the transformation it needs to effect. A stylesheet may also contain elements and Chapter 2 that - Accessing with DOM, SAX, JAXB,XSLT and StAX attributes are not XML in the XSLT namespace. processors typically interpret these as markup to be directly Chapter 3 the - Transforming XML with XSLTis and added to result tree. An exception the XPath case of extension-elements, which serve as XSLT processor Chapter 4 - Validating with DTDs and XML Schemas instructions and are inXML a separate namespace defined using a special mechanism. Part I - Oracle and the XML Standards

Chapter 5

- XML Operations with XQuery

XSLT instructions are contained within The result tree is constructed by finding the template rule for the Chapter 6 - XML Messaging and RPC withtemplates. SOAP root node instantiating its template. When a template is instantiated, each instruction within it is executed and Chapter 7 -and Putting It All Together with XML Pipeline, JSPs, and XSQL replaced by theXML result tree fragment it creates. These instructions may select and process descendant source Part II - Oracle Management for DBAs elements, may entailwith instantiating other Chapter 8 -which Getting Started the Oracle XMLtemplates. Database It is important to note that elements are only processed

when they-have been selected by the execution of an instruction. XSLT uses the XPath language to select elements Storing XML Data from the source tree and to do conditional processing.

Chapter 9

Chapter 10 - Generating and Retrieving XML

Chapter 11 processor - Searchinginstantiates XML Data templates based on pattern-matching rules. In the process of finding an applicable An XSLT Chapter 12rule, - Managing the one Oracle XML Database template more than template rule may have a pattern that matches a given element. The processor then Part III - Oracle XML for Java Developers uses special conflict-resolution logic (which uses template priorities) to ensure the best template rule is applied.

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XSL Templates PL/SQL

ISBN:0072229527 V. Scardina, Ben Chang Jinyu Wang Templates canby beMark compared to procedures in aand structural programming language. Templates contain programming © 2004 (600 pages) logic expressedMcGraw-Hill/Osborne in terms of XSLT instructions that process the source tree and change the result tree. In some cases, even a This single template can guide be used to transform your source tree intowithin a result tree. In fact, XSLT products, has a comprehensive focuses on utilizing XML technologies Oracle's XML-enabled with emphasis onLiteral XML standards, their usage and best practices. special mechanism called Result Element as Stylesheet, which enables you to embed all your XSLT processing logic in the body of the result document you want to create.

Table of Contents

Templates can either be explicitly named or contain a match expression. When the XSLT processor encounters an xsl:apply-templates instruction, it attempts to match the nodes that were selected with the most appropriate Introduction template (using the match expression). Sometimes, more than one template might match. XSLT specifies a complex Part I - Oracle and the XML Standards set of rules to help resolve this conflict by assigning priorities to various kinds of match expressions (patterns). Chapter 1 - Introducing XML Additionally, a template may itself specify an explicit priority, which the XSLT processor considers while determining Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX which template to instantiate. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & The XSLTOracle Process Model PL/SQL

ISBN:0072229527 by Mark V. Scardina, Chang and that Jinyu Wang you to use it almost like a programming language XSLT comes with a full-fledged set Ben of instructions enable of its McGraw-Hill/Osborne © 2004 (600 pages) and loops exist, just as you would expect in any programming own. Conditional statements, variables, parameters, language. Obviously, XSLT is geared more to doontransformations than to write general-purpose programs, but its with This comprehensive guide focuses utilizing XML technologies within Oracle's XML-enabled products, onit XML standards, usage and best practices. rich instructionemphasis set makes a powerful tool,their indeed.

The various instructions you can use in XSLT, their syntax, and a brief explanation of what they do are described in the next few sections.

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

<xsl:apply-imports/>

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

This instruction, when encountered while processing a node within a template, directs the processor also to apply - Accessing XML with DOM, SAX, JAXB, and StAX template rules imported into the stylesheet on that node. It has no attributes or content.

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

<xsl:apply-templates> - XML Operations with XQuery

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

The following instruction directs the processor to instantiate a template that matches the XPath expression given by - Putting It All Together with XML Pipeline, JSPs, and XSQL the value of the select attribute. In the absence of a select attribute, the instruction processes all the children of the Part II - Oracle XML Management for DBAs current node, including text nodes. The optional mode attribute can be used to specify the mode of the template to Chapter 8 - Getting Started with the Oracle XML Database be used if a conflict occurred. This instruction can also be made to pass parameters to the template being Chapter 9 - Storing XML Data instantiated (using xsl:with-param) and change the order of processing the selected nodes (as given by xsl:sort): Chapter 7

Chapter 10 - Generating and Retrieving XML

<xsl:apply-templates select = node-set-expression mode = qname> <!–– Content: (xsl:sort | xsl:with-param)* ––> Chapter 12 - Managing the Oracle XML Database </xsl:apply-templates> Chapter 11 - Searching XML Data

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database Introducing XSLT 2.010g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 by1.0 Mark V. Scardina, Ben Chang and was Jinyuno Wang When the XSLT standard was released, there XML Schema standard. Consequently, stylesheets were McGraw-Hill/Osborne © 2004 (600 pages) extremely limited in the types of transformations and XML operations that they could perform. As of this writing, the XSLT 2.0 standard is in its final stages will bring significant along with expanded functionality This comprehensive guideand focuses on utilizing XML enhancements technologies within Oracle's XML-enabled products,and with emphasis onBecause XML standards, theirJava usage and best practices. support for XML Schema. the Oracle XSLT processor will support this standard, the following sections provide a brief overview of it.

Table of Contents

Note There is also a companion XPath 2.0 standard that incorporates an extensive set of functions and operators on XML Schema data types. This standard will not be discussed because there is not as yet an Introduction Oracle implementation. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Grouping - Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

In XSLT 1.0, stylesheet writers had great difficulty in creating templates that grouped items. In fact, the most popular - Validating XML with DTDs and XML Schemas method was one developed by Steve Muench of Oracle that involves using <xsl:key> to create keys for grouping. In Chapter 5 - XML Operations with XQuery 2.0, <xsl:for-each-group> has been introduced to perform this function. An example of its usage to subset and sort Chapter 6 - XML Messaging RPC is with thebooklist.xml example byand author as SOAP follows: Chapter 4

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

<xsl:for-each-group select="book" group-by="author"> <xsl:sort select="current-grouping-key()" /> Chapter 8 - Getting Started with the Oracle XML Database <author> Chapter 9 - Storing XML Data <xsl:value-of select="current-grouping-key()" /> Chapter 10 - Generating and Retrieving XML <xsl:for-each select="current-group()"> Chapter <book> 11 - Searching XML Data Chapter 12<xsl:value-of - Managing the Oracle XML Database /> select="title" Part III </book> - Oracle XML for Java Developers Chapter 13 - Getting Started with Oracle XML and Java </xsl:for-each> Chapter 14 - Building an XML-Powered Web Site </author> Chapter </xsl:for-each-group> 15 - Creating a Portal Site with XML and Web Services Part II - Oracle XML Management for DBAs

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

This produces the following XML output: Chapter 17 - Developing XML-Based Reusable Components <book isbn="0-07-213495-X"> Part IV - Oracle XML for C Developers <title>Oracle9i Handbook</title> Chapter 18 - Getting Started XML with Oracle XML and C <author>Chang, Scardina Application and Kiritzov</author> Chapter 19 - Building an XML-Managed </book> Chapter 20 - Build an XML Database OCI Application <book Chapter 21 -isbn="1230-23498-2349879"> Create an XML-Configured High-Performance Transformation Engine New Mind</title> Part V <title>Emperor's - Oracle XML for C++ Developers <author>Roger Penrose</author> </book>

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Function Definitions

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

In XSLT 2.0, functions can be defined via the xsl:function declaration, callable from any XPath expression in the stylesheet. The name of the function must be a QName, along with any parameters defined via xsl:param Chapter 28 - Putting It All Together elements. In this manner, stylesheet creators can define their own functions in much the same way that functions Appendix - XML Standards Bodies and Open Specifications are created in other programming or scripting languages. The following example defines a function that takes an Glossary integer and returns its lexical name in uppercase: Chapter 27 - Extending PL/SQL XML Functionality with Java

Index

<xsl:function name="str:numtostr" as="xs:string"> <xsl:param name="value" as="xs:integer"/> List of Tables <xsl:number value="$value" format="N"/> List of Sidebars </xsl:function> List of Figures

This can be used in a template: <xsl:template match="/"> <output> <xsl:value-of select="str:numtostr(9)"/> </output> </xsl:template>


This template returns the following: <output>NINE</output> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Multiple Result Documents by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

In XSLT 2.0, stylesheet writers can invoke <xsl:result-document> to create a result tree that can then be guide focuses on utilizing technologies within Oracle's XML-enabled products, validated. The This root comprehensive node of this tree is the document node. XML The utility of this is that different output formats can be with emphasis on XML standards, their usage and best practices. specified for the result tree and validation can occur on these different formats. Turning once again to booklist.xml, the following template will split it into separate files, book1.htmland book2.html: Table of Contents

<xsl:template match="/">

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <xsl:for-each-group select="/booklist/book"> Introduction <xsl:result-document href="book{position()}.html" Part I - Oracle and the XML Standards format="book-format"

validation="strip">

Chapter 1 - Introducing XML <html xmlns="http://www.w3.org/1999/xhtml"> Chapter 2 - Accessing XML with DOM, SAX, select="./title"/></title></head> JAXB, and StAX <head><title><xsl:value-of Chapter 3 - Transforming XML with XSLT and XPath <body> Chapter <xsl:copy-of 4 - Validating XML select="current-group()"/> with DTDs and XML Schemas

</body> Chapter 5 - XML Operations with XQuery </html> Chapter 6 - XML Messaging and RPC with SOAP </xsl:result-document> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL </xsl:for-each-group> Part II - Oracle XML Management for DBAs </xsl:template> Chapter 8 - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

The output of book1.htmlwill be

Chapter 11 - Searching XML Data

<html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Oracle9i XML Handbook</title></head> Part III - Oracle XML for Java Developers <body> Chapter 13 - Getting Started with Oracle XML and Java <title>Oracle9i XML Handbook</title> Chapter 14 - Building an XML-Powered Web Site <author>Chang, Scardina and Kiritzov</author> Chapter 15 - Creating a Portal Site with XML and Web Services <publisher>Osborne</publisher> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <price>49.99</price> Chapter 17 - Developing XML-Based Reusable Components </body> Part IV Oracle XML for C Developers </html> Chapter 12 - Managing the Oracle XML Database

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Temporary Trees

Chapter 20 - Build an XML Database OCI Application Chapter 212.0, - Create an XML-Configured High-Performance Transformation Engine In XSLT temporary trees are available for processing. In this manner, intermediate results of transformations Part V - Oracle XML for C++ Developers

can be accessed and then discarded. These trees can be constructed by evaluating an xsl:variable,xsl:param, or

Chapter 22 - Getting Started with Oracle XML and C++ (referred to as the variable-binding element), the value of which xsl:with-param element that has nonempty content Chapter 23 the - Build an XMLnode Database C++ Application becomes document of theOCI temporary tree. Chapter 24 - Building an XML Data-Retrieval Application

TheVI advantage is that instead of employing one large template, complex XSLT transformations can be broken Part - Oracle XML fornow, PL/SQL Developers down and Since passed in, lookup tables for various mappings can be employed. The Chapter 25 -modularized. Getting Started withvalues Oraclecan XMLbeand PL/SQL following syntax Web showing how to pass the tree between templates that may apply successive styles: Chapter 26is- example Building PL/SQL Services <xsl:import href="modern.xsl"> Chapter 27 - Extending PL/SQL XML Functionality with Java <xsl:import href="sophisticated.xsl"> Chapter 28 - Putting It All Together <xsl:variable name="style"> Appendix - XML Standards Bodies and Open Specifications <xsl:apply-templates select="/" mode="modern" /> Glossary </xsl:variable> Index <xsl:template match="/" /> <xsl:apply-templates select="$style" mode="sophisticated"/> List of Tables </xsl:template> List of Figures

List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & The Oracle XSLT Extensions PL/SQL

ISBN:0072229527 by extensions, Mark V. Scardina, Ben to Chang and Jinyu Wang For Oracle XSLT you need understand that once you define an XSLT extension in a certain McGraw-Hill/Osborne 2004be (600 pages) programming language, the XSL file©can used only with XSL processors that can invoke such an extension. For example, if youThis define an XSLT extension function Java, XML this function can be invoked onlyXML-enabled by an XSL processor comprehensive guide focuses on in utilizing technologies within Oracle's products, with on Currently, XML standards, their usage andfor best practices. that can invokeemphasis Java calls. no extensions exist Oracle XSL processors in C/C++.

In addition, you should use XSLT extensions only if the built-in XSL functions can’t help you solve the problem. For example, instead of creating an arc tangent function, you can use the built-in cosine and sine functions to achieve Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL this functionality.

Table of Contents Introduction

Part I - Oracle the XML of Standards Finally, if you and are thinking using a specific XSL processor, you need to have the namespace of the extension

Chapter 1 -with Introducing XMLURL. For example, when using the Oracle XSLT extensions, the namespace to prefix is class start the proper Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX http://www.oracle.com/XSL/Transform/java. Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

Validating XML with DTDs and XML Schemas Useful -Built-in Java Oracle XSLT Extensions

Chapter 5

- XML Operations with XQuery

Chapter Messaging RPC XSLT with SOAP Defined6 for- XML use by the Javaand Oracle processor, two such extensions are <ora:output> element and Chapter <ora:node-set>, 7 - Puttingwhere It All Together xmlns:ora=“http://www.oracle.com/XSL/Transform/java”. with XML Pipeline, JSPs, and XSQL When <ora:output> is used Part as aIItop-level - Oracle element, XML Management it is similar fortoDBAs the <xsl:output> extension function, except that <ora:output> has an

additional is the used as anXML identifier. When <ora:output> is used in an XSL template, again, it is Chapter 8 -attribute Getting name Startedthat with Oracle Database similar 9to the <xsl:output> Chapter - Storing XML Dataextension function, except that it has two additional attributes, use and href, which specify10 the- name of theand top-level <ora:output> to be used and give the output URL for the subtree of the XSLT Chapter Generating Retrieving XML result, respectively. Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

<xsl:output> is very useful when you need to create multiple outputs from one XSLT transformation, such as the product specifications. Using <xsl:output>, you can create the index pages with links to the set of subpages for the Chapter 13 - Getting Started with Oracle XML and Java topic details. Part III - Oracle XML for Java Developers

Chapter 14 - Building an XML-Powered Web Site

Chapter The second 15 - Creating built-in extension a Portal Site function, with XML <ora:node-set>, and Web Services converts a result tree fragment into a node-set, which

makes 16 it a-very useful convenience function. This function is useful if you need to refer the existing text or Chapter Developing an XML Gateway Application with SOAP and AQ intermediate text result XML-Based in XSL for further XSL transformation. Chapter 17 - Developing Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & The XSLTOracle Virtual Machine PL/SQL

ISBN:0072229527 Mark V. 10g Scardina, Ben Chang Jinyu Wang New in Oracle by Database is an XSLT Virtualand Machine (XSLTVM) available for C and C++. It is the software © 2004 (600 pages) XSLT code. To do this, XSL stylesheets need to be compiled implementationMcGraw-Hill/Osborne of a CPU designed to run compiled into the code the XSLTVM understands. Therefore, an XSLXML compiler is also included that isXML-enabled compliant with the XSLT This comprehensive guide focuses on utilizing technologies within Oracle's products, with emphasis on XMLcan standards, usage practices. 1.0 standard. This compilation occur attheir runtime or and can best be stored for runtime retrieval. Thus, transformations are performed more quickly with higher throughput, as the stylesheet not only doesn’t need to be parsed, but the templates are applied with an index lookup instead of an XML operation. Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Using the XSLTVM involves a bit different processing model and APIs. The following is a code listing of this process:

Introduction

Part I - Oracle and the XML Standards

/* Create or re-use an XML meta context object. / - Introducing XML xctx = XmlCreate(&err,...); Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX /* Create or re-use an XSLT Compiler object. / Chapter 3 - Transforming XML with XSLT and XPath comp = XmlXvmCreateComp(xctx); Chapter 4 - Validating XML with DTDs and XML Schemas /* Compile an XSL stylesheet and store/cash the result bytecode. / Chapter 5 - XML Operations with XQuery code = XmlXvmCompileFile(comp, xslFile, baseuri, flags, &err); Chapter 6 - XML and RPC withobject. SOAP /* Create or Messaging reuse an XSLTVM The explicit stack size setting is needed Chapter 7 Putting It All Together with XML and XSQLmessage or when smaller when XSLTVM terminates with "...Pipeline, Stack JSPs, Overflow" Part II Oracle XML Management for DBAs memory footprints are required (see XmlXvmCreate). / Chapter - Getting Started with the Oracle XML Database vm = 8XmlXvmCreate(xctx, "StringStack", 32, "NodeStack", 24); Chapter 9 a- Storing XML Data /* Set stylesheet bytecode to the XSLTVM object. */ Chapter Generating and Retrieving XML len 10 = -XmlXvmGetBytecodeLength(code, &err); Chapter err 11 = -XmlXvmSetBytecodeBuffer(vm, Searching XML Data code, len); /* Transform an instance XMLDatabase document. */ Chapter 12 - Managing the Oracle XML XmlXvmTransformFile(vm, xmlFile, baseuri); Parterr III - =Oracle XML for Java Developers /* Clean up. */Started with Oracle XML and Java Chapter 13 - Getting XmlXvmDestroy(vm); Chapter 14 - Building an XML-Powered Web Site XmlXvmDestroyComp(comp); Chapter 15 - Creating a Portal Site with XML and Web Services XmlDestroy(xctx); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 1

Chapter 17 - Developing XML-Based Reusable Components

We discuss the XSLTVM in more detail in Chapter 21, in which we use it in an application.

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XSLT andOracle the Database PL/SQL

by developers Mark V. Scardina, Ben Chang and Jinyudata Wang Many application are putting their business to work over the Web as the Internet drives ISBN:0072229527 an McGraw-Hill/Osborne © 2004 exchange. (600 pages) Developers require standards-based solutions to this problem. explosive demand for flexible information SQL, XML, andThis XSLT are the standards that canonget the jobXML done in practice.within Oracle's XML-enabled products, with comprehensive guide focuses utilizing technologies emphasis on XML standards, their usage and best practices.

SQL is the standard you are already familiar with for accessing appropriate views of database-stored business information in your production systems. XML provides an industry-standard, platform-neutral format for representing Table of Contents the results of SQL queries as datagrams for exchange. XSLT defines the industry-standard way to transform XML Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL datagrams into target XML, HTML, or text format as needed. Introduction

Part I - Oracle and the XML Standards Beginning in Oracle9i, XSLT transformations can be invoked from SQL with the xsltransform() function. It is also

Chapter 1 as - Introducing XML available xmltype.transform(). This function invokes the C XSLT 1.0 processor from the XDK that is linked into Chapter 2 -ofAccessing XML with DOM, SAX, JAXB, takes and StAX the kernel the Oracle database. The function as parameters an XMLType and the stylesheet, as shown in Chapter the following 3 - Transforming example: XML with XSLT and XPath Chapter 4 XMLTransform(booklist.xmlcol, - Validating XML with DTDs and XML Schemas SELECT Chapter 5 - XML Operations with XQuery (select stylesheet from stylesheet_tab where id = 1)).getStringVal() Chapter 6 - XMLFROM Messaging and RPC with SOAP AS result book_tab booklist; Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

ThisIIfunction take an explicit stylesheet or a DBURI to the stored location. The following is the same query Part - Oraclecan XMLalso Management for DBAs using a8DBURI: Chapter - Getting Started with the Oracle XML Database SELECT Chapter 9 XMLTransform(booklist.xmlcol, - Storing XML Data dburiType('/SCOTT/STYLESHEET_TAB/ROW[ID = 1] Chapter 10 - Generating and Retrieving XML Chapter /STYLESHEET/text()').getXML()).getStringVal() 11 - Searching XML Data

AS 12 result FROM Chapter - Managing thebook_tab Oracle XML booklist; Database Part III - Oracle XML for Java Developers

We will discuss the SQL XML functions in greater detail in the chapters that deal with the Oracle XML database.

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Best Practices PL/SQL

ISBN:0072229527 by Mark describe V. Scardina, Benbest Chang and Jinyu Wangwhen employing XSL and XSLT functionality. The following sections some practices to follow Simply McGraw-Hill/Osborne © 2004 (600 pages) that you may encounter and explain how to solve them. put, these sections go over some common problems

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Tuning Tips for XSLT

Table Contents Hereofare two tips for tuning XSLT. First, avoid unconstrained axes such as //foo because they cause the entire tree Oracle to be Database traversed.10g Second, XML &ifSQL—Design, element whitespace Build & Manage is not needed XML Applications by the transformed in Java, C,output, C++ &then PL/SQL <xsl:strip-space

elements=“*”/> can be set in the stylesheet, dramatically reducing the size of the DOM tree built and thus Introduction improving theand transformation performance. Note that when using <xsl:strip-space elements=“*”/>, a prebuilt DOM Part I - Oracle the XML Standards for the 1input XML document Chapter - Introducing XML cannot be passed as a parameter to the XSLT processor. Instead, you need to pass in an URL2 or-aAccessing text stream. Chapter XML with DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

- Validating XMLFunction with DTDs andin XML Schemas The document() XSLT

Chapter 4 Chapter 5

- XML Operations with XQuery

This function is useful whenand theRPC XSLT transformation needs data from multiple XML documents. In addition, when Chapter 6 - XML Messaging with SOAP the XSLT includes a large section ofPipeline, XML data, useand theXSQL <xsl:copy> extension function to copy the XML Chapter 7 output - Putting It All Together with XML JSPs, document content fromfor theDBAs document() function. Finally, when using the document() function in the XSL Part II - Oracle XML returned Management file, make that Started the setBaseURL() is correctly set; if it is not set, the XSL file will not be found by the XSLT Chapter 8 -sure Getting with the Oracle XML Database processor.- Storing XML Data

Chapter 9

Chapter 10 - Generating and Retrieving XML

Improving the Overall Performance of XSLT for Multiple Transformations

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database

In Oracle Database 10g,Java the Developers Oracle XML Developer’s Kit provides an XSLT that is useful when you need to reuse Part III - Oracle XML for XSL stylesheets for a large number of XSL transformations. It precompiles the XSL in binary format with optimizations for use in the XSL TVM. This greatly speeds up the overall XSL transformation, up to 200 percent, Chapter 14 - Building an XML-Powered Web Site especially if you have large XSL stylesheets. Chapter 13 - Getting Started with Oracle XML and Java

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an reuse XML Gateway Application with SOAPby and AQ Using Java, you can also the XSLStylesheet objects prebuilding them and reusing them in the Chapter 17 - Developing XML-Based Reusable XSLProcessor.process() procedures. The Components Java XSLT processor also allows multiple processors in different Part IV - Oracle XML C Developers threads to share thefor same XSL stylesheet, because it is threadsafe.

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 4: Validating XML with DTDs and XML Schemas PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Although XML enables users to define their own markup languages to describe and encapsulate data into XML files, McGraw-Hill/Osborne © 2004 (600 pages) all XML documents must conform to basic “grammar” rules so that application developers can develop software with guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with the assurance This that comprehensive all XML documents conform to certain basic rules of syntax. Document type definitions (DTDs) emphasis on XML standards, their usage and best practices. and XML schemas (XSDs) help you to ensure that your XML documents adhere to specified structures, constraints, and in the case of XSDs, datatypes so that they can be used by applications. This chapter discusses both of these Table of Contents methods while comparing and contrasting how and when they should be used. It will then discuss how these relate Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL to database data and specifically the XML support in Oracle Database 10g. Introduction Part I - Oracle and the XML Standards

Introducing the DTD - Introducing XML

Chapter 1

Chapter 2 -inherited Accessing XMLSGML with DOM, SAX, JAXB, andsyntax. StAX They specify the structure of an XML document including DTDs are from and are not in XML Chapter 3 - Transforming XML with XSLT and XPath the hierarchical relationship between specified elements and their included attributes. A DTD can be associated with Chapter - Validating XMLby with DTDs and XML Schemas an XML4 document either its being included in that document or by internally referencing an external file. If the Chapter DTD is 5contained - XML Operations in an external with XQuery file, it is referenced through a uniform resource locator (URL) of the form

http://www.foobar.com/book.dtd. Chapter 6 - XML Messaging and RPC with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

For example, the following booklist.xmlfile can have a DTD associated as an embedded decalarion within the XML file itself:

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

<?xml 9version "1.0"?> Chapter - Storing =XML Data <!-DTD bookcatalog may have a number of book entries --> Chapter 10 - Generating and Retrieving XML <!DOCTYPE bookcatalog [ Chapter 11 - Searching XML Data <!ELEMENT bookcatalog (book)*> Chapter 12 - Managing the Oracle XML Database <!-- Each book element has a title, 1 or more authors, etc. --> Part III - Oracle XML for Java Developers <!ELEMENT book (title, author+, ISBN, publisher, publishyear, price)> Chapter 13 - Getting Started with Oracle XML and Java <!ELEMENT title (#PCDATA)> Chapter 14 - Building an XML-Powered Web Site <!ELEMENT author (firstname, lastname)> Chapter 15 - Creating a Portal Site with XML and Web Services <!ELEMENT firstname (#PCDATA)> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <!ELEMENT lastname (#PCDATA)> Chapter 17 Developing XML-Based Reusable Components <!ELEMENT ISBN (#PCDATA)> Part<!ELEMENT IV - Oracle XML for C Developers publisher (#PCDATA)> Chapter 18 - Getting Started with Oracle XML and C <!ELEMENT publishyear (#PCDATA)> Chapter 19 Building an XML-Managed Application <!ELEMENT price (#PCDATA)> Chapter 20 - Buildprice an XMLtype Database OCI Application <!ATTLIST (US|CAN|UK|EURO) #REQUIRED> Chapter ]> 21 - Create an XML-Configured High-Performance Transformation Engine Part <bookcatalog> V - Oracle XML for C++ Developers <book> Chapter 22 - Getting Started with Oracle XML and C++ <title>History ofDatabase Interviews</title> Chapter 23 - Build an XML OCI C++ Application <author> Chapter 24 - Building an XML Data-Retrieval Application <first name> Part VI - Oraclename>Juan</first XML for PL/SQL Developers <last name>Smith</last name> Chapter 25 - Getting Started with Oracle XML and PL/SQL </author> Chapter 26 - Building PL/SQL Web Services <ISBN>99999-99999</ISBN> Chapter 27 - Extending PL/SQL XML Functionality with Java <publisher>Oracle Press</publisher> Chapter 28 - Putting It All Together <publishyear>2000</publishyear> Appendix - XML Standards Bodies and Open Specifications <price type="US">1.00</price> Glossary </book> Index </bookcatalog> List of Figures List of Tables List Following of Sidebars the DOCTYPE declaration of the DTD is the root element declaration <!ELEMENT> of bookcatalog. An

element simply consists of a start tag, other elements or text and an end tag. For example, the <bookcatalog> element contains all of the elements, attributes, and text within the document. Such an element is called the root element. Only one root element may exist within an XML document. The root element marks the beginning of the document and is considered the parent of all the other elements, which are nested within its start tag and end tag. For XML documents to be considered “valid” with respect to this DTD, the root element <bookcatalog> must be the first element to start off the body of the XML document. Following this is the element declaration, which stipulates the child elements that must be nested within the root


element <bookcatalog>, the content model for the root element. Note that all the child elements of <bookcatalog> are explicitly called out in its element declaration, and author has a + as a suffix. This is an example of the Extended Backus-Naur Format that10g canXML be used for Design, describing the & content model. allowed suffixes are Oracle(EBNF) Database & SQL: Build Manage XML The Applications in Java, C, C++ & PL/SQL

? For 0 or 1 occurrence

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne * For 0 or more occurrences © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML standards, their usage and best practices. + For 1 or emphasis more occurrences

Note also the use of #PCDATA to declare that the element text must be non-marked-up text, and the price’s required attribute values are explicitly declared. The difference between CDATA and PCDATA is that CDATA Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL sections are simply skipped by the parser and aren’t checked for well-formedness; hence, they can be viewed as Introduction non-parsed character data.

Table of Contents

Part I - Oracle and the XML Standards

Chapter - Introducing A DTD 1in an external fileXML can also be used. In this case only a reference is embedded in the XML document as this Chapter 2 - Accessing XML with DOM, other version of the booklist.xml file.SAX, JAXB, and StAX Chapter - Transforming XML with XSLT and XPathstandalone="no" ?> <?xml 3version="1.0" encoding="UTF-8" Chapter 4 - Validating XML with DTDs and XML Schemas <!DOCTYPE bookcatalog SYSTEM "booklist.dtd"> Chapter 5 - XML Operations with XQuery <bookcatalog> Chapter 6 - XML Messaging and RPC with SOAP <book> Chapter <title>History 7 - Putting It Allof Together Interviews</title> with XML Pipeline, JSPs, and XSQL Part II <author> - Oracle XML Management for DBAs

<first name>Juan</first name> Chapter 8 - Getting Started with the Oracle XML Database <last name>Smith</last name> Chapter 9 - Storing XML Data </author> Chapter 10 - Generating and Retrieving XML <ISBN>99999-99999</ISBN> Chapter 11 - Searching XML Data <publisher>Oracle Press</publisher> Chapter 12 - Managing the Oracle XML Database <publishyear>2000</publishyear> Part III - Oracle XML for Java Developers <price type="US">1.00</price> </book> Chapter 14 - Building an XML-Powered Web Site </bookcatalog>

Chapter 13 - Getting Started with Oracle XML and Java Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 within - Developing an XML Gateway Application with SOAP and AQ Note that the <!DOCTYPE> processing instruction, in place of the actual DTD content, is SYSTEM Chapter 17 - Developing XML-Based “booklist.dtd”, which refers to theReusable externalComponents DTD. This DTD is then of the following form: Part IV - Oracle XML for C Developers

<!ELEMENT bookcatalog (book)*> <!-- Each book element has a title, 1 or more authors, etc. --> Chapter 19 - Building an (title, XML-Managed Application <!ELEMENT book author+, ISBN, publisher, publishyear, price)> Chapter 20 Build an XML Database OCI <!ELEMENT title (#PCDATA)> Application Chapter 21 - Create an XML-Configured High-Performance <!ELEMENT author (firstname, lastname)> Transformation Engine Part<!ELEMENT V - Oracle XML for C++ Developers firstname (#PCDATA)> Chapter 22 - Getting Started with Oracle XML and C++ <!ELEMENT lastname (#PCDATA)> Chapter 23 - BuildISBN an XML Database OCI C++ Application <!ELEMENT (#PCDATA)> Chapter <!ELEMENT 24 - Building publisher an XML Data-Retrieval (#PCDATA)>Application Part<!ELEMENT VI - Oracle XML publishyear for PL/SQL Developers (#PCDATA)> <!ELEMENT price (#PCDATA)> Chapter 25 - Getting Started with Oracle XML and PL/SQL <!ATTLIST price type (US|CAN|UK|EURO) #REQUIRED> Chapter 26 - Building PL/SQL Web Services Chapter 18 - Getting Started with Oracle XML and C

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

When it comes to validating XML documents, functionally these two methods are the same.

Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g DTDs XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ValidatingOracle XMLDatabase Against PL/SQL

by parser, Mark V. by Scardina, and Jinyu according Wang A validating XML parsingBen the Chang XML document to the rules specified in the DTD, triesISBN:0072229527 to McGraw-Hill/Osborne © 2004 (600 determine whether the document conforms to pages) the DTD (valid), meaning that the structural relationships and sequences areThis the comprehensive same. Depending onfocuses the implementation of the parser, if an errorOracle's is encountered during guide on utilizing XML technologies within XML-enabled products, with emphasis on stop, XML standards, their usage and bestprocessing, practices. or continue with internal corrections. validation, processing may as in “panic mode” exception Warnings or errors may be reported either as processing occurs or at the very end of the processing. Finally, most processors have a mode whereby validation can be turned off; however, with DTDs, certain constructs defined in Table of Contents DTDs not discussed here, such as entityBuild definitions, must still be processed. Oracle Database 10g XML & SQL—Design, & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Introducing the XML 10g Schema Language PL/SQL

by Mark V. Scardina, Ben Chang andSchema Jinyu Wang In February 1999, a W3C Note detailing the XML Working Group’s XML Schema requirements ISBN:0072229527 was © 2004 (600 pages) published. ThisMcGraw-Hill/Osborne document, titled “XML Schema Requirements,” includes an overview, purpose, usage scenarios, design principles, the structural, datatype, conformance requirements for the XML Schema language. Thisand comprehensive guide focusesand on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

The“Overview” section states that the XML Schema Working Group, by charter, is assigned to look into a more informative constraint on the XML document than is provided by DTDs, namely one that would also, among other Table of Contents things: Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Support both primitive and complex datatypes Part I - Oracle and the XML Standards

Support restrictionsXML or extensions on datatypes Chapter 1 - Introducing Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Be written in XML

Chapter 4 - Validating DTDssnippet and XML For example, considerXML the with following ofSchemas a DTD: Chapter 5

- XML Operations with XQuery <!ELEMENT book (title, author, publisher, price)>

Chapter 6 - XML Messaging and RPC with SOAP <!ELEMENT title (#PCDATA)> Chapter 7 - Putting It All(#PCDATA)> Together with XML Pipeline, JSPs, and XSQL <!ELEMENT author Part II - Oraclepublisher XML Management for DBAs <!ELEMENT (#PCDATA)>

Chapter 8 - Getting with the Oracle XML Database <!ELEMENT priceStarted (#PCDATA)*> Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

This could in XML format as the following XSD file: Chapter 11 -appear Searching XML Schema Data Chapter <?xml 12 version="1.0"?> - Managing the Oracle XML Database Part <xsd:schema III - Oracle XML xmlns:xsd="http://www.w3.org/2001/XMLSchema" for Java Developers

xmlns:bk=http://www.mypublishsite.com/book> Chapter 13 - Getting Started with Oracle XML and Java <xsd:annotation> Chapter 14 - Building an XML-Powered Web Site <xsd:documentation Chapter 15 - Creating a Portalxml:lang="en"> Site with XML and Web Services Possible XML Schema of a with DTD SOAP shown Chapter 16 - Developing an XMLequivalent Gateway Application andin AQListing 1. </xsd:documentation> Chapter 17 - Developing XML-Based Reusable Components </xsd:annotation> Part IV - Oracle XML for C Developers <xsd:element name="title" type="xsd:string" minOccurs="1" maxOccurs="1"/> Chapter 19 - Building an XML-Managed Application <xsd:element name="author" type="xsd:string" minOccurs="1" Chapter 20 - Build an XML Database OCI Application maxOccurs="unbounded"/> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <xsd:element name="publisher" type="xsd:string" minOccurs="1" Part V - Oracle XML for C++ Developers maxOccurs="unbounded"/> Chapter 22 - Getting Started with Oracle XML and C++ <xsd:element name="price" type="xsd:string" minOccurs="0" Chapter maxOccurs="*"/> 23 - Build an XML Database OCI C++ Application Chapter 24 - Buildingname="Book"/> an XML Data-Retrieval Application <xsd:element Part VI Oracle XML for PL/SQL Developers <xsd:complexType> Chapter 25 Getting Started with Oracle XML and PL/SQL <xsd:sequence> Chapter <xsd:element 26 - Building PL/SQL Web Services ref="bk:title"/> Chapter <xsd:element 27 - Extending PL/SQL XML Functionality with Java ref="bk:author"/> Chapter <xsd:element 28 - Putting It All ref="bk:publisher"/> Together ref="bk:price"/> Appendix<xsd:element - XML Standards Bodies and Open Specifications </xsd:sequence> Glossary </xsd:complexType> Index </xsd:element> List of Figures </xsd:schema> List of Tables Chapter 18 - Getting Started with Oracle XML and C

List of Sidebars

The “Purpose” section of the “XML Schema Requirements” Note succinctly states the purpose of a schema: The purpose of a schema is to define and describe a class of XML documents by using these constructs to constrain and document the meaning, usage and relationships of their constituent parts: datatypes, elements and their content, attributes and their values, entities and their contents and notations. Schema constructs may also provide for the specification of implicit information such as default values. Schemas document their own meaning, usage, and function. Thus, the XML schema language can be used to define, describe and catalogue XML vocabularies for classes of XML documents.


The “Usage Scenarios” section of the Note lists the types of XML applications and activities that should benefit from an XML schema: Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

PublishingPL/SQL and syndication

Mark V. Scardina, Ben Chang and Jinyu Wang Electronic by commerce transaction processing

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

Supervisory control and data acquisition This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Traditional document authoring/editing governed by schema constraints Table of Contents Use schema to help query formulation and optimization Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Open and uniform transfer of data between applications, including databases Introduction Part I - Oracle and the XML Standards

Metadata Interchange - Introducing XML

Chapter 1

Chapter 2 - Accessing XML with DOM, SAX,specific JAXB, and StAX The “Design Principles” section set forth goals for the XML Schema language to be met in order to meet the Chapter - Transforming XMLincluded with XSLT and XPathbe a simple, self-describing language in XML that was widely design 3requirements. These that it must Chapter Validating XML withthe DTDs and XML usable 4by -applications across Internet andSchemas was coordinated with core XML specifications such as XML Chapter 5 - XML with XQuery Information Set, Operations Links, Namespaces, Pointers, Style and Syntax. Chapter 6

- XML Messaging and RPC with SOAP

Thefinal7 section, “Requirements,” lists XML the structural requirements Chapter - Putting It All Together with Pipeline, JSPs, and XSQLof what the XML Schema language must define, the II datatype of thefor language, and the conformance requirements. The XML Schema Working Group Part - Oraclerequirements XML Management DBAs took these and produced a number of working drafts, which culminated in the May 2001 “W3C Chapter 8 - requirements Getting Started with the Oracle XML Database

Recommendation for XML Schema.” This document consists of three parts: “XML Schema Part 0: Primer”; “XML - Storing XML Data Schema Part 1: Structures”; and “XML Schema Part 2: Datatypes.”

Chapter 9

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Simple and Complex Datatypes PL/SQL

ISBN:0072229527 by Mark V. 2 Scardina, Ben Chang Jinyu Wang XML Schema Part 1 and goes over the basicand concepts of what datatypes can be declared in an XML schema and McGraw-Hill/Osborne 2004 (600 pages) the properties associated with such ©datatypes. Simple built-in datatypes exist, along with complex datatypes defined by the XML schema designer. An example of a complex type definition for anwithin address in a purchase order follows: with This comprehensive guide focuses on utilizing XML technologies Oracle's XML-enabled products,

emphasis on XML standards, their usage and best practices. <xsd:complexType name="USAddress"> <xsd:sequence> Table of Contents <xsd:element name="name" type="xsd:string"/> Oracle <xsd:element Database 10g XML name="street" & SQL—Design,type="xsd:string"/> Build & Manage XML Applications in Java, C, C++ & PL/SQL <xsd:element name="city" type="xsd:string"/> Introduction Part<xsd:element I - Oracle and thename="state" XML Standards type="xsd:string"/> <xsd:element name="zip" type="xsd:decimal"/> Chapter 1 - Introducing XML </xsd:sequence> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/> Chapter 3 - Transforming XML with XSLT and XPath </xsd:complexType> Chapter 4 - Validating XML with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

Important things to note are that XML Schema namespace prefixes appear even on the built-in datatypes, such as - XML Messaging and RPC with SOAP string, and that a complex data type is surrounded by an inner sequence tag. In addition, constraints such as Chapter 7 - Putting It All Together with XML Pipeline, JSPs, 1, and XSQL minOccurs and maxOccurs, whose default values equal could have been put on the name element for number Part II Oracle XML Management for DBAs of occurrences, as in the following: Chapter 6

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

<xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="2"/>

Chapter 10 - Generating and XMLsimple built-in datatypes for XML Schema, as outlined in Table 4-1. XML Schema Part 2 lists allRetrieving the possible Chapter 11 - Searching XML Data Chapter 12 - XML Managing the Oracle XML Database Table 4-1: Schema Built-in Datatypes Part III - Oracle XML for Java Developers

Simple Type Chapter 13 Built-in - GettingData Started with Oracle XML and Java

Example (Comments)

Chapter string14 - Building an XML-Powered Web Site

this is a string

Chapter 15 - Creating a Portal Site with XML and Web Services

normalizedString thisand is aAQ string (newlines, tabs, carriage returns, Chapter 16 - Developing an XML Gateway Application with SOAP Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers token

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

etc., are translated into spaces)

this is another string (newlines, tabs, carriage returns, etc., are translated into spaces; adjacent spaces are collapsed into 1 space; trailing and leading spaces are removed)

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

byte

Part V - Oracle XML for C++ Developers

Chapter unsignedByte 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

base64Binary

Chapter 24 - Building an XML Data-Retrieval Application Part hexBinary VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

integer

Chapter 26 - Building PL/SQL Web Services

positiveInteger Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

negativeInteger

Appendix

- XML Standards Bodies and Open Specifications

–1, 126 0, 126 GpM7 0fff

–126789, 0, 126789 (integer values only) 1, 2, 126789 (positive integer values only) –126789, –2, –1 (negative integer values only)

nonNegativeInteger Glossary

0, 1, 126789

Index

–126789, –1, 0

nonPositiveInteger

List of Figures Listint of Tables

–1, 0, 2, 126789675

ListunsignedInt of Sidebars

0, 1, 1267896754

long

–1, –2, 0, 12678967543233

unsignedLong

0, 1, 3, 12678967543233

short

–1, –2, –5, 0, 1, 12678

unsignedShort

0, 1, 5, 12678

decimal

–1.2, 0, 1.2, 10000.00


Float

–0, 0, 12, INF, NaN 1.0E-2 (32-bit floating point)

Double

0, 13, INF, NaN 1.0E-20 (64-bit floating point) Oracle Database 10g XML & SQL: Design,–0, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Boolean

true, false, 1, 0

by Mark V. Scardina, Ben Chang and Jinyu Wang 21:21:21.000–01:00 (UTC) McGraw-Hill/Osborne © 2004 (600 pages)

Time dateTime

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with 2001–01–01T121:21:21.000–01:00 (date + time emphasis on XML standards, their usage and best practices.

zone + UTC)

duration Table of Contents

P1Y2M3DT10H30M12.0S (year, month, day, hour, minute, second) Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction date

1999–05–31

Part I - Oracle and the XML Standards

gMonth Chapter 1 - Introducing XML

–01–

Chapter gYear2

- Accessing XML with DOM, SAX, JAXB, and StAX 2001

Chapter 3

- Transforming XML with XSLT and XPath

gYearMonth Chapter 4 - Validating XML with DTDs and XML Schemas

2001–01

Chapter gDay 5

- XML Operations with XQuery

–31

Chapter 6

- XML Messaging and RPC with SOAP

gMonthDay –05–31 - Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 7

Part II - Oracle XML Management for DBAs Name

Chapter 8

- Getting Started with the Oracle XML Database

QName - Storing XML Data

Chapter 9

Chapter 10 - Generating and Retrieving XML NCName Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

anyURI

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java language Chapter 14 - Building an XML-Powered Web Site

ID

anyname (XML 1.0 Name) xsd:anyname (XML Namespace Qualified Name) anyname (XML Namespace Qualified Name without the prefix and colon) http://www.oracle.com en-US (a unique token, XML 1.0 ID attribute)

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter IDREF 16 - Developing an XML Gateway Application with SOAP (a token and AQ that matches an ID, XML 1.0 IDREF Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

IDREFS

Chapter 18 - Getting Started with Oracle XML and C

ENTITY Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

ENTITIES

attribute) (list of IDREF, XML 1.0 IDREFS attribute) (XML 1.0 ENTITY attribute) (XML 1.0 ENTITIES attribute)

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

NOTATION Part V - Oracle XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++

NMTOKEN

Chapter 23 - Build an XML Database OCI C++ Application

NMTOKENS Chapter 24 - Building an XML Data-Retrieval Application

(XML 1.0 NOTATION attribute) US, Canada (XML 1.0 NMTOKEN attribute) US UK Canada (XML 1.0 NMTOKENS attribute)

Part VI - Oracle XML for PL/SQL Developers

These simple datatypes canwith alsoOracle be used a base type for ones that you can create. You can create these userChapter 25 - Getting Started XMLas and PL/SQL defined26 types by specifying constraints in three ways. First you can define a type by restriction by specifying Chapter - Building PL/SQL Web Services additional such as a pattern, value range, Secondly, you can define a list type made up of a set of Chapter 27 -aspects Extending PL/SQL XML Functionality withetc. Java simple 28 datatypes. you can define a uniontype which can be satisfied from a set of types. There are, Chapter - PuttingFinally, It All Together

however, no extension constraints. Some additional examples are the string, normalizedString, token, - XML Standards Bodies and Open Specifications base64Binary, hexBinary, Name, QName, NCName, anyURI, language, ID, IDREFS, ENTITY, ENTITIES, Glossary NOTATION, NMTOKEN,and NMTOKENSdatatypes all can take the following facets: length, minLength, Index maxLength, pattern (this can be a regular expression such as a date format like MM/DD/YYYY), enumeration, List of Figures and whiteSpace. The number-oriented datatypes, such as byte, unsignedByte, integer, positiveInteger, List of Tables negativeInteger, nonNegativeInteger,nonPositiveInteger, int,unsignedInt,long, unsignedLong, short, List of Sidebars unsignedShort, and decimal,all can take the following facets: maxInclusive, maxExclusive,minInclusive, minExclusive, totalDigits, and fractionDigits. Appendix

The following examples illustrate the syntax of restrictions on simple types: <!-- Range --> <xsd:simpleType> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="0"/> <xsd:maxInclusive value="100"/>


</xsd:restriction> </xsd:simpleType> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

<!-- Enumeration PL/SQL --> <xsd:simpleType> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <xsd:restriction base="xsd:string"> McGraw-Hill/Osborne © 2004 (600 pages) <xsd:enumeration value="Audi"/> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <xsd:enumeration emphasis on value="Golf"/> XML standards, their usage and best practices. <xsd:enumeration value="BMW"/> </xsd:restriction> Table of Contents </xsd:simpleType> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

<!-- Patterns --> <xsd:simpleType> Chapter 1 - Introducing XML <xsd:restriction base="xsd:string"> Chapter 2 - Accessing value="[a-zA-Z0-9]{8}"/> XML with DOM, SAX, JAXB, and StAX <xsd:pattern Chapter 3 - Transforming XML with XSLT and XPath </xsd:restriction> Chapter 4 - Validating XML with DTDs and XML Schemas </xsd:simpleType> Part I - Oracle and the XML Standards

Chapter 5

- XML Operations with XQuery

Chapter <!-- Whitespace: 6 - XML Messaging preserve, and RPC with collapse, SOAP replace -->

<xsd:simpleType> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL <xsd:restriction base="xsd:string"> Part II - Oracle XML Management for DBAs <xsd:whiteSpace value="preserve"/> Chapter 8 - Getting Started with the Oracle XML Database </xsd:restriction> Chapter 9 - Storing XML Data </xsd:simpleType> Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

<!-- String length --> <xsd:simpleType> Part III - Oracle XML for Java Developers <xsd:restriction base="xsd:string"> Chapter 13 - Getting Started with Oracle XML and Java <xsd:minLength value="5"/> Chapter 14 - Building an XML-Powered Web Site <xsd:maxLength value="8"/> Chapter 15 - Creating a Portal Site with XML and Web Services </xsd:restriction> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ </xsd:simpleType> Chapter 12 - Managing the Oracle XML Database

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle Developers Complex typesXML alsofor canC be constrained, but they have the flexibility of accepting both restriction and extension

Chapter 18 - Getting Startedexamples with Oracle XML and constraints. The following illustrate theC syntax for complex types along with their constraints: Chapter 19 - Building an XML-Managed <!-- Element Extensions --> Application Chapter 20 - Build an XML Database OCI Application <xsd:complexType name="fpersont"> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <xsd:complexContent> Part V<xsd:extension - Oracle XML for C++ Developers base="personinfo">

Chapter <xsd:sequence> 22 - Getting Started with Oracle XML and C++ Chapter 23<xsd:element - Build an XML Database name="address" OCI C++ Application type="xsd:string"/>

type="xsd:string"/> Chapter 24<xsd:element - Building an XMLname="city" Data-Retrieval Application <xsd:element name="country" Part VI - Oracle XML for PL/SQL Developers

type="xsd:string"/>

Chapter </xsd:sequence> 25 - Getting Started with Oracle XML and PL/SQL

</xsd:extension> Chapter 26 - Building PL/SQL Web Services </xsd:complexContent> Chapter 27 - Extending PL/SQL XML Functionality with Java </xsd:complexType> Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

<!-- Attribute only -->> <xsd:element name="product"> Index <xsd:complexType> List of Figures <xsd:attribute name="prodid" type="xsd:positiveInteger"/> List of Tables </xsd:complexType> List of Sidebars </xsd:element> Glossary

<!--Simple Content - Extension/Restriction --> <xsd:element name="shoesize"> <xsd:complexType> <xsd:simpleContent> <xsd:extension base="xsd:integer"> <xsd:attribute name="country" type="xsd:string" /> </xsd:extension>


</xsd:simpleContent> </xsd:complexType> </xsd:element> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

<!-- Mixed by Content ISBN:0072229527 Mark V. --> Scardina, Ben Chang and Jinyu Wang <xsd:element name="letter"> McGraw-Hill/Osborne © 2004 (600 pages) <xsd:complexType mixed="true"> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <xsd:sequence> emphasis on XML standards, their usage and best practices. <xsd:element name="name" type="xsd:string"/> <xsd:element name="orderid" type="xsd:positiveInteger"/> Table of Contents <xsd:element name="shipdate" type="xsd:date"/> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL </xsd:sequence> Introduction </xsd:complexType> Part I - Oracle and the XML Standards </xsd:element> Chapter 1

- Introducing XML

Chapter 2 - Accessing SAX, JAXB, andand StAX XML Schema extendsXML the with DTDDOM, functionality of IDs IDREFs by introducing user-defined KEYs and KEYREFs. Chapter The following 3 - Transforming examples illustrate XML withtheir XSLT syntax: and XPath Chapter 4 - Validating XML with DTDs and XML Schemas <element name="purchaseReport"> Chapter 5 - XML Operations with XQuery <complexType> Chapter 6 - XML Messaging and RPC with SOAP <sequence> Chapter <element 7 - Puttingname="regions" It All Together withtype="r:RegionsType"> XML Pipeline, JSPs, and XSQL Part II -<keyref Oracle XML name="dummy2" Management for DBAs refer="r:pNumKey">

xpath="r:zip/r:part"/> Chapter 8<selector - Getting Started with the Oracle XML Database xpath="@number"/> Chapter 9<field - Storing XML Data Chapter </keyref> 10 - Generating and Retrieving XML

</element> Chapter 11 - Searching XML Data <element name="parts" type="r:PartsType"/> Chapter 12 - Managing the Oracle XML Database </sequence> Part III - Oracle XML for Java Developers <attribute name="period" type="duration"/> <attribute name="periodEnding" type="date"/> Chapter 14 - Building an XML-Powered Web Site </complexType> Chapter 13 - Getting Started with Oracle XML and Java

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

<unique name="dummy1"> <selector xpath="r:regions/r:zip"/> Part IV - Oracle XML for C Developers <field xpath="@code"/> Chapter 18 - Getting Started with Oracle XML and C </unique>

Chapter 17 - Developing XML-Based Reusable Components

Chapter 19 - Building an XML-Managed Application Chapter 20name="r:pNumKey"> - Build an XML Database OCI Application <key Chapter 21 - Createxpath="r:parts/r:part"/> an XML-Configured High-Performance Transformation Engine <selector Part V<field - Oracle xpath="@number"/> XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ </key> Chapter </element> 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

Note thereXML is anfor XPath selector to specify the path to the named key as well as the attribute value to be used for Part VIthat - Oracle PL/SQL Developers the key’s Chapter 25 value. - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Note The Oracle XML Database does not currently support KEY/KEYREFs directly; however, this functionality

Chapter 27 can - Extending PL/SQL XML Functionality with Java be implemented using SQL constraints. Chapter 28 - Putting It All Together

Additionally, union types such as <xsd:union memberTypes=“mystates allstate”/>, complexTypes from simple Appendix - XML Standards Bodies and Open Specifications types, mixed attributes for complexTypes to indicate data between child elements, anyType such as Glossary type=“xsd:anyType”to indicate that the element could be of any datatype, are also allowed. Annotations such as Index <xsd:annotation> are also allowed, because they are simply mechanisms to embed documentation in the schema, List of Figures such as in this example: List of Tables <xsd:annotation> List of Sidebars <xsd:documentation xml:lang="en"> hi there </xsd:documentation> </xsd:annotation> Finally, user-defined mechanisms such as an attribute group can be created to have a number of attributes associated with an element. This includes <xsd:attributeGroup name=“BookDelivery”> with a reference like <xsd:attributeGroup ref=“BookDelivery”> within the definition of the complexType. We recommend that you


review the XML Schema Part 0:Primer for a full discussion of the specification. See the Appendix for the locations of all the XML Schema specifications. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ValidatingOracle XMLDatabase with XML Schemas (XSDs) PL/SQL

ISBN:0072229527 by parser, Mark V. by Scardina, and Jinyu according Wang A validating XML parsingBen the Chang XML document to the rules specified in the XML schema, tries to McGraw-Hill/Osborne © 2004 (600 determine whether the document conforms to pages) the XML schema (valid), meaning that the structural relationships and sequences areThis the comprehensive same and that guide conformance to the datatype specified in the XML schema are observed. focuses on utilizing XML rules technologies within Oracle's XML-enabled products, with on XML standards, their usage and best practices. Depending on emphasis the implementation of the parser, as with parsers that validate XML documents against DTDs, if an error is encountered during validation, processing may stop (as in “panic mode” exception processing) or continue with of internal corrections. Warnings or errors may be reported either as processing occurs or at the very end of the Table Contents processing. For a validating XML Schema parser, one final if a included by the XML Oracle Database 10g XML & SQL—Design, Build & Manage XMLrequirement Applications is in that Java, C,DTD C++ is& also PL/SQL document and entity definitions are encountered in the DTD, these must be taken into account by the XML schema, Introduction along with any other constructs possibly defined in the DTD. However, since the XML Schema specification does Part I - Oracle and the XML Standards not exactly define what occurs if both a DTD and an XML schema exist for an XML document, such a situation is left Chapter 1 - Introducing XML to the validating parser to determine what exactly to do, which creates an implementation-dependent scenario.

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter - Transforming with XSLT andXML XPathSchema processors, Java, C, and C++, that can perform both DTD Oracle 3produces, as part XML of the XDK, three Chapter 4 validations. - Validating In XML with DTDs XMLXML Schemas and XSD addition, the and Oracle DB can perform validation on XML documents as they are inserted Chapter 5 - XML or updated. This Operations is built in towith the XQuery support for XMLType but can also be directly invoked from PL/SQL. Specific code Chapter 6 -schema XML Messaging and RPC SOAP later in the chapter, but it is useful to understand the underlying illustrating validation will be with presented Chapter process7 model. - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Schema be triggered in two XML ways: external to the input document or as a result of the input document. Chapter 8 validation - Getting can Started with the Oracle Database This means that an XML schema can be passed in when the XML parser is invoked or, if the input document - Storing XML Data includes an XML Schema declaration providing a URL to the location, the XML schema can be fetched during the Chapter 10 - Generating and Retrieving XML process. The following is the syntax of this type of declaration with and without namespaces: Chapter 9

Chapter 11 - Searching XML Data

<root 12 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance Chapter - Managing the Oracle XML Database Part III - xsi:schemaLocation="[target_namespace] Oracle XML for Java Developers

[schemafile_location]">

Chapter 13 - Getting Started with Oracle XML and Java

<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="[schemafile_location]">

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing XML not Gateway Application with SOAP AQdocument through parsing but also to parse the The schema processoran needs only to build an object of theand input Chapter - Developing Reusable Components schema17document into XML-Based an object for the validation process to begin. This is where the different processors depart. Part - Oracle XML and for Cschema Developers For IV Java, the input documents are parsed using SAX with a DOM built as needed from these SAX

Chapter - Getting Started with Oracle XML C events.18 If validation is only required, then it and is completely SAX based. For C and C++ processors, DOM parsing and Chapter 19 - is Building an XML-Managed Application processing used throughout the validation process. Chapter 20 - Build an XML Database OCI Application

The Oracle XML DB, though it uses the C XDK components, performs this processing quite differently. If it has Chapter 21 - Create an even XML-Configured High-Performance Transformation Engine a registered XML schema, it has already compiled and stored it as a database object, so no schema Part V - Oraclecopy XMLof forthe C++ Developers

parsing is required. Upon inserting a document, the C SAX parser is invoked and the validation occurs against the compiled schema.

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application

Chapter 24 - Building an XML Data-Retrieval In all cases, if the XML schema has one orApplication more <xsd:import> or <xsd:include> elements, as illustrated next, they Part Oracle XML PL/SQL Developers will VI be -retrieved andfor expanded into one aggregated schema before any validation occurs.

Chapter 25 - Getting Started with Oracle XML and PL/SQL

<xsd:import namespace=http://www.w3schools.com/schema schemaLocation="http://www.w3schools.com/schema/customer.xsd"/> Chapter 27 - Extending PL/SQL XML Functionality with Java <xsd:include schemaLocation="http://www.w3schools.com/schema/customer.xsd"/> Chapter 26 - Building PL/SQL Web Services Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g and XML &the SQL:Database Design, Build & Manage XML Applications in Java, C, C++ & XML Document Models PL/SQL

by consist Mark V.ofScardina, Chang to and Jinyu Wang XML documents text thatBen conforms a hierarchy or tree structure specified by a DTD or XMLISBN:0072229527 schema. In most © 2004 (600 pages) cases you can McGraw-Hill/Osborne easily store this hierarchical data in an optimal internal form using object-relational tables. All the existing and future internal canguide workfocuses with theoninformation in the most efficient possible. When you retrievewith This applications comprehensive utilizing XML technologies withinway Oracle's XML-enabled products, on XML standards, their usage and best practices. information, foremphasis sharing with partners or other applications, you can present the appropriate view of data and document content specific to the task at hand as integrated XML. Oracle Database’s 10g XMLType views enable you to present data in any of “logical” combinations, hiding any details of their underlying physical storage. You can effectively Table of number Contents transform the structure or more underlying tablesXML intoApplications a more useful or more appropriate structure for the demands Oracle Database 10g XMLof & one SQL—Design, Build & Manage in Java, C, C++ & PL/SQL of a specific application. When you link views of information with other views of related information, they quite naturally Introduction form “trees” or “graphs” of related data. When you represent database information as XML, the previous related views Part I - Oracle and the XML Standards provide the foundation for many different tree-structured XML documents. Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Mapping DTDs to Database Chapter 3 - Transforming XML with XSLT andSchemas XPath Chapter 4

- Validating XML with DTDs and XML Schemas

Here, we offer a simple example of mapping a database table to an XML DTD of the following form: - XML Operations with XQuery

Chapter 5

<!ELEMENT table (rows)*> Chapter 6 - XML Messaging and RPC with SOAP <!ELEMENT rows It(column1, ...)>JSPs, and XSQL Chapter 7 - Putting All Together column2, with XML Pipeline, <!ELEMENT (#PCDATA)> Part II - Oraclecolumn1 XML Management for DBAs <!ELEMENT column2 (#PCDATA)> Chapter 8 - Getting Started with the Oracle XML Database ...

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

However, a database provides even more capability than a DTD for expressing rules. Using DTDs, you cannot define type

Chapter 11 - Searching Data strings, and IDs. The database schema defines type information and constraints, such as information other thanXML numbers, Chapter 12 - Managing the Oracle XML Database permissible value ranges. A database schema enables you to define relationships or dependencies. For example, your ePart III - Oracle XML for Java Developers commerce business might receive orders as XML documents. By using a database, you can link customer and order

Chapter 13 - Getting Started with Oracle and Javaorders for closed accounts. In spite of the limitations in DTDs, mapping information, and define a rule about notXML processing Chapter 14 - Building Web a database schema an to aXML-Powered DTD presents theSite database as a virtual XML document to the tools that need XML documents as Chapter input. 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

A database consists of XML-Based a schema associated with each database user. Each schema associated with a user is a Chapter 17 - Developing Reusable Components

collection of schema objects accessible to the user. While mapping a database scheme to a DTD, each user is mapped Part IV - Oracle XML for C Developers

as a child element of the top-level element identified by the SID of the database instance. An element representing a user schema and its child elements uses a unique namespace to avoid conflicts with schema objects defined in other user Chapter 19 - Building an XML-Managed Application schemas. Chapter 18 - Getting Started with Oracle XML and C

Chapter 20 - Build an XML Database OCI Application

Chapter 21perform - Createthe an following XML-Configured Transformation Engine schema: You can steps toHigh-Performance generate a simple DTD from a relational Part V - Oracle XML for C++ Developers

1. For each table, create an element.

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 -each Buildcolumn an XML in Database C++ Application 2. For a table, OCI create a PCDATA-only child element. Chapter 24 - Building an XML Data-Retrieval Application

For VI each objectXML or nested tableDevelopers column, create an ELEMENT-content only child element with attributes or nested columns Part - Oracle for PL/SQL as child25elements. Chapter - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

For example, the following DTD corresponds to a simple database schema:

Chapter 27 - Extending PL/SQL XML Functionality with Java

<!ELEMENT dbschema (sys, scott, ...)> <!ATTLIST dbschema Appendix - XML Standards Bodies and Open Specifications xmlns CDATA #FIXED "http://www.oracle.com/xml/dbschema" Glossary sid CDATA #REQUIRED> Index <!ELEMENT scott (BookList, ...)> List of Figures scott <!ATTLIST List of Tablesxmlns CDATA #FIXED "http://www.oracle.com/xml/dbschema/scott"> List of SidebarsBookList (Book)*> <!ELEMENT <!ATTLIST Book row_num CDATA #IMPLIED> <!ELEMENT Book (Title, ISBN, Author, Publisher, (Review)*)> ... Chapter 28 - Putting It All Together

Unfortunately, a number of drawbacks exist to mapping a database schema to a DTD. For example, there is no way to predict datatypes or column lengths definitively from the DTD. The solution to this problem is to use datatypes in XML documents using XML schemas.


Mapping XML Documents to a Database Schema The format for Oracle DTDs isDatabase an existing worldwide standard and Build will likely exist and be Applications improved upon years. However, 10g XML & SQL: Design, & Manage XML infor Java, C, C++ & because of thePL/SQL inherent limitations of DTDs and the increasingly data-oriented role that XML is being asked to assume ISBN:0072229527 because of developments by Mark V. Scardina, in e-business Ben Chang and e-commerce, and Jinyu Wang the W3C standards body is promoting XML Schema, rather than attemptingMcGraw-Hill/Osborne to push the current ©DTD 2004standards (600 pages) any further. Using an XML schema, you can map the simple database table into an XML of the following form: on utilizing XML technologies within Oracle's XML-enabled products, with Thisschema comprehensive guide focuses emphasis on XML standards, their usage and best practices. <schema targetNamespace="some NSURI"> <xsd:complexType name="table"> Table <xsd:sequence> of Contents <xsd:element name="rows" minOccurs="0" Oracle Database 10g XML & SQL—Design, Build & Manage maxOccurs="unbounded"/> XML Applications in Java, C, C++ & PL/SQL </xsd:sequence> Introduction </xsd:complexType> Part I - Oracle and the XML Standards <xsd:complexType name="rows" > Chapter 1 - Introducing XML <xsd:sequence> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <xsd:element name="column1" Chapter 3 - Transforming XML with XSLT andtype="xs:string"/> XPath <xsd:element name="column2" type="xs:date"/> Chapter 4 - Validating XML with DTDs and XML Schemas ... Chapter 5 - XML Operations with XQuery </xsd:sequence> Chapter 6 - XML Messaging and RPC with SOAP </xsd:complexType> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL </xsd:schema> Part II - Oracle XML Management for DBAs

Chapter 8 you - Getting Startedadditional with the Oracle XML using Database Note that can specify datatypes the <xsd:element> attribute of the form type="xsd:datatype" where Chapter 9 is - Storing XML Data datatype either an XML Schema simple datatype or a named type defined in the XML schema. Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

Supported Database Mappings

Chapter 12 - Managing the Oracle XML Database

Part III - Oracle for Java To transfer dataXML between an Developers XML document and a database, you must map a document structure defined by a DTD or an

Chapter 13 - Getting Started with Oracle XML andversa. Java XML schema to a database schema and vice Chapter 14 - Building an XML-Powered Web Site

When mapping XML adocuments associated with a DTD or an XML schema to a database schema for the purpose of Chapter 15 - Creating Portal Site with XML and Web Services storing 16 XML in Oracle XML DB,Gateway four basic strategieswith exist: Chapter - Developing an XML Application SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Map the complete XML document as a single, intact object, such as CLOBs

Part IV - Oracle XML for C Developers

Chapter 18XML - Getting Started with Oracle XML and C and columns in the database schema Map elements to object-relational tables Chapter 19 - Building an XML-Managed Application

Map of XML documents as CLOBs and the rest of the document as object-relational tables Chapter 20fragments - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Map XML documents to an Oracle XMLType

Part V - Oracle XML for C++ Developers

Chapter 22choose - Getting Started Oracle XML and C++ You can one of the with previous approaches, depending on the structure of the XML document and operations Chapter performed 23 -by Build thean application. XML Database You can OCI also C++ store Application the XML DTD or schema in the database to validate the XML

documents. Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

XML Documents in CLOBs Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Storing an intact XML document in a Character Large Object (CLOB) or Binary Large Object (BLOB) is a good strategy if the XML document contains static content that will only be updated by replacing the entire document. Examples include Chapter 28 - Putting It All Together written text such as articles, advertisements, books, and legal contracts. Documents of this nature are known as Appendix - XML Standards Bodies and Open Specifications document-centric and are delivered from the database as a whole. Storing this kind of document intact within the database Glossary gives you the advantages of an industry-proven database and its reliability over file system storage. If you choose to store Index an XML document outside the database, you can still use the database features to index, query, and efficiently retrieve the List of Figures document through the use of BFILES, URLs, and text-based indexing. Chapter 27 - Extending PL/SQL XML Functionality with Java

List of Tables List XML of Sidebars Documents as Object-Relational Data

If the XML document has a well-defined structure and contains data that is updatable or used in other ways, the document is data-centric. Typically, the XML document contains elements or attributes that have complex structures. Examples of this kind of document include sales orders, invoices, and airline flight schedules. Oracle Database 10g, with its objectrelational extensions, has the capability to capture the structure of the data in the database using object types, object references, and collections. Two options exist for storing and preserving the structure of the XML data in an objectrelational form:


Store the attributes of the elements in a relational table and define object views to capture the structure of the XML elements Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

Store the structured XML elements in an object table PL/SQL

ISBN:0072229527 V. Scardina, Ben and can Jinyu Once stored inby theMark object-relational form,Chang the data beWang easily updated, queried, rearranged, and reformatted as needed McGraw-Hill/Osborne © 2004 (600 pages) using SQL. The XML SQL Utility then provides the means to store an XML document by mapping it to the underlying This comprehensive guide focuses on the utilizing XML technologies within Oracle's XML-enabled products, object-relational storage and, conversely, provides capability to retrieve the object-relational data as an XML with on XML standards, their usage and best practices. document. If anemphasis XML document is structured, but the structure of the XML document is incompatible with the structure of the underlying database schema, you must transform the data into the correct format before writing it to the database. You Table of Contents can achieve this using XSL stylesheets or other programming approaches; but, depending on your needs, you might want Oracle to store Database the data-centric 10g XML &XML SQL—Design, document Build as an&intact Manage single XMLobject. Applications Or, you in can Java,define C, C++ object & PL/SQL views corresponding to the various XML document structures and define INSTEAD OF triggers to perform the appropriate transformation and to Introduction update the base Part I - Oracle anddata. the XML Standards

Chapter 1

- Introducing XML

Chapter 3

- Transforming XML with XSLT and XPath

XML Documents as with Fragment Documents and Object-Relational Data Chapter 2 - Accessing XML DOM, SAX, JAXB, and StAX You can use Oracle Database 10g’s views to view and operate a combination of structured and unstructured XML data as - Validating XML with DTDs and XML Schemas a whole. Views enable you to construct an object on-the-fly by combining XML data stored in a variety of ways. So, you Chapter 5 - XML Operations with XQuery can store structured data (such as employee data, customer data, and so on) in one location within object-relational tables Chapter 6 related - XML Messaging and data RPC with and store unstructured (suchSOAP as descriptions and comments) within a CLOB. When you need to retrieve the Chapter 7 Putting It All Together with XMLstructure Pipeline, from JSPs,the andvarious XSQL pieces of data using type constructors in the view’s data as a whole, you simply construct the Part II Oracle XML Management for DBAs SELECT statement. The XML SQL Utility then enables you to retrieve the constructed data from the view as a single XML Chapter 8 - Getting Started with the Oracle XML Database document. Chapter 4

Chapter 9

- Storing XML Data

Chapter XML Documents 10 - Generating as andXMLTypes Retrieving XML Chapter 11 - Searching XML Data

Finally,12 you- Managing can store the an XML document in an Oracle XML DB’s XMLType. XMLType supports searches and queries using Chapter Oracle XML Database XPATH-like syntax. can beDevelopers created as a database table, view, columns, and as the parameter and return type of SQL, Part III - Oracle XML It for Java

PL/SQL, and Java functions. For example, the SYS_XMLGEN and SYS_XMLAGG Oracle SQL functions, which generate an XML document and aggregate a number of XML documents, respectively, can take as a parameter an XMLTypeobject Chapter 14 - Building an XML-Powered Web Site and return an XMLType object. These functions can be embedded in SQL queries as in a simple SELECT statement and Chapter 15 - Creating a Portal Site with XML and Web Services return XML: Chapter 13 - Getting Started with Oracle XML and Java

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

SELECT SYS_XMLGEN(book) FROM bookcatalog WHERE title LIKE '%ELLISON%';

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

and

Chapter 18 - Getting Started with Oracle XML and C

SELECT SYS_XMLAGG(SYS_XMLGEN(book)).getClobVal() book_list FROM bookcatalog GROUP BY title;

Chapter 19 - Building an XML-Managed Application

Chapter 20would - Build an XML Application The first return theDatabase XML of aOCI book entry and the second would return a list of all the titles of the book entries. Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part Similarly, V - Oracle the DBMS_XMLGEN XML for C++ Developers PL/SQL package converts the result set from SQL queries to an XML stored in an

XMLType, in Chapter 22 -as Getting Started with Oracle XML and C++ Chapter 23SYS_XMLAGG(SYS_XMLGEN(book)).getClobVal() - Build an XML Database OCI C++ Application SELECT book_list FROM bookcatalog GROUP BY title Chapter 24 - Building an XML Data-Retrieval Application

resulting in a listing of all the book titles in XML. Part VI - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

Table creation using XMLTypecolumns and database manipulation language (DML) operations to insert, update, and delete values is allowed with this new data type, along with datatype member functions such as existsNode() and Chapter 27 - Extending PL/SQL XML Functionality with Java extract() that take arguments with XPATH-like syntax to return fragments of XML in the XMLType, such as Chapter 26 - Building PL/SQL Web Services Chapter 28 - Putting It All Together

SELECT book.extract('//title/text()').getStringVal() FROM bookcatalog;

Appendix

- XML Standards Bodies and Open Specifications

Glossary and Index

SELECT * FROM bookcatalog where book.existsNode('//book/title') != 0;

List of Figures List of Tables

List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Best Practices PL/SQL

by Mark Scardina, BentoChang Jinyu Wang DTDs and XML schemas. The following are someV.best practices followand when employing

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages) comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with DesigningThis Your Schema emphasis on XML standards, their usage and best practices.

Defining a schema from scratch can be a daunting task. The following are a set of guidelines that will make your job Table of Contents easier, reduce errors, and ease maintenance. Oracle 10g XMLSchema & SQL—Design, Build XMLroot Applications 1. Database Name the XML document file &toManage reflect the element. in Java, C, C++ & PL/SQL Introduction Part 2. I - Oracle Ensureand thethe rootXML element Standards is defined as the first top-level element and based on the rootType.

Chapter 1

- Introducing XML

3. Ensure XML Schemas are versioned using the optional version attribute in the <schema/> element. - Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 2

Chapter 3 -xsd:token Transforming XML with XSLT and XPath 4. Use instead of xsd:string because the lexical space of a token is the set of strings that do not Chapter contain 4 - Validating DTDs the lineXML feedwith (#xA) norand tab XML (#x9)Schemas characters, that have no leading or trailing spaces (#x20) and that Chapter have 5 - XML Operations with XQuery no internal sequences of two or more spaces. The base type of token is normalizedString. Chapter 6

- XML Messaging and RPC with SOAP

XML element and attribute nameswith should entirelyJSPs, upperand case and use the underscore to separate word Chapter 7 - Putting It All Together XMLbe Pipeline, XSQL boundaries. This makes the database objects easier to create and use when registering the XML schema to Oracle Part II - Oracle XML Management for DBAs XML DB. Chapter 8 - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

Elements vs. Attributes

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

A classic thatthe every XML schema and DTD designer faces at some point is this: Shall I design my DTD or Chapter 12 question - Managing Oracle XML Database XMLIIIschema modeling the data as elements or attributes? It is also a very crucial question as its answer can be the Part - Oracle XML for Java Developers difference a successful future-proof design Chapter 13 -between Getting Started with Oracle XML and Java and one that fails. To illustrate this, consider the following two fragments describing an instance of an address. The first is attribute-based:

Chapter 14 - Building an XML-Powered Web Site

<Address Street="123 St." Francisco" State="CA" Zip="94127"/> Chapter 15 - Creating a Portal Main Site with XML City="San and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Notice how it reads very nicely and appears to be a compact representation because there are no end tags. Now consider the following element-based instance:

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

<Address> Chapter 18 - Getting Started with Oracle XML and C <Street>123 Main St.</Street> <City>San Francisco</City> Chapter 20 - Build an XML Database OCI Application <State>CA<State> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <Zip>94127</Zipcode> Part V - Oracle XML for C++ Developers </Address> Chapter 19 - Building an XML-Managed Application

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 -version Build an XMLnot Database OCI While this does read left to C++ right Application as conveniently, its DOM representation is not significantly larger than Chapter - Building XMLelements Data-Retrieval Application the first24 one becauseanboth and attributes are nodes. More importantly, if at a later time you want to add Part VI - Oracle Developers structure to anyXML onefor of PL/SQL the elements, you can with the second one but not the first, because attributes cannot have

Chapter 25 or - Getting Oracle XML PL/SQL structure be moreStarted than awith simple type. Anand example would be where you want to support extended ZIP codes: Chapter <Zip> 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java <Code>94127</Code> Chapter 28 - Putting It All Together <Ext>8522</Ext> Appendix </Zip>

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures

Designing Element and Attribute Names

List of Tables

List of has Sidebars XML the characteristic of being human-readable with no effective limit to the number of characters used in

element and attribute names. The temptation is therefore to create very explicit names, the result being an instance document that is many times larger than the data it is conveying, as shown in this XML fragment: <ArrivalInfo> <TripCityTimeInfo> <CodeDescription> <Code>CVG</Code> <Description>CVG - Cincinnati,OH, United States - Northern Kentucky Intl</Description>


<AdditionalData>Northern Kentucky Intl</AdditionalData> </CodeDescription> <Date> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <Month>5</Month> PL/SQL <Day>21</Day> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <Year>2002</Year> McGraw-Hill/Osborne © 2004 (600 pages) </Date> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <Time Format="Military">0759</Time> emphasis on XML standards, their usage and best practices. <FlightSearchByTimeType Type="Arriving"/> </TripCityTimeInfo> Table of Contents </ArrivalInfo> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Introduction This actual XML fragment contains 471 bytes yet only 114 bytes of data. This does add significantly to the Part I - Oracle and in the XMLresources Standardsand time. Remember, ultimately XML is a machine-processed document; processing costs both

Chapter 1 -it Introducing therefore, is importantXML for names to be reasonable. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath Loading External DTDs from a JAR File

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter - XML Operations with XQuery A very 5convenient way to handle multiple DTDs is to put them in a JAR file, so that when the XML parser needs one Chapter 6 - XML Messaging RPCthe with SOAP of the DTDs, it can access and it from JAR. The Oracle XML parser supports a base URL (setBaseURL()), but that Chapter just points 7 -to Putting a place It All where Together all thewith DTDs XML are Pipeline, exposed. JSPs, The and solution XSQL involves the following steps: Part 1. II - Load Oracle XML Management for DBAs using the DTD as an InputStream

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

InputStream is = YourClass.class.getResourceAsStream("/foo/bar/your.dtd");

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data 2. This opens ./foo/bar/your.dtd in the relative location on the CLASSPATH so that it can be found in your Chapter JAR. 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

3. Parse the DTD with with the following code: Chapter 13 - Getting Started Oracle XML and Java new DOMParser(); ChapterDOMParser 14 - Buildingdan=XML-Powered Web Site "rootelementname"); Chapterd.parseDTD(is, 15 - Creating a Portal Site with XML and Web Services Chapterd.setDoctype(d.getDoctype()); 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

4. Parse your document with the following code:

Part IV - Oracle XML for C Developers

Chapterd.parse("yourdoc"); 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 5: XML Operations with XQuery PL/SQL

Overview

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

XQuery, or XML emphasis Query, is onaXML query standards, languagetheir thatusage operates and on best a practices. data model for XML documents that is based on the W3C XML Infoset and supports W3C XML Namespaces and W3C XML Schema data types. The XQuery language operates on XML documents or databases viewed as XML documents, thereby allowing transparent access to both Table of Contents and further enabling seamless transactions on the Internet. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction From the requirements set out by the user community, the XQuery functionality should be able to perform queries on Part Oracle the XMLofStandards XMLI -that are and in the form human-readable documents, data-oriented documents, mixed document-oriented and

Chapter 1 - Introducing XML data, streaming data, DOM objects, native repositories and web servers, and catalogs. data-oriented, administrative Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

This chapter will introduceXML thewith basics of and XQuery, Chapter 3 - Transforming XSLT XPathintroduce the Oracle XQuery engine and describe how it interacts with the Oracle database, and present XQuery best practices. Chapter 4 - Validating XML with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Introducing XQuery PL/SQL

by Mark Scardina, ChangW3C and Jinyu XQuery is described at V. length in theBen following Last Wang Call Working Draft specifications per McGraw-Hill/Osborne 2004 (600 pages) www.w3.org/TR/xquery/ (referenced©in a prior chapter):

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

XQuery 1.0: An XML Language Describes how thepractices. language is an extension of XPath 2.0 and emphasis on Query XML standards, their usage and best describes in-depth the grammar and how it is processed. It describes the different expressions that are allowed (such as primary, path, sequence, arithmetic, comparison, logical, and so on), how the expressions can be Table of Contents nested, and the possible data types for the various expressions, operators, and functions. The module section Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL describes the main module and the prolog that can be type-checked on a stand-alone basis. Introduction

Part IXQuery - Oracle 1.0 andand the XML Standards XPath 2.0 Data Model Describes the data model of the XML document on which the XQuery

Chapter 1 - Introducing operators function. XML The data model is simply a representation of the XML document, e.g., elements, attributes, Chapter 2 - Accessing XML withinstructions, DOM, SAX, JAXB, and namespaces, processing and so on,StAX that is provided as input to an XML processor, along with how Chapter that 3 information - Transforming is qualified XML with in terms XSLT and of data XPath types and allowed values. This specification also describes the

different accessorXML functions to this information. Users do not need to concern themselves with this specification Chapter 4 - Validating with DTDs and XML Schemas because it isOperations aimed at implementers Chapter 5 - XML with XQuery of XQuery processors. Chapter 6

- XML Messaging and RPC with SOAP

XQuery 1.0 and XPath 2.0 Formal Semantics Describes the formal semantics of the language with a formal - Putting It All Together with XML Pipeline, JSPs, and XSQL notation governed by grammar productions. It complements the first specification in this list and the XML Path Part II - Oracle XML Management for DBAs Language (XPath) 2.0 specification by strictly defining the meaning of the language’s objects, such as Chapter 8 - Getting Started with the Oracle XML Database expressions, values, and data types, with formal notations. With this specification’s formal semantics, reference Chapter 9 - Storing XML Data implementations can easily be prototyped and problems with this language can thereby be eliminated. Like the Chapter 10 - Generating and Retrieving preceding specification in this list,XML this specification is not intended for users. Chapter 7

Chapter 11 - Searching XML Data

XQuery 1.0 and XPath 2.0 XML Functions and Operators Introduces new functions and operators to the XPath Chapter 12 - Managing the Oracle Database 2.0- language and error, trace, constructor, strings, qualified names, context, and casting functions. It Part III Oracle XML forincludes Java Developers also functions and operators on Java the XML Schema simple data types such as numeric types and Chapter 13introduces - Getting Started with Oracle XML and values, Booleans, dates, Chapter 14 - Building an durations, XML-Powered Webtime, Site any URI, base64Binary, hexBinary, and NOTATION as well as on nodes, and on sequences. Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

XML Syntax for XQuery 1.0 (XQueryX) Maps the grammar productions outlined in the “XQuery 1.0 and XPath 2.0 Formal Semantics” specification into XML. Thus, XML parsers and XSLT stylesheets can process, Part IV - Oracle XML for C Developers query, generate, modify, and reuse the XQuery operations. It makes the productions more easy for humans to Chapter 18 and - Getting Startedthemselves with Oraclemore XML and read the queries easyC to deal with. Chapter 17 - Developing XML-Based Reusable Components

Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

Basics

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

XPath is used quite extensively in the XQuery specification, along with regular expressions, which explains the joint

Chapter 22 - Getting Started in with Oracle chapters, XML and C++ data model. As mentioned previous XPath is simply a way to select of create portions of an XML

Chapter 23 - and BuildXQuery an XMLmakes Database OCI C++ document, extensive useApplication of this syntax in its queries and expressions. The joint data model upon Chapter 24 - Building an XML Data-Retrieval Application which XQuery operators operate defines the input and output of XQuery operators. This data model relies on the Part VI - Oracle XML for PL/SQL concept of a sequence, which isDevelopers an ordered collection, (e.g., in document order) of zero or more items, which are

Chapter Getting Started with Oracle XML andtext, PL/SQL defined25 to -be a node (e.g., element, attribute, document, comment, PI or namespace node), or an atomic value Chapter 26 - Building Web Services that is typed via XMLPL/SQL Schema data types (one special value is an error value). The language itself is simply Chapter composed 27 - of Extending keywords PL/SQL and such XML operators Functionality defined with Java via these expressions or constructors. For example, variables,

which are $ signs, can be used in various expressions, such as loops or assignments, or in function calls Chapter 28 -prefixed Putting by It All Together or constructors. Appendix - XML Standards Bodies and Open Specifications Glossary

Expressions

Index

List of Figures

A number of expressions exist within the XQuery language, so we will concentrate on just the three that we think will List of Tables be of theSidebars most heavily used: List FLWOR expression Path expression Predicate expression For these expressions, the following variation of the book.xml file will be used: <book xmlns:bk="http://www.mcgraw-hill.com" bk:ISBN="99999-99999">


<title>Oracle Database 10g XML and SQL</title> <author> <name bk:type="person"> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <first>Mark</first> PL/SQL <last>Scardina</last> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang </name> McGraw-Hill/Osborne © 2004 (600 pages) <name bk:type="person"> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <first>Ben</first> emphasis on XML standards, their usage and best practices. <last>Chang</last> </name> Table of Contents <name bk:type="person"> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <first>Jinyu</first> Introduction <last>Wang</last> Part I - Oracle and the XML Standards </name> Chapter 1 - Introducing XML </author> Chapter 2 - Accessing XMLPress</publisher> with DOM, SAX, JAXB, and StAX <publisher>Oracle Chapter 3 - Transforming XML with XSLT and XPath <publishyear>2003</publishyear> Chapter 4 -type="US">10.00</price> Validating XML with DTDs and XML Schemas <price Chapter 5 - XML Operations with XQuery </book> Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

FLWOR Expression

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

The FLWOR expression consists of the FOR, LET, WHERE, ORDER BY, and RETURN keywords. For example, Chapter 9 - Storing XML Data the following code loops over all book instances, finds the respective authors, and returns result nodes containing Chapter 10 - Generating and Retrieving XML the book's title and the authors for each book: Chapter 11 - Searching XML Data

<Result> Chapter 12 - Managing the Oracle XML Database { III - Oracle XML for Java Developers Part FOR $book in fn:doc("book.xml")/book LET $author:=collection('author')/$book/author Chapter 14 - Building an XML-Powered Web Site WHERE count($author)>0 Chapter 15 - Creating a Portal Site with XML and Web Services ORDER BY $author/name/last Chapter 16 - Developing an XML Gateway Application with SOAP and AQ RETURN Chapter 17 - Developing XML-Based Reusable Components <title> {$book/title} </title> Part IV - Oracle XML for C Developers <author> Chapter 18 - Getting Started with Oracle XML and C {fn:string-join(($author/name/first/text(), $author/name/last/text(),)," ")} Chapter 19 - Building an XML-Managed Application </author> Chapter 20 - Build an XML Database OCI Application ) Chapter 21 - Create an XML-Configured High-Performance Transformation Engine </result> Chapter 13 - Getting Started with Oracle XML and Java

Part V - Oracle XML for C++ Developers

The following is theStarted result ofwith thisOracle XQuery: Chapter 22 - Getting XML and C++ Chapter 23 - Build an XML Database OCI C++ Application <result> Chapter <title>Oracle 24 - Building an Database XML Data-Retrieval 10g XML Application and SQL</title> Part <author> VI - OracleBen XMLChang, for PL/SQL Mark Developers Scardina,

Jinyu Wang</author>

</result> Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Examining the operation of this XQuery entails the following steps:

Chapter 27 - Extending PL/SQL XML Functionality with Java

1. The set to the <book> element by FOR and assigned to the $book variable. Chapter 28 - iteration Putting ItisAll Together Appendix

- XML Standards Bodies and Open Specifications

2. The variable $author is assigned via LET to /<book>/<author> for all input books.

Glossary

Index3. The predicate WHERE ensures that only books with authors are selected. List of Figures

4. Tables ORDER BY causes the results to return sorted based on the author’s last name. List of List of Sidebars

RETURN defines the actual format of the result. Note that in this case an XML document is constructed as the result in a similar fashion to the result from an XSLT template, and we will be discussing XQuery versus XSLT in the “Best Practices” section.

Path Expression The path expression is based on the abbreviated syntax of XPath 1.0 and is extended in 2.0 with dereference operators and range predicates—i.e., expressions enclosed in square brackets that are often used to filter a


sequence of values. These expressions are evaluated by performing node tests on one or more steps delineated by / or // by performing a node test. There are two types of node tests. The Kind Test checks for whether the type of XML item is either an ElementTest, AttributeTest, CommentTest, TextTest AnyKindTest. Name Test& Oracle Database 10g XML & SQL:PITest, Design, Build & Manage XMLor Applications in The Java, C, C++ adds the further qualification of matching the QName as well. For example, the following are several node tests: PL/SQL ISBN:0072229527 by Mark V. Scardina, Ben Chang Jinyuelements Wang Element(child::book) – matches all and child of book McGraw-Hill/Osborne © 2004 (600 person) pages) Element(child::/book/author/name, – matches all names of child element, author, of This typecomprehensive person guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML standards, usage and node best practices. Attribute()emphasis – matches any singletheir attribute regardless of name Attribute(/book/@bk:ISBN) - matches all book elements containing ISBN attributes the XML namespace associated with the br prefix. Table in of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Predicate Expression Introduction

Part I - Oracle and the XML Standards

The predicate expression can be used to identify certain nodes (e.g., the expression starting with title used in - Introducing XML book[title="Oracle Database 10g XML and SQL"]),to help determine values (e.g., the expression price in Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX book[price > 10] or book[price –10]),or to determine the ordinal position (such as book[5]). Chapter 1 Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Query -Prolog XML Operations with XQuery

Chapter 5 Chapter 6

XML Messaging and RPC with SOAP The query-prolog, along with the query body, comprises an XQuery query. It contains constructs such as

Chapter 7 - Putting It All Together Pipeline, JSPs, and namespace declarations, functionwith and XML variable definitions, andXSQL module imports such as XML Schema imports. The Part II -body Oracle XML Management for DBAs defined or declared in the query prolog, and utilizes the aforementioned query thus references the constructs

Chapter 8 - Getting Startedthe with the Oracle XML Database expressions to determine result of an XQuery query. Some of the other constructs mentioned in the XQuery Chapter 9 - Storing XML Data specification that are contained in the query prolog are version declaration, validation declaration, default Chapter 10 - Generating Retrieving XML namespace declaration,and xmlspace declaration, and default collation. Chapter 11 - Searching XML Data

With a 12 namespace declaration the Database query prolog, a prefix can be used in qualified names to differentiate names of Chapter - Managing the OracleinXML elements, attributes, etc. ForDevelopers example, Part III - Oracle XML for Java declare bk with = "http://www.oracle.com/book" Chapter 13 -namespace Getting Started Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

can be used to uniquely define an element <mybook> as in the qualified name <bk:mybook>. A default namespace declaration could also be made to apply to all unqualified elements, attributes, etc., such as:

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

declare elementComponents namespace bk = "http://www.oracle.com/book" Chapter 17 -default Developingnamespace XML-Based Reusable Part IV - Oracle XML for C Developers

without which these unqualified elements, attributes, etc., would be considered to be in no namespace.

Chapter 18 - Getting Started with Oracle XML and C

Chapter 19 -to Building an XML-Managed Application In addition namespace declarations, the query prolog can also contain function definitions that can be called Chapter 20 -query Buildbody. an XML Database OCI Application within the The function definition consists of the function name, with an optional prefix, preceded by Chapter 21 function - Create keyword an XML-Configured High-Performance Engine thedefine and followed by a parameterTransformation list and the expressions that make up the function body. Part - Oracle in XML for C++ Developers For Vexample,

Chapter 22 -default Getting Started with Oracle XML and C++ declare namespace element namespace bk = http://www.oracle.com/book Chapter 23function - Build an XML Database OCI C++ Application define bk:getbookname($node) { Chapter - Building XML Data-Retrieval Application let 24 $name := an $node/bookname Partreturn VI - Oracle XML for PL/SQL Developers $name

Chapter 25 - Getting Started with Oracle XML and PL/SQL } Chapter 26 - Building PL/SQL Web Services

the function name is bk:getbookname, which contains Chapter 27 - Extending PL/SQL XML Functionality with Javathe namespace prefix to prevent it from colliding with other getbookname functions. It takes a node as a parameter, and in its body it creates a return variable, $name, that is Chapter 28 - Putting It All Together used to return the <bookname> nodes that are children of the passed-in node. - XML Standards Bodies and Open Specifications

Appendix

Glossary Finally, the import keyword can be used in the query prolog to include other bodies of definitions, such as XML Index schemas, which can then be referenced in the query body. For example, List of Figures

import schema namespace mybook=http://www.mcgrawhill.com/book at "http://xmlns.mcgraw-hill.com/mybook.xsd" List of Sidebars declare default namespace element namespace bk = http://www.oracle.com/book define function bk:getbookname($node) { let $name := $node/bookname return $name } List of Tables

Introducing XQueryX


XQueryX is simply an XML representation of an XQuery query. The XQueryX specification maps the grammar productions outlined in the XQuery 1.0 and XPath 2.0 Formal Semantics specification into XML. Thus, using XML parsers you can process, query, 10g generate, and reuse the & XQuery expressions. It enables Oracle Database XML &modify, SQL: Design, Build Manage XML Applications in XML Java,processes C, C++ & such as XSLT PL/SQL stylesheets to generate productions. At the time of this writing, this specification is undergoing significant rewriting andV.thus may not exit the W3C process as it currently stands. We mention it here forISBN:0072229527 by Mark Scardina, Ben Chang and Jinyu Wang informational purposes because the©Oracle XQuery McGraw-Hill/Osborne 2004 (600 pages) prototype discussed in the following section supports the original syntax. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

To give you a specific example of how the XQuery XML looks, the following FLWOR expression is transformed from FOR $b IN document("book.xml")//book WHERE $b/publisher = "Oracle Press" AND $b/year = "2003" Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL RETURN Introduction $b/title

Table of Contents

Part I - Oracle and the XML Standards

Chapter 1 - Introducing XML to the following XML representation: Chapter 2

XML with DOM, SAX, JAXB, and StAX <q:query- Accessing xmlns:q="http://www.w3.org/2001/06/xqueryx"> Chapter 3 - Transforming XML with XSLT and XPath <q:flwr> Chapter 4 - Validating XML with DTDs and XML Schemas <q:forAssignment variable="$b"> Chapter 5<q:step - XML Operations with XQuery axis="SLASHSLASH"> Chapter 6 -<q:function XML Messaging name="document"> and RPC with SOAP Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL <q:constant datatype="CHARSTRING">book.xml</q:constant> Part II - Oracle XML Management for DBAs </q:function> Chapter 8 -<q:identifier>book</q:identifier> Getting Started with the Oracle XML Database </q:step> Chapter 9 - Storing XML Data </q:forAssignment> Chapter 10 - Generating and Retrieving XML <q:where> Chapter 11 - Searching XML Data <q:function Chapter 12 - Managing thename="AND"> Oracle XML Database <q:function name="EQUALS"> Part III - Oracle XML for Java Developers <q:step axis="CHILD"> Chapter 13 - Getting Started with Oracle XML and Java <q:variable>$b</q:variable> Chapter 14 - Building an XML-Powered Web Site <q:identifier>publisher</q:identifier> Chapter 15 - Creating a Portal Site with XML and Web Services </q:step> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <q:constant datatype="CHARSTRING">Oracle Press</q:constant> Chapter 17 - Developing XML-Based Reusable Components </q:function> Part IV - Oracle XML for C Developers <q:function name="EQUALS"> Chapter 18 - Getting Started with Oracle XML and C <q:step axis="CHILD"> Chapter 19 - Building an XML-Managed Application <q:variable>$b</q:variable> Chapter 20 - Build<q:identifier>year</q:identifier> an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine </q:step> Part V - Oracle <q:constant XML for C++ Developers datatype="CHARSTRING">2003</q:constant> Chapter 22 -</q:function> Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application </q:function> Chapter </q:where> 24 - Building an XML Data-Retrieval Application Part VI<q:return> - Oracle XML for PL/SQL Developers <q:step Chapter 25 - Gettingaxis="CHILD"> Started with Oracle XML and PL/SQL Chapter 26 -<q:variable>$b</q:variable> Building PL/SQL Web Services Chapter 27 -<q:identifier>title</q:identifier> Extending PL/SQL XML Functionality with Java </q:step> Chapter 28 - Putting It All Together </q:return> Appendix - XML Standards Bodies and Open Specifications </q:flwr> Glossary </q:query> Index

List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & The Oracle XQuery Engine PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang The Oracle XQuery engine is a prototype implementation of the evolving XQuery language, with Oracle extensions. McGraw-Hill/Osborne © 2004 (600 Written in Java, the engine can be invoked viapages) its OJXQI Java API, or via its XQLPlus command-line utility. This engine can be This usedcomprehensive either within the Oracle database or outside, as in a webwithin application server or client.products, The only with guide focuses on utilizing XML technologies Oracle's XML-enabled emphasis on XMLXDK standards, their usage and best JDBC practices. other requirements are Oracle 9i or above, an associated driver, and JDK 1.3. This prototype is based on the November 15, 2002 draft of the specification.

Table of Contents

Setting Up the Environment

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

On IWindows platforms, xq.zip needs to be downloaded and unzipped. The directory contains the JAR file, Part - Oracle and the XML Standards xquery.jar, an exampleXML XQuery file and XML file, and a Javadoc directory. The next step is to include in your Chapter 1 - Introducing CLASSPATH the location of this JARSAX, and JAXB, the JARs the Oracle XDK, along with your desired JDK or JRE. Chapter 2 - Accessing XML with DOM, and in StAX Chapter 3

- Transforming XML with XSLT and XPath

Similarly, on UNIX platforms, the xq.tar.gz file needs to be downloaded, unzipped, and extracted; and the - Validating XML with DTDs and XML Schemas CLASSPATH needs to be set properly. These distributions contain the same files and can also be used on any Chapter 5 - XML Operations with XQuery Oracle-supported platform with the appropriate port of the JDK or JRE. Chapter 4 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Testing Your Installation

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

On both Windows and UNIX platforms, in order to test the installation, after you make sure the CLASSPATH has Chapter 9 - Storing XML Data been set correctly, run XQLPlus via the following command: Chapter 10 - Generating and Retrieving XML

java oracle.xquery.XQLPlus exmpl1.xql

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database Part XML Java Developers ThisIII will- Oracle process thefor following XQuery contained in exmpl1.xql:

Chapter 13 - Getting Started with Oracle XML and Java

<bib> { Chapter 15 -$b Creating a Portal Site with XML and Web Services FOR IN document("bib.xml")/bib/book Chapter 16 - Developing an XML Gateway Application with SOAP AQ WHERE $b/publisher = "Addison-Wesley" AND and $b/@year > 1991 Chapter 17 - Developing XML-Based Reusable Components RETURN Part IV - Oracle for C Developers <bookXML year="{ $b/@year }"> Chapter 18 -{Getting Started} with Oracle XML and C $b/title Chapter 19 - Building an XML-Managed Application </book> Chapter } 20 - Build an XML Database OCI Application </bib> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Chapter 14 - Building an XML-Powered Web Site

Part V - Oracle XML for C++ Developers

The preceding query parseswith bib.xml, Chapter 22 - Getting Started Oracleiterating XML andover C++all the <book> elements that it has assigned to the $b variable. For each<publisher> element, it attempts to match the string value as well as a numeric comparison against the yearattribute. For each entry that satisfies both conditions, it creates an XML output of the title and year published. Chapter 24 - Building an XML Data-Retrieval Application The matched portion of bib.xmland the result is as follows: Chapter 23 - Build an XML Database OCI C++ Application Part VI - Oracle XML for PL/SQL Developers

<bib> 25 - Getting Started with Oracle XML and PL/SQL Chapter <book Chapter 26year="1994"> - Building PL/SQL Web Services <title>TCP/IP Illustrated</title> <author><last>Stevens</last><first>W.</first></author> Chapter 28 - Putting It All Together <publisher>Addison-Wesley</publisher> Appendix - XML Standards Bodies and Open Specifications <price> 65.95</price> Glossary </book> Index <book year="1992"> List <title>Advanced of Figures Programming in the Unix environment</title> List <author><last>Stevens</last><first>W.</first></author> of Tables List <publisher>Addison-Wesley</publisher> of Sidebars <price>65.95</price> </book> … </bib> Result -------------------------------------------------------<bib> <book year="1994"> Chapter 27 - Extending PL/SQL XML Functionality with Java


<title>TCP/IP Illustrated</title> </book> <book year="1992"> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <title>Advanced PL/SQL Programming in the Unix environment</title> </book> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang </bib> McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Note that the file being queried, bib.xml, is in the query itself and is not passed on the command line. emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Querying Oracle XMLDatabase Documents PL/SQL

ISBN:0072229527 by XQuery Mark V. engine, Scardina,it Ben Chang and to Jinyu Wang Using the Oracle is quite simple query XML documents either interactively via the command line McGraw-Hill/Osborne © 2004 (600 pages) or programmatically.

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Running in Interactive Mode

Table of Contents XQLPlus can be run in interactive mode in the same way as SQLPlus. In fact, where appropriate, it uses the same Oracle commands. Database To 10g run XQLPlus XML & SQL—Design, in interactive Build mode, & Manage invokeXML the Applications following command: in Java, C, C++ & PL/SQL Introduction java oracle.xquery.XQLPlus Part I - Oracle and the XML Standards

Then, an can beXML entered from the XQL prompt, terminated by /, or a script invoked via @exmpl. Typing Chapter 1 XQuery - Introducing help returns the following: Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 Command - Transforming with XSLT and XPath XQuery LineXML Tool Chapter Enter 4XQuery - Validating statements XML with DTDs followed and XMLby Schemas /;

To execute inwith a XQuery file from the XQL prompt, enter @ followed by Chapter 5 - XMLqueries Operations the <fileName> Chapter 6 - XML Messaging and RPC with SOAP To execute queries in a file from the shell prompt, enter Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL java <fileName> Part II -XQLPlus Oracle XML Management for DBAs Set command helps set environment Chapter 8 - Getting Started with the Oracle XMLvariables: Database set sqlconn default=<jdbc-connect-string> Chapter 9 - Storing XML Data set sqlconn <name> =<jdbc-connect-string> set echo (ON | OFF) Chapter 11 - Searching XML Data set timing (ON | OFF) Chapter 12 - Managing the Oracle XML Database set var <variable name> <value> Part III - Oracle XML for Java Developers set print_plan (ON | OFF) Chapter 10 - Generating and Retrieving XML

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Querying XML from the Command Line

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

In addition to interactive mode XQLPlus can be invoked with arguments:

Chapter 17 - Developing XML-Based Reusable Components

java Part IV -oracle.xquery.XQueryContext Oracle XML for C Developers

–xqfile /private/exmp11.xql

Chapter 18 - Getting Started with Oracle XML and C

These can be the XQuery file containing the query, an optional base URL to be used when accessing filenames inside document functions in the XQuery, and optional debug features. For example:

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application

java oracle.xquery.XQueryContext –xqfile /private/exmp11.xql –baseurl /private –debug

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

Querying XML with XQueryX

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

TheVI XQueryX alsoDevelopers be run from the XQLPlus engine via Part - OracleXML XML file for can PL/SQL java oracle.xquery.XQLPlus @foo.xml Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

or at the command-line prompt after invoking XQLPlus.

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10gDatabase XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XQuery and the Oracle PL/SQL

by Mark V. Scardina, and Jinyu The Oracle XQuery engine enables Ben you Chang to connect to theWang Oracle database and execute XQuery queries ISBN:0072229527 over the McGraw-Hill/Osborne © 2004 data stored in the database, the result sets(600 of pages) which are returned via an XQueryResultSetObject object. This capability is made throughguide Oracle extensions that allow the execution of XQuery expressions over Thispossible comprehensive focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on viewed XML standards, usage bestofpractices. traditional database tables as XML.their Hence, theand power XQuery has been significantly enhanced with the Oracle implementation. Table of Contents

XQuery API for Java

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

OJXQI is the and Javathe API for Standards XQuery proposed by Oracle, and includes various extensions that Oracle supports for Part I - Oracle XML connecting the database Chapter 1 - to Introducing XML and binding variables, among other things. OJXQI provides an XqueryResultSet class that can2 be used to obtain the results of executing the XQuery. Chapter - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

To use OJXQI, you first need to construct a context. To do so, use the default constructor or pass in the connection - Validating XML with DTDs and XML Schemas information, prepare an XQuery or XQueryX statement by calling prepareXQuery() or prepareXQueryX(), Chapter 5 - XML Operations with XQuery respectively, bind any values to the return object of these calls, PreparedXQuery, execute the PreparedXQuery Chapter with SOAP object, 6and- XML then Messaging iterate overand theRPC XQueryResultSetObject. The following code fragment illustrates this: Chapter 4

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

XQueryContext ctx = new XQueryContext(); try { Chapter 8 - Getting Started with the Oracle XML Database // create a string from the file Chapter 9 - Storing XML Data Reader strm = new FileReader("exmpl1.xql"); Chapter 10 - Generating and Retrieving XML // prepare the query Chapter PreparedXQuery 11 - Searching XML Data xq = ctx.prepareXQuery(strm); Chapter 12 - Managing the Oracle XML Database // get a resultset Part III XQueryResultSet - Oracle XML for Java rset Developers = xq.executeQuery(); Chapter 13while - Getting Started with Oracle (rset.next()) { XML and Java Chapter 14 Building an XML-Powered Web Site // get result nodes Chapter 15XMLNode - Creating node a Portal= Site rset.getNode(); with XML and Web Services NODE "+ node.getNodeName()); Chapter 16System.out.println(" - Developing an XML Gateway Application with SOAP and AQ node.print(System.out); Chapter 17 - Developing XML-Based Reusable Components Part IV -}Oracle XML for C Developers } 18 - Getting Started with Oracle XML and C Chapter catch (Exception e) { Chapter 19 - Building an XML-Managed Application // do something.. Chapter 20 - Build an XML Database OCI Application } Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part II - Oracle XML Management for DBAs

Part V - Oracle XML for C++ Developers

A number of Oracle enhancements were made to support embedding SQL inside XQuery queries, to support bind variables so that the XQuery query is not re-executed, and to support XMLType.

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

Querying XML in the Database

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Invoking the methods defined in OJXQI in a Java program enables you to query the database using XQuery expressions and operators. For example, the following XQuery will return the results of all the names and titles from Chapter 27 -table: Extending PL/SQL XML Functionality with Java an author Chapter 26 - Building PL/SQL Web Services Chapter 28 - Putting It All Together

FOR $i IN sqlquery("select * from booklist.author"/ROW) - XML Standards Bodies and Open Specifications RETURN Glossary $i/NAME, Index $i/TITLE Appendix

List of Figures List of Tables

Theofcode to convert that to a Java program would look something like this: List Sidebars // get the connection DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection("jdbc:oracle:@", "scott", "tiger"); // create the context using that connection XqueryContext ctx = new XQueryContext(conn); // create a string from the file Reader strm = new StringReader("For $i IN sqlquery(\"select * from booklist.author\"), "+ " RETURN $i/NAME, $i/TITLE");


// prepare the query PreparedXQuery xq = ctx.prepareXQuery(strm); // get a result set Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XqueryResultSet rset = xq.executeQuery(); PL/SQL while (rset.next()) { ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang XMLNode node = rset.getNode(); McGraw-Hill/Osborne © 2004 (600 pages) System.out.println(" NODE "+ node.getNodeName()); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Node.print(System.out); emphasis on XML standards, their usage and best practices. } Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Best Practices PL/SQL

ISBN:0072229527 by XQuery Mark V. has Scardina, Benfinalized, Chang and Jinyu Obviously, since not been there is Wang little user experience with it. However, we feel there is value McGraw-Hill/Osborne © 2004 (600 pages) in comparing its functionality with two alternative technologies—XSLT 2.0 and SQL/XML. Oracle Database 10g has implementations of comprehensive both of these technologies. This guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

XQuery Versus XSLT 2.0

Table of Contents

Oracle XSLTDatabase is a mature 10glanguage XML & SQL—Design, that has Oracle Buildimplementations & Manage XML Applications in Java, C, in and Java, C++C,asC++ well&as PL/SQL SQL access. XSLT 2.0,

as discussed in Chapter 3, is incorporating more functionality, including support for data types and XPath 2.0. Introduction XQuery, which also uses 2.0, is also still brewing even as this is being written, and as seen from the Part I - Oracle and the XMLXPath Standards examples similar Chapter 1 -supports Introducing XMLfunctionality. Therefore, the following are legitimate questions: Do we need both XSLT and XQuery? and AreXML there advantages one over the other? Chapter 2 - Accessing with DOM, SAX,ofJAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

Since XSLT is a function-based language in which each template needs to be evaluated against the entire - Validating XML with DTDs and XML Schemas document, its processing model is considered recursive. This can produce less-than-optimum performance when Chapter 5 - XML Operations with XQuery processing large documents, not only because XSLT processors require an in-memory representation of the entire Chapter 6 - such XML Messaging and RPC with SOAP document, as DOM, to traverse, but also because the frequent XPath traversals reduce throughput of the Chapter 7 Putting It All Together with XML Pipeline, JSPs, and XSQL processing. Chapter 4

Part II - Oracle XML Management for DBAs

XQuery, the other hand,with whilethe still usingXML XPath, is neither function-based nor recursive. Therefore, its processing Chapter 8 on - Getting Started Oracle Database model can optimized by compiling the queries, potentially producing more efficient processing. However, XQuery, Chapter 9 -be Storing XML Data without10 XQueryX, is notand an Retrieving XML syntax, thus limiting its integration into an XML processing stack. Chapter - Generating XML Chapter 11 - Searching XML Data

Finally, between the work being done to compile XSLT stylesheets and the fact that few XQuery implementations exist due to the standard’s draft status, the verdict is still out as to whether both will find a niche or one will prevail.

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

XQuery Versus SQL/XML

Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

In the case of XQuery versus SQL/XML, they are two emerging standards that can be considered to be competing for the same function space. We will be discussing SQL/XML in detail in later chapters because its functionality is Chapter 17 - Developing XML-Based Reusable Components included in Oracle Database 10g. Of particular note is that SQL/XML depends on SQL for its datatype support and Part IV - Oracle XML for C Developers not XML Schema. Thus, as its name implies, SQL/XML integrates XML processing with SQL and therefore would be Chapter 18 - Getting Started XML and C the technology of choice forwith SQLOracle environments or when you need to mix table-based, structured data with XML or Chapter 19 Building an XML-Managed Application document data. Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 20 - Build an XML Database OCI Application

On the 21 other hand,an XQuery is designed for an XML environment where Engine a database is not a required component. Chapter - Create XML-Configured High-Performance Transformation While will access collections of documents, it does not depend on any particular repository model. It is also Part V -itOracle XML for C++ Developers designed work with XML with Schema data types. Therefore, taking into account the XSLT issues, XQuery will Chapter 22 to - Getting Started Oracle XML and C++ generally the choice yourOCI XML processing doesn’t have access to or will not benefit from a SQL engine Chapter 23 be - Build an XMLwhere Database C++ Application and requires XML Schema Chapter 24 - Building an XML support. Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 6: XML Messaging and RPC with SOAP PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

The Oracle E-Business Suite of applications offers companies a new and better way to conduct business. The EMcGraw-Hill/Osborne © 2004 (600 pages) Business Suite combines customer relationship management (CRM), supply chain management, and internal guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with operations as aThis fullycomprehensive integrated solution. The Oracle E-Business XML Services component, which is available in emphasis on XML standards, their usage and best practices. release 11.5.6 of Oracle Applications, provides a framework and system infrastructure for deployment, management, and run-time execution of XML Services, the foundation for developing a new generation of Web-enabled eTable of Contents business applications. Central to this notion of XML Services is the concept of XML messaging based on SOAP, Oracle & SQL—Design, Buildapplications & Manage XML in Java, C, C++(for & PL/SQL whichDatabase underlies10g the XML communication of these via Applications their key integration points example, XML Services, Introduction how XML Services are invoked, what events trigger them, and how event subscribers are able to handle them). Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML Introducing SOAP

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 - Transforming XML with XSLT and XPath The Simple Object Access Protocol (SOAP) is a lightweight, XML-based protocol for exchanging information in a Chapter 4 - Validating XMLenvironment. with DTDs and XML Schemas decentralized, distributed SOAP consists of three parts: Chapter 5

- XML Operations with XQuery

The defines an overall framework for expressing what is in the message, who should Chapter 6 SOAP - XML Envelope, Messaging which and RPC with SOAP process the message, and whether the processing is optional or mandatory. - Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 7

Part II - Oracle XML Management for DBAs

A set of encoding rules for expressing instances of application-defined data types. These rules define a

Chapter 8 - Getting Started with Oracle XML Database data types to XML and vice versa. serialization mechanism thatthe converts the application Chapter 9

- Storing XML Data

A SOAP remote procedure call (RPC) Chapter 10 - Generating and Retrieving XML convention for representing remote procedure calls and responses. Chapter 11 - Searching XML Data

The major design goal for SOAP is simplicity and extensibility. SOAP has a looser coupling between the client and the server than some similar distributed computing protocols, such as Common Object Request Broker Part III - Oracle XML for Java Developers Architecture/Internet Inter-ORB Protocol (CORBA/IIOP). All this makes the protocol even more compelling. SOAP is Chapter 13 - Getting Started with Oracle XML and Java transport protocol independent and thus can be used with any transport protocol. At the same time, when used with Chapter 14 - Building an XML-Powered Web Site HTTP for remote service invocation over the Internet, SOAP emerged as a de facto standard for delivering Chapter 15 - Creating a Portal Site with XML and Web Services programmatic content over the Web. SOAP 1.2 became a W3C recommendation in June 2003; however, the Oracle Chapter 16implementation - Developing anisXML Gateway Application with is SOAP andnote. AQ XFK 10g based on SOAP 1.1, which a W3C Chapter 12 - Managing the Oracle XML Database

Chapter 17 - Developing XML-Based Reusable Components Part Since IV SOAP - OracleisXML XMLfor based, C Developers it is platform and operating system independent. It supports communication between a

client and that use different programming Chapter 18 -server Getting Started with Oracle XML and Clanguages. SOAP requests are easy to generate, and a client can easily process the responses. By using SOAP, one application can become a programmatic client of another Chapter 19 - Building an XML-Managed Application application's services, with the twoOCI applications exchanging rich, structured information. SOAP provides a robust Chapter 20 - Build an XML Database Application programming model creates the possibility to aggregate powerful, distributed web services (such as XML Chapter 21 - Create anthat XML-Configured High-Performance Transformation Engine services) to turn the into an application development platform of the future. Part V - Oracle XML forInternet C++ Developers Chapter 22 - Getting Started with Oracle XML and C++

Literal, Encoded SOAP Messages

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

TheVI SOAP specification describes a standard, XML-based way to encode requests and responses, including: Part - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

Requests to invoke a method/function as a service, including in parameters

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending XML Functionality with Java return value and out parameters Responses from aPL/SQL service method/function, including Chapter 28 - Putting It All Together

Errors- from a service Bodies and Open Specifications Appendix XML Standards Glossary

An illustration of a SOAP message format appears in Figure 6-1.

Index

List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Figure 6-1: SOAP message format

Part II - Oracle XML Management for DBAs

Basically, the message itself is the key for a SOAP message; the payload is encoded in XML and has no knowledge

Chapter 8 - Getting with the XML Database details. of processing, whileStarted the header mayOracle contain processing Chapter 9

- Storing XML Data

Consider following example: a GetLastTradePrice SOAP request is sent to a StockQuote service. The request Chapter 10 the - Generating and Retrieving XML takes a11 string parameter, company ticker symbol, and returns a float in the SOAP response. The XML document Chapter - Searching XMLthe Data represents SOAPthe message. The Database SOAP Envelope element is the top element of the XML document. XML Chapter 12 - the Managing Oracle XML namespaces are used disambiguate Part III - Oracle XML forto Java DevelopersSOAP identifiers from application-specific identifiers. The example uses HTTP as transport protocol. The rules Chapter 13 the - Getting Started with Oracle XMLgoverning and Java XML payload format in SOAP are entirely independent of the fact that payloadan is XML-Powered carried in HTTP (because SOAP is transport independent). The SOAP request message Chapter 14the - Building Web Site embedded in the HTTP request looks like this:

Chapter 15 - Creating a Portal Site with XML and Web Services

POST /StockQuote Chapter 16 - Developing HTTP/1.1 an XML Gateway Application with SOAP and AQ Host: 17 www.stockquoteserver.com Chapter - Developing XML-Based Reusable Components Content-Type: charset="utf-8" Part IV - Oracle XMLtext/xml; for C Developers Content-Length: nnnn with Oracle XML and C Chapter 18 - Getting Started SOAPAction: "Some-URI"

Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

<SOAP-ENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> Part V - Oracle XML for C++ Developers <SOAP-ENV:Body> Chapter 22 - Getting Started with Oracle XML and C++ <m:GetLastTradePrice xmlns:m="Some-URI"> Chapter 23 - Build an XML Database OCI C++ Application <symbol>ORCL</symbol> Chapter 24 - Building an XML Data-Retrieval Application </m:GetLastTradePrice> Part VI Oracle XML for PL/SQL Developers </SOAP-ENV:Body> Chapter 25 - Getting Started with Oracle XML and PL/SQL </SOAP-ENV:Envelope> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

What follows is the Itresponse HTTP message containing the XML message in SOAP format as the payload: Chapter 28 - Putting All Together Appendix Bodies and Open Specifications HTTP/1.1- XML 200 Standards OK Glossary Content-Type: text/xml; charset="utf-8"

Content-Length: nnnn Index List of Figures

<SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/ List of Tables SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> List of Sidebars <SOAP-ENV:Body> <m:GetLastTradePriceResponse xmlns:m="Some-URI"> <Price>34.5</Price> </m:GetLastTradePriceResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

One-Way and Two-Way SOAP Messaging and RPCs


The preceding example is an example of two-way SOAP messaging in that both the request and response are encapsulated in SOAP messages. A one-way SOAP message is one that simply sends out a request or a message, Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & without needingOracle an acknowledging SOAP message in return. In addition, SOAP allows the encapsulation and PL/SQL exchange of RPCs and responses.

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) Using SOAP for RPCs is not limited to HTTP requests and responses. In order to invoke a method, the following is

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

needed:

A method name Table of Contents

An optional method signature

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction The parameters to the method Part I - Oracle and the XML Standards

The of the target object Chapter 1 URI - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Optional header data

Chapter 4 - Validating with DTDs XML Schemas The method calls and XML responses are and embedded in the SOAP Body using the following representation: Chapter 5

- XML Operations with XQuery

The invocationand is aRPC datawith structure Chapter 6 method - XML Messaging SOAP whose name and type is the same as the method name. Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

The data structure contains fields that act as accessors for each parameter of the method, each of whose name, type, and order are the same as in the method signature.

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 method - Storing XML Data The response is also a data structure, similar to the data structure that models the data invocation, Chapter except 10 - Generating that the name andisRetrieving typically name_Response XML and the first accessor is the return value. Chapter 11 - Searching XML Data

A method fault is encoded in the SOAP Fault section.

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

If additional information relevant to the encoding of a method request exists, it must be expressed within the SOAP

Chapter - Getting withanOracle XML and Java Header13 section. ForStarted example, alternative book ID may be embedded in the SOAP Header when passing along a Chapter 14 - Building an XML-Powered Site since this book ID would not be part of the method signature and SOAP message concerning the sale Web of a book, Chapter - Creating a Portal Site with XML and Web Servicesside. can be 15 extracted from the header by code on the receiving Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML &XDK SQL: Design, Build & Manage XML Applications in Java, C, C++ & Using SOAP and the Oracle PL/SQL

ISBN:0072229527 by Mark V. Ben10g Chang and Wang XML Services included in Scardina, Oracle XDK uses theJinyu Oracle SOAP implementation that is part of Oracle AS 10g McGraw-Hill/Osborne © 2004 (600 pages) version 9.0.4 as its SOAP run-time engine, which is part of the Oracle XDK. The Oracle SOAP implementation is based on the Apache SOAP implementation andonis utilizing SOAP 1.1. thewithin XML Oracle's ServicesXML-enabled are SOAP services This comprehensive guide focuses XMLTherefore, technologies products,and with on XML standards,client, their usage and best practices. can be invokedemphasis by any SOAP-compatible the description of which follows.

SOAP Client

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

The SOAP client must perform the following steps: Introduction Part 1. I - Oracle the XML Standards Gatherand all parameters that are needed to invoke a service.

Chapter 1

- Introducing XML

2. Create a SOAPXML service request message. This is an XML message, built according to the SOAP protocol, Chapter 2 - Accessing with DOM, SAX, JAXB, and StAX all ofXML the values of all input parameters encoded in XML. This process is called serialization of Chapter that 3 - contains Transforming with XSLT and XPath Chapter the 4 -parameters. Validating XML with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

3. Submit the request to a SOAP server using some transport protocol that is supported by the SOAP server.

Chapter 7 - Putting It All Together XML Pipeline, JSPs, and XSQL 4. Receive a SOAP responsewith message. Part II - Oracle XML Management for DBAs

5. Determine success failure of XML the request by handling the SOAP Fault element. Chapter 8 - Gettingthe Started withorthe Oracle Database Chapter 9

- Storing XML Data

6. Convert the returned parameter from XML to a native data type. This process is called deserialization.

Chapter 10 - Generating and Retrieving XML Chapter - Searching XML Data Use the11result as needed.

Chapter 12 - Managing the Oracle XML Database

To enable you to avoid dealing with XML and SOAP at a very low level, a number of SOAP clients are available that Part III - Oracle XML for Java Developers will do most of this work forwith you.Oracle To facilitate easy application development and to insulate the application Chapter 13 - Getting Started XML and Java

developers from all details of using SOAP, XML Services includes a SOAP client API. This API provides an easy way to invoke SOAP services from the XML Services framework. The XML Services SOAP client API supports a Chapter 15 - Creating a Portal Site with XML and Web Services synchronous invocation model for requests and responses. Chapter 14 - Building an XML-Powered Web Site

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

SOAP Server

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

Any SOAP server follows the following general steps while executing a SOAP service request:

Chapter 19 - Building an XML-Managed Application

1. The receives the service request. Chapter 20 - server Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

2. After parsing the XML request, the server must decide whether to execute the message or reject it.

Part V - Oracle XML for C++ Developers

Chapter 22the - Getting Started Oracle XML C++finds out if the service that is requested exists. 3. If message is to with be executed, theand server Chapter 23 - Build an XML Database OCI C++ Application

4. The converts input parameters from XML into data types that the service understands. Chapter 24 - server Building an XML all Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

5. The server invokes the service.

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - server Building PL/SQL the Webreturn Services 6. The converts parameter to XML and generates a SOAP response message. Chapter 27 - Extending PL/SQL XML Functionality with Java

The server response message back to the caller. Chapter 28 - sends Puttingthe It All Together Appendix

- XML Standards Bodies and Open Specifications

SOAP Handlers

Glossary Index

A SOAP handler is simply a mechanism that is used to intercept the SOAP message to do either pre- or postList of Figures processing List of Tables as indicated by the SOAP request or response. These can be used on the client or server side, or both, andofcan add additional features to XML services, such as security, error handling, and so forth. For the Java List Sidebars language binding, all SOAP handlers live in the package namespace user.soap.handlers hierarchy. An example of such a handler would be the following in a SOAP XML configuration file: <osc:handlers> <osc:handler name="book" class="opress.soap.handlers.book.BookLogger"> <osc:option name="BookLogDirectory" value="/private1/opress/app/product/tv02/soap/webapps/soap/WEB-INF"/> <osc:option name="filter" value="(!(host=localhost))"/>


</osc:handler> </osc:handlers> <osc:requestHandlers names="book"/> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <osc:responseHandlers names="book"/> PL/SQL <osc:errorHandlers names="book"/> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database XML &Database SQL: Design, Build & Manage XML Applications in Java, C, C++ & Using SOAP and the 10g Oracle PL/SQL

ISBN:0072229527 by Database Mark V. Scardina, Ben as Chang and Jinyu Wang Using the Oracle with SOAP the underlying messaging protocol to queue and operate on messages McGraw-Hill/Osborne © 2004 (600 pages) from applications working on top of the database allows all the traditional features, such as performance, scalability, security, high reliability, and recoverability, to be on associated withtechnologies such messages. addition, an Oracle Advanced This comprehensive guide focuses utilizing XML withinInOracle's XML-enabled products, with emphasis on XML standards, their and usage and best practices. Queuing (AQ) servlet allows clients to interpret communicate with the back-end database to extract information and to retrieve, update, enqueue, and dequeue these messages, which are stored in message queue tables in the database. Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Finally, allowing AQ messages in SOAP format and the XML-based Internet Data Access Presentation (iDAP) formats allows transformation, extraction, and other standards-based operations associated with XML to occur.

Introduction

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Oracle- Streams Accessing XMLAQ with Support DOM, SAX, JAXB, and StAX

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

Oracle’s AQ acts as the hub for either native XML or XML defined using iDAP, meaning that such messages can be - Validating XML with DTDs and XML Schemas sent over HTTP or SMTP protocols. In either case, clients such as browsers and servers such as Oracle can Chapter 5 - XML Operations with XQuery communicate through enqueue, dequeue, publish, and register functionality encapsulated by Oracle-specific tags Chapter - XML Messaging and RPC with SOAP such as6 AQXMLSend, AQXMLReceive, AQXMLPublish,AQXMLRegister,AQXMLReceiveResponse, Chapter 7 Putting It All Together with XML Pipeline, JSPs, andwith XSQL AQXMLPublishResponse,AQXMLNotification, and along other required elements. For example, a client can Part II Oracle XML Management for DBAs construct the following iDAP XML message and send it over HTTP to be processed by Oracle: Chapter 4

Chapter 8

- Getting Started with the Oracle XML Database

<?xml version="1.0"?> Chapter 9 - Storing XML Data <Envelope xmlns=http://www.oracle.com/schemas/IDAP/envelope> Chapter 10 - Generating and Retrieving XML <Body> Chapter 11 - Searching XML Data <AQXMLSend xmlns=http://www.oracle.com/schemas/AQ/access> Chapter 12 Managing the <!-- mandatory Oracle --> XML Database Part III Oracle XML for Java <producer_options>Developers Chapter <!--mandatory 13 - Getting Started--> with Oracle XML and Java Chapter <destination>BOOKLIST.BOOK_QUEUE</destination> 14 - Building an XML-Powered Web Site Chapter </producer_options> 15 - Creating a Portal Site with XML and Web Services <!—mandatory Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <message_set> Chapter 17 - Developing XML-Based Reusable Components Part IV -<message> Oracle XML for C Developers <message_number>1</message_number> Chapter 18 - Getting Started with Oracle XML and C mandatory --> Chapter 19<!—- Building an XML-Managed Application <message_header> Chapter 20 - Build an XML Database OCI Application <correlation>BOOK</correlation> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <sender_id> Part V - Oracle XML for C++ Developers <agent_name>Juan</agent_name> Chapter 22 - Getting Started with Oracle XML and C++ </sender_id> Chapter 23 - Build an XML Database OCI C++ Application </message_header> Chapter 24 - Building an XML Data-Retrieval Application <message_payload> Part VI - Oracle XML for PL/SQL Developers <Book> Chapter 25 - Getting Started with Oracle XML and PL/SQL <Title>Introducing XML</Title> Chapter 26 - Building PL/SQL Web Services <Author_Lastname>Smith</Author_Lastname> Chapter 27 - Extending PL/SQL XML Functionality with Java <ISBN>11-0342000123</ISBN> Chapter 28 -</Book> Putting It All Together Appendix </message_payload> - XML Standards Bodies and Open Specifications Glossary </message> Index </message_set> </AQXMLSend> List of Figures </Body> List of Tables </Envelope> List of Sidebars In this manner, messages can be intelligently managed, so that data about them can be extracted at a later point to help in configuring the architecture and viewing the messages through SQL.

AQ Servlet Oracle Advanced Queuing (AQ) is a database facility that provides an integrated message queuing capability, enabling and managing asynchronous communication between applications using Oracle messaging formats. The


AQ servlet is simply a servlet that operates in the middle tier that acts on AQ messages in both SOAP format and the IDAP format, a format that uses XML for the data representation and HTTP and e-mail protocols as the transport mechanism. The servlet then can10g interpret the incoming message the client communicate backC,toC++ it, and Oracle Database XML & SQL: Design, Build &from Manage XML and Applications in Java, & can connect toPL/SQL the Oracle database from the middle tier to perform operations on the message queues. by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Enqueuing and Dequeuing Messages

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML queues standards, usage and practices. To begin with, emphasis Oracle message cantheir be created withbest messages that contain XML messages—these are encapsulated by the XMLType data type. To do this, a queue table is created using the dbms_aqadm.create_queue_table call, with the queue_payload_type as SYS.XMLType; the table can be Table of Contents populated via the dbms_aqadm.create_queue call. ForXML example, a book and a queue with Oracle Database 10g XML & SQL—Design, Build & Manage Applications inorder Java, queue C, C++table & PL/SQL different priorities could be created in PL/SQL via the following code. Introduction

BEGIN Part I - Oracle and the XML Standards … Chapter 1

- Introducing XML

EXECUTE Chapter 2 -dbms_aqadm.create_queue_table Accessing XML with DOM, SAX, JAXB, and( StAX queue_table => and 'book_order_table', Chapter 3 - Transforming XML with XSLT XPath sort_list 'ship_book_order', Chapter 4 - Validating XML with DTDs=> and'book_order, XML Schemas comment- XML Operations with XQuery => 'book order message queue table', multiple_consumers => TRUE, Chapter 6 - XML Messaging and RPC with SOAP queue_payload_type => 'SYS.XMLType', Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL compatible => '8.1', Part II - Oracle XML Management for DBAs primary_instance => 2, Chapter 8 - Getting Started with the Oracle XML Database secondary_instance => 1); Chapter 9 - Storing XML Data … Chapter END; 10 - Generating and Retrieving XML Chapter BEGIN 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database … Part III - Oracle XML for Java Developers EXECUTE dbms_aqadm.create_queue ( Chapter 13 Getting and Java queue_name Started with Oracle =>XML 'book_order_queue', Chapter 14 Building an XML-Powered Web Site queue_table => 'book_order_table'); Chapter … 15 - Creating a Portal Site with XML and Web Services END; 16 - Developing an XML Gateway Application with SOAP and AQ Chapter Chapter 5

Chapter 17 - Developing XML-Based Reusable Components

To enqueue a message SOAP, the following could be an XML representation of the message: Part IV - Oracle XML for C using Developers <?xml 18 version="1.0"?> Chapter - Getting Started with Oracle XML and C <Envelope xmlns=http://schemas.xmlsoap.org/soap/envelope/> Chapter 19 - Building an XML-Managed Application <Body> Chapter 20 - Build an XML Database OCI Application <AQXmlSend xmlns=http://ns.oracle.com/AQ/schemas/access> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V <producer_options> - Oracle XML for C++ Developers

<destination>book.book_order_queue</destination> </producer_options> Chapter 23 - Build an XML Database OCI C++ Application <message_set> Chapter 24 - Building an XML Data-Retrieval Application <message_count>1</message_count> Part VI - Oracle XML for PL/SQL Developers <message> Chapter 25 - Getting Started with Oracle XML and PL/SQL <message_number>1</message_number> Chapter 26 - Building PL/SQL Web Services <message_header> Chapter 27 -<correlation>order1</correlation> Extending PL/SQL XML Functionality with Java Chapter 28 -<priority>1</priority> Putting It All Together Appendix -<sender_id> XML Standards Bodies and Open Specifications Glossary <agent_name>JuanL</agent_name> Index </sender_id> List of Figures </message_header> <message_payload> List of Tables <BOOKORDER_TYPE> List of Sidebars <BOOKORDER>5</BOOKORDER> <BOOKORDER_SHIP>5</BOOKORDER_SHIP> <BOOKCUSTOMER> <BOOKCUSTOMER_ID>99999999</BOOKCUSTOMER_ID> <BOOKCUSTOMER_LASTNAME>Loaiza</BOOKCUSTOMER_LASTNAME> <BOOKCUSTOMER_STREET>1 Oracle Parkway</BOOKCUSTOMER_STREET> <BOOKCUSTOMER_CITY>Redwood Shores</BOOKCUSTOMER_CITY> <BOOKCUSTOMER_STATE>California</BOOKCUSTOMER_STATE> Chapter 22 - Getting Started with Oracle XML and C++


<BOOKCUSTOMER_ZIP>94065</BOOKCUSTOMER_ZIP> <BOOKCUSTOMER_COUNTRY>USA</BOOKCUSTOMER_COUNTRY> </BOOKCUSTOMER> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <BOOKTITLE>Oracle and XML</BOOKTITLE> PL/SQL <BOOKID>3333333333333</BOOKID> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <BOOKPRICE>49.99</BOOKPRICE> McGraw-Hill/Osborne © 2004 (600 pages) </BOOKORDER_TYPE> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with </message_payload> emphasis on XML standards, their usage and best practices. </message> </message_set> Table of Contents <AQXmlCommit/> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL </AQXMlSend> Introduction </Body> Part I - Oracle and the XML Standards </Envelope> Chapter 1

- Introducing XML

Chapter 2 - Accessing XML with SOAP, DOM, SAX, JAXB, andcould StAX be an XML representation of the message: To dequeue a message using the following Chapter - Transforming XML with XSLT and XPath <?xml 3version="1.0"?> Chapter 4 - Validating XML with DTDs and XML Schemas <Envelope xmlns=http://schemas.xmlsoap.org/soap/envelope/> Chapter 5 - XML Operations with XQuery <Body> Chapter 6 - XML Messaging and RPC with SOAP <AQXmlReceive xmlns=http://ns.oracle.com/AQ/schemas/access> Chapter <consumer_options> 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II -<destination>book.book_order_queue</destination> Oracle XML Management for DBAs

Chapter <consumer_name>JuanL</consumer_name> 8 - Getting Started with the Oracle XML Database Chapter <wait_time>0</wait_time> 9 - Storing XML Data Chapter <selector> 10 - Generating and Retrieving XML

<correlation>order1</correlation> Chapter 11 - Searching XML Data Chapter </selector> 12 - Managing the Oracle XML Database

</consumer_options> Part III - Oracle XML for Java Developers <AQXmlCommit/> </AQXmlReceive> Chapter 14 - Building an XML-Powered Web Site </Body> Chapter 15 - Creating a Portal Site with XML and Web Services </Envelope> Chapter 13 - Getting Started with Oracle XML and Java

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Using SOAP from PL/SQL

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

PL/SQL Java stored procedures that encapsulate SOAP services are invoked in exactly the same manner as any other Java stored procedure. The SOAP JAVA jar file created during the translation/deployment of a PL/SQL Chapter 20 - Build an XML Database OCI Application package is also needed on the client side to compile application programs that invoke the SOAP service. As in the Chapter 21 - Create an XML-Configured High-Performance Transformation Engine example given above, the basics are to declare a set of variables to represent the request and the response, and to Part V - Oracle XML for C++ Developers declare the XMLType that would represent the message itself. Since this is more RPC-style, PL/SQL functions Chapter 22 - Getting Started with Oracle XML and C++ would be created to build a SOAP message body and envelope, build a SOAP request to invoke a web service, Chapter Buildservice, an XMLprocess Database OCI C++ Application invoke 23 the-web any SOAP faults or exceptions, and possibly extract information from the returned Chapter 24 Building an XML Data-Retrieval Application SOAP message. Chapter 19 - Building an XML-Managed Application

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Best Practices PL/SQL

ISBN:0072229527 by Mark V. XML Scardina, Ben that Chang Jinyuby Wang Web services are simply services areand shared and used as components of web-based applications. © scenarios, 2004 (600 pages) Depending on McGraw-Hill/Osborne different technologies, and computer configurations, these services can reside on dissimilar computers and can be accessed and transported using different standard protocols. Though these This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasisthese on XML standards, their usage and bestbecause practices.XML is the language used as the message protocols are different, services are made interoperable format, the services themselves can be encapsulated via XML, and the services can be accessed on the Internet fromof the different applications. The following sections will go over some alternative mechanisms for transporting Table Contents messages. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Introduction

SOAP vs. JAX-RPC

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Java API XML-based is a Sun Java Specification Request (JSR) that specifies Chapter 2 for - Accessing XMLRPC with (JAX-RPC) DOM, SAX, JAXB, andMicrosystems StAX the client for invokingXML a web service. TheXPath java.xml.rpc interfaces consist of the main client interface, the factory Chapter 3 API - Transforming with XSLT and class for the main clientDTDs interfaces, the client proxy for invoking the operations of a web service, the call Chapter 4 creating - Validating XML with and XML Schemas interface used to dynamically invoke a web service, and an exception class that is thrown if a web service error - XML Operations with XQuery occurs. This specification is more interface-driven, i.e., methods, parameters, return values, and synchronous, Chapter 6 - XML Messaging and RPC with SOAP meaning that the client waits for the response; in short, more RPC-style. Chapter 5 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

SOAP vs. JMS - Getting Started with the Oracle XML Database

Chapter 8 Chapter 9

- Storing XML Data

Java Message Service (JMS)—or message Enterprise Java Beans (EJBs)—is more message-style than SOAP, in that it’s more message-based and asynchronous and involves sending or receiving an XML document. Inherently, Chapter 11 - Searching XML Data with the use of EJBs, the traditional facilities of persistence, security, transactions, and concurrency are available Chapter 12 - Managing the Oracle XML Database with these messages. Essentially, two types of operations exist with JMS: operations that send data and operations Part III - Oracle XML for Java Developers that receive data. JMS can send messages to the JMS destination, which then forwards it on the client, and JMS Chapter 13 - Getting Started with Oracle XML and Java can also receive messages from the JMS destination that received a message from the client. Chapter 10 - Generating and Retrieving XML

Chapter 14 - Building an XML-Powered Web Site

Chapter These operations 15 - Creating contrast a Portalwith SiteSOAP with XML in that andthere Web needs Services to be a Java-compatible JMS client receiving these

messages, theanSOAP messageApplication is platformwith independent Chapter 16 - whereas Developing XML Gateway SOAP and and AQ can support a broadcast protocol that doesn’t depend17 on- getting responses. Chapter Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 7: Putting It All Together with XML Pipeline, JSPs, PL/SQL ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang and XSQL McGraw-Hill/Osborne © 2004 (600 pages) This focuses XML Previously, technologiesXML within Oracle's XML-enabled products, XML processing hascomprehensive evolved quite guide a bit over the on lastutilizing few years. application developers needed to with emphasis on XML standards, their usage and best practices. come up with quite a bit of code to parse an XML file, apply a stylesheet to it, and transmit the results. With the acceptance of XML in modern business applications, the demands on the processing infrastructure to access and Table of Contents exchange business data in the form of XML also grew; and associated with that growth came even higher Oracle Database 10g XML &and SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL application development maintenance cost. Introduction

To reduce thisand cost, XML Developer’s Kit 10g (XDK) extends and supports XML standards and introduces Part I - Oracle theOracle XML Standards new processing technologies Chapter 1 - Introducing XML and features that simplify XML creation, access, transformation, and validation. With

these new-mechanisms, XML application developers can more easily process XML within their business-to-business Accessing XML with DOM, SAX, JAXB, and StAX (B2B), business-to-customer (B2C), and Enterprise Application Integration (EAI) applications. This chapter explains Chapter 3 - Transforming XML with XSLT and XPath how the XML Pipeline Processor, JSPs, and the XSQL Servlet enable Oracle XML application developers to achieve Chapter 4 - Validating XML with DTDs and XML Schemas this goal of greatly reducing the complexity of today’s XML processing. Chapter 2

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Introducing XML Pipeline Processor - Putting the It All Together with XML Pipeline, JSPs, and XSQL

Chapter 7

Part II - Oracle XML Management for DBAs

The XML Pipeline Processor establishes a reusable component framework that supports declarative pipelining of - Getting Started with the Oracle XML Database XML resources so that different processes, such as XML parsing, XML schema validation, and XSL transformations, Chapter 9 - Storing XML Data can be performed for an application within this framework. Compliant with the W3C XML Pipeline Definition Chapter 10 -Version Generating and Retrieving XML Language 1.0 Note (http://www.w3.org/TR/2002/NOTE-xml-pipeline-20020228/), Oracle’s implementation Chapter 11 Searching XML Data of this processing framework allows developers to avoid dealing with all of these different process interfaces Chapter 12 - Managing Oracle XML individually, in a sensethe “pipelining” theDatabase processing of XML in one module. Chapter 8

Part III - Oracle XML for Java Developers

To begin an XML document detailing must be created according to the rules specified in the W3C Chapter 13with, - Getting Started with Oracle XMLthis andpipeline Java Note. For XML Pipeline ProcessorWeb to act Chapter 14 the - Building an XML-Powered Siteupon it, the use of the available XML processing components and the inputs and these Site processes must established Chapter 15 - outputs Creatingfor a Portal with XML andbe Web Services in this document. For Oracle’s XML Pipeline Processor, these available components include the Application DOM and SAX Chapter 16 - Developing an XML Gateway with XML SOAPparsers and AQ for parsing the XML documents, the XML Schema Processor for the XML schema validations, the XSL Processor for transforming XML documents, SAXSerializer for printing XML, and the XML Compressor to compress XML into binary format. Part IV - Oracle XML for C Developers Chapter 17 - Developing XML-Based Reusable Components

Chapter 18 - Getting with Oracle XML and C the chain of XML processing according to the descriptions in the Put simply, the XMLStarted Pipeline Processor executes Chapter - Buildingand an XML-Managed Application pipeline19document returns a particular result. The following is an example of an XML Pipeline document that Chapter 20 an - Build antransformation XML Database of OCI Application performs XSLT book.xml usingbook.xsl and producing booklist.html: Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

<pipeline xmlns=http://www.w3.org/2002/02/xml-pipeline xml:base="http://example.org/"> Chapter 22 -name="target" Getting Started with Oracle XML and C++ <param select="booklist.html"/> Part V - Oracle XML for C++ Developers

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application <processdef name="domparser.p" Part VI - Oracle XML for PL/SQL Developers definition="oracle.xml.pipeline.processes.DOMParserProcess"/>

Chapter 25 - Getting Started with Oracle XML and PL/SQL <processdef name="xslstylesheet.p" Chapter 26 -definition="oracle.xml.pipeline.processes.XSLStylesheetProcess"/> Building PL/SQL Web Services Chapter <processdef 27 - Extending name="xslprocess.p" PL/SQL XML Functionality with Java Chapter 28 -definition="oracle.xml.pipeline.processes.XSLProcess"/> Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

<process id="p2" type="xslstylesheet.p" ignore-errors="false"> Glossary <input name="xsl" label="book.xsl"/> <outparam name="stylesheet" label="xslstyle"/> List of Figures </process> List of Tables Index

List of Sidebars

<process id="p3" type="xslprocess.p" ignore-errors="false"> <param name="stylesheet" label="xslstyle"/> <input name="document" label="xmldoc"/> <output name="result" label="booklist.html"/> </process> <process id="p1" type="domparser.p" ignore-errors="true"> <input name="xmlsource" label="book.xml "/>


<output name="dom" label="xmldoc"/> <param name="preserveWhitespace" select="true"></param> <error name="dom"> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <html xmlns="http://www/w3/org/1999/xhtml"> PL/SQL <head>by Mark V. Scardina, Ben Chang and Jinyu Wang ISBN:0072229527 <title>DOMParser Failure!</title> McGraw-Hill/Osborne © 2004 (600 pages) </head> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <body>emphasis on XML standards, their usage and best practices. <h1>Error parsing document</h1> </body> Table of Contents </html> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL </error> Introduction </process> Part I - Oracle and the XML Standards </pipeline> Chapter 1

- Introducing XML

Chapter 2 any - Accessing with as DOM, and StAX Note that error is XML returned an SAX, HTMLJAXB, document, which is consistent with the output format. Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas Multistage XML Processing

Chapter 5

- XML Operations with XQuery

Chapter 6 -XML XML processing Messaging and RPC with SOAP Multistage is quite straightforward, allowing processing of XML components in parallel and at Chapter different 7 stages. - Putting Thus, It Allthe Together output with fromXML processing Pipeline,an JSPs, XMLand document XSQL can immediately act as one input or multiple Part inputs II -to Oracle otherXML stages Management of processing for DBAs XML. All of this multistage XML processing is encapsulated within an XML

Pipeline8 document. Chapter - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

Parsing, then Validation, then Serialization or Transformation Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

When users need to process and access XML data, the first step is to parse the XML document by using an XML parser. XML parsers are the components that read in XML documents and provide the programmatic access to the Part III - Oracle XML for Java Developers content and structure of XML. Depending on whether the structure of the document is governed by a DTD or an Chapter 13 - Getting Started with Oracle XML and Java XML schema, the validating parser performs the checking operations necessary during the parsing. In Oracle’s Java Chapter 14 - Building an XML-Powered Web mode Site also exists, in addition to the strict validation mode, whereby XML Schema Processor, a lax validation Chapter 15 - Creating Portal Site with XML and Weband Services synchronous retrievala of the metadata information the validation processing status from the XML Schema Chapter 16 -during Developing an XML Processor the SAX XMLGateway parsing Application can occur. with SOAP and AQ Chapter 12 - Managing the Oracle XML Database

Chapter 17 - Developing XML-Based Reusable Components

TheIV management handlers for SAX events streaming from XML SQL Utility (XSU) output after SQL queries return Part - Oracle XMLoffor C Developers rowset 18 data is greatly simplified a new Chapter - Getting Started with with Oracle XML Java and Cinterface, oracle.xml.parser .v2.SAXSerializer, which provides output options to specify if the pretty printing format is needed, what the XML declaration and encoding information Chapter 19 - Building an XML-Managed Application is, which are elements whose content needs to be set as CDATA sections, and what the DTD system-id Chapter 20if- any Build anthe XML Database OCI Application and public-id are. To use this new feature, you simply use it as another type of SAX content handler. For example, you can register it to the XSU’s SAX output interface as follows: Part V - Oracle XML for C++ Developers Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

OracleXMLQuery.getXMLSAX(sample); Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

This generates unbounded XML documents from result sets returned from queries, with warnings or errors reported either as processing occurs or at the very end of the processing.

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 26 - Building PL/SQL Web Services Alternatively, XSL Transformation (XSLT) stylesheets can then be applied to either the streaming XML data or the Chapter 27 -documents Extending PL/SQL XML Functionality with Java semantics on the text output. input XML to transform and apply formatting Chapter 28 - Putting It All Together

SAX vs.-DOM Appendix XML Standards Bodies and Open Specifications Glossary

SAX parsing is event-based XML parsing, meaning that when certain events occur or are encountered when processing the XML document—for example, when the root node of the document is encountered—the event List of Figures handlers or functions, startDocument for this example, are then invoked through function callbacks. Compared to List of Tables DOM parsing, SAX is much faster and less memory-intensive in that an in-memory tree representation is not List of Sidebars constructed. For multistage XML processing, this lightweight XML parsing is ideal when you need to filter and search from large XML documents, but the drawbacks are that the XML content cannot be changed in place and dynamic access to the content is not as efficient as with DOM. In the case of the current Pipeline Processor implementation, the SAX Parser can be connected to the XML Compressor and the SAXSerializer but not to the XSLT Processor, because that requires a DOM. Index


Oracle Database XML & SQL:XML Design,Beans Build & Manage XML Applications in Java, C, C++ & Processing XML with10g JSPs and PL/SQL

by Mark V. Scardina, Ben Chang and Jinyu Wang Many XML developers today use Oracle JDeveloper as an integrated development environment (IDE) toISBN:0072229527 speed their McGraw-Hill/Osborne © 2004 development cycle and take advantage of (600 the pages) component approach in building applications based on numerous prebuilt components. The JavaBeans component is fully in within OracleOracle's JDeveloper. In JDeveloper, you This comprehensive guide focuses onmodel utilizing XML supported technologies XML-enabled products, with emphasis XML standards, their best practices. can build JavaBeans thatoncan later be reused in usage other and projects, or install and use JavaBeans that are built by Oracle or third-party vendors. Table of Contents

You can install the beans in JDeveloper on the JDeveloper Tools palette and later customize and include them in your application. Once the beans are installed, you can use drag-and-drop to add beans from the Tools palette to Introduction your application. When you add a bean to your application design surface, JDeveloper automatically generates the Part I - Oracle and the XML Standards code needed to instantiate and customize the bean. This usually includes creating an instance of the bean, setting Chapter 1 - Introducing XML the bean properties to customize the bean, and adding action listeners to the bean to enable the application to Chapter Accessing XML withbyDOM, SAX, JAXB, and this StAX handle 2the- events generated the bean. Because technology is so powerful and easy to use, it is natural to Chapter 3 - Transforming XML with XSLT and XPath encapsulate key XML functionality into JavaBeans. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter 4

- Validating XML with DTDs and XML Schemas

The Oracle XMLOperations JavaBeanswith areXQuery a set of XML components for Java applications or applets that make adding XML Chapter 5 - XML support6to-an application easy. These Java components can be integrated into Oracle JDeveloper to enable Chapter XML Messaging and RPC with SOAP developers to create deploy XML-based database applications Chapter 7 - Putting It and All Together with XML Pipeline, JSPs, and XSQL quickly. The following beans are provided: Part II - Oracle XML Management for DBAs

DOMBuilder bean

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 - Storing XML Data XSLTransformer bean Chapter 10 - Generating and Retrieving XML

DBAccess bean XML Data Chapter 11 - Searching Chapter 12 - Managing the Oracle XML Database

XMLDBAccess bean

Part III - Oracle XML for Java Developers

Chapter 13 - Getting XMLDiff bean Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

XMLCompress Chapter 15 - Creatingbean a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

XSDValidator bean

Chapter 17 - Developing XML-Based Reusable Components Part IV install - Oracle XMLbeans for C Developers If you these into your JDeveloper environment, as described in Chapter 13, you benefit by the

Chapter 18 -code Getting Started with Oracle XML and C automatic generation that JDeveloper performs when you include the beans in your application. If you do not Chapter use JDeveloper 19 - Building andan work XML-Managed in a command-line Application JDK environment, you can also use the beans to visualize and

transform case, you simply use the beans as you would any other classes. The examples in this chapter Chapter 20 -XML. BuildInanthis XML Database OCI Application were developed using JDeveloper. High-Performance Transformation Engine Chapter 21 - Create an XML-Configured Part V - Oracle XML for C++ Developers

DOMBuilder Bean

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

The DOMBuilder bean the Java XML Parser with a bean interface and extends its functionality to Chapter 24 - Building an encapsulates XML Data-Retrieval Application permit registering a listener, Java applications can parse large or successive documents Part VI -asynchronous Oracle XML forparsing. PL/SQLBy Developers by having control returnwith immediately to the The following sample code shows a program that takes a list of Chapter 25 -the Getting Started Oracle XML andcaller. PL/SQL XML files parameters andWeb parses all of these files concurrently: Chapter 26 as - Building PL/SQL Services Chapter package 27 -sample; Extending PL/SQL XML Functionality with Java

import Chapter 28java.awt.event.*; - Putting It All Together import oracle.xml.async.*; Appendix - XML Standards Bodies and Open Specifications import oracle.xml.parser.v2.*; Glossary import org.w3c.dom.*; Index import java.net.*; List of Figures import java.io.*;

List of Tables

List of Sidebars

public class MParse extends Object implements DOMBuilderListener, DOMBuilderErrorListener{ int numArgs,i; String Args[]; DOMBuilder tParser; public MParse(String[] args) { Args=args;


} public void parse() { for (i=0;i<Args.length;i++) { Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & // PL/SQL new instance of the asynchronous parser tParser=new DOMBuilder(i); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang // McGraw-Hill/Osborne add this Listener object to be notified when parsing is complete © 2004 (600 pages) tParser.addDOMBuilderListener(this); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with // emphasis or when onanXML error occurs standards, their usage and best practices. tParser.addDOMBuilderErrorListener(this); System.out.println("Start parsing "+Args[i]); Table of Contents try { Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL tParser.parse(new URL("file:"+(String)Args[i])); Introduction } catch (Exception e) { Part I - Oracle and the XML Standards System.out.println(e.toString()); Chapter 1 -}Introducing XML Chapter } 2 - Accessing XML with DOM, SAX, JAXB, and StAX Chapter System.out.println("Multiple 3 - Transforming XML with XSLT and XPath files parsed in background threads"); Chapter } 4 - Validating XML with DTDs and XML Schemas Chapter 5 - XML Operations XQuery public static void with main(String[] args) { Chapter MParse 6 - XMLmParse Messaging = new and RPC MParse(args); with SOAP mParse.parse(); Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part}II - Oracle XML Management for DBAs // Implementing DOMBuilderListener Interface Chapter 8 - Getting Started with the Oracle XML Database // Method called by DOMBuilder when document parsing starts Chapter 9 - Storing XML Data public void domBuilderStarted(DOMBuilderEvent p0) { Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

} // Method called by DOMBuilder when document parsing returns an error. Part III - Oracle XML for Java Developers public void domBuilderError(DOMBuilderEvent p0) { Chapter 12 - Managing the Oracle XML Database

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

} // Method called by DOMBuilder when document parsing is completed. Chapter 16 - Developing an XML Gateway Application with SOAP and AQ public void domBuilderOver(DOMBuilderEvent p0) { Chapter DOMBuilder 17 - Developingparser; XML-Based Reusable Components Part IV -XMLDocument Oracle XML for xmlDoc; C Developers Chapter int 18 - Getting id; Started with Oracle XML and C Chapter // 19 -Get Building an XML-Managed Application a reference to the parser instance that finished parsing. Chapter parser=(DOMBuilder)p0.getSource(); 20 - Build an XML Database OCI Application Chapter // 21 -Get Create an parser XML-Configured the id toHigh-Performance identify the Transformation file being Engine parsed Part V - id=parser.getId(); Oracle XML for C++ Developers Chapter System.out.println("Parse 22 - Getting Started with Oracle XMLcompleted and C++ for file "+Args[id]); domDatabase tree OCI C++ Application Chapter // 23 -get Buildthe an XML Chapter xmlDoc=parser.getDocument(); 24 - Building an XML Data-Retrieval Application YouXML canforadd custom code here to work with the parsed document. Part VI -// Oracle PL/SQL Developers } 25 - Getting Started with Oracle XML and PL/SQL Chapter Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 26 - Building PL/SQL Web Services

// Implementing Interface Chapter 27 - Extending DOMBuilderErrorListener PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

// This method is called when parsing error occurs. - XML Standards Bodies and Open Specifications public void domBuilderErrorCalled(DOMBuilderErrorEvent p0) { Glossary int id=((DOMBuilder)p0.getSource()).getId(); Index System.out.println("Parse error for "+Args[id]+": "+ List of Figures p0.getException().getMessage()); List } of Tables List } of Sidebars Appendix

If you run this program using the following command, you get the output displayed in Figure 7-1. java Sample.mParse booklist1.xml booklist2.xml booklist3.xml


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table Figure of Contents 7-1: Example output in JDeveloper that uses the DOMBuilder bean Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

If you have to parse a large number of files, the DOMBuilder bean can deliver significant time savings. Depending Introduction on the systemand andthe theXML number of concurrent threads (instances of DOMBuilder), we have achieved up to 40 percent Part I - Oracle Standards faster times compared to parsing the files one after another. Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 8

- Getting Started with the Oracle XML Database

The asynchronous parsing in a background thread implemented in DOMBuilder can also be used in interactive Chapter 3 - Transforming XML with XSLT and XPath visual applications. If the application parses a large file using the normal parser, the user interface will freeze until Chapter 4 - Validating XML with DTDs and XML Schemas the document is parsed completely. This can easily be avoided if the DOMBuilder bean is used instead. After calling Chapter 5 -method XML Operations with XQuery the parse of DOMBuilder, the application receives the control back immediately. The application can then Chapter 6 XML Messaging and RPC with SOAPplease wait.” The window can also show a Cancel button, so that the display a window with the message “Parsing, Chapter 7 Putting It All Together with XML Pipeline, and XSQL user can abort the operation if they decide to do so. JSPs, If no user action is taken, the program resumes when Part II Oracle XML Management for DBAs domBuilderOver() is called by the DOMBuilder bean upon completion of the parsing task in the background. Chapter 9

- Storing XML Data XSLTransformer Bean

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching bean XML Data The XSLTransformer encapsulates the Java XML Parser’s XSLT processing engine with a bean interface and Chapter Managing thetoOracle Database transformation. By registering a listener, Java applications can extends12its- functionality permitXML asynchronous Part III - Oracle for Java Developers transform large XML or successive documents by having the control returned immediately to the caller. Because the XSL

Chapter 13 - Getting with Oracleyou XML andconsider Java transformations areStarted time-consuming, may using this asynchronous interface for XSL transformations. Chapter The XSLTransformer 14 - Building anbean XML-Powered can benefit Web applications Site that transform large numbers of files by transforming multiple

files concurrently. It also canSite be used for visual applications Chapter 15 - Creating a Portal with XML and Web Services to achieve responsive user interfaces. The considerations here arean the same as with the DOMBuilder bean. Chapter 16 - Developing XML Gateway Application with SOAP andFrom AQ a programming standpoint, the preceding sample17 demonstrates general approach that can also be applied to the XSLTransformer bean. The main point is Chapter - Developingthe XML-Based Reusable Components thatIV by- implementing the XSLTransformerListener interface, the calling application is notified when the Part Oracle XML for C Developers transformation is over. Therefore, the calling application can do something else between requesting the Chapter 18 - Getting Started with Oracle XML and C transformation and getting the result. Application Chapter 19 - Building an XML-Managed Chapter 20 - Build an XML Database OCI Application

DBAccess Bean

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

The DBAccess bean maintains that are used to store XML documents. This functionality is quite useful Chapter 22 - Getting Started with CLOB Oracle tables XML and C++ when you storing a wide rangeOCI of XML Chapter 23 -are Build an XML Database C++documents Application and you are most interested in storing and retrieving them

quickly without performing any XML processing within the database. This type of storage is also important when you wish to preserve any entities within the XML document instead of having them expanded, as would occur with an Part VI - Oracle XML for PL/SQL Developers XMLType CLOB. Chapter 24 - Building an XML Data-Retrieval Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 26 - Building PL/SQL Web Services The database access is through JDBC to the CLOB tables that may store the XML and XSL files, or even files Chapter 27from - Extending XML Functionality with Java resulting applyingPL/SQL the XSL stylesheet to the XML file. The DBAccess bean provides the following functionality: Chapter 28 - Putting It All Together

Creates andStandards deletes CLOB tables. Appendix - XML Bodies and Open Specifications Glossary Index

Lists a CLOB table’s contents.

List ofAdds, Figures replaces, or deletes XML documents in the CLOB table. List of Tables

Theoffollowing List Sidebars code fragments demonstrate this functionality. These fragments assume the appropriate strings are passed in on the command line or through prompts. // Create a new XML CLOB Table void createXMLCLOBTable(String tableName) { log.println("\nDemo for createXMLTables():"); try { db.createXMLCLOBTable(con, tableName); } catch (Exception ex) { log.println("Error creating XML CLOB table: " + ex.getMessage());


} log.println("Table +'" + tableName + "' successfully created."); return; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

} PL/SQL // Replace by XML Data in CLOBBen Table ISBN:0072229527 Mark V. Scardina, Chang and Jinyu Wang void replaceXMLCLOBData( String String xmlname, McGraw-Hill/Osborne © 2004 (600 tablename, pages) String filename) { This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with log.println("\nDemo for replaceXMLCLOBData() (similar to insert):"); emphasis on XML standards, their usage and best practices. String xmldata = loadFile(filename); try { Table of Contents db.replaceXMLCLOBData(con, tablename, xmlname, xmldata); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL } catch (Exception ex) { Introduction log.println("Error inserting into XML CLOB table: " + Part I - Oracle and the XML Standards ex.getMessage()); Chapter 1} - Introducing XML Chapter 2log.println("XML - Accessing XML with Data DOM, SAX, StAX fromJAXB, +'"and + filename + "' successfully Chapter 3 - Transforming XML with XSLT XPath'" + tablename + "'."); replaced inand table Chapter 4return; - Validating XML with DTDs and XML Schemas Chapter } 5 - XML Operations with XQuery Chapter // Retrieve 6 - XML XML Messaging Dataand from RPCCLOB with SOAP Table void tablename, String xmlname) { Chapter 7 getXMLCLOBData(String - Putting It All Together with XML Pipeline, JSPs, and XSQL log.println("\nDemo Part II - Oracle XML Management forfor DBAsgetXMLCLOBData():"); xmlText=null; Chapter 8String - Getting Started with the Oracle XML Database try { Chapter 9 - Storing XML Data xmlText=db.getXMLCLOBData(con, tablename, xmlname); Chapter 10 - Generating and Retrieving XML } catch (Exception ex) { Chapter 11 - Searching XML Data log.println("Error getting XML data: " + ex.getMessage()); Chapter 12 - Managing the Oracle XML Database return; Part III - Oracle XML for Java Developers } Chapter 13 - Getting Started with Oracle XML and Java log.println("XML CLOB data fetched: "); Chapter 14 - Building an XML-Powered Web Site log.println(xmlText); Chapter 15 - Creating a Portal Site with XML and Web Services return; Chapter 16 - Developing an XML Gateway Application with SOAP and AQ } Chapter 17 -all Developing XML-Based Reusable Components // List XML CLOB Tables Partvoid IV - Oracle XML for C Developers listXMLCLOBTables() { Chapter 18 Started with Oracle XML C tables //- Getting list all recognized XML and CLOB Chapter 19 Building an XML-Managed Application log.println("\nDemo for listXMLCLOBTables():"); Chapter 20 - Build an XML Database OCI Application String tableNames[]; Chapter 21 Create an XML-Configured High-Performance Transformation Engine int i; Part V - Oracle XML for C++ Developers try { Chapter 22 - Getting tableNames=db.getXMLCLOBTableNames(con,""); Started with Oracle XML and C++ for an (i=0;i<tableNames.length;i++) { Chapter 23 - Build XML Database OCI C++ Application log.println("tablenamename="+tableNames[i]); Chapter 24 - Building an XML Data-Retrieval Application } XML for PL/SQL Developers Part VI - Oracle } -catch ex) XML { and PL/SQL Chapter 25 Getting(Exception Started with Oracle log.println("Error listing XML CLOB tables: " Chapter 26 - Building PL/SQL Web Services ex.getMessage()); Chapter 27 - Extending PL/SQL+XML Functionality with Java } Chapter 28 - Putting It All Together } Appendix

- XML Standards Bodies and Open Specifications

Glossary The complete DBAccess bean demo code is available as DBAccessDemo.java in the source download. Index List of Figures

XMLDBAccess Bean

List of Tables

List Sidebars TheofXMLDBAccess bean is a simple extension of the DBAccess bean to support XMLType CLOBs that were

introduced in Oracle9i. This bean has different packaging because it additionally depends upon the xdb.jar file that provides Java access to the XMLType. While the functionality includes all the equivalent methods to the DBAccess bean, it adds one useful function based upon the fact that the document is parsed on insert as XML. The getXMLXPathTextData() method retrieves the value of an XPath expression from the XML document stored in the table. The following code fragment illustrates this: void getXMLTypeData(String tablename, String xmlname) { log.println("\nDemo for getXMLTypeData():");


String xmlText=null; try { xmlText=db.getXMLTypeData(con, tablename, xmlname); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & } catch (Exception ex) { PL/SQL log.println("Error getting XMLType data: " + ex.getMessage()); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang return; McGraw-Hill/Osborne © 2004 (600 pages) } This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with log.println("XMLType data their fetched: ");best practices. emphasis on XML standards, usage and log.println(xmlText); return;

Table of Contents

}

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction On the surface it would appear that you should always use the XMLDBAccess bean over the DBAccess bean Part I - Oracle and the XML Standards because of this increased functionality. Note, however, that since the XML documents are parsed, any referenced

Chapter 1 -need Introducing XML and entities replaced. Thus, the document stored will not be identical to its inserted DTDs will to be fetched Chapter 2 - it Accessing XML with DOM, SAX, JAXB, and StAX state when is retrieved. Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas XMLDiff Bean

Chapter 5

- XML Operations with XQuery

Chapter 6 time, - XML Messaging and RPC with At some you may be faced with theSOAP task of determining whether two XML documents are the same. In practice Chapter this is usually 7 - Putting not a Itsimple All Together character-for-character with XML Pipeline,comparison, JSPs, and XSQL because for many XML documents, white space and Part linefeeds II - Oracle are insignificant. XML Management Instead, for what DBAsis important is to determine how the structure and text content differ. The

XMLDiff8 bean was created just this purpose. It does a DOM tree comparison of file A to file B while producing an Chapter - Getting Startedfor with the Oracle XML Database XSL stylesheet to convert A into B. There is additional visual functionality available that uses JPanel to visually Chapter 9 - Storing XML Data display10 the- differences detected. Chapter Generating and Retrieving XML Chapter 11 - Searching XML Data

This bean has many uses and, since it uses the standards-based XSLT language to indicate the differences, it is an excellent component for pipeline applications. One particular application would be to keep track of document Part III - Oracle XML for Java Developers revisions. As each XML document is submitted, it can be compared to its previous version, and the resulting XSLT Chapter 13 - Getting Started with Oracle XML and Java stylesheet can be stored. Another application would be to use it to detect whether material differences have Chapter 14between - BuildingXML an XML-Powered occurred files, such asWeb XMLSite schemas. You will be building such an application using the XMLDiff bean Chapter 15 -17. Creating a Portal Site with XML and Web Services inChapter Chapter 12 - Managing the Oracle XML Database

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

XMLCompress Bean

Part IV - Oracle XML for C Developers

Chapter Getting Started of with Oracle One of 18 the- disadvantages XML is theXML factand thatC whenever it is received in serialized form, it needs to be parsed in Chapter 19any - Building an XML-Managed Application order for operations to be performed. There is the additional disadvantage of the growth in size caused by the Chapter 20 - Build an Database tag encapsulation ofXML the data. We OCI haveApplication seen real production schemas where the instance XML documents were 10 Chapter 21 - Create an of XML-Configured Transformation Engine to 100 times the size the data they High-Performance contained! The XMLCompress bean provides an efficient solution to these Part V - Oracle XML for C++ the Developers situations. It encapsulates XMLCompress serialization method that creates a binary format from the DOM that

Chapter 22 -the Getting Started with Oracle XML and C++ XML stream. Additionally, Oracle XML processors such as XSL tokenizes XML tags, resulting in a more compact Chapter and XSD 23 can - Build read anfrom XMLthe Database compressed OCI C++ stream Application directly to re-create the DOM without reparsing the document. Chapter 24 - Building an XML Data-Retrieval Application

To maximize flexibility of theDevelopers bean, both DOMCompress()and SAXCompress() are provided, which support a Part VI - Oraclethe XML for PL/SQL full range of input sources, including files, strings, and streams. Additionally, the DOM method supports the XMLType, CLOB, and BLOB Oracle SQL data- types. It should be noted that there is only a complementary Chapter 26 - Building PL/SQL Web Services DOMExpand()method, as applications that don’t need the DOM can work exclusively with SAX input and output Chapter 27 - Extending PL/SQL XML Functionality with Java events, therefore making a SAXExpand() function unnecessary. Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

XSDValidator Bean

Glossary Index

Rounding out the set of XML beans is the XSDValidator bean. While, like the other beans, it encapsulates the XSDValidator class in the XML parser, it has one significant feature that makes it the choice for visual or editor List of Tables applications. The XSDValidator bean includes a getStackList() method that returns the list of DOM tree paths that List of to Sidebars lead the invalid node if a validation error is returned. To use this function, you need to use the java.util.vector and java.util.stackclasses, which are populated with the path list as follows: List of Figures

static void printError(XSDValidator xsdval) { // Initialize list of paths Vector vectPath = xsdval.getStackList(); // Register error handler DocErrorHandler errHndl = DocErrorHandler)xsdval.getError().getErrorHandler();


// Initialize list of errors Vector errlist = errHndl.getErrorList(); if (vectPath.isEmpty()) { Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & System.out.println("Schema validation successful! No errors."); PL/SQL } ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang if (!(vectPath.isEmpty())) McGraw-Hill/Osborne © 2004 { (600 pages) // Initialize Stack for nodes This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Stackemphasis tempStack ; standards, their usage and best practices. on XML XMLNode xnode; Enumeration enum1 = vectPath.elements(); Table of Contents Enumeration enum2 = errlist.elements(); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL // Print paths and corresponding nodes that had errors Introduction while (enum1.hasMoreElements() && enum2.hasMoreElements()) { Part I - Oracle and the XML Standards System.out.println(enum2.nextElement()); Chapter 1tempStack - Introducing = XML (Stack)enum1.nextElement(); Chapter 2 -while Accessing XML with DOM, SAX, JAXB, and (!(tempStack.empty())) { StAX Chapter 3 - Transforming XML with XSLT and XPath xnode = (XMLNode)((tempStack).pop()); Chapter 4 - Validating XML with DTDs and XML Schemas System.out.print(xnode.getNodeName()); Chapter 5 - XML if Operations with XQuery (!(tempStack.empty())) Chapter 6 - XML Messaging System.out.print("->"); and RPC with SOAP Chapter 7 -}Putting It All Together with XML Pipeline, JSPs, and XSQL System.out.println(); Part II - Oracle XML Management for DBAs Chapter } 8 - Getting Started with the Oracle XML Database } 9 - Storing XML Data Chapter } Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

Using XML Beans in JSPs

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

You can the Oracle XML beans in XML your and JSPJava pages just like you would any other bean because they all conform Chapter 13use - Getting Started with Oracle to the Sun Chapter 14 -JavaBeans Building an specification XML-Poweredand Webinclude Site the requisite BeanInfo class that extends java.beans.SimpleBeanInfo. Bywith using theand <jsp:usebean> Chapter 15 - Creating a Portal Site XML Web Services tags, you can embed your Java program code easily into an 16 HTML page as follows: Chapter - Developing an XML Gateway Application with SOAP and AQ <%@ page language="java" Chapter 17 - Developing XML-Based Reusable Components contentType="text/xml; charset=UTF-8" Part IV - Oracle XML for C Developers

%> <jsp:useBean class="XMLDiff" id="xml_diff" Chapter 18 - Getting Started with Oracle XML and C scope="request" Chapter 19 - Building an> XML-Managed Application <% Chapter 20 - Build an XML Database OCI Application <jsp:setProperty name="booklist" property="file" value="booklist.xml"/> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine // Your Java Code Part V - Oracle XML for C++ Developers %> Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 you - Build XML Database Application Note that cananset properties forOCI theC++ execution of the class using one or more <jsp:setproperty> tags. Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database XML &Publishing SQL: Design, Build & Manage XML Applications in Java, C, C++ & Introducing the XSQL10g Page Framework PL/SQL

by Mark V. Scardina, Chang Jinyu Building upon the functionality of theBen XML SQLand Utility andWang the XML parser is the XSQL Servlet. Written inISBN:0072229527 Java, this McGraw-Hill/Osborne © 2004 (600 pages) servlet provides a high-level declarative interface to developers and webmasters to render data across the Internet dynamically and in custom formats.guide Ablefocuses to run with the servlet of most webOracle's servers, the XSQL Servlet This comprehensive on utilizing XMLengines technologies within XML-enabled products, with emphasis XML standards, best practices. delivers the capability to on transform a single their data usage sourceand automatically in terms of the client browser and the format best suited to its capabilities and those of the platform. Table of Contents

The XSQL Pages

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

TheI heart of the Servlet is the XSQL page. This page is simply an XML file that contains specific elements to Part - Oracle andXSQL the XML Standards direct the of the servlet. The following booklist.xsql file is a simple XSQL page: Chapter 1 action - Introducing XML Chapter - Accessing XML with DOM, SAX, JAXB, and StAX <?xml 2version="1.0"?> Chapter <?xml-stylesheet 3 - Transforming type="text/xsl" XML with XSLT and XPath href="booklist.xsl"?>

<xsql:query connection="demo" Chapter 4 - Validating XML with DTDs andxmlns:xsql="urn:oracle-xsql"> XML Schemas select * from Booklist Chapter 5 - XML Operations with XQuery </xsql:query> Chapter 6 - XML Messaging and RPC with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Figure 7-2 shows the process flow when an Internet browser requests this page and the web server hands over the request to the XSQL Servlet after it registers the xsql extension with the server. The servlet then hands the page to Chapter 8 - Getting Started with the Oracle XML Database the XML parser to retrieve its instructions. In this case, it is asked to open a JDBC connection with the alias of Chapter 9 - Storing XML Data demo and submit the query Select * from Booklist. It does this by passing this data to the XML SQL Utility, which Chapter 10 - Generating and Retrieving XML performs the query as described previously and returns the result as an XML DOM object. Finally, the servlet passes Chapter 11 - Searching XMLalong Datawith the DOM object to the XML parser’s XSLT processor to apply the transformation the stylesheet reference Chapter 12 Managing the Oracle XML Database to HTML for display in the client’s browser. Part II - Oracle XML Management for DBAs

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix Bodies and Open Specifications Figure- XML 7-2: Standards XSQL page process Glossary Index The essential elements of the file are the <xsql:query> element, which includes the database connection

information List of Figureswithin its connection attribute, and the SQL query within its body. The connection value is an alias contained within the <connectiondefs> section of the XMLConfig.xml file: List of Tables List of Sidebars <connectiondefs>

<connection name="demo"> <username>scott</username> <password>tiger</password> <dburl>jdbc:oracle:thin:@localhost:1521:ORCL</dburl> <driver>oracle.jdbc.driver.OracleDriver</driver> </connection> <connection name="xmlbook">


<username>xmlbook</username> <password>xmlbook</password> <dburl>jdbc:oracle:thin:@localhost:1521:ORCL</dburl> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <driver>oracle.jdbc.driver.OracleDriver</driver> PL/SQL </connection> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

<connection name="lite"> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <username>system</username> emphasis on XML standards, their usage and best practices. <password>manager</password> <dburl>jdbc:Polite:POlite</dburl> Table of Contents <driver>oracle.lite.poljdbc.POLJDBCDriver</driver> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL </connection> Introduction </connectiondefs> Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2 - Accessing with DOM, SAX, JAXB, StAX This section from the XML default XMLConfig.xml fileand shows the declaration of the database connection string and the Chapter JDBC driver 3 - Transforming that will be used XML by with the XSLT XMLand SQL XPath Utility. Because you can have this file reside on the server in a

directory is not accessible the and client, this information remains secure. Chapter 4 that - Validating XML with to DTDs XML Schemas Chapter 5

- XML Operations with XQuery

- XMLthe Messaging and Servlet RPC with SOAP Installing XSQL

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part TheIIXSQL - Oracle Servlet XML is Management designed tofor beDBAs quite flexible in its installation and setup. It may be used in any Java 1.2 or

greater8JVM and with any JDBC-enabled Specific testing has been done with JDK 1.2.2, 1.3.1, and 1.4.2 Chapter - Getting Started with the Oracledatabase. XML Database on Windows and several Unix platforms, including Solaris, Linux, and HP-UX. Even though it has previously Chapter 9 - Storing XML Data supported the 10g libraries no longer Chapter 10 -1.1.8, Generating and Retrieving XML support this JDK version, nor does Sun. Chapter 11 - Searching XML Data

Submitting Queries to the XSQL Servlet

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

The XSQL designed create dynamic web pages from database queries. The XSQL pages can be linked Chapter 13 - Servlet Getting is Started withto Oracle XML and Java to any web and an canXML-Powered contain one or more Chapter 14 - site Building Web Sitequeries whose results will replace the respective <xsql:query> section in the page. These results can bewith further through the use of attributes within the <xsql:query> tag. Chapter 15 - Creating a Portal Site XMLcustomized and Web Services Table 7-1 the various thatApplication are available. Chapter 16 -shows Developing an XMLoptions Gateway with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Table Attribute Options for the <xsl:query> Element Part IV -7-1: Oracle XML for C Developers Chapter 18 - Getting Started with Oracle XML and C Attribute Default

Description

Chapter 19 - Building an XML-Managed Application

rowset-element <ROWSET> Chapter 20 - Build an XML Database OCI Application

Element name for the query

Chapter 21 - Create an XML-Configured High-Performance Transformation Engineresults. Set equal to the empty Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application row-element <ROW> Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

max-rows

Fetch all rows

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary

string to suppress printing a document element.

Element name for each row in the query results. Set equal to the empty string to suppress printing a row element. Maximum number of rows to fetch from the query. Useful for fetching the top N rows or, in combination with skip-rows, the next N rows from a query result.

Index Listskip-rows of Figures

Skip no rows

Number of rows to skip over before returning the query results.

id-attribute

Id

Attribute name for the id attribute for each row in the query result.

id-attribute-column

Row count value

Column name to supply the value of the id attribute for each row in the query result.

List of Tables List of Sidebars


null-indicator

Omit elements with a NULL value

If set to y or yes, causes a nullindicator attribute Oracle Database 10g XML & SQL: Design, Build & Manage XML in Java, for C, C++ & to beApplications used on the element PL/SQL any column whose value is ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang NULL. McGraw-Hill/Osborne © 2004 (600 pages)

tag-case

Use theoncase of the column If set to upper,XML-enabled the element products, with This comprehensive guide focuses utilizing XML technologies within Oracle's name aliasand from thepractices. query names for columns in the query emphasis on XML standards, theiror usage best

result appear in uppercase letters. Table of Contents If set to lower, the element Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL names for columns in the query Introduction result appear in lowercase Part I - Oracle and the XML Standards letters. Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 - Transforming XML with XSLT XPath Parameters can also be passed into theand query from the HTTP request line. By prefixing an @ to the parameter Chapter name, the 4 -XSQL Validating Servlet XMLwill with search DTDsthe andHTTP XML Schemas request parameters and then the <xsql:query> attributes to find a

match. 5Once a match is found, straight lexical substitution is performed. The following is an example of an XSQL Chapter - XML Operations withaXQuery page using this function when request line is http://localhost/xsql/demo/booksearch.xsql?year=2001: Chapter 6 - XML Messaging andthe RPCHTTP with SOAP Chapter - Putting It All Together with XML Pipeline, JSPs, and XSQL <?xml 7version="1.0"?> Part II - Oracle XML Management for DBAs <xsql:query xmlns:xsql="urn:oracle-xsql"

connection="demo"

Chapter SELECT 8 - Getting TITLE, Started AUTHOR, with the DESCRIPTION Oracle XML Database FROM BOOKLIST

YEAR {@year} Chapter 9WHERE - Storing XML=Data </xsql:query> Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

Queries that return no rows can also be handled by adding an optional <xsql:no-rows-query> element within the <xsql:query> tags. This allows the user to see a formatted page instead of the raw error. The following is an Part III - Oracle XML for Java Developers example that initially tries to retrieve the listings corresponding to the author’s name; failing that, it attempts to do a Chapter 13 - Getting Started with Oracle XML and Java fuzzy match on the submitted name: Chapter 12 - Managing the Oracle XML Database

Chapter 14 - Building an XML-Powered Web Site

<?xml version="1.0"?> <xsql:query xmlns:xsql="urn:oracle-xsql" connection="demo" Chapter 16 - Developing an XML Gateway Application with SOAP and AQ SELECT TITLE, AUTHOR, DESCRIPTION FROM BOOKLIST Chapter 17 - Developing XML-Based Reusable Components WHERE AUTHOR = UPPER ('{@author}') Chapter 15 - Creating a Portal Site with XML and Web Services

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

<xsql:no-rows-query> SELECT TITLE, AUTHOR, DESCRIPTION FROM BOOKLIST Chapter 20 - BuildAUTHOR an XML Database OCI Application WHERE LIKE UPPER ('%{@author}%') Chapter 21 Create an XML-Configured High-Performance Transformation Engine ORDER BY AUTHOR Part</xsql:no-rows-query> V - Oracle XML for C++ Developers Chapter 19 - Building an XML-Managed Application

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application </xsql:query> Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Transforming the XSQL Output with Stylesheets

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 26power - Building PL/SQL Services The real of the XSQLWeb Servlet lies in its capability to dynamically transform query results by applying XSL Chapter 27 - Extending PL/SQLdeclaration XML Functionality withinJava stylesheets. The stylesheet is included the XSQL file and is applied once the XML output from the Chapter - PuttingItItmost All Together query is28received. commonly transforms query results into HTML, as can be seen in the following example; Appendix - XML Standards Bodies andany Open Specifications however, the stylesheet can perform text-based transformation. The following XSQL page and its associated Glossary stylesheet will return the results to the requesting browser as an HTML table: Index <?xml version="1.0"?> List of Figures <xsql-stylesheet type="text/xsl" href="totable.xsl"?> List of Tables <xsql:query xmlns:xsql="urn:oracle-xsql" connection="demo" List of Sidebars SELECT Title, Author, Description FROM Booklist

WHERE Author = UPPER ('{@author}') <xsql:no-rows-query> SELECT Title, Author, Description FROM Booklist WHERE Author LIKE UPPER ('%{@author}%') ORDER BY Author </xsql:no-rows-query> </xsql:query>


This is the Totable.xsl stylesheet: <html xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <head> PL/SQL <title>Book Listing</title> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang </head> McGraw-Hill/Osborne © 2004 (600 pages) <body> comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <table This border="1" cellspacing="0"> emphasis on XML standards, their usage and best practices. <tr> <th><b>Author</b></th> Table of Contents <th><b>Title</b></th> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <th><b>Description</b></th> Introduction </tr> Part I - Oracle and the XML Standards <xsl:for-each select="ROWSET/ROW"> Chapter 1 -<tr> Introducing XML Chapter 2 - Accessing <td><xsl:value-of XML with DOM, select="TITLE"/></td> SAX, JAXB, and StAX <td><xsl:value-of select="AUTHOR"/></td> Chapter 3 - Transforming XML with XSLT and XPath <td><xsl:value-of Chapter 4 - Validating XML with DTDsselect="DESCRIPTION"/></td> and XML Schemas </tr> Chapter 5 - XML Operations with XQuery Chapter 6</xsl:for-each> - XML Messaging and RPC with SOAP </table> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL </body> Part II - Oracle XML Management for DBAs </html> Chapter 8 - Getting Started with the Oracle XML Database Chapter 9

Storing XML Data Figure 7-3-shows the query result and subsequent transformation.

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

Figure 7-3: Formatted from theApplication SearchAuthor.xsql page Chapter 24 - Building an XML output Data-Retrieval Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Multiple stylesheet declarations are also supported. In such instances, the XSQL Servlet chooses the transformation

Chapter Building PL/SQL Web Services method26 by- matching the user-agent string in the HTTP header to an optional media attribute in the <xml-

Chapter 27 - Extending XML is Functionality with Java stylesheet> element. PL/SQL The match case-insensitive, and the first match in file order is the one applied. The following Chapter 28shows - Putting All Together example howIt multiple browsers are supported. Appendix

- XML Standards Bodies and Open Specifications <?xml version="1.0"?>

Glossary <?xml-stylesheet type="text/xsl" media="lynx" href="booklist-lynx.xsl"?> Index <?xml-stylesheet type="text/xsl" media="msie" href="booklist-ie.xsl"?> List of Figures <?xml-stylesheet type="text/xsl" href="booklist.xsl"?> List of Tables List of Sidebars connection="demo" xmlns:xsql="urn:oracle-xsql"> <xsql:query

select * from BOOKLIST </xsql:query> Note that the last stylesheet declaration has no media attribute. It will be applied to any HTTP requests that do not match the others and thus acts as the default stylesheet. Table 7-2 shows the allowable attributes that can be added to the <xml-stylesheet> element and their functions. Table 7-2: Attribute Options for the <?xml-stylesheet?> Element


Attribute

Default

Description

rowset-element Element name for in theJava, queryC, C++ & Oracle Database 10g XML<ROWSET> & SQL: Design, Build & Manage XML Applications PL/SQL results. Set equal to the empty by Mark V. Scardina, Ben Chang and Jinyu Wang string to suppress printing aISBN:0072229527 McGraw-Hill/Osborne © 2004 (600 pages) document element. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

row-element emphasis on XML standards, <ROW> their usage and best practices. Table of Contents

Element name for each row in the query results. Set equal to the empty string to suppress printing a row element.

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

max-rows Introduction

Fetch all rows

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4 - Validating XML with DTDs and Skip XML Schemas skip-rows no rows Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

id-attribute

Id

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

id-attribute-column Chapter 10 - Generating and Retrieving XMLRow count value Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

null-indicator

Omit elements with a NULL

Chapter 13 - Getting Started with Oracle XML and Java value Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Maximum number of rows to fetch from the query. Useful for fetching the top N rows or, in combination with skip-rows, the next N rows from a query result. Number of rows to skip over before returning the query results. Attribute name for the id attribute for each row in the query result. Column name to supply the value of the id attribute for each row in the query result. If set to y or yes, causes a nullindicator attribute to be used on the element for any column whose value is NULL.

Chapter 17 - Developing XML-Based Reusable Components

tag-case

If set to upper, the element names for columns in the query Chapter 18 - Getting Started with Oracle XML and C result appear in uppercase Chapter 19 - Building an XML-Managed Application letters. Chapter 20 - Build an XML Database OCI Application If set to lower, the element Chapter 21 - Create an XML-Configured High-Performance Transformation Enginenames for columns in the query Part V - Oracle XML for C++ Developers result appear in lowercase Chapter 22 - Getting Started with Oracle XML and C++ letters. Part IV - Oracle XML for C Developers

Use the case of the column name or alias from the query

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24way - Building anaXML Data-Retrieval Application The final to apply stylesheet is to pass its URL as an HTTP parameter as follows: Part VI - Oracle XML for PL/SQL Developers

http://localhost/yourdatapage.xsql?param1=value&xml-stylesheet=yourstyle.xsl

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 26 - Building PL/SQL Web Services This techniqvue is especially useful for prototyping and development. By replacing the stylesheet URL with none, Chapter 27 - Extending PL/SQL Functionality Java you ensure that the raw XML XML document is sent with without any stylesheet processing. Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications Inserting XML Documents with the XSQL Servlet

Glossary

Index By leveraging the full capability of the XML SQL Utility, you can set up an XSQL page to insert XML documents into List a database. of Figures An XML document can be submitted to the OracleXMLSave class of the XML SQL Utility by employing

theofAction List TablesElement, <xsql:insert-request>. As discussed previously, the schema must already exist in the database to save a document. While at first this may be considered a limitation, the XSQL Servlet’s capability to List of Sidebars apply a stylesheet to the XML document on submission provides the necessary functionality to filter or transform documents as needed. Returning to the book listing example presented earlier in the chapter, an XSQL page can be set up to accept book listings not only in the prescribed format of the database but also from virtually any text-based format. For example, consider the case in which a local bookseller would like to list his books on the pages, but his book listings use a different set of tags from the database schema. By creating an XSLT stylesheet and applying it on receipt of his listings, his selections could be accommodated. The following XSQL page could accept the book feed from “Joe’s


Books” via HTTP and transform it into the Booklist database schema by applying the joesbooks.xsl stylesheet and then submitting the resulting XML to the OracleXMLSave class for insertion: <?xml version="1.0"> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <xsql:insert-request xmlns:xsql="urn:oracle-xsql" ISBN:0072229527 by Mark V. Scardina, Ben Chang Wang connection = "demo" tableand = Jinyu "BOOKLIST" McGraw-Hill/Osborne © 2004 (600 pages) transform = "joesbooks.xsl"/> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

However, one more itemon must set up to their makeusage this example properly. The database generates the emphasis XMLbe standards, and best function practices. BookID column; therefore, this column’s entry must be created for each new insertion. This can be done by setting up a trigger on the Booklist table that generates this ID whenever an insertion is made. The following SQL script will Table of Contents create a new BookID when each new listing is added, assuming you have already created a sequence named Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL bookid_seq: Introduction

CREATE TRIGGER Part I - Oracle and thebooklist_autoid XML Standards BEFORE ON BOOKLIST FOR EACH ROW Chapter 1 INSERT - Introducing XML BEGIN - Accessing XML with DOM, SAX, JAXB, and StAX SELECT bookid_seq.nextval Chapter 3 - Transforming XML with XSLT and XPath INTO :new.BookID Chapter 4 - Validating XML with DTDs and XML Schemas FROM dual; Chapter 5 - XML Operations with XQuery END; Chapter 2

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7 - Putting It Allthat Together with XML by Pipeline, JSPs,Servlet and XSQL Other Action Elements are supported the XSQL and their functions are listed in Table 7-3. Part II - Oracle XML Management for DBAs

Chapter 8 - Action Getting Elements Started with theTheir Oracle XML Database Table 7-3: and Functions for XSQL Pages Chapter 9

- Storing XML Data

Action Element

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data <xsql:set-stylesheet-param> Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

<xsql:set-page-param>

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Description Sets the value of a top-level XSLT stylesheet parameter. Sets a page-level (local) parameter that can be referred to in subsequent SQL statements in the page.

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter <xsql:set-session-param> 16 - Developing an XML Gateway Application with SOAP Setsand anAQ HTTP session-level parameter. Chapter 17 - Developing XML-Based Reusable Components

<xsql:set-cookie>

Part IV - Oracle XML for C Developers

Chapter <xsql:query> 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

<xsql:ref-cursor-function>

Sets an HTTP cookie. Executes an arbitrary SQL statement and includes its result set in canonical XML format. Includes the canonical XML representation of the result set of a cursor returned by a PL/SQL stored function.

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

<xsql:include-param> Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers <xsql:include-request-params>

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Includes a parameter and its value as an element in your XSQL page. Includes all request parameters as XML elements in your XSQL page.

Chapter 26 - Building PL/SQL Web Services

<xsql:include-xml> Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

Includes arbitrary XML resources at any point in your page by relative or absolute URL.

Appendix - XML Standards Bodies and Open Specifications Includes the results of executing a stored <xsql:include-owa> Glossary procedure that uses the Oracle Web Agent (OWA) Index List of Figures

<xsql:if-param>

List of Tables

List of Sidebars

packages inside the database to generate XML. Includes nested actions and/or literal XML content if some condition based on a parameter value is true.

<xsql:include-xsql>

Includes the results of one XSQL page at any point inside another.

<xsql:insert-request>

Inserts the XML document (or HTML form) posted in the request into a database table or view.

<xsql:update-request>

Updates an existing row in the database based on the posted XML document supplied in the request.


<xsql:delete-request>

Deletes an existing row in the database based on the posted XML document supplied in the request.

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

<xsql:insert-param> PL/SQL <xsql:dml>

Inserts the XML document contained in the value

of a single parameter. by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Executes a SQL DML statement or PL/SQL

This comprehensive guide focuses on utilizinganonymous XML technologies block. within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

<xsql:action>

Invokes a user-defined action handler, implemented in Java, for executing custom logic Table of Contents and including custom XML information into your Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XSQL page. Introduction

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Updating DataXML with Servlet - Accessing with the DOM, XSQL SAX, JAXB, and StAX

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

Many applications require that data or documents be updated instead of wholly replaced. In a similar manner to the - Validating XML with DTDs and XML Schemas way the BookID was automatically generated, you can use a form of trigger to provide this functionality.

Chapter 4 Chapter 5

- XML Operations with XQuery

Chapter - XML Messaging RPC with Oracle 6makes available an and INSTEAD OFSOAP trigger that allows a stored procedure in PL/SQL or Java to be called Chapter 7 -an Putting It All XML Pipeline, JSPs, and XSQL whenever INSERT ofTogether any kind with is attempted. These triggers utilize Oracle’s Object Views to be associated with Part - Oracle XML Management for DBAs the II INSERT.

Chapter 8

- Getting Started with the Oracle XML Database

For example, if you XML wanted Chapter 9 - Storing Datato have the Booklist table be updatable, you could initially search for the unique combination of title and author and, if XML one is found, perform an UPDATE instead of doing an INSERT. To set this up, Chapter 10 - Generating and Retrieving you must create an Object View corresponding to the Booklist table. This can be done using the following SQL: Chapter 11 - Searching XML Data CREATE Booklistview AS Database Chapter 12VIEW - Managing the Oracle XML SELECT * FROM Part III - Oracle XMLBooklist; for Java Developers Chapter 13 - Getting Started with Oracle XML and Java

Next, the trigger needs to be created and associated with this view. In this example, PL/SQL is being used, but the job could also be done with a Java stored procedure.

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services

CREATE REPLACEan TRIGGER insteadOfIns_booklistview Chapter 16OR - Developing XML Gateway Application with SOAP and AQ INSTEAD OF INSERT ON booklistview FOR EACH ROW DECLARE Part IV - Oracle XML for C Developers notThere BOOLEAN := TRUE; Chapter 18 - Getting Started with Oracle XML and C tmp VARCHAR2(1); Chapter 19 - Building an XML-Managed Application CURSOR chk IS SELECT 'x' FROM BOOKLIST Chapter 20 - Build an XML Database OCI Application WHERE TITLE = :new.title AND AUTHOR = :new.author; Chapter 21 - Create an XML-Configured High-Performance Transformation Engine BEGIN Part V - Oracle XML for C++ Developers OPEN chk; Chapter 22 -chk Getting Started with Oracle XML and C++ FETCH INTO tmp; Chapter 23 Build an XML Database OCI C++ Application notThere := chk%NOTFOUND; Chapter 24 -chk; Building an XML Data-Retrieval Application CLOSE Chapter 17 - Developing XML-Based Reusable Components

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - GettingTHEN Started with Oracle XML and PL/SQL IF notThere Chapter 26 - Building Web Services AUTHOR, PUBLISHER, YEAR, UPDATE INTOPL/SQL Booklist(TITLE, Chapter 27 - Extending PL/SQL XML ISBN, Functionality DESCRIPTION) with Java

VALUESIt All (:new.title, :new.author, :new.Publisher, Chapter 28 - Putting Together Appendix

:new.Year, :new.Description); - XML Standards Bodies and :new.ISBN, Open Specifications

END IF; Glossary END; Index List of Figures

Finally, the XSQL file needs to be changed as follows to update the Booklistview instead of the Booklist table:

List of Tables

<?xml version="1.0"> <xsql:insert-request xmlns:xsql="urn:oracle-xsql" connection = "demo" table = "Booklistview" transform = "joesbooks.xsl"/>

List of Sidebars

As a final note, since the uniqueness is being checked in terms of the combination of the title and author, a unique index can be created to speed up the check and improve performance. The following SQL statement will create the index:


CREATE UNIQUE INDEX booklist_index ON booklist(Title, Author); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

While the previous example explained how to perform an update using the trigger functionality of an object view, you PL/SQL can also use the XML SQL Utility update capability from the XSQL Servlet using the following very simple .xsqlfile: ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang

<?xml version="1.0"?> McGraw-Hill/Osborne © 2004 (600 pages) <xsql:dml connection="demo" xmlns:xsql="urn:oracle-xsql"> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with update Booklist status='S' where BookID '1'; emphasis set on XML standards, their usage and best=practices. </xsql:dml> Table of Contents

This example illustrates the simplicity and power of the XSQL’s XML-based interface.

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Using JSPs and XSQL Pages

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

While you can extend XSQL pages with custom action handlers to call Java classes, you can also use JSP pages to - Accessing XML with DOM, SAX, JAXB, and StAX include XSQL pages using <jsp:include> or forward to them using <jsp:forward>. For example, this allows you to Chapter 3 - Transforming with XSLT andbe XPath bind variables into a SQLXML query that would run by an XSQL page. Consider the query used earlier with a simple Chapter 4 Validating XML with DTDs and XML Schemas booksearch.xsql page: Chapter 2

Chapter 5

- XML Operations with XQuery

<?xml version="1.0"?> - XML Messaging and RPC with SOAP <xsql:query xmlns:xsql="urn:oracle-xsql" connection="demo" Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL bind-param={@param} Part II - Oracle XML AUTHOR, Management for DBAs SELECT TITLE, DESCRIPTION FROM (@table) Chapter 8 Getting Started with the Oracle XML Database </xsql:query> Chapter 6

Chapter 9

- Storing XML Data

This XSQL can beand called from the following JSP fragment to pass in the bound parameters: Chapter 10 - page Generating Retrieving XML Chapter 11 - Searching XML Data <jsp:forward page="booksearch.xsql"> Chapter 12 - Managing the Oracle XML Database <jsp:param name="table" value="BOOKLIST WHERE YEAR = ?"/> Part<jsp:param III - Oracle XML for Java Developers name="YEAR" value="2001"/>

Chapter <jsp:param 13 - Getting name="param" Started with Oracle value="YEAR"/> XML and Java

</jsp:forward> Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

When you want to include the results of an XSQL page within a JSP, you can use <jsp:include> in the following manner:

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

<jsp:include page="booksearch.xsql">. Part IV - Oracle XML for C Developers Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Best Practices PL/SQL

ISBN:0072229527 Scardina, Bentechniques Chang andthat Jinyu Wang In this chapter by youMark haveV.seen several can be used to put together XML-enabled applications. The 2004 (600 pages) Processor, JSPs, or the XSQL Servlet, the code is almost common themeMcGraw-Hill/Osborne is that whether you ©use the Pipeline entirely declarative. This is distinctly different from and linked applications that the code can be with This comprehensive guide focuses on normal utilizingcompiled XML technologies within Oracle's in XML-enabled products, emphasis XML standards, theirThis usage and best practices. changed, customized, oron updated at any time. approach has the advantage of allowing you to develop generic, high-quality, reusable components that can be easily put together in the same way that integrated circuits simplified and of improved electronic circuit design over discrete transistors. Table Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Creating a More Secure Connection

Introduction

Part I - Oracle and the XML Standards

In most1applications, you will use the XSQL Servlet to connect to a database. The XSQLConfig.xml file must be Chapter - Introducing XML kept secure on the server. ThisDOM, file should neverand be in any directory tree that is mapped to a virtual path of your web Chapter 2 - Accessing XML with SAX, JAXB, StAX server. 3You should set upXML an account that your servlet engine for your application and make sure that only this Chapter - Transforming with XSLT andowns XPath account4 has read permissions theand file.XML Schemas Chapter - Validating XML with on DTDs Chapter 5

- XML Operations with XQuery It is also important that you control the parameters passed by the URL into the XSQL Servlet. By default, it will

Chapter - XML Messaging andxml-sytlesheet RPC with SOAP parameter unless you add the attribute allow-client-style="no" to the accept 6a stylesheet using the Chapter 7 -element Putting of It All Together document your page. with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Finally,8you- Getting saw how to usewith lexical of variables into SQL queries. This is a common feature of many Chapter Started the substitution Oracle XML Database Oracle 9products. It is also potentially a dangerous one. Therefore, you can guard against abuses by limiting the Chapter - Storing XML Data scope of access users of your application. You can also bind variables (as shown in the Chapter 10database - Generating and permitted Retrieving to XML “Using 11 JSPs and XSQL Pages” Chapter - Searching XML Data section) or, even better, perform the entire database transaction in a custom action handler12 call. Chapter - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

When You Need Simple JSP XML Functionality

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Besides15all- of this powerful by the XDK, Oracle does supply an XML JSP tag library with Chapter Creating a PortalXML Site functionality with XML andprovided Web Services its OC4J container. This Gateway library is Application called xml.jar canand be AQ found in the /j2ee/jsp/lib/tldsdirectory. It Chapter 16J2EE - Developing an XML withand SOAP provides the following custom JSP tags to perform simple XML processing:

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

xml:transform Takes a stylesheet and applies it to the XML in the tag’s body

Chapter 18 - Getting Started with Oracle XML and C

Chapter xml:styleSheet 19 - Building an Declares XML-Managed and locates Application the stylesheet to be used for xml:transform Chapter 20 - Build an XML Database OCI Application

xml:parsexml Parses the XML in the body of the tag into a DOM for node access

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

xml:cacheXMLObject Allows for XML objects such as DOMs to be cached in the Web Object cache

Chapter 22 - Getting Started with Oracle XML and C++

Chapter In Oracle 23 XML - Build Database an XML Database 10g or earlier, OCI C++ these Application tags do not use the XDK libraries, but instead use the XML ones

included 1.4.an XML Data-Retrieval Application Chapter 24in- JDK Building Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Part II: Oracle XML Management for DBAs PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Chapter List

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Chapter 8: Getting Started with the Oracle XML Database

Table of Contents

OracleChapter Database XMLXML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL 9: 10g Storing Data Introduction

and Retrieving XML Part IChapter - Oracle 10: andGenerating the XML Standards Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 11: Searching XML Data

Chapter 3 - Transforming XML XSLT andDatabase XPath Chapter 12: Managing thewith Oracle XML Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 8: Getting Started with the Oracle XML Database PL/SQL

Overview

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

TheOracle XML emphasis Database on (XML XML standards, DB) referstheir to the usage collection and best of XML practices. technologies built into the Oracle Database 10g database, providing high-performance and native storage, retrieval, and processing of XML. This native XML functionality is seamlessly integrated with the Oracle relational database server to bridge the gap between the Table of Contents relational table-row and XML hierarchical storage. Therefore, you have the advantage of leveraging the power of Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL both. Introduction

Part I - Oracle and XML Standards As companies arethe seeking XML technologies to automate and enhance their core business processes over the

Chapter 1 the - Introducing XML Internet, Oracle XML Database, along with the programming interfaces in the Oracle XML Developer’s Kit Chapter - Accessing XML with DOM, SAX, JAXB, StAXXML solutions. (XDK), 2provides a platform to efficiently build andand deploy Chapter 3

- Transforming XML with XSLT and XPath

This chapter discusses what theDTDs Oracle Chapter 4 - Validating XML with andXML XML database Schemas is, what the related XML features are, and how to set up the environment to make sure that features are ready for use. It will then work though some examples to help you Chapter 5 - XML Operations withthese XQuery get familiar with the basic XML DB functionality. Chapter 6 - XML Messaging and RPC with SOAP Finally, it will provide information to help you make decisions regarding -when and how to use the XML database features. Specifically, it will Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 7

Part II - Oracle XML Management for DBAs

Show how to set up the XML database environment

Chapter 8

- Getting Started with the Oracle XML Database

Chapter Discuss 9 - Storing variousXML uses Data of the native XMLType data type Chapter 10 - Generating and Retrieving XML

Explore the various XML storage and processing options

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML of Database Investigate the effective design XML database solutions Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL:in Design, BuildDatabase & Manage XML Applications in Java, C, C++ & A Brief History of XML Support Oracle PL/SQL

ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang The support ofby XML in the Oracle database began with Oracle8i, in which users could load the Java packages from 2004 (600 the Oracle XDKMcGraw-Hill/Osborne into Oracle JServer©as well aspages) create the XML PL/SQL packages built on the Java stored procedures. The XML PL/SQL packages includeon the DBMS_XMLSAVE and within the DBMS_XMLQUERY packages, This comprehensive guide focuses utilizing XML technologies Oracle's XML-enabled products, with emphasis on XML usage and practices. which are packaged as the XMLstandards, SQL Utilitytheir (XSU), and thebest XMLPARSER, XMLDOM, and XSLPROCESSOR packages. The two XSU PL/SQL packages allow users to insert XML documents into the database tables and retrieve SQL data in XML format through a canonical mapping. The XMLPARSER package is used for parsing XML, Table of Contents the XMLDOM for XML DOM and the XSLPROCESSOR package is used for XSLT Oracle Databasepackage 10g XMLis & used SQL—Design, Build &operations, Manage XML Applications in Java, C, C++ & PL/SQL transformations. Introduction Part I - Oracle and the XML Standards

Since all of these packages are built on Java stored procedures, you need to initialize the Oracle Java Virtual - Introducing XML Machine (Oracle JVM) and load the Java packages before using the functionality. This leads additional database Chapter 2 - Accessing XMLand withhigh DOM, SAX, JAXB, cost. and StAX management complexity maintenance Chapter 1 Chapter 3

- Transforming XML with XSLT and XPath

In Oracle9i a new dataSchemas type—XMLType—was introduced to store and query XML data in the Chapter 4 - Release Validating1,XML withnative DTDsXML and XML database. provides member Chapter 5 -XMLType XML Operations with XQueryfunctions to access, extract and query XML data using XPath expressions, such as6 XMLType.extract(), XMLType.extractValue() and XMLType.existsNode(). Additionally, the C-based Chapter - XML Messaging and RPC with SOAP DBMS_XMLGEN package and a set of SQLJSPs, functions, including the SYS_XMLGEN() and Chapter 7 - PuttingPL/SQL It All Together with XML Pipeline, and XSQL SYS_XMLAGG(), provided tofor create Part II - Oracle XMLare Management DBAsXMLTypes. The new DBUri-refs allow URL-based content references in database. these built-in XML andDatabase operators, processing XML is simplified, because you do not need Chapter 8 -With Getting Started with thefunctions Oracle XML

to initialize-and maintain the Java classes in the Oracle database. However, these XML functions do not scale well, Storing XML Data because XMLTypes are stored as CLOBs and requires the building of DOM in memory before processing XML Chapter 10 - Generating and Retrieving XML content. In addition, in this release, the text-search functionality in Oracle Text provides the XPATH support Chapter 11 - Searching XML Data within the CONTEXT index. Chapter 9

Chapter 12 - Managing the Oracle XML Database

Part III - Oracle XML for Java Developers Oracle9i Release 2 introduces additional XML Schema–based data storage for XMLType, which allows users to

Chapter - Getting Started Oracle and Java register13 XML schemas that with conform to XML the W3C XML Schema recommendation. After an XML schema is registered, Chapter - Building sets of 14 object types an andXML-Powered object tablesWeb are Site created to store XML instances conforming to the schema. The XML Chapter 15documents - Creating aare Portal Site withand XMLstored and Web Services instance “shredded” in the objects. This “preparsed” storage of XML helps avoid the runChapter time DOM 16 -parsing Developing needed an XML by the Gateway CLOB-based Application XMLTypes with SOAP in Oracle9i and AQ R1. Additionally, the Oracle XML DB is

capable17of- rewriting theXML-Based XML queries with XPath expressions into the relational SQL queries for fast data access. In Chapter Developing Reusable Components thisIV release, a new index—CTXXPATH index—is integrated in XMLType to speed up the performance of Part - Oracle XML text-search for C Developers XPath searching when using XMLType.existNode() Chapter 18 - Getting Started with Oracle XML and C function. Chapter 19 - Building an XML-Managed Application

Along with the new storage model, Oracle9i Release 2 provides a document-centric XML DB Repository for highperformance document management in the Oracle database. The XML DB Repository provides the protocol Chapter 21 - Create an XML-Configured High-Performance Transformation Engine interfaces in addition to the SQL interfaces, such as FTP, HTTP, and WebDAV, to help users easily access and Part V - Oracle XML for C++ Developers manipulate the XML documents stored in the Oracle database. Chapter 20 - Build an XML Database OCI Application

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build XML Database C++ Application Furthermore, the an SQL and PL/SQLOCI support for XML processing is enhanced in this release by including the new Chapter XMLType 24 -member Buildingfunctions, an XML Data-Retrieval the new SQL/XML Application functions, and the C-based PL/SQL packages for processing XML Part data. VIA- set Oracle of PL/SQL XML for packages PL/SQL Developers and XDBUriType are also provided for the resource management of the XML DB

Repository. As previously built-in C functions and PL/SQL packages have less management and Chapter 25 - Getting Starteddiscussed, with Oraclethe XML and PL/SQL processing than the Java-based Chapter 26 - overhead Building PL/SQL Web Services PL/SQL packages. Chapter 27 - Extending PL/SQL XML Functionality with Java

Note Because C-based PL/SQL packages provide compatible APIs with better performance, the Java-based XML PL/SQL packages, including XMLPARSER, XMLDOM, and XSLPROCESSOR, are deprecated and Appendix - XML Standards Bodies and Open Specifications are not included in the Oracle Database 10g release. Chapter 28 - Putting It All Together Glossary

Index In Oracle Database 10g, native XML support is further enhanced by supporting a certain level of XML Schema List evolution. of Figures This allows you to update the registered XML schemas for XMLTypes without performing an import/export

on of your data. Additionally, the existing XML applications can now have a single code line for multi-tier XML List Tables application deployment as Oracle XDK in Oracle Database 10g provides unified DOM interfaces to access List of Sidebars XMLTypes. This support speeds up the XML processing by eliminating the need to reparse the XML documents in mid-tier and directly utilize the DOM objects stored in the database with “lazy” DOM manifestation. This feature is initially available in C and C++ for OCI and OCCI applications respectively. The Oracle Database 10g database now contains extensive native XML functionality within the database server. The technical details of this technology will be discussed in later chapters. Table 8-1 provides a summary of the evolution of Oracle XML features.


Table 8-1: XML Features in Oracle Database Database Version

Major XML Features

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Java-based XML SQL Utility (XSU):

Oracle8i

ISBN:0072229527 by Mark V. Scardina, Ben Chang and JinyuDBMS_XMLQUERY, Wang DBMS_XMLSAVE McGraw-Hill/Osborne © 2004 (600 pages) Java-based XML PL/SQL packages: XMLPARSER,

XSLPROCESSOR, This comprehensive guide focuses on utilizing XML technologiesXMLDOM within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Text search for XML: Searching within XML elements/attributes using the AUTO_SECTION_GROUP/XML_SECTION_GROUP Table of Contents in theApplications CONTEXTinindex Oracle Database 10g XML & SQL—Design, Build & Manage XML Java, C, C++ & PL/SQL Introduction Oracle9i

XMLType with CLOB storage: XMLType.extract(), XMLType.extractValue(), XMLType.existsNode() Chapter 1 - Introducing XML SQL functions for XML generation and aggregation: Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX SYS_XMLGEN(), SYS_XMLAGG() Chapter 3 - Transforming XML with XSLT and XPath C-based PL/SQL package for XML generation: Chapter 4 - Validating XML with DTDs and XML Schemas DBMS_XMLGEN Native DBURI-refs: UriType,DBUriType, Chapter 5 - XML Operations with XQuery HttpUriType,UriFactoryType Chapter 6 - XML Messaging and RPC with SOAP Text Chapter 7 - Putting It All Together with XML Pipeline, JSPs, andsearch XSQL for XML: XPATH searching using the PATH_SECTION_GROUP Part II - Oracle XML Management for DBAs Chapter 8 - Getting Started with the Oracle XML Databasein the CONTEXT index Text search integration within XMLType: CTXXPATH Chapter 9 - Storing XML Data index integrated within XMLType.existsNode() Chapter 10 - Generating and Retrieving XML Part I - Oracle Release 1 and the XML Standards

Chapter 11 - Searching XML Data Oracle9i

XML Schema–based XMLType and CLOB-based XMLType Part III - Oracle XML for Java Developers New XMLType member functions such as Chapter 13 - Getting Started with Oracle XML and Java XMLType.transform() XML DB Repository and protocol data access Chapter 14 - Building an XML-Powered Web Site interfaces: HTTP, WebDAV over HTTP, FTP, Chapter 15 - Creating a Portal Site with XML and Web Services support Chapter 16 - Developing an XML Gateway Application with SQL/XML SOAP and AQ Oracle SQL extensions for XML Processing: Chapter 17 - Developing XML-Based Reusable Components UPDATEXML(), XMLSEQUENCE() Part IV - Oracle XML for C Developers C-based XML PL/SQL packages: Chapter 18 - Getting Started with Oracle XML and C DBMS_XMLDOM for XML DOM operations Chapter 19 - Building an XML-Managed Application DBMS_XSLPROCESSOR for XSLT transformations Chapter 20 - Build an XML Database OCI Application and XPath-based data extraction Chapter 21 - Create an XML-Configured High-Performance Transformation Engine DBMS_XMLPARSER for XML parsing Part V - Oracle XML for C++ Developers DBMS_XMLTRANSFORM for XSLT transformations Chapter 22 - Getting Started with Oracle XML and C++ DBMS_XMLSCHEMA for XML Schema operations Chapter 23 - Build an XML Database OCI C++ Application such as XML Schema registration and validation Chapter 24 - Building an XML Data-Retrieval Application DBMS_XDB for XML DB Repository configuration Part VI - Oracle XML for PL/SQL Developers DBMS_XDBZ for XML DB hierarchical indexing Chapter 25 - Getting Started with Oracle XML and PL/SQL DBMS_XDB_VERSION for XML document Chapter 26 - Building PL/SQL Web Services versioning in XML DB Repository Chapter 27 - Extending PL/SQL XML Functionality with JavaAdditional native DBUri-refs: XDBUriType Chapter 12 -2 Managing the Oracle XML Database Release

Chapter 28 - Putting It All Together

Oracle Database 10g Release 1

Appendix

XML Schema evolution New C-based XML PL/SQL package for inserting XML data: DBMS_XMLSTORE Unified DOM interfaces to XMLType for OCI/OCCI applications

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables

List ofNote Sidebars In OracleX, most of the functionality in DBMS_XMLQUERY and DBMS_XMLSAVE is covered by the C-

based PL/SQL packages—the DBMS_XMLGEN and DBMS_XMLSTORE, respectively. For better performance, you should always use the C-based packages if they cover the functionality you need. However, you generally cannot mix the two within a single XML process. Along with the XML functionality centralized in the Oracle database, you can also take advantage of the XML interfaces in the Oracle XDK and connect to databases through JDBC or OCI to build mid-tier XML database applications. This will be discussed in the following chapters.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle XML Database & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Setting Up theDatabase Oracle10g XML PL/SQL

ISBN:0072229527 by Mark Scardina, Ben Changinand Wang chapters, you need to have access to Standard To make sure that you V. can run the examples theJinyu upcoming or Enterprise Ed McGraw-Hill/Osborne 2004 (600 Oracle Database 10g database and©follow thepages) setup procedures explained in this section.

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Note Mostemphasis of the Oracle XML DB functionality discussed inpractices. this section also works in Oracle 9.2.0.2 and later releases. Ho on XML standards, their usage and best directory structures for SQL files may be different from Oracle Database 10g. Table of Contents

Installing Oracle XML Database

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

If you thethe Oracle Part I - installed Oracle and XML Database Standards 10g database using Database Configuration Assistant (DBCA), you do not need to perfor

steps to set up Oracle XML DB because it is set up by default. Otherwise, after the database installation, you need to perform - Introducing XML following steps to enable the Oracle XML DB functionality:

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

1. Create an Oracle XML DB tablespace (as XDB) for Oracle XML DB Repository. Chapter 3 - Transforming XML with XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Enable protocol access.

Chapter 6 -toXML Messaging RPC with SOAP You need connect as theand SYS user and run the SQL scripts in the $ORACLE_HOME/rdbms/ admin (or

Chapter 7 - Putting It All Together withfor XML Pipeline,directory. JSPs, andThese XSQL steps assume your Oracle Database 10g installation is in D %ORACLE_HOME%\rdbms\admin Windows) Part II -isOracle XML Management for DBAs which the Oracle home directory.

Chapter 8

- Getting Started with the Oracle XML Database

Note term XML XDB,Data which will be introduced, was the original name used by Oracle development for XML DB. Therefore, Chapter 9 The - Storing confusing as it is used internally for labeling users, schemas, tablespaces, etc. For clarification, XML DB will continu Chapter 10 - Generating and Retrieving XML used to refer to functionality and the Repository, and XDB to describe XML DB metadata, users, and where it is used Chapter 11 - Searching XML Data default. Chapter 12 - Managing the Oracle XML Database

in toXML a SQL*Plus session and connect as the SYS user with SYSDBA privilege: Part 1. III Log - Oracle for Java Developers ChapterOSPrompt> 13 - Getting SQLPLUS Started with "SYS/<sys_password> Oracle XML and Java as sysdba" Chapter 14 - Building an XML-Powered Web Site

2. Create a new aXDB tablespace as follows: Chapter 15 - Creating Portal Site with XML and Web Services TABLESPACE LOGGIN ChapterCREATE 16 - Developing an XML XDB Gateway Application with SOAP and AQ DATAFILE 'D:\oracle\oradata\ORCLX\xdb.dbf' Chapter 17 - Developing XML-Based Reusable Components AUTOEXTEND Part IV -SIZE Oracle25M XML REUSE for C Developers

ON NEXT 1280K MAXSIZE 100M EXTENT MANAGEMENT LOCAL; Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

3. Then, run the catqm.sql script to create the XDB database registry, PL/SQL packages, and so forth:

Chapter 20 - Build an XML Database OCI Application

SQL> @catqm.sql <XDBUSER_password> <XDB_TS_NAME> <TEMP_TS_NAME>

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

4. For example, the following command creates the XDB user using the XDB tablespace and sets the temporary tablespa TEMP (the password for the XDB user is XDBPW):

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application

SQL> @catqm XDBPW XDB TEMP

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with and Oracle XML and PL/SQL 5. After all the tablespaces built-in PL/SQL packages are created, you can reconnect to SQL*Plus as a SYS user with Chapter SYSDBA 26 - Building PL/SQL Web privilege and runServices the catxdbj.sql script to load XML DB Java libraries: Chapter 27 - Extending PL/SQL XML Functionality with Java

SQL> @catxdbj

Chapter 28 - Putting It All Together

Appendix - XML Bodies Open Specifications 6. If you likeStandards to install the XDKand packages, such as the DBMS_XMLQUERY and DBMS_XMLSAVE PL/SQL packages, you Glossaryrun initxml.sql as follows: Index SQL> @initxml.sql List of Figures

Finally, you need to shut down and restart the database. List of Tables List of Sidebars

Now, you have set up the database schema for Oracle XML DB, created the supporting PL/SQL packages, and set up the ass component registries in the Oracle database. Next, you need to set up the XML DB HTTP and FTP listeners to allow users to XML DB Repository through the WebDAV/HTTP and FTP protocols.

First, you need to make sure the Oracle Net Services are started. To check the status, you can use the lsnrctl status comma command-line window. As shown in Figure 8-1, the XML DB service, orclXXDB, (<Oracle SID>XDB naming convention), and the XML DB HTTP and listeners have started. By default, the HTTP listener listens on port 8080 and the FTP listener uses port 2100.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Figure 8-1: Oracle Net Services status

Chapter 4 - Validating XML with DTDs and If the status is not as shown in Figure 8-1,XML youSchemas need to perform the following steps, assuming you have the default port 1521 r Chapter - XML Operations for the 5database listener: with XQuery Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs,Initializing and XSQL the Oracle JVM

Part II - Oracle XML Management for DBAs

If the JVM is notwith initialized, youXML mustDatabase initialize it before loading the Java package for the XSU PL/SQL packages. T Chapter 8 Oracle - Getting Started the Oracle the JVM: - Storing XML Data

Chapter 9

1. - Run the initjvm.sql and initdbj.sql scripts in the $ORACLE_HOME/javavm/install (%ORACLE_HOME%\javavm\in Chapter 10 Generating and Retrieving XML Chapter 11 - Windows) Searching directory. XML Data Chapter 12 - Managing the Oracle XML Database

2. When you upgrade the XDK PL/SQL packages, you need to uninstall the XDK with the rmxml.sql utility and reload t XDK PL/SQL packages into Oracle JServer with the initxml.sql utility in the $ORACLE_HOME/rdbms/admin dire Chapter 13 - Getting Started with Oracle XML and Java However, you do not need to reinitialize the Oracle JVM during this reloading process. Part III - Oracle XML for Java Developers

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 Creating a Portal SitePL/SQL with XML and Webare Services 3. - By default, the XDK packages loaded into the SYS or SYSTEM user. However, for easier maintenance

Chapter 16 - reloading Developing Java an XML packages Gateway is needed, Application it iswith suggested SOAP and to load AQ them into a specific user schema. For example, you can

namedXML-Based XDK and load the Java classes to this user's schema. This keeps them separated from the other Java Chapter 17 - user Developing Reusable Components

thusXML eliminating potential compatibility problems during upgrades. You should also notice that, by default, the public Part IV - Oracle for C Developers created for the names, and the execution privileges are granted to PUBLIC. Chapter 18 - are Getting Started withpackage Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

To set up the TCP dispatcher, you need to add the dispatchers parameter to a server parameter file (SPFILEORCLX.ORA) fi

Part V - Oracle XML for C++ Developers

dispatchers="(PROTOCOL=TCP) (SERVICE=<SID>XDB)"

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XMLyour Database OCIisC++ Application For example, assuming instance ORCLX, you need to run the following command as the SYS user: Chapter 24 - Building an XML Data-Retrieval Application

SQL> ALTER SYSTEM SET dispatchers='(PROTOCOL=TCP)(SERVICE=ORCLXXDB)' SCOPE=SPFILE; SQL> SHOW PARAMETERS dispatchers;

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 26 -need Building PL/SQL Services Then, you to stop and Web restart the listener by running the following in the command-line window: Chapter 27 - Extending PL/SQL XML Functionality with Java

OSPrompt> lsnrctl stop

Chapter 28 - Putting It All start Together OSPrompt> lsnrctl Appendix

- XML Standards Bodies and Open Specifications

Glossary Finally, you need to shut down and restart the database from SQL*Plus: Index SQL> shutdown immediate; List of Figures SQL> startup List of Tables List of Sidebars

To make sure the listeners work properly and the XML DB service is registered, you can check the listener status by running th command: OSPrompt> lsnrctl status You should now be able to see the XML DB service and the HTTP and FTP listeners up and running.


Note After Oracle9i, instead of updating the init<SID>.ora file to change the initialization parameters of the Oracle databas you need to update the Stored Parameter File (SPFILE), which is used by default. To do this, you can run the ALTE Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & command in the SYS user:ALTER SYSTEM set parameter = value SCOPE = MEMORY | SPFILE | BOTH; PL/SQL SCOPE clause allows you to set the scope parameters: MEMORY affects the current running ISBN:0072229527 database but will not b by Mark V. Scardina, Ben Chang and Jinyu Wang after a database is restarted, SPFILE does not change the current database setting of the parameter but will modify McGraw-Hill/Osborne © 2004 (600 pages) SPFILE so that this parameter will take effect when the database is restarted, and BOTH changes system paramete This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with current database instance and updates the SPFILE. emphasis on XML standards, their usage and best practices.

If the database listener does not use the default 1521 port (i.e., 1581), the XML DB service and FTP and HTTP listeners cann

Table of Contents dynamically registered to the listener. Therefore, you need extra setup steps. For example, if you have the following Oracle Ne

defined in $ORACLE_ %ORACLE_HOME%\network\admin\tnsname.ora on Window Oracle Database 10g XMLHOME/network/admin/tnsname.ora & SQL—Design, Build & Manage XML(or Applications in Java, C, C++ & PL/SQL Introduction ORCLX = Part(DESCRIPTION I - Oracle and the=XML Standards

Chapter 1 - Introducing XML (ADDRESS_LIST = Chapter 2(ADDRESS - Accessing= XML with DOM, =SAX, JAXB, and = StAX (PROTOCOL TCP)(HOST mylaptop)(PORT = 1581)) Chapter ) 3 - Transforming XML with XSLT and XPath

(CONNECT_DATA = with DTDs and XML Schemas Chapter 4 - Validating XML = DEDICATED) Chapter 5(SERVER - XML Operations with XQuery = ORCLX) Chapter 6(SERVICE_NAME - XML Messaging and RPC with SOAP )7 Chapter

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part)II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

and you have the listener defined in the following section of the listener.ora:

LISTENER = (DESCRIPTION_LIST = Chapter 11 - Searching XML Data (DESCRIPTION = Chapter 12 - Managing the Oracle XML Database (ADDRESS_LIST = Part III - Oracle XML for Java Developers (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) Chapter 13 - Getting Started with Oracle XML and Java ) Chapter 14 - Building an XML-Powered Web Site (ADDRESS_LIST = Chapter 15 -(ADDRESS Creating a Portal Site with XML and Web Services = (PROTOCOL = TCP)(HOST = mylaptop)(PORT = 1581)) Chapter 16 ) - Developing an XML Gateway Application with SOAP and AQ Chapter ) 17 - Developing XML-Based Reusable Components Part)IV - Oracle XML for C Developers Chapter 10 - Generating and Retrieving XML

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

then you to an configure the LOCAL_LISTENER Chapter 20need - Build XML Database OCI Application parameter in the initialization parameter file referring to the TNSNAME ent

in the tnsnames.ora points to theHigh-Performance correct listener. You can run theEngine following command in SQL*Plus to update the SPFILE Chapter 21 - Create an that XML-Configured Transformation Part SQL> V - ALTER Oracle XML SYSTEM for C++ SET Developers dispatchers='(PROTOCOL=TCP)(LISTENER=ORCLX)'

SCOPE=SPFILE;

SQL> SHOW PARAMETERS local_listener; Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

Finally, you also need to shut down and restart the database as follows:

Chapter 24 - Building an XML Data-Retrieval Application

SQL> Part VI -shutdown Oracle XMLimmediate; for PL/SQL Developers SQL> startup Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Oracle XML DB allows you to change the default configurations of the HTTP and FTP ports. However, that process is not disc here, because the preceding setups are enough for you to get started to run the XML DB samples. Such management and se Chapter 28 - Putting It All Together are discussed in Chapter 12, which presents some tips and techniques for using the XML DB features. Chapter 27 - Extending PL/SQL XML Functionality with Java Appendix

- XML Standards Bodies and Open Specifications

Glossary

Installing the Sample Database Schemas

Index

List of Figures

The Oracle sample database schemas are used in the examples for the book. However, the installation of the sample schema option when creating a database with DBCA in Oracle Database 10g. If the sample schemas are not installed during database List Sidebars youofneed to start SQL*Plus to run the following command in the $ORACLE_HOME or %ORACLE_HOME% directory: List of Tables

SQL> @demo\schema\mksample <SYS_PASSWORD> <SYSTEM_PASSWORK> HR OE PM QS SH BI EXAMPLE TEMP D:\

Themksample.sql script requires you to supply the SYS and SYSTEM password followed by the password for the six sample users, HR, OE, PM, QS, SH, and BI. To help remember the password for each user, you can specify the password same as t names. For example, the password for user HR is HR. Then, you need to specify the default tablespace (i.e., EXAMPLE), the tablespace (i.e., TEMP), and the directory where you want the log file to be generated for the sample schema installation.

Upon installation, the sample schemas are created. The six sample schemas build up a general database schema for compan


management, which consists of different divisions represented by different users: HR The Human Resource division contains information about the company’s employees and the organizational structure. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

PL/SQL OE The Ordering Entry division tracks the product inventory and fulfills purchase orders of products through different chan by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne 2004 (600 pages) PM The Product Media division©maintains the product-related information. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

QS The Quality Shipping division manages shipping of practices. the products to customers. emphasis on XML standards, their the usage and best SH The Sale History division tracks business statistics.

Table of Contents

OracleBI Database The Business 10g XML Intelligence & SQL—Design, division Build provides & Manage decision XML support Applications information. in Java, C, C++ & PL/SQL Introduction

TheI XML generation (O-R) XMLType storage examples will use the HR schema, and the XML-based co Part - Oracle and the and XMLObject-Relational Standards management samples will be built on the PM schema. - Introducing XML

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Creating a User XML to Run theandXMLType Samples Chapter 3 - Transforming with XSLT XPath Chapter 4

- Validating XML with DTDs and XML Schemas

You need -toXML create a temporary user account to run the examples of XMLType in this chapter. For example, you can run the fo Operations with XQuery SQL commands in SYS user to create a user named demo:

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

CREATE demo Chapter 7 USER - Putting It AllIDENTIFIED Together withBY XMLdemo Pipeline, JSPs, and XSQL DEFAULT TABLESPACE USERS Part II - Oracle XML Management for DBAs QUOTA ON USERS Chapter 8 50M - Getting Started with the Oracle XML Database TEMPORARY TABLESPACE TEMP; - Storing XML Data

Chapter 9

Chapter 10 - Generating and Retrieving XML

This user needs to have the following privileges:

Chapter 11 - Searching XML Data

Chapter CREATE 12 - Managing SESSION the Oracle XML Database Part III - Oracle XML for Java Developers

CREATE TABLE Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

CREATE PROCEDURE

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter CREATE 16 - Developing TYPE an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

CTXAPP Part IV - OracleROLE XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

You can grant the privileges as follows:

Chapter 19 - Building an XML-Managed Application

GRANT CREATE SESSION TO demo; GRANT CREATE TABLE TO demo; Chapter 21 - Create an XML-Configured High-Performance Transformation Engine GRANT CREATE PROCEDURE to demo; Part V - Oracle XML for C++ Developers GRANT CREATE TYPE TO demo; Chapter 22 - Getting Started with Oracle XML and C++ GRANT CTXAPP TO demo; Chapter 20 - Build an XML Database OCI Application

Chapter 23 - Build an XML Database OCI C++ Application

Chapter 24three - Building an XML Application The first privileges areData-Retrieval granted for basic DDL operations. The third one has to be granted to create object types during th Part VI - Oracle XML for PL/SQL Developers Schema registration. The CTXAPP role is used to create and synchronize Oracle Text indexes.

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Setting Up a WebDAV Folder

Chapter 27 - Extending PL/SQL XML Functionality with Java

Chapter 28 support - PuttinginItOracle All Together WebDAV XML DB allows you to create WebDAV folders in the Windows environment. It makes accessing th

Appendix XML DB Repository - XML Standards just likeBodies accessing and Open any other Specifications folder on your disk drive. The following instructions work through the procedu

up a WebDAV Folder in a Windows XP system: Glossary Index1. From the START menu, open My Network Places. List of Figures

2. Tables Click Add A Network Place, which allows you to pick up the kind of network place to add. List of List of Sidebars

3. Click Next, choose Choose Another Network Connect, and then type http://<host-name>:8080/ as the address. You c use127.0.0.1 or localhost for your hostname.

4. Click Next. A window pops up asking for login information. You can type any valid database username and password he to XML DB. Note that different users may have different views of data because of the security protection in the XML DB Repository. 5. Click OK. In the next wizard window, type in the name XML DB Repository and click Next. 6.


5. 6. Deselect the Open Folder By Default option and then click Finish to complete the wizard.

7. Back in the window My Network Places window, you will now see that the folder XML DB Repository has been created, Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & inFigurePL/SQL 8-2. by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

8-2: WebDAV folder - Figure XML Messaging and RPC withcreated SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Double-click the XML DB Repository folder icon. You will be asked to log in. You can use the same database username and p

Chapter 8 - web Getting Started with Oracle XML Database log in. The folder opens, asthe shown in Figure 8-3. Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Figure 8-3: Example Oracle XML DB Repository

Part V - Oracle XML for C++ Developers

Chapter 22 you - Getting Started with Oracle XML and C++ Now that have created the WebDAV folder, any application that supports WebDAV, such as Microsoft Word, can use this Chapter Buildfiles an XML Database C++ Application access23 or -save in the XML DBOCI Repository. The setup of the folder is complete and will be used later. Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & What Is the Oracle XML Database? PL/SQL

bybeginning Mark V. Scardina, Ben Chang and Jinyu Wang As stated at the of the chapter, the Oracle XML database refers to a collection of native XML ISBN:0072229527 technologies © 2004 (600 pages) in the databaseMcGraw-Hill/Osborne server. However, the native XML support is only one part of the XML infrastructure in the Oracle database. The This overall XML infrastructure in Oracle database provides both high-performance native XMLproducts, support with comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled emphasis on on XML standards, theirbuild usage anddeploy best practices. and an extensible platform which users can and their own solutions.

The native XML DB functionality is available without having to run through a separate installation process. The extension platform is based on the Java Stored Procedures running in the Oracle JVM and the C-based external Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL procedures. You can build customized XML solutions using the XML functionality in the Oracle XDK to compliment Introduction the existing native XML functionality. Figure 8-4 illustrates the overall XML infrastructure in the Oracle database.

Table of Contents

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7 - Putting It All database Together with Pipeline, JSPs, and XSQL Figure 8-4: Oracle XMLXML support Part II - Oracle XML Management for DBAs

Chapter 8 - Getting Startedthe with the Oracle XML and Database In the native XML engine, XMLType tables views provide the storage of XML data. The XML DB Repository Chapter provides 9 an - Storing XML document XML Datarepository that is optimized for handling XML documents, and the PL/SQL and SQL/XML

functions XML operations on SQL data and XML content. The Java and C XML programming APIs in the Chapter 10 allow - Generating and Retrieving XML Oracle 11 XDK can be used add functionality by building external procedures, such as creating a Java Stored Chapter - Searching XMLto Data Procedure SAX stream-based XML processing, which is not available as part of the native XML support. Chapter 12 - for Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Exploring the native XML features is the focus in this section. The examples for building Java or C extensions using XDK will be included in later chapters to demonstrate the value of the entire Oracle XML infrastructure.

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web In the coming section, the following features will be Services demonstrated: Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

The XMLType data typeReusable used to Components store and manage XML documents Chapter 17native - Developing XML-Based Part IV - Oracle XML for C Developers

XMLType functions and SQL/XML functions operating on XMLType data in SQL

Chapter 18 - Getting Started with Oracle XML and C

Chapter 19 DB - Building an XML-Managed Application XML Repository and its protocols interfaces including the FTP, HTTP, and WebDAV interfaces on Chapter 20 - Build an XML Database OCI Application XMLTypes Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Text search on Developers XMLTypes Part VOracle - Oracle XML for C++ Chapter 22 - Getting Started with Oracle XML and C++

Oracle Advanced Queuing extensions for XMLTypes

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

XMLType

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

XMLType is the native data type for storing XML data in the Oracle database. It is similar to the DATE data type in that you can use it to define table columns or use it as parameters, return values, or variables in the PL/SQL Chapter 27 - Extending PL/SQL XML Functionality with Java procedures. Chapter 26 - Building PL/SQL Web Services Chapter 28 - Putting It All Together

Appendix XMLType -provides XML Standards a set ofBodies built-inand member Open Specifications functions that operate on XML content, enabling you to create an

XMLType instance from various resources, extract XML content, validate XML against XML Schemas, apply XSL Glossary transformations, and so on. Index List of Figures

Note The content stored in XMLType must be well-formed XML, or you will get an ORA-31011: XML parsing failed error. All the entity references in the XML document will be resolved to ensure it is well formed List of Sidebars during the data insertion into XMLTypes. List of Tables

The following example creates a product table called product with an XMLType column called description for storing the product descriptions: CREATE TABLE product( id VARCHAR(10), name VARCHAR2(100), description XMLType);


You insert sample data into this table using the following SQL: INSERT INTO product(id, name, description) VALUES('xdk', Developer''s Kit', Oracle 'XML Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XMLTYPE('<DESCRIPTION><KEYWORD>xdk</KEYWORD> is a set of ISBN:0072229527 by Mark V. Scardina, Ben Chang Jinyu standards-based utilities that and help toWang build XML applications. McGraw-Hill/Osborne © 2004 (600 pages) It contains XDK Java, C/C++ components.</DESCRIPTION>')); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

In this example, the XMLType() construction function used create an XMLType instance from a string input. emphasis on XML standards, their usage is and besttopractices. As previously discussed, you can process XML by creating the PL/SQL procedures taking XMLType as parameters, variables, or return types. To demonstrate this, you create a PL/SQL procedure, in which the descriptions of each Oracle Database 10g XML SQL—Design, Build & Manage Applications in Java, C, C++ & PL/SQL product are passed in as& an XMLType parameter calledXML p_desc. Using the UPDATEXML() SQL function, you Introduction update this product description by substituting all of the <KEYWORD> elements whose content equals p_id that are Part I - Oracle andp_name the XML Standards passed in by the parameter:

Table of Contents

Chapter 1

- Introducing XML

CREATE OR REPLACE FUNCTION MYTRANSFORM (p_desc IN XMLTYPE, - Accessing XML with DOM, SAX, JAXB, and StAX p_id IN VARCHAR2, p_name IN VARCHAR2) RETURN XMLTYPE AS Chapter 3 - Transforming v_result XMLType;XML with XSLT and XPath Chapter 4 Validating XML with DTDs and XML Schemas BEGIN Chapter 5 XML Operations with XQuery SELECT UPDATEXML(p_desc, Chapter 6 -'//KEYWORD[text()='''||p_id||''']/text()',p_name) XML Messaging and RPC with SOAP INTO v_result Chapter - Putting It All Together with XML Pipeline, JSPs, and XSQL FROM 7dual; Part II - Oracle XML Management for DBAs RETURN v_result; Chapter END MYTRANSFORM; 8 - Getting Started with the Oracle XML Database Chapter 2

Chapter 9

- Storing XML Data

After you created and the Retrieving PL/SQL procedure, you can run the following SQL command: Chapter 10 have - Generating XML SQL> set long 10000 Chapter 11 - Searching XML Data SQL> SELECT MYTRANSFORM(description, id, name) FROM product; Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

You will see the following output:

Chapter 13 - Getting Started with Oracle XML and Java

MYTRANSFORM(DESCRIPTION,ID,NAME) Chapter 14 - Building an XML-Powered Web Site ----------------------------------------------------------------------Chapter 15 - Creating a Portal Site with XML and Web Services <DESCRIPTION> <KEYWORD>XML Developer's Kit</KEYWORD> is a set of standards-based utilities that help to build XML applications. It Chapter 17 - Developing XML-Based Reusable Components contains XDK Java, C/C++ components.</DESCRIPTION> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building XML-Managed Application When storing XML inanXMLTypes, there are several storage options. Basically, you can create XMLTypes as: Chapter 20 - Build an XML Database OCI Application

XML XMLTypesHigh-Performance Stored under an Transformation object-relationalEngine structure specified by a registered XML Chapter 21 Schema–based - Create an XML-Configured you specify the storage options when creating the objects. Part Vschema - Oracleunless XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++

Non XML Schema–based XMLTypes Stored in CLOBs.

Chapter 23 - Build an XML Database OCI C++ Application

Chapter 24 Schema - Buildingdefines an XMLhow Data-Retrieval Application The XML to “shred” the content of an XML document and store it as a set of SQL objects. For Part VI - Oracle XMLregister for PL/SQL Developers example, you can an XML Schema as follows:

Chapter 25 - Getting Started with Oracle XML and PL/SQL

BEGIN

Chapter 26 - Building PL/SQL Web Services DBMS_XMLSCHEMA.registerSchema( Chapter 27 - Extending PL/SQL XML Functionality with Java SCHEMAURL=>'http://xmlns.oracle.com/xml/content.xsd', Chapter 28 - Putting It All Together SCHEMADOC=>'<?xml version="1.0" encoding="UTF-8"?> Appendix - XML Standards Bodies and Open Specifications <xs:schema Glossary xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> Index <xs:element name="DESCRIPTION">

mixed="true"> List of<xs:complexType Figures <xs:choice minOccurs="0" maxOccurs="unbounded"> List of Tables <xs:element name="KEYWORD" type= "xs:string" maxOccurs="unbounded"/> List of Sidebars </xs:choice> </xs:complexType> </xs:element> </xs:schema>', LOCAL=>TRUE, GENTYPES=>TRUE, GENTABLES=>FALSE); END;


In the Oracle XML database, each XML schema is registered under a unique URL so that XMLTypes can identify the XML schemas when referring to them. The preceding example uses the http://xmlns.oracle.com/xml/content.xsd Oracle Database 10g XML &URL. SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

During the XMLbySchema Oracle generates SQL objects to store XMLTypes that are complaint ISBN:0072229527 Mark V. registration, Scardina, Ben ChangXML and DB Jinyu Wang with the XML schema and, optionally, generates a default table. This example does not generate the default tables McGraw-Hill/Osborne © 2004 (600 pages) for the XMLTypes, we will discuss this later in “Oracle XML DB Repository” You can lookproducts, at the with This but comprehensive guide focuses onthe utilizing XML technologies within section. Oracle's XML-enabled objects generated using on theXML following SQL their commands: emphasis standards, usage and best practices. SQL> COLUMN object_name format a30 SQL>of COLUMN Table Contentsobject_type format a30 SQL> SELECT object_name, object_type FROM XML user_objects; Oracle Database 10g XML & SQL—Design, Build & Manage Applications in Java, C, C++ & PL/SQL Introduction

The objects created by the XML Schema registration are listed as follows:

Part I - Oracle and the XML Standards

OBJECT_NAME Chapter 1 - Introducing XML

OBJECT_TYPE ----------------------------------------------------------Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX DESCRIPTION163_T TYPE Chapter 3 - Transforming XML with XSLT and XPath KEYWORD164_COLL TYPE Chapter 4 - Validating XML with DTDs and XML Schemas PRODUCT TABLE Chapter 5 - XML Operations with XQuery SYS_LOB0000042735C00004$$ LOB Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part - Oracle XML Management forcreated DBAs for each complex type in the XML schema, such as the YouIIwill see the SQL object types

Chapter 8 - Getting Started with the Oracle XML Database DESCRIPTION163_T and KEYWORD164_COLL. You can use the desc command to show the details of the Chapter object types: 9 - Storing XML Data Chapter 10 - Generating and Retrieving XML SQL> desc DESCRIPTION163_T Chapter 11 - Searching XML DESCRIPTION163_T isData NOT FINAL Chapter Name 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers -----------------------------------------

Chapter SYS_XDBPD$ 13 - Getting Started with Oracle XML and Java

KEYWORD Chapter 14 - Building an XML-Powered Web Site

Null? Type -------- -----------------------XDB.XDB$RAW_LIST_T KEYWORD164_COLL

SQL> desc KEYWORD164_COLL Chapter 15 - Creating a Portal Site with XML and Web Services KEYWORD164_COLL OFwith VARCHAR2(4000) Chapter 16 - Developing VARRAY(2147483647) an XML Gateway Application SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

A VARRAY of VARCHAR2(4000) is created for elements such as<KEYWORD> where its occurrence is unbounded. By default, its size is 2147483647 bytes! Not only is the default size of VARRAY too large for storing Chapter 18 - Getting Started with Oracle XML and C XML documents, the extra SYS_XDBPD$ column created to preserve the DOM fidelity of XML content may not be Chapter 19 - Building an XML-Managed Application needed by your application. To customize these storage modes, you can annotate the XML schemas. How can you Chapter 20 - Build an XML Database OCI Application annotate the XML schema? What is the SYS_LOB0000042735C00004$$column? We will answer these kinds of Chapter 21 -storage–related Create an XML-Configured Transformation Engine XMLType questions inHigh-Performance Chapter 9. Part IV - Oracle XML for C Developers

Part V - Oracle XML for C++ Developers

Chapter By default, 22 - XMLTypes Getting Started are stored with Oracle in CLOBs XML and unless C++you associate a registered XML schema URL with the XMLType

columns XMLType object tables.OCI ForC++ example, in the previous product table, the description column is an Chapter 23or- Build an XML Database Application XMLType CLOB storage. Instead, you can define the column description as an XML Schema–based XMLType Chapter 24 -inBuilding an XML Data-Retrieval Application using registered http://xmlns.oracle.com/xml/content.xsd schema as follows: Part VI the - Oracle XML for PL/SQL Developers Chapter 25TABLE - Getting Started with Oracle XML and PL/SQL CREATE product( Chapter id VARCHAR(10), 26 - Building PL/SQL Web Services

name 27 VARCHAR2(100), Chapter - Extending PL/SQL XML Functionality with Java description Chapter 28 - PuttingXMLType) It All Together XMLType -COLUMN description Appendix XML Standards Bodies and Open Specifications XMLSCHEMA "http://xmlns.oracle.com/xml/content.xsd" Glossary ELEMENT "DESCRIPTION"; Index List of Figures

Thedescription column uses the structured storage of XMLType. The following example shows that when inserting the same XML data into XML Schema–based XMLType columns, you need to use the List of Sidebars XMLType.createSchemaBasedXML() function: List of Tables

INSERT INTO product(id, name, description) VALUES('xdk', 'XML Developer''s Kit', XMLTYPE('<DESCRIPTION> <KEYWORD>xdk</KEYWORD> is a set of standards-based utilities that helps to build<KEYWORD>XML</KEYWORD> applications. It contains XDK Java, C/C++ Components.</DESCRIPTION>').CreateSchemaBasedXML( 'http://xmlns.oracle.com/xml/content.xsd'));


Note If you do not specify the registered XML schema URL for XMLTypes using the XMLType.createSchemaBasedXML(), you will get the error - ORA-19007: Schema and element do not Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & match. PL/SQL ISBN:0072229527 by Mark V. Scardina,you Bencan Chang Wangmember functions to operate on the XML content. After XML is stored in XMLTypes, useand the Jinyu XMLType We McGraw-Hill/Osborne © 2004 (600 pages) will discuss this with more examples in Chapter 10. In this section, we just look at a simple example, which extracts Thisthe comprehensive guide focuses on The utilizing XML technologies within Oracle's XML-enabled products, XML nodes using XMLType.extract() function. following query extracts all <KEYWORD> elements in the with emphasis on XML standards, their usage and best practices. product description.

SQL> SELECT p.description.extract('//KEYWORD') FROM product p; Table of Contents P.DESCRIPTION.EXTRACT('//KEYWORD') Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL --------------------------------------------------------------------Introduction <KEYWORD>xdk</KEYWORD> Part I - Oracle and the XML Standards <KEYWORD>XML</KEYWORD>

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX XMLType Views Chapter 3 - Transforming XML with XSLT and XPath Chapter 4 -can Validating with DTDs and XML Schemas XMLType be usedXML to define views, called XMLType Views. For example, you can create an XMLType view Chapter 5 the - XML Operationstable within XQuery based on employees the HR user schema: Chapter 6

- XML Messaging and RPC with SOAP CREATE OR REPLACE VIEW employee_vw AS

Chapter 7 -XMLELEMENT("Employee", Putting It All Together with XML Pipeline, JSPs, and XSQL SELECT Part II - Oracle XML Management for DBAs XMLATTRIBUTES(employee_id

AS "empno"),

Chapter 8

- Getting Started with the Oraclelast_name, XML Database job_id))AS result XMLFOREST(first_name, Chapter - Storing XML Data FROM 9hr.employees; Chapter 10 - Generating and Retrieving XML

You may be familiar with the SQL/XML functions used in the example. Do not worry. We will discuss these in the Chapter 11not - Searching XML Data next section. Simply query the view, you will see the XML content that is returned: Chapter 12 - Managing the Oracle XML and Database Part III SELECT - Oracle XML for Java Developers SQL> * FROM employee_vw

WHERE ROWNUM<2;

Chapter RESULT 13 - Getting Started with Oracle XML and Java

---------------------------------------------------------------------------Chapter 14 - Building an XML-Powered Web Site <Employee empno="100"> Chapter 15 - Creating a Portal Site with XML and Web Services <FIRST_NAME>Steven</FIRST_NAME> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <LAST_NAME>King</LAST_NAME> Chapter 17 - Developing XML-Based Reusable Components Part<JOB_ID>AD_PRES</JOB_ID> IV - Oracle XML for C Developers

</Employee> Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

From this example, you can see that the XMLType view provides an option to wrap up existing object-relational data in XML, which then can be used for both Web publishing and data exchange. Additionally, XMLType views can Chapter 21an - Create an XML-Configured High-Performance Transformation Enginecontent navigation and updates. You serve as XML interface for XML-centric processing, such as XPath-based Part V - Oracle XML for C++ Developers can build XMLType views based on XML schemas. The major difference between these XML Schema–based Chapter 22 -views Getting withviews Oraclethat XMLare and C++ XMLType andStarted XMLType not based on XML schemas is that the XML Schema validation can Chapter 23 - Build an rich XML data-type Database constraints OCI C++ Application occur, which brings and XPath query optimization. Chapter 20 - Build an XML Database OCI Application

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

SQL/XML Processing

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter Building PL/SQL Web Services SQL is 26 the- standard for efficiently managing relational data. The XML extensions of SQL in Oracle XML Database Chapter 27 -operations Extending PL/SQL XMLlimited Functionality with Java allow SQL previously to relational data to operate on XML data as well. Table 8-2 outlines the Chapter - Putting It Togetherand Oracle extension support in Oracle Database 10g. overall 28 functionality ofAll SQL/XML Appendix

- XML Standards Bodies and Open Specifications

Glossary Table 8-2: Basic Functions for SQL XML Processing Index List of Figures List of Tables List of Sidebars


Type

Function

Description

Oracle SQL extensions Takes an XPath expression Oracle Database 10g XMLEXISTSNODE() & SQL: Design, Build & Manage XML Applications in Java, C,and C++ & PL/SQL returns true (1) if the XML ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang document contains the node McGraw-Hill/Osborne © 2004 (600 pages) specified by XPath. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with EXTRACT() Takes an XPath expression and emphasis on XML standards, their usage and best practices.

returns the node or node set that matches the XPath.

Table of Contents

EXTRACTVALUE() Takes an XPath expression and Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL returns the text of the XML nodes that match the XPath.

Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

UPDATEXML()

XMLCOLATTVAL()

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

SYS_XMLGEN()

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

XMLSEQUENCE()

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Takes an XPath expression and updates the XML nodes that match the XPath. Generates an XML fragment converting each passed column name to an attribute namevalue pair within a <column> element. Generates XML from SQL queries passed as parameters. Returns a sequence of XMLType using VARRAY of the top-level elements.

Chapter 13 - Getting Started with Oracle XML and Java

SQL/XML functionsan XML-Powered WebXMLELEMENT() Chapter 14 - Building Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C XMLATTRIBUTES() Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

Creates an XML element in XMLType by taking an element name, an optional collection of attributes for the element, and the element content. Used within XMLELEMENT() to specify attributes of that element.

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

XMLFOREST()

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

Converts each of its argument parameters to XML, and then returns an XML fragment that is the concatenation of these converted arguments.

Part VI - Oracle XML for PL/SQL Developers

XMLCONCAT() Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index

XMLAGG()

Takes as input a series of XMLType instances, concatenates the series of elements for each row, and returns the complete series. Aggregates XML fragments to build up an XML document.

List of Figures

By of using Oracle SQL extensions and the SQL/XML functions for XML processing, you can easily leverage the List Tables relational data model and XML data model in one SQL query. This gives you the maximum flexibility to solve List of Sidebars business problems. In the previous example, the SQL/XML functions are used to create XMLType views. We will use additional SQL operators and functions in later chapters, and discuss the technical details of how to use these SQL functions in Chapter 10.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle XML DB Repository PL/SQL

ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang Oracle XML DBbyRepository is a queryable, hierarchically organized repository, which is ideal for managing McGraw-Hill/Osborne © 2004in (600 pages) formats including XML. With this repository, you can document- or content-centric documents various

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Store and emphasis view XMLon content stored in XML as and a directory hierarchy of folders. XML standards, their DB usage best practices.

Use the hierarchical metaphors, such as XPath and URLs, to access XML documents and represent the

Table of Contents between documents. relationships

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

XML documents stored in the repository can be accessed through the protocol interfaces such as HTTP, WebDAV, Introduction andIFTP. In addition, you can access the repository from SQL and PL/SQL scripts using the two public views, Part - Oracle and the XML Standards RESOURCE_VIEW andXML PATH_VIEW. We will discuss the Oracle XML DB Repository in detail in Chapter 10 and Chapter 1 - Introducing the memoryand performance-tuning techniques for StAX the repository in Chapter 12. Chapter 2 - Accessing XML with DOM, SAX, JAXB, and Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle Text PL/SQL

ISBN:0072229527 by as Mark V. Scardina, Ben Chang Wang XML data stored XMLTypes in either CLOBsand or Jinyu XML Schema–based structured storage can be indexed by McGraw-Hill/Osborne 2004 (600 pages) Oracle Text. For example, to create©an Oracle Text index and query the product table, you can use the following code: This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices. CREATE INDEX desc_idx ON product(description) INDEXTYPE IS CTXSYS.CONTEXT Table of Contents PARAMETERS('section group ctxsys.path_section_group'); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Note You must have the CTXAPP role granted to create the Oracle Text indexes. Introduction Part I - Oracle and the XML Standards

Thereafter, you can use the CONTAINS() function in SQL queries to search the XML content as follows:

Chapter 1

- Introducing XML

SELECT name - Accessing XML with DOM, SAX, JAXB, and StAX FROM product Chapter 3 - Transforming XML with XSLT and XPath WHERE CONTAINS(description,'about(xml utilities)')>0; Chapter 2 Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 - XML Operations with XQuery Theabout() is provided in Oracle Text to allow semantic search. There are additional XML search capabilities. For Chapter 6 you - XML Messaging and RPC with SOAP example, can do the following: Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Use the ora.contains() function in XMLType.existsNode() for text searches within XPath-based searches. Part II - Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

Use the HASPATH() and INPATH() operators to optimize XML data searches within the content specified by the Chapter 9 - Storing XML Data XPath expressions. Chapter 10 - Generating and Retrieving XML

Chapter 11 - Searching XMLsearching Data Additionally, Oracle Text capabilities are integrated into XMLType by introducing the new CTXXPATH Chapter 12 - is Managing Oracle XML index. This detailedthe in Chapter 11, Database where we will also discuss how you can create various SQL indexes on Part III - Oracle XML Java indexes, Developers XMLTypes, such as for B*Tree bitmap indexes, and functional indexes to speed up queries on the XML

Chapter documents. 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Oracle Advanced Queuing

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter Oracle 17 Advanced - Developing Queuing XML-Based supports Reusable XMLType Components as a message type. In other words, users can enqueue and dequeue Part XMLIVmessages - Oracle XML from for and C Developers into XMLTypes. In later chapters, you will see examples using the XMLType message

queues18 and how to Started use XMLType functions for message processing. Chapter - Getting with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XML Database and Standards PL/SQL

ISBN:0072229527 byhave Markintroduced V. Scardina, Ben Chang and of Jinyu Wang At this point, we the broad extent Oracle XML support. Equally important is that its XML © 2004standards. (600 pages) These standards and the corresponding XML functionality are infrastructure isMcGraw-Hill/Osborne built on a family of open summarized inThis Table 8-3. comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

Table Table8-3: XML DB Standards and Functionality Table of Contents

Standard

Current Status

Oracle XML Functionality

Extensible Markup Language 1.0

XMLType DBMS_XMLPARSER (DOM Parser) XDK XML PARSERS (DOM and SAX Parser) in C, C++ and Java

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction XML 1.0

Part I - Oracle and the XML Standards W3C Recommendation Oct. 2000

www.w3.org/TR/REC-xml

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 - XML Operations with XQuery XML Namespaces XML Namespaces Chapter 6

- XML Messaging and RPC with SOAP www.w3.org/TR/REC-xml-names

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

XML Schema 1.0

XML Schema 1.0 W3C Recommendation May 2001 Chapter 8 - Getting Started with the Oracle XML Database www.w3.org/TR/xmlschema-0 Part II - Oracle XML Management for DBAs

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

XML Schema–based XMLType with XML DB XML Schema annotations; used as the basis for mapping XML to SQL data types DBMS_XMLSCHEMA XDK XML SCHEMA PROCESSORS in C, C++ and Java

Chapter 15 - Creating a Portal Site with XML and Web Services

DOM 16 1.0- &Developing 2.0 Document Object Level Chapter an XML Gateway Application withModel SOAP and AQ2

DBMS_XMLDOM XDK DOM Parser in C, C++ and Java

Chapter XML Transformation and C XSLT18 1.0- Getting Started with Oracle XSLT 1.0

XMLType.transform() DBMS_XSLPROCESSOR C/C++ XDK XSL Processor in C, C++ and Java

W3C Recommendation Jan. 2003 Chapter 17 - Developing XML-Based Reusable Components www.w3.org/TR/DOM-Level-2-HTML Part IV - Oracle XML for C Developers Chapter 19 - Building an XML-Managed W3C Application Recommendation Nov. 1999 Chapter 20 - Build an XML Database OCI www.w3.org/TR/xslt Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

XPath 1.0

XML Path Language 1.0 W3C Recommendation Nov. 1999 Chapter 23 - Build an XML Database OCI C++ Application www.w3.org/TR/xpath Chapter 22 - Getting Started with Oracle XML and C++

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures ListXQuery of Tables 1.0 List of Sidebars

SQL/XML

Used for hierarchical queries against XML documents: XMLType.extract() XMLTypes.extractValue() XMLType.existsNode() The selectNodes(),valueOf() and selectSingleNode() functions in: DBMS_XSLPROCESSOR XDK XML Parser in Java XDK XSL Processor in C

XML Query Language 1.0 W3C Working Draft, Nov. 2002 www.w3.org/TR/xquery/

Standard XML query interfaces independent from the storage model

XML-Related Specifications ISO-ANSI Working Draft www.sqlx.org

SQL/XML functions Oracle SQL extension functions for XML operations


WebDAV

HTTP 1.1

Web-based Distributed Authoring and WebDAV for Oracle XML Versioning DB Repository Oracle Database 10g IETF XML RFC & SQL: Design, Build & Manage XML Applications in Java, C, C++ & 2518 in 1999 PL/SQL http://asg.web.cmu.edu/rfc/rfc2518.html by Mark V. Scardina, Ben Chang and Jinyu Wang Transfer Protocol McGraw-Hill/Osborne ©Hypertext 2004 (600 pages)

ISBN:0072229527

WebDAV for Oracle XML www.w3.org/Protocols/rfc2616/ DBOracle's Repository This comprehensive guide focuses on utilizing XML technologies within XML-enabled products, with rfc2616.html DBURI Servlet emphasis on XML standards, their usage and best practices. XML DB Servlet

Table of Contents FTP

File Transfer Protocol

FTP for Oracle XML DB

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, Repository C, C++ & PL/SQL www.ietf.org/rfc/rfc959.txt Introduction Part I - Oracle and the XML Standards

We will1cover these features Chapter - Introducing XML in detail in later chapters. If you are not familiar with these standards, check out the associated in the Appendix. Chapter 2 - URLs Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & DesigningOracle the Database XML Database PL/SQL

V. Scardina, Ben Chang andOracle Jinyu Wang When you startbytoMark design XML applications using XML DB, you need to make several decisions, ISBN:0072229527 including McGraw-Hill/Osborne © 2004 how to store XML data in a database, what(600 is pages) the strategy to retrieve or generate XML, and how to create proper indexes for searching the content in the XML documents. thistechnologies section, we within will discuss some helpful approaches to This comprehensive guide focuses on utilizingInXML Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. these decisions.

How to Store XML Data

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

As you have learned, there are different ways to store XML documents inside an Oracle XML database, and each of Introduction them in both performance and functionality. From experience, we find that the design flow Part I -offers Oracledifferent and thetrade-offs XML Standards depicted 8-5 isXML helpful in simplifying the selections. Chapter 1 in- Figure Introducing Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database Application Figure 8-5: Decision flowchartOCI for C++ storing XML in Oracle XML DB Chapter 24 - Building an XML Data-Retrieval Application

By walking through thisPL/SQL flowchart, you can explore the design strategy for using different storage types. First, you Part VI - Oracle XML for Developers can start asking Started whetherwith you Oracle need to store documents in relational tables or as XMLType objects. This Chapter 25by - Getting XML andXML PL/SQL greatly 26 affects the application development Chapter - Building PL/SQL Web Services process, the technologies you use, and the performance of your application. Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

XMLType or Relational Tables? - XML Standards Bodies and Open Specifications

Appendix

Glossary This initial decision can generally be based on the format of the XML data and the DOM fidelity requirement on XML Index content. For format, the XML documents generally can be categorized as the data-centric or the document-centric List of Figures document. List of Tables

Data-centric List of SidebarsXML documents are characterized by the regular structure for the data, in which the smallest data unit is either an XML element with simple content or an XML attribute. In such XML document, there is little or no mixing content (i.e., tags within an XML element’s string content). Additionally, the DOM Fidelity for the document is not required to preserve. The following XML document is an example data-centric XML document: <?xml version="1.0"?> <purchaseOrder orderDate="1999-10-20"> <shipTo country="US">…</shipTo> <billTo country="US">…</billTo> <items>


<item partNum="872-AA"> <productName>Lawnmower</productName> <quantity>1</quantity> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <USPrice>148.95</USPrice> PL/SQL <comment>Confirm this electric</comment> ISBN:0072229527 by Mark V. Scardina, Benis Chang and Jinyu Wang </item> … McGraw-Hill/Osborne © 2004 (600 pages) </items>This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with </purchaseOrder> emphasis on XML standards, their usage and best practices. All the data in the above purchase order document are represented either as XML elements or as the attributes for

Table Contents XMLof elements.

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Most of the data-centric XML documents are created based on the relational data for exchanging and sharing data Introduction between applications. YouStandards can think of XML as the boxes used for moving things around. When relocating them to Part I - Oracle and the XML another1 place, you needXML to put items in boxes in order to protect them and organize them for easy delivery. Chapter - Introducing However, the items the destination, thereStAX is no need to keep them in the box. Chapter 2 -when Accessing XML reach with DOM, SAX, JAXB, and Chapter 3

- Transforming XML with XSLT and XPath

Likewise, for data-centric XML documents, there is no need to keep data in XML once it reaches the database. For - Validating XML with DTDs and XML Schemas a data-centric XML document, if XML elements and attributes are properly stored in relational table columns, it has Chapter 5 - XML Operations with XQuery the optimized storage for further processing, which avoids the overhead of keeping and managing the XML structure Chapter 6 - XML Messaging with in the database. Wheneverand youRPC need theSOAP data in XML for data exchange and Web publishing, you can build up Chapter 7 Putting It All Together with XML Pipeline, JSPs, and XSQL XMLType views to wrap up data in XML. Chapter 4

Part II - Oracle XML Management for DBAs

On the 8other hand, Started there are document-centric XML documents, which are characterized by less regular or irregular Chapter - Getting with the Oracle XML Database data structure with lots mixing content. For example, the following faq.xml is a document-centric XML document, Chapter 9 - Storing XMLof Data in which10the <ANSWER> element contains Chapter - Generating and Retrieving XML the mixing content of both text and <KEY> and <CODE> elements. Chapter <FAQ> 11 - Searching XML Data

<TITLE>What is wrong ifXML I got "ClassNotFoundException"? </TITLE> Chapter 12 - Managing the Oracle Database <ANSWER> IfXML you kind Part III - Oracle forget Java this Developers

of error, you need to check if the

<KEY>CLASSPATH</KEY> is Oracle correctly set. Chapter 13 - Getting Started with XML and Java Basically you need to add the following <KEY>jar files</KEY> in your Java CLASSPATH environment Chapter 14 - Building an XML-Powered Web Site variable: Chapter 15 - Creating a Portal Site with XML and Web Services <CODE> xmlparserv2.jar: XML Application Parser V2 for Java Chapter 16 - Developing an XML Gateway with SOAP and AQ xschema.jar: XML Schema Processor for Java xsu12.jar(xsu12.jar): XML SQL Utility for Java Part IV - Oracle XML for C Developers … Chapter 18 - Getting Started with Oracle XML and C </CODE> Chapter 19 - Building an XML-Managed Application </ANSWER> Chapter 20 - Build an XML Database OCI Application <CATEGORY>xdk</CATEGORY> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <LANGUAGE>java</LANGUAGE> Part V - Oracle XML for C++ Developers </FAQ> Chapter 17 - Developing XML-Based Reusable Components

Chapter 22 - Getting Started with Oracle XML and C++ Chapter - Build an XML Database OCI Application Dealing23 with the document-centric XMLC++ documents, you can store them in the native XMLTypes that well preserves Chapter the original 24 - XML Building dataanstructure. XML Data-Retrieval If there areApplication many queries on the XML content, the XML Schema–based XMLType is Part suggested VI - Oracle as itXML wellfor maintains PL/SQL the Developers XML structure in the database and provides high-performance data retrieval and

updates25using the XML metadata. Chapter - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

However, sometimes no clear line exists between these two categories. A document may be highly structured without mixed content, but still cannot be shredded into tables if it has some XML-specific information—such as Chapter 28 - Putting It All Together comments, processing instructions, and document order— that needs to be preserved. The following document Appendix - XML Standards Bodies and Open Specifications shows a variation of the previous purchase order that now contains processing instructions (PIs) in the XML content. Glossary To keep the information, such as namespace prefixes, processing instructions, and even the order of the elements, Index in the XML document, you can choose to use the native XMLType to preserve the DOM byte for byte. Chapter 27 - Extending PL/SQL XML Functionality with Java

List of Figures

<?xml version="1.0"?> <?dml name="Welcome"?> List of Sidebars <purchaseOrder orderDate="1999-10-20"> <shipTo country="US">…</shipTo> <?dml name="Welcome"?> <billTo country="US">…</billTo> <items> <item partNum="872-AA"> <productName>Lawnmower</productName> <quantity>1</quantity> List of Tables


<USPrice>148.95</USPrice> <comment>Confirm this is electric</comment> </item> Oracle … Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & </items> PL/SQL </purchaseOrder> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

In general, when selecting between relational and native XML storage, you need to ask yourself whether your This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with application really needs the full XML document preserved. Otherwise, you should leverage the database’s ability to emphasis on XML standards, their usage and best practices. generate XML from relational tables using XMLType views to void the overhead for preserving the XML markups, the whitespaces for XML indentations, and so on.

Table of Contents

Oracle Note that Database if you10g store XML XML & SQL—Design, in relational tables Build & but Manage construct XMLXML Applications interfaces in Java, with XMLType C, C++ & views PL/SQL that are deeply

nested, the data queries and operations with many table joins may degrade the performance. In this case, you Introduction should choose thethe native Part I - Oracle and XML XMLType Standardsdata type because it well preserves the hierarchical structure of the XML documents and thus optimizes the related XML queries or operations. Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 5

- XML Operations with XQuery

Finally, the native XML Schema–based XMLType storage binds the underlying database schema tightly to the XML Chapter 3 - Transforming XML with XSLT and XPath schemas. Currently, there are limitations on how much the schema can evolve before an export and import of the Chapter 4 - Validating XML with DTDs and XML Schemas data set would be needed. Chapter 6 - XML Messaging and RPC with XML Schema–Based Types or SOAP CLOB XMLTypes? Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part If you II -decide Oracleto XML useManagement XMLType, you for need DBAs to decide whether you want to store XML in CLOBs or use the XML

Schema–based XMLTypes by shredding XML content and storing it in a set of SQL objects. Chapter 8 - Getting Started with the Oraclethe XML Database Chapter 9

- Storing XML Data

If you store XML in CLOBs, you keep the document in the original format byte for byte and can use the XMLType functions and the SQL commands to update and query the XML data. This type of storage is optimum for DTDChapter 11 - Searching XML Data based documents and XML Schema–based documents where the schemas are changing or varied. Since the Chapter 12 - Managing the Oracle XML Database storage is not based upon the XML structure, documents of any size and hierarchical depth can be accommodated Part III - Oracle XML for Java Developers equally. However, since the XML data is not stored in a preparsed structure, it takes time to parse the documents Chapter 13 - Getting Started with Oracle XML and Java before accessing the XML content. If your application requires intensive data retrievals or updates on XML element Chapter 14 - Building XML-Powered Web Site or attributes, or you an want to extract the data out of XML documents for different use, you should not use the CLOB Chapter 15 - Creating a Portal Site with XML and Web Services storage. Chapter 10 - Generating and Retrieving XML

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

In the XML XMLTypes, the Components XML documents are shredded and stored as a set of SQL objects. The Chapter 17 - Schema–based Developing XML-Based Reusable XMLIVcontent validated and stored in a preparsed format. This storage is optimized in database for the fine-grained Part - OracleisXML for C Developers data queries and retrievals. Because kind Chapter 18 - Getting Started with Oraclethis XML andofCXMLType is stored using offsets based on its XML Schema, called XML Objects (XOBs), not materialized into the DOM tree until needed, it saves system resources. In addition, Chapter 19 - Building anand XML-Managed Application you have option to preserve theOCI byte-for-byte Chapter 20 the - Build an XML Database ApplicationDOM fidelity, such as the order of XML elements and attributes, the whitespace between elements and attributes, XML comments, XML PIs, namespace declarations, and so on. However, XML Schema–based XMLTypes have high cost for schema evolutions. Part V - Oracle XML for C++ Developers Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Chapter 22 Because - Getting Started with Oracle and to C++ Note extra information is XML needed preserve the DOM fidelity, you should avoid using it unless Chapter 23 necessary. - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

After all the storage Developers models for XML documents in the Oracle Database 10g database, Table 8-4 Part VIdiscussing - Oracle XML for PL/SQL compares threeStarted types ofwith XML storage the pros (+) and cons (-) based on the different application Chapter 25 -the Getting Oracle XMLand andshow PL/SQL design 26 considerations. Chapter - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

Table 8-4: of XML Storage Chapter 28 - Comparison Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Category Modeling

Relational Storage with XMLType Views

CLOB XMLType

Schema-Based XMLType

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL (+) Relational modeling (–) No data (–) No data by Mark V. Scardina, and Jinyu Wang withBen dataChang normalization normalization McGraw-Hill/Osborne © 2004 (600 storage pages) (+) Relational (+)Flexible storage

ISBN:0072229527 normalization (–) Limited XML that handles theon utilizing when XML Schemas Schema evolution products, with This comprehensive guide focuses XML technologies within Oracle's XML-enabled emphasis on XML schema standards, their usage practices. evolution well and best evolve or document support (+) No XML overhead size varies (+) Data reused by after data is stored (–) Document view of building up multiple Table of Contents in database the XML data prevents views on XML data Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL (+) Easy reuse of reuse as SQL data Introduction the data Part I - Oracle and the XML Standards

Chapter 1 - Introducing XML Loading Chapter 2

(–) Low throughput for

(+) Fast XML

Chapter 3

- Accessing XML with DOM, SAX, JAXB, and StAX uploading data uploading - Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Query

(+) High performance for SQL queries Chapter 5 - XML Operations with XQuery (–) Requires table joins Chapter 6 - XML Messaging and RPC with SOAP for XML queries

(–) Low throughput for data uploading

(–) Low performance for XPath queries with run-time DOM building and DOM tree Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL transversal.

(+) XPath queries are rewritten to SQL queries for highperformance data retrieval

XML fidelity DOM fidelity Chapter 8 - Getting Started with (+) the No Oracle XML Database

(+) Maintains the original XML byte for byte

(+) DOM fidelity as an option when setting the xdb:maintainDOM= “true”

Full support

Limited support

Part II - Oracle XML Management for DBAs

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle Full XMLsupport Database Data replication Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle and Java In summary, using the relational tables XML to create XMLType views or simply deliver XML encapsulated output using Chapter 14 -functions Building an XML-Powered Web Sitepackage, you have the normalized data storage with high-performance SQL/XML or the DBMS_XMLGEN Chapter 15 - Creating a Portal Site with XMLofand SQL queries. However, the DOM fidelity theWeb XMLServices documents is lost. Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

The CLOB bestXML-Based preservesReusable the original XML document and has the flexibility to handle XML Schema Chapter 17 - storage Developing Components evolution. However, theC run-time DOM building and DOM tree transversal slows down the SQL queries. Part IV - Oracle XML for Developers Chapter 18 - Getting Started with Oracle XML and C

The XML Schema–based XMLTypes store XML in Object-Relational tables preserving the XML document with high-

Chapter 19 - Building an XML-Managed Application performance SQL queries resulting from query rewrite support. However, it has limited support of XML schema

Chapter 20 and - Build an XML OCIsupport. Application evolution limited dataDatabase replications You should analyze your application requirements and pick the best Chapter - Create XML-Configured High-Performance Transformation Engine storage21 that meetsan your needs. Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ XMLType Object Tables or XMLType Columns? Chapter 23 - Build an XML Database OCI C++ Application

Creating table column or asApplication an object table is determined by whether you want to store relational data Chapter 24XMLType - Buildingas anaXML Data-Retrieval along the XML documents. If there is relational data associated with the XML documents, such as the Part VI with - Oracle XML for PL/SQL Developers document time and the of PL/SQL the XML document, you can create a set of columns in relational Chapter 25 -create Getting Started withcurrent Oracle owner XML and tables to store such information and use XMLType columns to store XML documents.

Chapter 26 - Building PL/SQL Web Services

Chapter - Extending PL/SQL XML Functionality Java On the 27 other hand, there are options on how towith create XMLType object tables. You can create an XMLType object Chapter 28 - the Putting It All Together table using “CREATE TABLE … OF XMLType” command or create the XMLType object table when registering Appendix - XMLtoStandards Bodies Specifications XML schemas the Oracle XML and DB. Open However, the latter option allows you to use the Oracle XML DB Repository to Glossary manage the XML documents. By looking at what the Oracle XML DB Repository offers and what you need or how Index you can take advantage of the functionality, you can decide how to create the XMLType object tables. List of Figures

Use Oracle XML DB Repository? List of Tables List of Sidebars

To use the Oracle XML DB Repository, you need to create XMLType tables by specifying the xdb:defaultTable attribute for the root element of the XML document in the XML schema. After you do so, Oracle XML DB will create XMLType Object tables when registering the XML schemas. Using XML DB Repository, you have the highperformance hierarchical document navigation and easy-to-use protocol interfaces for document management.

How to Retrieve and Generate XML After you decide how to store XML documents, you need to figure out how to build the indexes and views for


querying XML data, generating new XML based on the existing XML/non-XML data, and securing the XML data by controlling user access. We will discuss the details of these XML features in Chapter 11 and explore several solutions in theOracle application development chapters. Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang How to Search XML Data

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

In Oracle Database 10g, there are guide two ways to search XMLXML datatechnologies using the XPath-based queries: Oracle products, Text This comprehensive focuses on utilizing within Oracle's XML-enabled with on XML standards, theirthe usage andsearch best practices. searches usingemphasis the CONTAINS() function and XPath using the XMLType.existsNode() function. In Oracle Database 10g, you can produce efficient searches by creating the CTXXPATH index for the XMLType.existsNode() queries. We will discuss this in Chapter 11. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

How to Design XML Database for Web Applications

Introduction

Part I - Oracle and the XML Standards

XML is 1widely used in content Chapter - Introducing XML management and Web publishing systems. One of the reasons is that data in XML format 2can- be easily transformed using XSLT to and various Chapter Accessing XML with DOM, SAX, JAXB, StAXpresentation formats, such as HTML, WML (Wireless Markup3Language), SVG,XML or any publishing format that clients request. These kinds of applications Chapter - Transforming withother XSLTWeb and XPath normally the structure shown in and Figure Chapter 4 have - Validating XML with DTDs XML8-6. Schemas Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle Database Figure 8-6: XML-based webXML application architecture Part III - Oracle XML for Java Developers

Chapter 13 - of Getting Startedan with Oracle XML and Java In this type application, XML document can be stored in XML Schema–based XMLTypes so that you can Chapter extract 14 the- data Building for different an XML-Powered content-publishing Web Site purposes and uses the Oracle XML DB Repository for easy

document To reuse theXML XMLand data, XMLType Chapter 15 -management. Creating a Portal Site with Web Services views can be created, which provide “pretransformed” XML documents. Finally, are usually created forSOAP frequently executed queries to speed XML retrieval from the Chapter 16 - Developing anindexes XML Gateway Application with and AQ database. Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

How to Design XML Database for Messaging Application

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

XML is 20 widely used application where applications run on different platforms or are from different Chapter - Build an for XML Database integration OCI Application vendors21that need an to exchange the application data. Figure 8-7 illustrates the architecture of an example XML-based Chapter - Create XML-Configured High-Performance Transformation Engine messaging system. InC++ this kind of application, you should think about using precompiled XSLT or XMLType views to Part V - Oracle XML for Developers transform XML data intowith appropriate formats for the application receiving the XML messages. Chapter 22 -the Getting Started Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Figure 8-7: XML messaging application Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 by DB Mark V. Scardina, Ben Chang and Jinyu Wang The Oracle XML provides high-performance XML functionality seamlessly integrated with SQL. The standardsMcGraw-Hill/Osborne © 2004 (600 pages) based XML loading, update, query, and transform interfaces greatly simplify your working with XML. Additionally, the Oracle Database 10g database provides an extensible platform which the Oracle XDK XML-enabled can be usedproducts, to build with This comprehensive guide focuses on utilizing XML from technologies within Oracle's emphasis on XML standards, their and bestfor practices. your customized solutions. Oracle Database 10gusage is a platform building and deploying successful XML applications; however, you still need to follow some simple design steps to make best use of it. Now we are ready to showofyou the technical details of the Oracle XML DB functionality. Table Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 9: Storing XML Data PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

In Oracle Database 10g, you have a number of choices for storing XML data. You can shred the XML documents McGraw-Hill/Osborne © 2004 (600 pages) and store the data in one or more relational tables, put them intact in CLOB XMLTypes, or register an XML schema comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with and store themThis in an XML Schema–based XMLType with object-relational storage. If there is no requirement for emphasis on XML standards, their usage and best practices. updating the XML content, you can also store the XML documents externally by creating External Tables. Table This of chapter Contents gives an overview of the XML storage options available in Oracle Database 10g and shows you various

examples of how toXML use &the technologies. You& will also learn how to use in theJava, Oracle utilities including the Oracle Database 10g SQL—Design, Build Manage XML Applications C, C++ & PL/SQL SQL*Loader and XML SQL Utility (XSU) to load XML documents into either XMLType tables or relational tables in Introduction Oracle Database We Standards start with the simplest storage format: the CLOB XMLTypes. Part I - Oracle and 10g. the XML Chapter 1

- Introducing XML

XML with DOM, SAX, and StAX Storing- Accessing XML Documents inJAXB, CLOB XMLTypes

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

Using the XMLType, XMLDTDs documents stored as CLOBs with a set of XML interfaces provided by the Chapter 4 -CLOB Validating XML with and XMLare Schemas XMLType. you can with optionally carry out any XML processing during the data ingestion, such as validating the Chapter 5 -Though XML Operations XQuery input XML an XML and schema or a DTD, Chapter 6 -against XML Messaging RPC with SOAP the CLOB XMLType storage does not require any XML processing except well-formedness checking and entity resolution. - Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 7

Part II - Oracle XML Management for DBAs

Updating - Getting and Started Querying with the Oracle CLOB XML Database XMLTypes

Chapter 8 Chapter 9

- Storing XML Data

The CLOB best preserves the original format of XML documents and gives the maximum flexibility Chapter 10 - XMLType Generatingstorage and Retrieving XML for XML schema evolution. However, storing XML documents in CLOB XMLTypes results in expensive processing overhead when querying the XML content, such as using the XMLType.Extract()orXMLType.ExistsNode() Chapter 12 - Managing the Oracle XML Database functions, because these operations require building an XML DOM tree in memory at run time and performing Part III - Oracle XML for Java Developers functional XPath evaluations. In addition, any update operation can be performed only at the document level. This Chapter 13 - Getting Started with Oracle XML and Java means that you need to update the entire XML document for even a small change to one XML element. Therefore, Chapter 14 - Building an XML-Powered Web Site normally you should avoid using XMLType functions to perform fine-grained XML updates or XPath-based queries Chapter 15 - Creating a Portal Site with XML and Web Services on CLOB XMLTypes. Chapter 11 - Searching XML Data

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter Instead, 17for - Developing XPath-based XML-Based queries on Reusable CLOB XMLTypes, Components Oracle Text provides a full text search supporting a limited Part set IV of XPaths. - Oracle This XML for functionality C Developers allows you to perform XPath queries on CLOB XMLTypes utilizing the CONTEXT

index created by Oracle Text, and it has proven Chapter 18 - Getting Started with Oracle XML and Cvery useful and scalable for enterprise applications, which we will discuss19 in -Chapter Chapter Building11. an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

Dealing with Character Encoding for CLOB XMLTypes

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

When storing XML documents the Oracle database, you should know that a character set conversion is Chapter 22 - Getting Started withinOracle XML and C++ automatically performed data insertions, which converts all the text data, including XML documents, to the Chapter 23 - Build an XML during Database OCI C++ Application database except when stored as BLOB, NCHAR, or NCLOB data types. Chapter 24 character - Building set, an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Because of this implicit character set conversion, the actual XML data encoding and the encoding declaration in the <?XML?> prolog may not be the same. In the current Oracle Database 10g release, XMLType APIs ignore the Chapter 26 - Building PL/SQL Web Services encoding declaration in the <?XML?> prolog and assume that XML data in CLOB XMLTypes is stored in the Chapter 27 - Extending PL/SQL XML Functionality with Java database character set. Therefore, when loading XML data from the client side, you need to make sure this Chapter 28 - is Putting It All Together conversion properly performed. Chapter 25 - Getting Started with Oracle XML and PL/SQL

Appendix

- XML Standards Bodies and Open Specifications

To ensure proper conversion from the client character set to the database character set, you are required to set up Glossary the NLS_LANG environment variable to reflect the client character set encoding if the XML document is originally Index stored in a client character set that is different from the database character set. Otherwise, if the variable is set to be List of Figures theofsame as the database character set, the original text will be stored as-is in the database without character List Tables validation and conversion. List of Sidebars In other words, if the NLS_LANG environment variable is not set or is set incorrectly and the XML document does not have the same encoding as the database, garbage data will be stored in the database. Note If the XML document contains characters that are invalid in the database character set, you will get an Invalid Character error during the data insertions to CLOB XMLTypes. The current solution for this is to use the NCLOB or BLOB for data storage in the database and build mid-tier XML applications or PL/SQL external procedures using the XDK APIs to process the XML data.


Because the character set conversion may result in conflict between the actual encoding and the encoding declaration in the <?XML?> prolog, when reading the XML data out of CLOB XMLTypes, you must do the reverse character set conversion or update the encoding in the prolog to make them consistent. Oracle Database 10g XML & SQL:declaration Design, Build & <?XML?> Manage XML Applications in Java, C, C++This & is important because although an XML parser can use the first 4 bytes of the <?XML?> prolog to detect the PL/SQL encoding of XML it canBen determine onlyJinyu whether the character encoding is an ASCII-based encoding or ISBN:0072229527 by documents, Mark V. Scardina, Chang and Wang EBCDIC encoding. If it is an ASCII-based encoding, McGraw-Hill/Osborne © 2004 (600 pages) an XML parser can detect only whether it is UTF-8 or UTF-16. Otherwise, it depends on the encoding inutilizing <?XML?>. if you have XML XML-enabled documents not in UTF-8 This comprehensive guideattributes focuses on XML Therefore, technologies within Oracle's products, with or UTF-16 encoding, you on must include a correct encoding emphasis XML standards, theirXML usage and bestdeclaration practices. indicating which character encoding is in use, as follows: <?xml version="1.0" encoding='Shift-JIS'?> Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML SQL: Design, Build & ManageXMLTypes XML Applications in Java, C, C++ & Storing XML Documents in &XML Schema–based PL/SQL

ISBN:0072229527 by XPath Mark V. Scardina, Chang and Jinyu Wang To speed up the queries andBen fine-grained updates on XMLTypes, you can create XML Schema–based XMLTypes. One McGraw-Hill/Osborne © 2004 (600with pages) this is to associate registered XML schemas the XMLType columns or XMLType tables using XMLSCHEMA. You can als XMLType tables bycomprehensive specifying the DEFAULT TABLE annotation in the registered XML schemas. This guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

All these approaches create XML Schema–based XMLTypes, where sets of object-relational tables/objects are bound to the X defined in the XML schema. The only difference between creating a default table during XML schema registration and using th Table of Contents XMLSCHEMA keyword is that the former approach allows XML documents conforming to the registered XML schema to be m Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Oracle XML DB repository. With the support of the XML DB repository, you can not only retrieve or update XML in SQL, but al Introduction XML documents stored in the XML DB repository using protocol interfaces such as FTP and HTTP/WebDAV. Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

XML Schema - Accessing Registration XML with DOM, SAX, JAXB, and StAX

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

XML schema registration defines the XML-to-SQL mapping and a hierarchical object-relational structure for storing XML docum - Validating XML with DTDs and XML Schemas Oracle database. We will explore this using the DEMO user and the WebDAV folder created in Chapter 8.

Chapter 4 Chapter 5

- XML Operations with XQuery

Chapter 6 need - XMLto Messaging with SOAP First, you copy the and XMLRPC schema for customer records, contact_simple.xsd, into the /public WebDAV folder. The fol Chapter content7of -this Putting schema: It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

Chapter 8 - Gettingname="Customer" Started with the Oracle XML Database <xsd:element type="CustomerType"/> Chapter 9 - Storing XML Data <xsd:complexType name="CustomerType"> Chapter 10 - Generating and Retrieving XML <xsd:sequence> Chapter <xsd:element 11 - Searching XML name="NAME" Data type="xsd:string"/>

<xsd:element name="EMAIL" type="xsd:string"/> Chapter 12 - Managing the Oracle XML Database <xsd:element Part III - Oracle XML forname="ADDRESS" Java Developers

type="xsd:string"/>

<xsd:element name="PHONE" type="phoneType"/> Chapter 13 - Getting Started with Oracle XML and Java <xsd:element type="contentType"/> Chapter 14 - Building an name="DESCRIPTION" XML-Powered Web Site </xsd:sequence> Chapter 15 - Creating a Portal Site with XML and Web Services </xsd:complexType> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <xsd:complexType name="ContentType" mixed="true"> <xsd:sequence> Part IV - Oracle XML for C Developers <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/> Chapter 18 - Getting Started with Oracle XML and C </xsd:sequence> Chapter 19 - Building an XML-Managed Application </xsd:complexType> Chapter 20 - Build an XML Database OCI Application <xsd:simpleType name="phoneType"> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <xsd:restriction base="xsd:string"> Part V - Oracle XML for C++ Developers <xsd:pattern value="\(\d{3}\)\d{3}-\d{4}"/> Chapter 22 - Getting Started with Oracle XML and C++ </xsd:restriction> Chapter 23 - Build an XML Database OCI C++ Application </xsd:simpleType> Chapter 24 - Building an XML Data-Retrieval Application </xsd:schema> Chapter 17 - Developing XML-Based Reusable Components

Part VI - Oracle XML for PL/SQL Developers

To register XMLStarted schema to Oracle the XML DB, you can call the following PL/SQL procedure: Chapter 25 - this Getting with XML and PL/SQL Chapter - BuildingSET PL/SQL Web Services trace name context forever'; ALTER 26 SESSION EVENTS='31098 Chapter 27 Extending PL/SQL XML Functionality with Java BEGIN Chapter DBMS_XMLSCHEMA.registerURI( 28 - Putting It All Together Appendix'http://localhost:8080/public/contact_simple.xsd', - XML Standards Bodies and Open Specifications Glossary'/public/contact_simple.xsd',

LOCAL=>TRUE, GENTYPES=>TRUE, GENBEAN=>FALSE, GENTABLES=>TRUE); END; List of Figures Index

List of Tables

Note To use the ALTER SESSION command, you need to log in as SYS and grant the ALTER SESSION privilege to the using “GRANT ALTER SESSION TO DEMO”. Otherwise, you will get an ORA-01031: Insufficient Privileges error.

List of Sidebars

In the DBMS_XMLSCHEMA.registerURI() function, the first parameter is the schema URI, http://localhost:8080/public/contact_simple.xsd, which uniquely identifies the registered XML schema in the XML DB. The parameter is an XML DB URI (XDBUri), /public/contact_simple.xsd, pointing to the contact_simple.xsd file in the /public fo DB repository. The following parameters control whether the XML schema is registered as a local (LOCAL=>TRUE) or global (LOCAL=>FALSE) schema, whether object types (GENTYPES=>TRUE) and default tables (GENTABLES=>TRUE) will be cre GENBEAN parameter is optional and does not perform any function at this time. If the XML schema is registered as a global X the XML DB, it can be shared across different database users. Otherwise, XML schema sharing is not allowed.


You can set GENTABLES=>FALSE if you do not want Oracle XML DB to create default tables during the XML schema registr case, you can create XMLType tables using the XMLSCHEMA keyword, as in: Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

CREATE TABLE customer_xmltype_tbl OF XMLTYPE PL/SQL XMLSCHEMA "http://localhost:8080/public/contact_simple.xsd" by Mark V. Scardina, Ben Chang and Jinyu Wang ELEMENT "Customer"; McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses utilizing XML technologies within Oracle's XML-enabled products, with Additionally, you can use the following syntax to on define XMLType columns using XML Schema–based storage: emphasis on XML standards, their usage and best practices.

CREATE TABLE customer_col_tbl( id NUMBER, Table of Contents record XMLType) Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XMLTYPE COLUMN record STORE AS OBJECT RELATIONAL Introduction XMLSCHEMA "http://localhost:8080/public/contact_simple.xsd" Part I - Oracle"Customer"; and the XML Standards ELEMENT Chapter 1

- Introducing XML

Chapter Since the 2 same - Accessing storage XML techniques with DOM,apply SAX, to JAXB, bothand XMLType StAX tables and XMLType columns, we will discuss only the details of h

Schema-based XMLTypeXML tables inXSLT later and sections. Chapter 3 - Transforming with XPath Chapter 4

- Validating XML with DTDs and XML Schemas

During XML schema registration, you can use the following command to create a trace file in the USER_DUMP_DIR showing - XML Operations with XQuery to create the object tables and datatypes:

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP ALTER EVENTS='31098' TRACEJSPs, NAME FOREVER; Chapter 7 SESSION - Putting ItSET All Together with XML Pipeline, andCONTEXT XSQL Part II - Oracle XML Management for DBAs

To locate the trace file, you need to check the current session ID by querying the V$SESSION and V$PROCESS views. Befo - Getting Started with the Oracle XML Database from the V$SESSION and V$PROCESS views in the DEMO user, you need to log in as SYS and grant to the DEMO user the Chapter 9 - Storing XML Data privilege on V_$SESSION and V_$PROCESS views, as follows: Chapter 8

Chapter 10 - Generating and Retrieving XML

$ZðÀáäïæææR„cÝd

Chapter 11 - Searching XML Data Chapter 12 Since - Managing the Oracle XML Database are just synonyms for the views, you cannot grant any privileges on them. Note V$SESSION and V$PROCESS Part III - Oracle XML for Java Developers

By issuing following SQL command, youand canJava find the ID of the session corresponding to the trace file: Chapter 13 -the Getting Started with Oracle XML Chapter 14a.spid - Building an XML-Powered Web Site SELECT Chapter 15 - Creating a, a Portal Site with XML FROM V$PROCESS V$SESSION b and Web Services Chapter WHERE 16 a.addr=b.paddr - Developing an XML Gateway Application with SOAP and AQ

AND b.audsid=userenv('sessionid'); Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

This returns the following: Chapter 18 - Getting Started with Oracle XML and C SPID 19 - Building an XML-Managed Application Chapter -----------Chapter 20 - Build an XML Database OCI Application 2796 21 - Create an XML-Configured High-Performance Transformation Engine Chapter Part V - Oracle XML for C++ Developers

The trace file has a name structured as orclX_ora_<Session_Id>.trc, and you can get the USER_DUMP_DIR by issuing the command in a SYS user account:

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application

SQL> SHOW PARAMETERS user_dump_dest NAME TYPE VALUE Part VI - Oracle XML for PL/SQL Developers ----------------------------------------------------------Chapter 25 - Getting Started with Oracle XML and PL/SQL user_dump_dest string D:\ORACLE\ADMIN\ORCLX\UDUMP Chapter 24 - Building an XML Data-Retrieval Application

Chapter 26 - Building PL/SQL Web Services

Chapter 27 trace - Extending PL/SQL XML Functionality Java Thus, the file is orclX_ora_2796.trc, in thewith USER_DUMP_DIR verified by running the following: Chapter 28 - Putting It All Together

SQL> host ls d:\oracle\admin\orclX\udump\orclX_ora_2796.trc - XML Standards Bodies and Open Specifications orclX_ora_2796.trc

Appendix Glossary Index

List Because of Figures this file lists the set of DDLs used to create the object table and data types, it is a good reference when debugging X

registrations. List of Tables List of Sidebars

Now, let’s examine the created storage structure in more detail by issuing the following command in SQL*Plus: SQL> SELECT object_name, object_type 2 FROM USER_OBJECTS 3 WHERE object_name LIKE '%Customer%'; OBJECT_NAME OBJECT_TYPE ------------------------- -------------------Customer260_TAB TABLE Customer260_TAB$xd TRIGGER


CustomerType259_T

TYPE

The result shows that three objects were created during the XML schema registration. If you further examine the types and the Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & definitions, youPL/SQL will see that the objects created are not limited to these. First, you can describe the Customer260_TAB table SQL> DESC "Customer260_TAB"; by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

This results in the following:

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Name Type emphasis on XML standards, their usage and Null? best practices. ----------------------------------------- -------- ------------------------TABLE of SYS.XMLTYPE(XMLSchema "http://localhost:8080/public/contact_simple.xsd" Element " Table of Contents Customer") STORAGE Object-relational TYPE "CustomerType259_T" Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Part INote - Oracle theelement XML Standards If anand XML uses mixed case or lowercase, the default table and object names by default will be case sensitiv

Chapter 1 you - Introducing XMLdouble quotes when referring these names, as in “Customer260_TAB”. need to use Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX

The preceding descriptionXML shows Chapter 3 - Transforming withthat: XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Customer260_TAB is an XMLType table.

Chapter 6 XMLType - XML Messaging RPC with SOAP The objects and in the table are associated with the registered XML schema, http://localhost:8080/public/contact Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

The root element of the XMLfor document is <Customer>. Part II - Oracle XML Management DBAs Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

The object type used to store the XMLTypes is CustomerType259_T.

Chapter Generating andof Retrieving XML Looking10at-the description CustomerType259_T, you can see that this type contains Chapter 11 - Searching XML Data

SQL> DESC "CustomerType259_T"

Chapter 12 - Managing the Oracle "CustomerType259_T" is XML NOT Database FINAL Part III - Oracle XML for Java Developers

Name

Null?

Type

Chapter 13 - Getting Started with Oracle XML and Java ------------------------------------------------ -----------------------Chapter 14 - Building an XML-Powered Web Site SYS_XDBPD$ XDB.XDB$RAW_LIST_T Chapter NAME 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ EMAIL Chapter ADDRESS 17 - Developing XML-Based Reusable Components Part PHONE IV - Oracle XML for C Developers

DESCRIPTION Chapter 18 - Getting Started with Oracle XML and C

VARCHAR2(4000 CHAR) VARCHAR2(4000 CHAR) VARCHAR2(4000 CHAR) VARCHAR2(4000 CHAR) contentType257_T

Chapter 19 - Building an XML-Managed Application

All the XML elements in XMLTypes are mapped to the corresponding database data types. In this example, the NAME, EMAIL and PHONE elements as simple types in the XML schema are stored as VARCHAR2. Since there is no limit on the string leng Chapter 21 - Create an XML-Configured High-Performance Transformation Engine schema, Oracle XML DB sets 4000 characters as the default length for these columns. On the other hand, new object types a Part V - Oracle XML for C++ Developers the complex types defined in the XML schema. In this example, contentType257_T is created to store the customer descriptio Chapter 22 - Getting Started with Oracle XML and C++ further shown as follows: Chapter 20 - Build an XML Database OCI Application

Chapter 23 - Build an XML Database OCI C++ Application

SQL> DESC "contentType257_T"; "contentType257_T" is NOT FINAL Part VI - Oracle XML for PL/SQL Developers Name Null? Type Chapter 25 - Getting Started with Oracle XML and PL/SQL ----------------------------------------- -------- -----------------------Chapter 26 - Building PL/SQL Web Services SYS_XDBPD$ XDB.XDB$RAW_LIST_T Chapter 27 - Extending PL/SQL XML Functionality with Java SYS_XDBANY258$ VARCHAR2(4000 CHAR) Chapter 24 - Building an XML Data-Retrieval Application

Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Note that Oracle XML DB defines the SYS_XDBANY258$ column as a VARCHAR2 (4000) to store the <xsd:any/> element d

Index <DESCRIPTION> element. The SYS_XDBPD$ column is a position descriptor column created by the XML DB to preserve the

of XML documents. Information, such as comments, processing instructions, namespace prefixes, and the order of sibling XM List of Figures stored in this SYS_XDBPD$ column. Therefore, this column is used to preserve the integrity of the original XML document for List of Tables transversals. List of Sidebars To examine further details of the Customer260_TAB table, you can query the USER_TAB_COLS view: SQL> SELECT column_name,data_type, 2 CASE WHEN hidden_column='YES' THEN 'hidden' 3 WHEN virtual_column='YES' THEN 'virtual' 4 ELSE null END as attr 5 FROM USER_TAB_COLS 6 WHERE table_name='Customer260_TAB'


7

ORDER by virtual_column desc, column_name;

COLUMN_NAMEOracle Database DATA_TYPE ATTR 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & -------------------------------------------- ------PL/SQL SYS_NC_ROWINFO$ XMLTYPE ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang virtual XMLDATA CustomerType259_T hidden McGraw-Hill/Osborne © 2004 (600 pages) ACLOID RAW hidden This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with OWNERID RAW emphasis on XML standards, their usage and best hidden practices. SYS_NC00007$ RAW hidden SYS_NC00014$ RAW hidden Table of Contents SYS_NC_OID$ RAW hidden Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL SYS_NC00009$ VARCHAR2 hidden Introduction SYS_NC00010$ VARCHAR2 hidden Part I - Oracle and the XML Standards SYS_NC00011$ VARCHAR2 hidden Chapter 1 - Introducing XML VARCHAR2 SYS_NC00012$ hidden Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX SYS_NC00016$ VARCHAR2 hidden Chapter 3 - Transforming XMLXDB$RAW_LIST_T with XSLT and XPath SYS_NC00008$ hidden Chapter 4 - Validating XML with DTDs and XML Schemas SYS_NC00015$ XDB$RAW_LIST_T hidden Chapter 5 - XML Operations with XQuery XMLEXTRA XMLTYPEEXTRA hidden Chapter SYS_NC00004$ 6 - XML Messaging and XMLTYPEPI RPC with SOAP hidden SYS_NC00005$ XMLTYPEPI hidden Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL SYS_NC00013$ contentType257_T hidden Part II - Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

Note that the CASE expression selects a result from one or more alternatives. It uses an optional SELECTOR, to specify an e Chapter 9 - Storing XML Data whose value determines which alternative to return. A normal CASE expression has the following form: Chapter 10 - Generating and Retrieving XML

CASE selector Chapter 11 - Searching XML Data WHEN THENXML result1 Chapter 12 -expression1 Managing the Oracle Database WHEN expression2 THEN result2 Part III - Oracle XML for Java Developers ... WHEN expressionN THEN resultN Chapter 14 - Building an XML-Powered Web Site [ELSE resultN+1] Chapter 15 - Creating a Portal Site with XML and Web Services END; Chapter 13 - Getting Started with Oracle XML and Java

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 17 query, - Developing XML-Based Reusable Components From the you can see that the Customer260_TAB table contains one virtual column called SYS_NC_ROWINFO$ and Part IV - Oracle XML XMLDATA, for C Developers columns, including ACLOID, OWNERID, XMLEXTRA and a set of $SYS_NC<number>$ columns.

Chapter 18 - Getting Started with Oracle XML and C

The virtual is an XMLType object that identifies the rows of the XMLType table. For example, Chapter 19 - column, Building SYS_NC_ROWINFO$, an XML-Managed Application of XMLType tables, use :new.SYS_NC_ROWINFO$ to refer to the current row of data. Chapter 20 - Build an you XML can Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

The XMLDATA column refers to the SQL objects used for storing the XMLTypes. It is useful when you want to query or create XMLTypes by directly working on the SQL objects. In the preceding example, XMLDATA is an alias for the CustomerType259 Chapter 22 - Getting Started with Oracle XML and C++ Therefore, you can add a unique constraint on the EMAIL element by referring to it as XMLDATA.EMAIL, as follows: Part V - Oracle XML for C++ Developers

Chapter 23 - Build an XML Database OCI C++ Application

ALTER TABLE Customer260_TAB ADD UNIQUE(XMLDATA.EMAIL);

Chapter 24 - Building an XML Data-Retrieval Application

Part - Oracle XML for PL/SQL TheVI XMLDATA.EMAIL refers toDevelopers the object storing the content of the EMAIL elements in the customer records. With the UNIQ

Chapter - Getting Started with Oracle XML and PL/SQL added, 25 if you try to insert the same customer record multiple times, you get the following error: Chapter 26 - Building PL/SQL Web Services

ORA-00001: unique constraint (DEMO.SYS_C003626) violated

Chapter 27 - Extending PL/SQL XML Functionality with Java

Chapter 28the - Putting All Together Some of hiddenItcolumns in Customer260_TAB are for Oracle XML DB repository use. For example, in Oracle XML DB re

Appendix - XML List Standards Specifications Access Control (ACL) Bodies definesand the Open permissions for each resource. The ACLOID specifies the ACL permissions for the XML Glossary the OWNERID specifies the ID of the table owner. The other hidden columns are used to create the hierarchical relationships

elements. Index List of Figures

Except for XMLDATA and SYS_NC_ROWINFO$, you should never access or manipulate these XMLType table columns direc

List of Tables

List of Sidebars

XML Schema Annotations

To control the mapping between XMLType storage and XML schemas, you need to use Oracle XML DB annotations. In Oracle 10g, these XML Schema annotations are a set of attributes added to an XML schema declaring the SQL object names, data ty various storage options. All of these annotations are in the Oracle XML DB namespace, http://xmlns.oracle.com/xdb, norma xdbprefix. Basically, you can use these annotations to specify the following: DefaultTable The name and storage attributes of the default XMLType table storing the XML documents.


SQLNames The SQL names for the XML elements defined in the XML schema.

SQLTypes The names of the SQL data types used to store simple or complex data types defined in the XML schema. Fo Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & unboundedPL/SQL XML element mapping to a collection SQL type, xdb:SQLCollType is used to specify the type name. ISBN:0072229527 by Mark Scardina, Ben Chang andXML Jinyu Wang MaintainDOM TheV.attribute that tells Oracle DB whether to preserve DOM fidelity of the element on output.

McGraw-Hill/Osborne © 2004 (600 pages)

Storage Options The XML DB annotations, as xdb:storeVarrayAsTable, xdb:mapUnboundedStringToLob, This comprehensive guide focuses onsuch utilizing XML technologies within Oracle's XML-enabled products, with emphasis onand XMLxdb:SQLInline, standards, theirspecify usage and practices. xdb:maintainOrder, the best options for optimizing storage.

Let’s examine the following annotated XML schema for the customer records, customer_simple_ann.xsd, explore some usefu techniques, and then register it to the XML DB.

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" Introduction xmlns:xdb="http://xmlns.oracle.com/xdb" Part I - Oracle and the XML Standards

xdb:storeVarrayAsTable="true"> <xsd:element name="Customer" type="CustomerType" Chapter 1 - Introducing XML xdb:defaultTable="CUSTOMER"/> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <xsd:complexType name="CustomerType" xdb:maintainDOM="false"> Chapter 3 - Transforming XML with XSLT and XPath <xsd:sequence> Chapter 4 - Validating XML with DTDs and XML Schemas <xsd:element name="NAME" type="xsd:string" Chapter 5 - XML Operations with XQuery xdb:SQLName="NAME" xdb:SQLType="VARCHAR2"/> Chapter 6 - XML Messaging and RPC withtype="xsd:string" SOAP <xsd:element name="EMAIL" Chapter 7xdb:SQLName="EMAIL" - Putting It All Together with XML Pipeline, JSPs, and XSQL xdb:SQLType="VARCHAR2"/> Part II Oracle XML Management for DBAs <xsd:element name="ADDRESS" type="xsd:string" maxOccurs="unbounded" Chapter 8xdb:SQLName="ADDRESS" - Getting Started with the Oracle XML Database xdb:SQLCollType="ADDRESS_TYPE" Chapter 9 xdb:SQLType="VARCHAR2" - Storing XML Data xbd:maintainOrder="false"/> Chapter 10 - Generatingname="PHONE" and Retrieving XML <xsd:element type="phoneType" xdb:SQLName="PHONE"/> Chapter <xsd:element 11 - Searching name="DESCRIPTION" XML Data type="contentType"/> </xsd:sequence> Chapter 12 - Managing the Oracle XML Database </xsd:complexType> Part III - Oracle XML for Java Developers <xsd:complexType name="contentType" mixed="true" Chapter 13 - Getting Started with Oracle XML and Java xdb:maintainDOM="true"> Chapter 14xdb:SQLType="CLOB" - Building an XML-Powered Web Site <xsd:sequence> Chapter 15 - Creating a Portal Site with XML and Web Services <xsd:any minOccurs="0" maxOccurs="unbounded" Chapter 16 - Developing an XML Gateway Application with SOAP andprocessContents="skip"/> AQ </xsd:sequence> Chapter 17 - Developing XML-Based Reusable Components </xsd:complexType> Part IV - Oracle XML for C Developers <xsd:simpleType name="phoneType"> Chapter 18 - Getting Started with Oracle XML and C <xsd:restriction base="xsd:string"> Chapter 19 - Building an XML-Managed Application <xsd:pattern value="\(\d{3}\)\d{3}-\d{4}"/> Chapter 20 - Build an XML Database OCI Application </xsd:restriction> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine </xsd:simpleType> Part V - Oracle XML for C++ Developers </xsd:schema> Chapter 22 - Getting Started with Oracle XML and C++

Chapter Build an XML Database Application Looking23at-the preceding example, OCI the C++ first thing to do when annotating the XML schema is to include the Oracle XML DB nam

declaration, in the <schema> element. This namespace prefix is then used to q Chapter 24 - xmlns:xdb=“http://xmlns.oracle.com/xdb”, Building an XML Data-Retrieval Application Part Oracle VI -XML Oracle DBXML annotations. for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Next,xdb:storeVarrayAsTable=“true” is a global XML DB annotation, which tells the XML DB to store all the VARRAY eleme object tables. This annotation helps to speed up the queries on XML elements that are defined with maxOccurs > 1. For exam Chapter 27 - Extending PL/SQL XML Functionality with Java customer_simple_ann.xsd, this annotation affects the storage of the <ADDRESS> elements. Chapter 26 - Building PL/SQL Web Services Chapter 28 - Putting It All Together

Appendix Standards andDB Open Specifications In addition,- XML you can specifyBodies an XML annotation xdb:mapUnboundedStringToLob=“true” in the <schema> element to m

Glossary strings to CLOB and unbounded binary data to BLOB with out-of-line table storage. By default, it is set to be false so that all u

Index strings defined in the XML schema map to VARCHAR2(4000) and unbounded binary data maps to RAW(2000) with inline tabl

List Since of Figures inline table storage does not efficiently store large XML documents, you should set xdb:mapUnboundedStringToLob= List of Tables

For all the global complex and simple types, you can define the following XML DB annotations to specify the corresponding SQ data types:

List of Sidebars

xdb:SQLType Specifies the SQL type mapped to the XML schema type definition. You can use this annotation to avoid h DB generate names for the SQL data types.

xdb:maintainDOM Specifies whether the complex type should maintain DOM fidelity. Normally, you should set this to fals the XML DB by default will add the SYS_XDBPD$ attribute (position descriptor) to each created object type to preserve in as comments, processing instructions, and the sibling element orders in XML, and thus increases the storage overhead. F avoid maintaining the DOM fidelity in the customer records, xdb:maintainDOM=“false” is set on CustomerType.


Note xdb:SQLName is not allowed on the complexType or simpleType definitions. Otherwise, you will get the followin 30937: No schema definition for ‘SQLName’ (namespace ‘http://xmlns.oracle.com/xdb’) in parent ‘complexType’ Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

PL/SQL For the root element of the XML document, you should specify the xdb:defaultTable attribute and optionally use xdb:tablePro ISBN:0072229527 table attributes:by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

xdb:defaultTable Specifies the name of theontable into XML which XML instances ofOracle's this schema should be stored. with It establishe This comprehensive guide focuses utilizing technologies within XML-enabled products, emphasis onrepository XML standards, their usagetable and best practices. between the XML DB and this default so that any insertion, update, or deletion of the XML documents con XML schema in the XML DB repository will have the corresponding changes in the default table, and vice versa. In the ex customer table will be created as the default table. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

xdb:tableProps Specifies the default table properties in SQL syntax that is appended to the CREATE TABLE clause.

Introduction

Part - Oracle and the XML For Iall XML elements, you Standards should specify the element names and the element type if the type they are based on is not among

Chapter 1 - Introducing XML types defined in the XML schema that have already been annotated. The following lists the XML DB annotations for the XML e Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

xdb:SQLName Specifies the name of the SQL object that maps to the XML element. Chapter 3 - Transforming XML with XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

xdb:SQLType Specifies the name of the SQL type corresponding to the XML element.

Chapter 6 - XML Messaging andwhether RPC withOracle SOAP XML DB should generate a new object table and define XMLType REFs to store xdb:SQLInline Specifies

Chapter elements. 7 - Putting The It default All Together setting with is true, XMLwhich Pipeline, specifies JSPs, and not XSQL to define REFs. The true setting of this annotation affects all the

Part II elements - Oracle declared XML Management in the XML forschema DBAs and the XML element with maxOccurs > 1. You need to set this to false for out-of-

This give better performance by avoiding table locks. Chapter 8 will - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

xdb:SQLCollType Specifies the name of the SQL collection type corresponding to the XML element that has maxOccurs example, in the <ADDRESS> element, the xdb:SQLCollType=“ADDRESS_TYPE” is added. By default, the collection will Chapter 11 - Searching XML Data VARRAY. Because xdb:storeVarrayAsTable=“true” is set, the storage of the VARRAY is a Ordered Collections in Table Chapter 12 - Managing the Oracle XML Database instead of LOBs (default). This is useful when you want to create constrains on the element. Chapter 10 - Generating and Retrieving XML

Part III - Oracle XML for Java Developers

Chapter Getting Started with Oracle XML and Java Instead13 of -covering all the possible annotations, we listed the most frequently used XML DB annotations. In summary, you sho Chapter 14points - Building an XML-Powered WebXML Site schemas. following in mind when annotating Chapter 15 - Creating a Portal Site with XML and Web Services

First, you specify name of theApplication default table and a SQL name for each XML element and da Chapter 16 should - Developing anthe XML Gateway withusing SOAPxdb:defaultTable and AQ XML schema using xdb:SQLName, xdb:SQLCollType, or xdb:SQLType. You should notice that, in the example:

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

xdb:SQLName defines the SQL names for the XML elements

Chapter 18 - Getting Started with Oracle XML and C

Chapter xdb:SQLCollType 19 - Building an XML-Managed defines the SQL Application names only for the XML elements with maxOccurs>1. Chapter 20 - Build an XML Database OCI Application

xdb:SQLType defines the SQL names for all the complexTypes or the simpleTypes that do not use the default mapping p Oracle XML DB. Part V - Oracle XML for C++ Developers Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Chapter 22 -the Getting XML and annotations C++ Specifying SQLStarted names with usingOracle XML schema is useful because the system-generated names are not easy to rem

Chapter - Build an XML Database Application should 23 also consider specifying all OCI SQLC++ names capitalized to eliminate case-sensitive names in the database, which require us Chapter - Building anto XML quotes 24 when referring theData-Retrieval SQL objects. Application For example, without capitalization, you have to use “Customer260_TAB” versus Part VI - Oracle XML for PL/SQL Developers CUSTOMER260_TAB to refer to the default table storing the customer records.

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Note XML elements andServices types, if no xdb:SQLName, xdb:SQLType, or xdb:SQLCollType is specified, Oracle XML Chapter 26 For - Building PL/SQL Web

of thePL/SQL element or data type to create the SQL name. Because XML is case sensitive, the SQL name will be ca Chapter 27 name - Extending XML Functionality with Java

you use quotes around it for all references. These annotations are also useful if the XML element or type Chapter 28 requiring - Putting It Allto Together Appendix

or has a name conflict in the XML schema. - XML Standards Bodies and Open Specifications

Glossary Next, you should define the storage minimizing any extra data storage, such as avoid preserving DOM fidelity. It is also useful Index trees or complex types as CLOBs by setting the xdb:SQLTypes =“CLOB” when no XPath-based queries on the content are List of Figures Oracle XML DB will not shred this XML data, thus saving time and resources. List of Tables

Finally, when working with small but unbounded XML elements you should store the content as VARRAYs by setting the List of Sidebars

xdb:storeVarrayAsTable=“false”. For large unbounded XML elements, you can instead use nested tables by specifying the xdb:storeVarrayAsTables=“true” in the <schema> element or even use nested tables by setting xdb:maintainOrder=“fals element for better performance.

XML Data Loading After you have defined the XMLType storage, you can load data into XMLType tables by using SQL, the protocol APIs, or the utility.


Using SQL Command

Oracle Database 10ginto XML & SQL: Design, & Manage XMLSQL Applications Java, & The simplest way to load XML data XMLType tables is Build through the INSERT command,insuch asC,inC++ the following exam PL/SQL

INSERT INTO customer VALUES(XMLType('<Customer> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <NAME>Steve Joes</NAME> McGraw-Hill/Osborne © 2004 (600 pages) <EMAIL>Steve.Joes@example.com</EMAIL> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <ADDRESS>Someroad, Somecity, Redwood Shores, CA 94065, U.S.A</ADDRESS> emphasis on XML standards, their usage and best practices. <PHONE>6505723456</PHONE> <DESCRIPTION>Very Important US Customer</DESCRIPTION> Table of Contents </Customer>').CreateSchemaBasedXML( Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL 'http://localhost:8080/public/contact_simple_ann.xsd')); Introduction

Using approach, construct the XMLType instance from XML in VARCHAR2, CLOB, or BFILE and optionally use t Part I - this Oracle and the you XMLcan Standards XMLType.CreateSchemaBasedXML() function to refer to a registered XML schema. Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 5

- XML Operations with XQuery

Without the XMLType.CreateSchemaBasedXML()function, you can insert XML into XML schema-based XMLTypes by includi Chapter 3 - Transforming XML with XSLT and XPath Schema reference in the root element of the XML document using the XML schema location attributes, including the xsi:sche Chapter 4 - Validating XML with DTDs and XML Schemas xsi:noNamespaceSchemaLocation attribute: INSERT INTO customer - XML Messaging and RPC with SOAP values(XMLType('<Customer xmlns:xsi="http://www.w3.org/2001/XMLSchema Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL -instance" xsi:noNamespaceSchemaLocation="http://localhost:8080/public/ Part II - Oracle XML Management for DBAs contact_simple_ann.xsd"> Chapter 8 - Getting Started with the Oracle XML Database <NAME>Steve Joes</NAME> Chapter 9 - Storing XML Data <EMAIL>Steve.Joes@example.com</EMAIL> Chapter 10 - Generating and Retrieving XML Redwood Shores, CA 94065, U.S.A</ADDRESS> <ADDRESS>Someroad, Somecity, Chapter 11 Searching XML Data <PHONE>6505723456</PHONE> Chapter 12 - Managing the Oracle XML Database <DESCRIPTION>Very Important US Customer</DESCRIPTION> Part III Oracle XML for Java Developers </Customer>')); Chapter 6

Chapter 13 - Getting Started with Oracle XML and Java

Thexmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” attribute declares the namespace for the XML Schema ins Chapter 14 - Building an XML-Powered Web Site

xsi:noNamespaceSchemaLocation= “http://localhost:8080/public/contact_simple_ann.xsd” attribute specifies the regis Chapter 15 - Creating a Portal Site with XML and Web Services

schema16URL. In this example, since theApplication XML document doesn’t Chapter - Developing an XML Gateway with SOAP andhave AQ a namespace, xsi:noNamespaceSchemaLocation is u XML document contains a namespace, for example, the XML schema of the XML document defines a target namespace as Chapter 17 - Developing XML-Based Reusable Components

targetNamespace=“http://www.example.com/customer”, you need to use the xsi:schemaLocation attribute as follows: Part IV - Oracle XML for C Developers

xsi:schemaLocation= http://localhost:8080/public/contact_simp Chapter 18 - Getting Started "http://www.example.com/customer with Oracle XML and C Chapter 19 - Building an XML-Managed Application

The attribute contains the targetNamespace,http://www.example.com/customer, and the URL of the XML schema, http://localhost:8080/public/contact_simple_ann.xsd.

Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Using Oracle XML DB Repository Interfaces

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 DB - Build an XMLprovides Databaseprotocol OCI C++ Application The XML repository interfaces, including FTP and WebDAV/HTTP interfaces, to insert XML and other ty

Chapter 24 - Building an XMLinData-Retrieval Application documents. As discussed Chapter 8, you can create a WebDAV folder and use it to copy or edit XML files in the XML DB re

Part VIanother - Oracledirectory XML for PL/SQL were on your Developers disk. When using the protocol interfaces, the XML document must have the XML schema locat

Chapter to ensure 25 that - Getting the data Started is inserted with Oracle into the XMLdefault and PL/SQL tables created during the XML schema registration. The following example u

interface insert a customer record to the default customer table after registering the contact_simple_ann.xsd to the XML Chapter 26to - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java D:\>ftp Chapter 28 - Putting It All Together ftp> open localhost 2100 Appendix Connected - XML to Standards [Machine_Name] Bodies and 220 Open[Machine_Name].FTP Specifications Server (Oracle XML

DB/Oracle Database 10g Enterprise Edition Release X.X.X.X.X) ready. Glossary User ([Machine_Name]:(none)): demo Index 331 pass required for DEMO List of Figures Password: List of Tables 230 DEMO logged in List of Sidebars ftp> cd public 250 CWD Command successful ftp> put customer1.xml 200 PORT Command successful 150 ASCII Data Connection 226 ASCII Transfer Complete ftp: 444 bytes sent in 0.00Seconds 444000.00Kbytes/sec. ftp> ls customer1.xml


200 PORT Command successful 150 ASCII Data Connection customer1.xml Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & 226 ASCII Transfer Complete PL/SQL ftp: 15 bytes received in 0.00Seconds 15000.00Kbytes/sec. ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang ftp>bye McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

After the operations, the new customer record is inserted into both the XML DB repository in /public directory and the default emphasis on XML standards, their usage and best practices. table. In addition to the two records inserted using SQL, there are now three records in the customer table: SQL> SELECT count(1) FROM customer; COUNT(1) Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL ---------Introduction 3

Table of Contents

Part I - Oracle and the XML Standards

Chapter - Introducing We will1discuss the XMLXML DB repository features in the “Oracle XML DB Repository” section. For now, you just need to know th

Chapter 2 - Accessing XML DB withrepository DOM, SAX, and StAXthe XML document, the new customer record will always be inserted i what directory in the XML is JAXB, used to store Chapter 3 -table Transforming with XSLT XPath XMLType as long asXML it refers to theand corresponding URL of the registered XML schema. Chapter 4

- Validating XML with DTDs and XML Schemas

Using5 SQL*Loader Chapter - XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP

SQL*Loader has been the predominant tool for loading data into the Oracle databases. In Oracle Database 10g, SQL*Loader - Putting It All Together with XML Pipeline, JSPs, and XSQL loading XML data into XMLType columns or XMLType tables independent of the underlying storage. In other words, you can u Part II - Oracle XML Management for DBAs method to load XML data to CLOBs or object-relational XMLTypes. Additionally, SQL*Loader allows XML data to be loaded us Chapter 8 - Getting Started with the Oracle XML Database conventional and direct path methods. The conventional path is the default mode that uses SQL to load data into Oracle datab Chapter 9 - Storing XML Data direct path mode bypasses SQL and streams the data directly into the Oracle database files. Chapter 7

Chapter 10 - Generating and Retrieving XML

Chapter - Searching XML Data To load11 XML data using SQL*Loader, you need a control file describing the input data and the target table or table columns. F

Chapter insert two 12 -customer Managingrecords the Oracle as inXML customer3.xml Database and customer4.xml into the customer table, you can create a control file a Part following: III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java LOAD DATA Chapter 14*- Building an XML-Powered Web Site INFILE Chapter 15 - Creating a Portal Site with XML and Web Services INTO TABLE customer Chapter APPEND 16 - Developing an XML Gateway Application with SOAP and AQ

XMLType(XMLDATA)( Chapter 17 - Developing XML-Based Reusable Components lobfn FILLER TERMINATED Part IV - Oracle XMLCHAR for C Developers

BY ',',

XMLDATA BYC EOF Chapter 18 -LOBFILE(lobfn) Getting Started withTERMINATED Oracle XML and ) Chapter 19 - Building an XML-Managed Application BEGINDATA Chapter 20 - Build an XML Database OCI Application xml/customer3.xml, Chapter 21 - Create an XML-Configured High-Performance Transformation Engine xml/customer4.xml Part V - Oracle XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++

The control file tells SQL*Loader to load data (LOAD DATA) by appending (APPEND) the new data contained within the contr *) to the customer table (INTO TABLE customer). XMLType(XMLDATA) refers to new data as XMLType. Since this is an app Chapter 24 -itBuilding an XML Data-Retrieval Application operation, means that SQL*Loader will load the new data without overwriting the old customer records. If you use REPLACE Part VI Oracle XML for PL/SQL Developers old customer records will be deleted before new data is inserted. Chapter 23 - Build an XML Database OCI C++ Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Thelobfn a FILLER In SQL*Loader, FILLER fields are used to collect the data from the inputs. In other words Chapter 26 operator - BuildingisPL/SQL Webfield. Services

fields are mapped PL/SQL to any table columns; instead they are used to skip or select data from the input data. In this example, lo Chapter 27 not - Extending XML Functionality with Java get the28 names of the XML documents after BEGIN DATA and the names are delimitated by comas (TERMINATED BY ‘,’). Th Chapter - Putting It All Together data in the- files delimitated by and the end-of-file (EOF). Appendix XML are Standards Bodies Open Specifications Glossary

After the control file is created, you can set the $ORACLE_HOME\bin directory in your PATH environment and run the followi invoke the SQL*Loader command-line utility sqlldr:

Index

List of Figures

D:\>sqlldr userid=demo/demo control=customerLoad.ctl SQL*Loader: Release X on Thu Jun 26 22:26:53 2003 List of Sidebars (c) Copyright 2001 Oracle Corporation. All rights reserved. Commit point reached - logical record count 2 List of Tables

Theuserid specifies the username and password for the database user who owns the customer table. The control option sp filename for the control file. The result shows that two logical records are recognized by SQL*Loader. The further logging infor sqlldr can be find in the <control_file_name>.log file. You can specify direct=yif you want to use the direct path mode to loa data. Compared to the conventional path mode, the direct path mode is faster because it bypasses the SQL layer and streams the Oracle database files without invoking any triggers or constraint checking.


XML Schema Validation

During XML loading orDatabase after content on theDesign, XML Schema–based XMLTypes, Oracle XML DB simply checks to see if t Oracle 10gupdates XML & SQL: Build & Manage XML Applications in Java, C, C++ & PL/SQL augmented with object checks instead of performing a full XML Schema validation. In other words, O document is well-formed performs only limited by Mark checks V. Scardina, to make Ben sure Chang the and XMLJinyu document Wang conforms to the object-relational storage. ISBN:0072229527 For example, the XML whether the <PHONE> McGraw-Hill/Osborne element exists © 2004 before (600 pages) inserting the customer records. It will not stop the data insertion when the phone violate the string pattern defined inguide the XML schema. This comprehensive focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

To void invalid data that could be inserted into XMLTypes, you need to explicitly call for XML Schema validation. The simplest is to set up a TRIGGER before the INSERT actions as follows:

Table of Contents

CREATE OR REPLACE TRIGGER customer_insert Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL AFTER INSERT ON customer FOR EACH ROW Part I - Oracle and the XML Standards DECLARE Chapter 1 - Introducing XML doc XMLType; Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX BEGIN Chapter 3 - Transforming XML with XSLT and XPath doc := :new.SYS_NC_ROWINFO$; Chapter 4 - Validating XML with DTDs and XML Schemas XMLType.schemaValidate(doc); Chapter 5 - XML Operations with XQuery END; Introduction

Chapter 6

- XML Messaging and RPC with SOAP

Chapter After the 7 trigger - Putting is created, It All Together full validation with XML is Pipeline, performed JSPs, when andyou XSQL insert sample data into the customer table: Part II - Oracle Management for DBAs INSERT INTOXML customer VALUES(

Chapter 8 - Getting Started with the Oracle XML Database XMLType('<CUSTOMER xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Chapter 9 - Storing XML Data xsi:noNamespaceSchemaLocation="http://localhost:8080/public/ Chapter 10 - Generating and Retrieving XML contact_simple_ann.xsd"> Chapter <NAME>Steve 11 - Searching Joes</NAME> XML Data

<EMAIL>Steve.Joes@example.com</EMAIL> Chapter 12 - Managing the Oracle XML Database Part<ADDRESS>Someroad, III - Oracle XML for Java Somecity, Developers

Redwood Shores, CA 94065, U.S.A</ADDRESS>

<PHONE>6505723456</PHONE> Chapter 13 - Getting Started with Oracle XML and Java <DESCRIPTION>Very Important Customer</DESCRIPTION> Chapter 14 - Building an XML-Powered WebUS Site </CUSTOMER>')); Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Thus this example returns the following errors:

Chapter 17 - Developing XML-Based Reusable Components

INSERT INTOXML customer Part IV - Oracle for C Developers * ERROR at line 1: Chapter 19 - Building an XML-Managed Application ORA-31154: invalid XML document Chapter 20 - Build an XML Database OCI Application ORA-19202: Error occurred in XML processing Chapter 21 - Create an XML-Configured High-Performance Transformation Engine LSX-00333: literal "6505723456" is not valid with respect to the pattern Part V - Oracle XML for C++ Developers ORA-06512: at "SYS.XMLTYPE", line 333 Chapter 22 - Getting Started with Oracle XML and C++ ORA-06512: at "DEMO.CUSTOMER_INSERT", line 5 Chapter 23 - Build an XML Database OCI C++ Application ORA-04088: error during execution of trigger 'DEMO.CUSTOMER_INSERT' Chapter 18 - Getting Started with Oracle XML and C

Chapter 24 - Building an XML Data-Retrieval Application

Part VI - see, Oracle formessage PL/SQL Developers As you theXML error states that the phone number does not follow the string pattern defined in the XML schema. Af

Chapter updated 25the - Getting phone Started number,with youOracle can tryXML again: and PL/SQL Chapter 26 - Building PL/SQL Web Services SQL> INSERT INTO customer VALUES( Chapter 27 - Extending PL/SQL XML Functionality with Java XMLType('<Customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Chapter 28 - Putting It All Together xsi:noNamespaceSchemaLocation="http://localhost:8080/public/ Appendix contact_simple_ann.xsd"> - XML Standards Bodies and Open Specifications

<NAME>Steve Joes</NAME> Glossary <EMAIL>Steve.Joes@example.com</EMAIL> Index Somecity, Redwood Shores, CA 94065, U.S.A List<ADDRESS>Someroad, of Figures List</ADDRESS> of Tables List<PHONE>(650)572-3456</PHONE> of Sidebars

<DESCRIPTION>Very Important US Customer</DESCRIPTION> </CUSTOMER>'));

The new valid customer record is inserted. You can check the XML Schema validation status of an XMLType object using eith XMLType.isSchemaValid() function or the XMLType.isSchemaValidated() function: SQL> SELECT x.isSchemaValid() FROM customer x; X.ISSCHEMAVALID() -----------------


1 0 ...0 Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

The preceding result shows that, so far, there is only one record in the table and it is valid against the XML schema. The recor ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang previously do not have a valid status. This is because the XMLType.schemaValidate() function validates the XMLType objec McGraw-Hill/Osborne © 2004 (600 pages) the validation status of XMLType objects in the XML DB. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices. Note Turning on full validation will have a significant negative effect on INSERT performance, thus should be used only if usually better to do validation checks at the time of document creation or in the middle tier. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Oracle XML DB Repository

Introduction

Part I - Oracle andRepository the XML Standards Oracle XML DB can function as a file system in the Oracle database. Any data in the Oracle XML DB Repository m

Chapter - Introducing XML resouce1 which has a pathname (or a URL) and is stored either in a BLOB or an XMLType object. The XML DB repository prov Chapter 2 - Accessing with DOM, SAX, JAXB, and StAX management facilitiesXML for these content resources. Chapter 3

- Transforming XML with XSLT and XPath

You have howXML to load the protocol interfaces of the XML DB repository. In this section, we will discuss ot Chapter 4 -learned Validating withXML DTDsthrough and XML Schemas

such as applying version control to documents and creating links, and managing resources. We will also discuss the major PL - XML Operations with XQuery that support this functionality:

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7 - Puttingprovides It All Together with Pipeline, JSPs, and XSQL DBMS_XDB functions forXML resource and session management of the XML DB repository. It also provides function Part II - Oracle XML Management for DBAs the hierarchical indexes.

Chapter 8

- Getting Started with the Oracle XML Database

DBMS_XDB_VERSION Chapter 9 - Storing XML Data provides functions for the version control of the resources. Chapter 10 - Generating and Retrieving XML

Resource Management Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database

In Oracle Database 10g, you can use the DBMS_XDB package to create and delete resources, folders, and links for the resou also use this package to lock/unlock resources when reading or updating XML data:

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

DECLARE res BOOLEAN; Chapter 15 - Creating a Portal Site with XML and Web Services xr REF XMLType; Chapter 16 - Developing an XML Gateway Application with SOAP and AQ x XMLType; Chapter 17 - Developing XML-Based Reusable Components BEGIN Part IV - Oracle XML for C Developers FOR po_rec IN (SELECT rownum id, ref(p) xref FROM customer p Chapter 18 - Getting with Oracle XML and C ORDER BY Started rowid) Chapter 19 Building an XML-Managed Application LOOP Chapter 20 Build an XML Database OCI Application res:=DBMS_XDB.createResource('/public/customer'||po_rec.id|| Chapter 21 Create an XML-Configured High-Performance Transformation Engine '.xml', po_rec.xref); PartEND V - Oracle XML for C++ Developers LOOP; Chapter END; 22 - Getting Started with Oracle XML and C++ Chapter 14 - Building an XML-Powered Web Site

Chapter 23 - Build an XML Database OCI C++ Application

In this example, all ofanthe customer recordsApplication are read out of the customer table, and XML resource documents are created in t Chapter 24 - Building XML Data-Retrieval directory of theXML XMLfor DBPL/SQL repository using the DBMS_XDB.createResource () function.You can additionally create a Part VI - Oracle Developers /public/important_customer in XML the XML DB repository as follows: Chapter 25 - Getting Started withfolder Oracle and PL/SQL DECLARE Chapter 26 - Building PL/SQL Web Services retb Chapter 27 -BOOLEAN; Extending PL/SQL XML Functionality with Java BEGIN 28 - Putting It All Together Chapter retb -:= Appendix XMLDBMS_XDB.createFolder('/public/important_customer'); Standards Bodies and Open Specifications COMMIT; END; Index / Glossary

List of Figures

List of Tables Then, you can create a resource such as README.txt to explain the content in this folder: List of Sidebars

DECLARE res BOOLEAN; BEGIN res := DBMS_XDB.createResource('/public/important_customer/README.txt', 'This folder lists all of the US customer who are important to our business'); COMMIT;


END; / Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Since you already have a set of customers listed in the /public directory, you can create a set of links instead of creating a sec ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang the data: McGraw-Hill/Osborne © 2004 (600 pages)

EXEC DBMS_XDB.link('/public/customer1.xml', This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with '/public/important_customer/','SteveJones.xml'); emphasis on XML standards, their usage and best practices. If you want to delete a resource, you can use the DBMS_XDB. DeleteResource() function, as follows:

Table of Contents

DBMS_XDB.DeleteResource('/public/important_customer/SteveJones.xml'); DBMS_XDB.DeleteResource ('/public/customer1.xml');

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Part - Oracle and the XML Standards YouI can delete a resource with resources linking to it. However, after the original resource is removed, all the linked resoruces

Chapter 1 - Introducing XML references. Each of them instead will hold a copy of the data. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 -Control Transforming XML with XSLT and XPath Version Chapter 4

- Validating XML with DTDs and XML Schemas

The DBMS_XDB_VERSION andXQuery DBMS_XDB PL/SQL packages implement Oracle XML DB versioning functions, which provid Chapter 5 - XML Operations with create and different versions of SOAP a Version-Controlled Resource (VCR) in Oracle XML DB. Chapter 6 - manage XML Messaging and RPC with Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL When an XML DB resource is turned into a VCR, a flag is set to mark it as a VCR and the current resource becomes the initai version is not physically stored in the database. In other words, there is no extra copy of this resource stored when it is version Chapter 8 - Getting Started with the Oracle XML Database Subsequent versions are stored in the same tables. Since the version resource is a system-generated resource, it does not ha Chapter 9 - But Storing Dataaccess the resource via the functions provided in the DBMS_XDB_VERSION package. pathname. you XML can still Part II - Oracle XML Management for DBAs

Chapter 10 - Generating and Retrieving XML

When the is XML checked Chapter 11 -resource Searching Data out, no other user can make updates to it. When the resource is updated the first time, a copy

is created. can make several changes to the resource without checking it back in. You will always get the latest copy of th Chapter 12 - You Managing the Oracle XML Database

even are XML a different user. When a resource is checked back in, the original version that was checked out is placed into h Part IIIif -you Oracle for Java Developers version13 storage. Chapter - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

The versioning properties for the VCR are maintained within the XML DB repository. In this release, versioning only works for n based resources. Thus XMLTypes based upon shredded XML documents or XMLType CLOBs that have schemas attached a Chapter 16 -toDeveloping anHowever, XML Gateway Application withas SOAP supported use VCRs. we have found that longand as AQ you do not create unique meta-data associated with a partic Chapter 17 Developing XML-Based Reusable Components such as an index, VCRs will work. Chapter 15 - Creating a Portal Site with XML and Web Services

Part IV - Oracle XML for C Developers

Note cannot switch a VCR back a non-VCR. Chapter 18 You - Getting Started with Oracle XMLtoand C Chapter 19 - Building an XML-Managed Application

Oracle XML DB provides functions to keep track of all changes on Oracle XML DB VCRs. The following code demonstrates th

Chapter 20 - Build an XML Database OCI Application

DECLARE Chapter 21 - Create an XML-Configured High-Performance Transformation Engine resid DBMS_XDB_VERSION.RESID_TYPE; Part V - Oracle XML for C++ Developers BEGIN 22 - Getting Started with Oracle XML and C++ Chapter resid := DBMS_XDB_VERSION.MakeVersioned('/public/important_customer/ SteveJones.xml'); Chapter 24 - Building an XML Data-Retrieval Application END; Part VI - Oracle XML for PL/SQL Developers / Chapter 23 - Build an XML Database OCI C++ Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Chapter 27get - Extending PL/SQL XML with Java You can the resource ID of theFunctionality VCR as follows: Chapter 28 - Putting It All Together

SET AUTOPRINT ON

Appendix XML Standards Bodies and Open Specifications VAR OUT -CLOB Glossary DECLARE Index resid DBMS_XDB_VERSION.RESID_TYPE; Listres of Figures XMLType; List of Tables BEGIN Listresid of Sidebars := DBMS_XDB_VERSION.MakeVersioned('/public/important_customer/SteveJones.xml');

-- Obtain the resource res := DBMS_XDB_VERSION.GetResourceByResId(resid); SELECT res.getClobVal() INTO :OUT FROM dual; END;

To update a VCR, you need to first check out the resource, make file updates, and then check them back in to the XML DB re follows: DECLARE


resid DBMS_XDB_VERSION.RESID_TYPE; BEGIN DBMS_XDB_VERSION.CheckOut('/public/important_customer/SteveJones.xml'); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & resid := PL/SQL DBMS_XDB_VERSION.CheckIn('/public/important_customer/SteveJones.xml'); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang END; McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Note that the resource is not updated until the new file is checked in. If you want to cancel the updates after the checkout, you emphasis on XML standards, their usage and best practices. out” the resource as follows: DECLARE resid DBMS_XDB_VERSION.RESID_TYPE; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL BEGIN Introduction resid := Part I - Oracle and the XML Standards DBMS_XDB_VERSION.UncheckOut('/public/important_customer/SteveJones.xml '); Chapter 1 - Introducing XML END;

Table of Contents

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML SQL: Design, Build & Manage XML Applications in Java, C, C++ & Storing XML Documents in &Relational Tables PL/SQL

by are Mark V. Scardina, Ben Chang Jinyu Wang Relational tables normally designed withoutand considering XML storage. However, in many cases theseISBN:0072229527 tables can McGraw-Hill/Osborne © 2004 (600 pages) be used to store shredded XML documents and produce a useful XML representation by creating XMLType views using Oracle Database 10g XML features or generating XML using the Oracle XDK.Oracle's XML-enabled products, with This comprehensive guide focuses on utilizing XML technologies within emphasis on XML standards, their usage and best practices.

Storing XML data in relational tables is useful if your application needs to avoid the limitations of the XMLType storage, such as limited XML schema evolution and data replication. Relational storage is also widely used by Table of Contents applications that require fine-grained access to the data in XML documents while not needing to preserve the Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL complete hierarchical structure of XML. Introduction

Part I - Oracle and 10g the XML Standards Oracle Database provides extensive support for loading, exporting, and processing XML data into relational

Chapter Introducing XML tables. 1To -load XML data, you can use the XML SQL Utility (XSU). XSU provides both Java and PL/SQL program Chapter 2 -and Accessing XML withutilities. DOM, SAX, andthe StAX interfaces command-line Built JAXB, on XSU, TransX Utility (XML Translation) further simplifies the Chapter character 3 set - Transforming conversion XML during with data XSLT loading, and XPath and the XSQL Servlet provides the HTTP interfaces. If the

functionality provided by these is not Chapter 4 - Validating XML with utilities DTDs and XMLsufficient Schemasfor your application, you can always use their programmatic APIs in5conjunction with other XDK libraries to build your own custom solution. Chapter - XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP

- Putting It All Together with XML Pipeline, JSPs, and XSQL XML SQL Utility

Chapter 7

Part II - Oracle XML Management for DBAs

XSU provides Java-based command-line utilities, and PL/SQL packages that support loading XML data into Chapter 8 - Getting Started APIs, with the Oracle XML Database relational including tables with XMLType columns. We will discuss how you can use its functionality in the Chapter 9 tables - Storing XML Data following Chapter 10sections. - Generating and Retrieving XML Chapter 11 - Searching XML Data

Canonical Mapping

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

The first thing you need to understand before using XSU is the canonical mapping used by XSU to map XML to relational tables and render the results of SQL queries in XML. In this canonical mapping, the <ROWSET> element Chapter 14 -element Buildingof anthe XML-Powered Web Site is the root XML document, and its child <ROW> elements map to rows of data in tables. The names Chapter 15 - elements Creating afor Portal with XML and Web of the child eachSite <ROW> element mapServices to the table column names or object names from which the Chapter Developing annum XML Gateway with SOAP and are AQ numbers that provide the order information. results 16 are- returned. The attributesApplication of the <ROW> elements Chapter 17 - Developing Reusable Components The following is an XMLXML-Based Schema representation of this metadata structure: Chapter 13 - Getting Started with Oracle XML and Java

Part IV - Oracle XML for C Developers

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

Chapter 18 - Getting Started with Oracle XML and C elementFormDefault="qualified" attributeFormDefault="unqualified"> Chapter 19 - Building an XML-Managed Application <xs:element name="ROWSET"> Chapter 20 - Build an XML Database OCI Application <xs:complexType> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <xs:sequence> Part V <xs:element - Oracle XML for name="ROW"> C++ Developers

Chapter <xs:complexType> 22 - Getting Started with Oracle XML and C++ Chapter 23 <xs:sequence> - Build an XML Database OCI C++ Application Chapter 24<xs:any/> - Building an XML Data-Retrieval Application

</xs:sequence> Part VI - Oracle XML for PL/SQL Developers <xs:attribute use="optional"/> Chapter 25 - Getting Started name="num" with Oracle XMLtype="xs:string" and PL/SQL Chapter </xs:complexType> 26 - Building PL/SQL Web Services

</xs:element> Chapter 27 - Extending PL/SQL XML Functionality with Java </xs:sequence> Chapter 28 - Putting It All Together </xs:complexType> - XML Standards Bodies and Open Specifications </xs:element> Glossary </xs:schema> Appendix Index

List of provides Figures ways to change the names of the <ROWSET> and <ROW> elements. For example, a XSU List of Tables CUSTOMER_TBL table is defined as follows: List of Sidebars

CREATE TABLE CUSTOMER_TBL ( NAME VARCHAR2(100), ADDRESS VARCHAR2(200), EMAIL VARCHAR2(200), PHONE VARCHAR2(50), DESCRIPTION VARCHAR2(4000));

The XML document mapping to this table with the canonical mapping is shown as follows:


<ROWSET> <ROW> <NAME>Steve Jones</NAME> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <EMAIL>Steve.Jones@example.com</EMAIL> PL/SQL <ADDRESS>Someroad, Somecity, Redwood Shores, ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang CA 94065, U.S.A</ADDRESS> <PHONE>6505723456</PHONE> McGraw-Hill/Osborne © 2004 (600 pages) <DESCRIPTION>Very Important US Customer</DESCRIPTION> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with </ROW> emphasis on XML standards, their usage and best practices. </ROWSET> Table of Contents

Note By default, all table, column, and object names are uppercase; therefore, if you want to have mixed-case XML documents successfully inserted you need to specify the ignoreCase options when using XSU.

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Part I - Oracle XML Standards utility, you need to set the following Java packages in your Java In order to runand thethe XSU command-line

Chapter CLASSPATH: 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

xmlparserv2.jar Oracle XML Parser for Java Chapter 3 - Transforming XML with XSLT and XPath

Chapter 4 - Validating XML JDBC with DTDs and XML Schemas classes12.jar Oracle Drivers Chapter 5

- XML Operations with XQuery

xsu12.jar XML and SQLRPC Utility Chapter 6 - XMLOracle Messaging with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Note You may need to add the orai18n.jar package to your Java CLASSPATH when handling XML with different character sets. Or, you might get an oracle.xml.sql.OracleXMLSQLException: Chapter 8 - Getting Started with the Oracle XML Database ‘java.sql.SQLException: Non supported character set…’ Part II - Oracle XML Management for DBAs

Chapter 9

- Storing XML Data

Chapter 10 - Generating and parser Retrieving XML a DOM and depends on the JDBC drivers to connect to the Oracle XSU depends on the XML to build Chapter 11 and - Searching Data metadata. After the Java CLASSPATH is properly set, you can run the XSU database retrieveXML the table Chapter command-line 12 - Managing utility with the java Oracle OracleXML, XML Databasewhich has two options, getXML for querying the database and putXML Part III - Oracle XML Java Developers for inserting data intofor the database.

Chapter 13 - Getting Started with Oracle XML and Java

Note and operations not included in the XSU command-line utility but they are supported by Chapter 14 Update - Building andelete XML-Powered Webare Site XSU through the Java and PL/SQL APIs.

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Application with you SOAP and AQthe following command: For example, to insert the XMLGateway data in contact01.xml, can run Chapter 17 - Developing XML-Based Reusable Components

java OracleXML putXML -conn "jdbc:oracle:thin:@localhost:1521:orclX" -user "demo/demo" -fileName "customer1_xsu.xml" "customr_tbl"

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Chapter 20 is - Build an XML OCI Application The data inserted into Database the CUSTOMER_TBL table in the demo schema. To query the content in the table and Chapter 21 -results Createinan XML-Configured Engine return the XML, you can runHigh-Performance the following XSUTransformation command: Part V - Oracle XML for C++ Developers

java OracleXML getXML -conn "jdbc:oracle:thin:@localhost:1521:orclX"

Chapter 22"demo/demo" - Getting Started"SELECT with Oracle C++ -user * XML FROMandcustomer_tbl" Chapter 23 - Build an XML Database OCI C++ Application

The following XML document is returned: Application Chapter 24 - Building an XML Data-Retrieval Part VI - Oracle XML=for'1.0'?> PL/SQL Developers <?xml version

Chapter 25 - Getting Started with Oracle XML and PL/SQL <ROWSET> Chapter - Building PL/SQL Web Services <ROW 26 num="1"> Chapter <NAME>Steve 27 - Extending Jones</NAME> PL/SQL XML Functionality with Java

<ADDRESS>Someroad, Somecity, Redwood Shores, CA 94065, U.S.A</ADDRESS> Chapter 28 - Putting It All Together <EMAIL>Steve.Jones@example.com</EMAIL> Appendix - XML Standards Bodies and Open Specifications <PHONE>6505723456</PHONE> Glossary <DESCRIPTION>Very Important US Customer</DESCRIPTION> Index List</ROW> of Figures

</ROWSET>

List of Tables

List of Sidebars

At this point, the XML document’s data has been successfully loaded into the database. However, input XML documents are not always in the canonical format. How can you deal with these XML documents? The usual approach is to use an XSLT stylesheet to transform the XML document into the canonical format. On the other hand, you can create database object views mapping to the incoming XML format.

Object Views If an XML document is not in the canonical format, you can create object views or XMLType views, to allow XSU to map XML documents to database tables. In the following contact.xml XML document, the contact information is


stored as follows: <Contact_List> <Contact> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <User_id>userid</User_id> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <First_Name>Steve</First_Name> McGraw-Hill/Osborne © 2004 (600 pages) <Last_Name>Jones</Last_Name> <Business> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. <Email>Steve.Jones@oracle.com</Email> <Phone>(650)5769801</Phone> Table <Address> of Contents Oracle <Street1>4op11</Street1> Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <Street2>500 Oracle Parkway</Street2> Introduction Shores</City> Part I -<City>Redwood Oracle and the XML Standards <State>CA</State> Chapter 1 - Introducing XML <Zipcode>94065</Zipcode> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <Country>USA</Country> Chapter 3 - Transforming XML with XSLT and XPath </Address> Chapter 4 - Validating XML with DTDs and XML Schemas </Business> Chapter 5 - XML Operations with XQuery </Contact> Chapter 6 - XML Messaging and RPC with SOAP </Contact_List> Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter The database 8 - Getting schema Started is defined with the asOracle follows: XML Database Chapter 9 TYPE - Storing XML Data CREATE address_typ AS OBJECT( Chapter 10 - Generating and Retrieving XML street1 VARCHAR2(200), Chapter 11 - Searching XML Data street2 VARCHAR2(200), Chapter city 12VARCHAR2(100), - Managing the Oracle XML Database Partstate III - Oracle VARCHAR2(20), XML for Java Developers

zipcode VARCHAR2(20), Chapter 13 - Getting Started with Oracle XML and Java country VARCHAR2(20)); Chapter 14 - Building an XML-Powered Web Site / Chapter 15 - Creating a Portal Site with XML and Web Services CREATE contact_tbl( Chapter 16TABLE - Developing an XML Gateway Application with SOAP and AQ contactid VARCHAR2(15) KEY, Chapter 17 - Developing XML-BasedPRIMARY Reusable Components VARCHAR2(100), Partfirstname IV - Oracle XML for C Developers lastname VARCHAR2(200), midname VARCHAR2(50), Chapter 19 - Building an XML-Managed Application business_phone VARCHAR2(20), Chapter 20 - Build an XML Database OCI Application home_phone VARCHAR2(10), Chapter 21 - Create an XML-Configured High-Performance Transformation Engine cell_phone VARCHAR2(20), Part V - Oracle XML for C++ Developers business_addr address_typ, Chapter 22 - Getting Started with Oracle XML and C++ business_email VARCHAR2(150)); Chapter 18 - Getting Started with Oracle XML and C

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 -canonical Building an XML Data-Retrieval Application Using the mapping, the XML document cannot directly map to the table columns as the document Part VI - Oracle XML for PL/SQL contains multiple levels; thus, toDevelopers insert this XML document, you need to create the following object view:

Chapter 25TYPE - Getting Started with Oracle XML and PL/SQL CREATE contactinfo_type AS OBJECT( Chapter 26 - Building PL/SQL Web Services phone VARCHAR2(20), Chapter 27 - Extending PL/SQL XML Functionality with Java email VARCHAR2(150), Chapter 28 - Putting It All Together address address_typ); Appendix /

- XML Standards Bodies and Open Specifications

-- Create Object View Glossary CREATE VIEW contact_view AS Index List ofSELECT Figures contactid AS user_id, firstname AS first_name, lastname AS

last_name,midname AS mid_name, List of Tables contactinfo_type(business_phone,business_email, List of Sidebars business_addr) AS business FROM contact_tbl; Then, you can run a similar command to load the XML file into CUSTOMER_VIEW: java OracleXML putXML -conn "jdbc:oracle:thin:@localhost:1521:orclX" -user "demo/demo" -fileName "contacts.xml" "contact_view" In this example, the contact_view is used by the Oracle database to map the XML data into underlying tables.


However, in many cases these types of views are not updateable, when they include multiple table joins or object type inheritance. You then must create an INSTEAD-OF TRIGGER on the views to handle data population for these tables or objects. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Dividing XML Documents Fragments by Mark V. Scardina,into Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

When storing XML documents, you sometimes do not want to map every XML element to relational table columns. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Instead, you might want to store some of the XML fragments in XML into CLOBs or XMLTypes. The following emphasis on XML standards, their usage and best practices. example illustrates an approach using XSLT to create such XML fragments and insert those XML fragments into one XMLType table column using XSU. In the example, the input XML document is shown as follows:

Table of Contents

<Contact_List> <Contact> Introduction <User_id>jwang</User_id> Part I - Oracle and the XML Standards <First_Name>Jinyu</First_Name> Chapter 1 - Introducing XML <Last_Name>Wang</Last_Name> Chapter 2 - Accessing Product XML with DOM, SAX, JAXB, and StAX <Title>Senior Manager</Title> Chapter 3 - Transforming XMLmanages with XSLTthe and XPath <Description>Jinyu <PRODUCT>Oracle XML Developer's Chapter 4 - Validating XML with DTDs and XML Schemas Kit</PRODUCT> product.</Description> Chapter 5 - XML Operations with XQuery </Contact> Chapter 6 - XML Messaging and RPC with SOAP </Contact_List>

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

TheII<Description> element contains mixed content, which we do not want to map to multiple table columns. A Part - Oracle XML Management for DBAs contact_tbl table isStarted definedwith as follows: Chapter 8 - Getting the Oracle XML Database CREATE contact_tbl( Chapter 9 TABLE - Storing XML Data contactid VARCHAR2(15) PRIMARY Chapter 10 - Generating and Retrieving XML KEY, firstname VARCHAR2(100), Chapter 11 - Searching XML Data lastname VARCHAR2(200), Chapter 12 - Managing the Oracle XML Database VARCHAR2(50), Partmidname III - Oracle XML for Java Developers description Chapter 13 - GettingCLOB); Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

To map the <Description> element to the description column using XSU, you need to apply the following setCDATA.xsl XSL stylesheet:

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> Part IV - Oracle XML for C Developers <xsl:output cdata-section-elements="CODE"/> Chapter 18 - Getting Started with Oracle XML and C <!-- Identity transformation --> Chapter 19 - Building an XML-Managed Application <xsl:template match="*|@*|comment()|processing-instruction()| Chapter text()"> 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <xsl:copy> Part V<xsl:apply-templates - Oracle XML for C++ Developers select="*|@*|comment()|processingChapter instruction()|text()"/> 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application </xsl:copy> Chapter 24 - Building an XML Data-Retrieval Application </xsl:template> Part VI - Oracle XML for PL/SQL Developers <xsl:template match="Description"> Chapter <xsl:element 25 - Getting Started name="Description"> with Oracle XML and PL/SQL <xsl:copy-of select="@*|comment()|processing-instruction()"/> Chapter 26 - Building PL/SQL Web Services <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text> Chapter 27 - Extending PL/SQL XML Functionality with Java <xsl:apply-templates Chapter 28 - Putting It All Togetherselect="*|./*/@*|./*/comment()|./*/ processing-instruction()|text()"/> Appendix - XML Standards Bodies and Open Specifications <xsl:text disable-output-escaping="yes">]]></xsl:text> Glossary </xsl:element> Index </xsl:template> List of Figures </xsl:stylesheet> Chapter 17 - Developing XML-Based Reusable Components

List of Tables

List of Sidebars

This XSLT transformation will transform the input XML document and include all the child elements of <Description> into one CDATA section so that each CDATA section can be stored to the description column by XSU. You can modify the XSL stylesheet for your application by specifying different match attributes for the following template: <xsl:template match="Description">… </ xsl:template>


The XPath in the match attribute specifies the root element of the XML fragment to be stored. Note Because XSLT requires a DOM to be built in memory, you may need to split the large documents before Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & the transformation. PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

TransX Utility McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

When populating the Oracle database with their multilingual databest or data translations, or when encoding, validation is emphasis on XML standards, usage and practices. needed for each XML file. The traditional way is to switch the NLS_LANG setting as you switch loading files with different encoding information. The NLS_LANG setting has to reflect the character set of the file loaded into the Table of Contents database. This approach is error-prone because the encoding information is maintained separately from the data Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL itself. Setting the NLS_LANG environment variable is also tedious work. Introduction

Part Oracle andUtility the XML Standards WithI -the TransX provided in the XDK, the encoding information is kept along with the data in an XML

Chapter 1 -ofIntroducing XML document a predefined format so that multilingual data can be transferred without having to switch NLS_LANG Chapter 2 TransX - Accessing with DOM, JAXB, and StAX settings. UtilityXML maintains the SAX, correct character set throughout the process of translating the data and Chapter successfully 3 - Transforming loading it intoXML thewith database. XSLT and WeXPath will not discuss the details of how to use the TransX Utility. However,

we include samples chapter source code for you to try its functionality. Chapter 4 - some Validating XML with the DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

- XML Messaging and RPC with SOAP DBMS_XMLSTORE

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part DBMS_XMLSTORE II - Oracle XML Management is a suppliedforPL/SQL DBAs package that supports inserting XML data into database tables. This C-

based implementation provides performance and system manageability than the Java-based Chapter 8 - Getting Started with better the Oracle XML Database DBMS_XMLSave Chapter 9 - Storingpackage. XML DataThis package eliminates the overhead of starting up Oracle JVM as well as translating Java class for each method call. In addition, DBMS_XMLSTORE is built based on SAX parsing instead of Chapter 10 - names Generating and Retrieving XML DOM parsing. Therefore, scales well for large XML documents. You can see this in the following comparison using Chapter 11 - Searching XMLitData the SH12 sample schema: Chapter - Managing the Oracle XML Database SQL> count(1) sales; Part III SELECT - Oracle XML for Java FROM Developers COUNT(1) Chapter 13 - Getting Started with Oracle XML and Java ---------Chapter 14 - Building an XML-Powered Web Site 1136945 Chapter 15 - Creating a Portal Site with XML and Web Services SQL> CREATE TABLEan test AS SELECT * FROM sales; Chapter 16 - Developing XML Gateway Application with SOAP and AQ Table created. SQL> CREATE TABLE result AS SELECT * FROM sales WHERE 0=1; Part IV - Oracle XML for C Developers Table created. Chapter 18 - Getting Started with Oracle XML and C SQL> SELECT count(1) FROM test; Chapter 19 - Building an XML-Managed Application COUNT(1) Chapter 20 - Build an XML Database OCI Application ---------Chapter 21 - Create an XML-Configured High-Performance Transformation Engine 1136945 Part V - Oracle XML for C++ Developers SQL> SELECT count(1) FROM result; Chapter 22 - Getting Started with Oracle XML and C++ COUNT(1) Chapter 23 - Build an XML Database OCI C++ Application ---------Chapter 24 - Building an XML Data-Retrieval Application 0 Part VI -SET Oracle XML forON PL/SQL Developers SQL> timing Chapter 25 - Getting Started with Oracle XML and PL/SQL SQL> DECLARE Chapter Building PL/SQL Web Services 2 26 -qryCtx DBMS_XMLQuery.ctxHandle; Chapter 3 27 -v_clob Extending CLOB; PL/SQL XML Functionality with Java 4 28 -savCtx Chapter Putting ItDBMS_XMLSave.ctxType; All Together 5 v_rows NUMBER; Appendix - XML Standards Bodies and Open Specifications 6 BEGIN Glossary 7 -- Query out the content Index 8 qryCtx := DBMS_XMLQuery.newContext('SELECT * FROM test'); List of Figures 9 v_clob := DBMS_XMLQuery.getXml(qryCtx); List of Tables 10 DBMS_OUTPUT.PUT_LINE('CLOB size = '||DBMS_LOB.GETLENGTH(v_clob)); List of Sidebars 11 -- Save the content 12 savCtx := DBMS_XMLSave.newContext('RESULT'); 13 v_rows := DBMS_XMLSave.insertxml(savCtx,v_clob); 14 DBMS_XMLSave.closeContext(savCtx); 15 DBMS_OUTPUT.PUT_LINE(v_rows || ' rows inserted...'); 16 END; 17 / DECLARE Chapter 17 - Developing XML-Based Reusable Components


* ERROR at line 1: ORA-29532: Oracle Java call terminated by uncaught Java exception: Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & java.lang.OutOfMemoryError PL/SQL ORA-06512: by atMark "SYS.DBMS_XMLSAVE", 114Wang ISBN:0072229527 V. Scardina, Ben Changline and Jinyu ORA-06512: McGraw-Hill/Osborne at line 13 © 2004 (600 pages) Elapsed: 00:11:57.05 This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

In the preceding example, the sales table in the SH sample schema described in Chapter 8 is used to generate a large XML document that, when parsed, is too large for the configured Oracle JVM memory. You can increase the Table of Contents JAVA_POOL_SIZE to give more memory for processing; however, this may not be sufficient, especially when this Oracle Database 10g XML & the SQL—Design, Build & Manage Applications Java,you C, C++ & PL/SQL memory takes away from database memory pool. InXML Oracle Databasein10g, can use DBMS_XMLSTORE to Introduction resolve this issue as follows: Part I - Oracle and the XML Standards

DECLARE - Introducing XML v_clob CLOB; Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX savCtx DBMS_XMLSTORE.ctxType; Chapter 3 - Transforming v_rows NUMBER; XML with XSLT and XPath Chapter 4 - Validating XML with DTDs and XML Schemas BEGIN Chapter 5 Query - XML Operations XQuery -out the with content Chapter 6 - XMLdoc Messaging and RPC with SOAP SELECT INTO v_clob FROM temp_clob; Chapter -7 Save - Putting theIt All content Together with XML Pipeline, JSPs, and XSQL Part IIsavCtx - Oracle XML := DBMS_XMLSTORE.newContext('RESULT'); Management for DBAs -the Started update columns toXML improve Chapter 8 Set - Getting with the Oracle Databaseperformance DBMS_XMLSTORE.SetUpdateColumn (savCtx, 'PROD_ID'); Chapter 9 - Storing XML Data DBMS_XMLSTORE.SetUpdateColumn (savCtx, 'CUST_ID'); Chapter 10 - Generating and Retrieving XML DBMS_XMLSTORE.SetUpdateColumn (savCtx, 'TIME_ID'); Chapter 11 - Searching XML Data DBMS_XMLSTORE.SetUpdateColumn (savCtx, 'CHANNEL_ID'); Chapter 12 - Managing the Oracle XML Database DBMS_XMLSTORE.SetUpdateColumn (savCtx, 'PROMO_ID'); Part III - Oracle XML for Java Developers DBMS_XMLSTORE.SetUpdateColumn (savCtx, 'QUANTITY_SOLD'); Chapter 13 - Getting Started with Oracle XML and Java DBMS_XMLSTORE.SetUpdateColumn (savCtx, 'AMOUNT_SOLD'); Chapter 14 - Building an XML-Powered Web Site -- Insert the document Chapter 15 - Creating a Portal Site with XML and Web Services v_rows := DBMS_XMLSTORE.insertxml(savCtx,v_clob); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ DBMS_XMLSTORE.closeContext(savCtx); Chapter 17 - Developing XML-Based Reusable Components DBMS_OUTPUT.PUT_LINE(v_rows || ' rows inserted...'); Part IV - Oracle XML for C Developers END; Chapter 1

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Buildingtoanuse XML-Managed Application SetUpdateColumn() function where applicable, as shown in the It is recommended the DBMS_XMLSTORE Chapter preceding 20 -example, Build an XML because Database this allows OCI Application the DBMS_XMLSTORE program to know the list of columns that need to

be updated so as to explicit SQL binding to the XMLTransformation data. The previous example uses the following SQL Chapter 21 - Create anuse XML-Configured High-Performance Engine statement when preparing data insertion: Part V - Oracle XML for C++ the Developers Chapter 22INTO - Getting Started with Oracle XML and C++ INSERT sales(prod_id, cust_id, ..., amount_sold) values Chapter 23:2, - Build an XML Database OCI C++ Application (:1, ..., :6); Chapter 24 - Building an XML Data-Retrieval Application

ThisVIspeeds upXML the for data-insertion process by eliminating the overhead of parsing of the SQL statements in the Part - Oracle PL/SQL Developers database. Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Using External Tables PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang Introduced in Oracle9i, Oracle’s external table feature offers a solution to define a table in the database while leaving © 2004Prior (600 pages) the data storedMcGraw-Hill/Osborne outside of the database. to Oracle Database 10g, external tables can be used only as read-only tables. In otherThis words, if you createguide an external for XML files, these fileswithin can be queries and the table can bewith comprehensive focuses table on utilizing XML technologies Oracle's XML-enabled products, emphasis XML standards, usage and best joined with other tables. on However, no DML their operations, such as practices. INSERT, UPDATE, and DELETE, are allowed on the external tables.

Table of Contents

Note In Oracle Database 10g, by using the ORACLE_DATAPUMP driver instead of the default ORACLE_DRIVER, you can write to external tables.

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Part I - Oracle and the10g, XMLyou Standards In Oracle Database can define VARCHAR2 and CLOB columns in external tables to store XML documents.

Chapter 1 - Introducing XML how you can create an external table with a CLOB column to store the XML The following example shows Chapter 2 - Accessing DOM, SAX, JAXB, and StAX documents. First, youXML needwith to create a DIRECTORY to read the data files: Chapter 3 DIRECTORY - Transforming XML with XSLT and CREATE data_file_dir ASXPath 'D:\xmlbook\Examples\Chapter9\src\xml'; Chapter - Validating DTDs and XML Schemas GRANT 4READ, WRITEXML ONwith DIRECTORY data_file_dir TO demo; Chapter 5

- XML Operations with XQuery

Then, you this DIRECTORY to define Chapter 6 -can XMLuse Messaging and RPC with SOAP an external table: Chapter 7 TABLE - Puttingcustomer_xt It All Together with XMLCLOB) Pipeline, JSPs, and XSQL CREATE (doc PartORGANIZATION II - Oracle XML Management EXTERNAL for DBAs

Chapter ( 8

- Getting Started with the Oracle XML Database

TYPE ORACLE_LOADER Chapter 9 - Storing XML Data DEFAULT DIRECTORY data_file_dir Chapter 10 - Generating and Retrieving XML ACCESS PARAMETERS Chapter 11 - Searching XML Data ( 12 - Managing the Oracle XML Database Chapter (lobfn CHAR TERMINATED BY ',') Part III - FIELDS Oracle XML for Java Developers COLUMN TRANSFORMS (doc FROMandlobfile (lobfn)) Chapter 13 - Getting Started with Oracle XML Java ) Chapter 14 - Building an XML-Powered Web Site LOCATION ('xml.dat') Chapter 15 - Creating a Portal Site with XML and Web Services ) Chapter 16 - Developing an XML Gateway Application with SOAP and AQ REJECT LIMIT UNLIMITED; Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Thexml.dat file follows: Chapter 19 - Building an XML-Managed Application

customer1.xml

Chapter 20 - Build an XML Database OCI Application customer2.xml Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V -describe Oracle XML C++ Developers If you the for table, you can see the following definition:

Chapter 22 - Getting Started with Oracle XML and C++ SQL> DESC customer_xt; Chapter Name 23 - Build an XML Database OCI C++ Application

Null?

Type

Chapter 24 - Building an XML Data-Retrieval Application ------------------------------------------------ -----------------------Part VI - Oracle XML for PL/SQL Developers DOC

CLOB

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Then, you queryPL/SQL the XML document Chapter 26 -can Building Web Services as follows: Chapter SELECT 27XMLType(doc).extract('/Customer/EMAIL') - Extending PL/SQL XML Functionality with Java

FROM customer_xt; Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Though the query requires run-time XMLType creation and XPath evaluation, this approach is useful when applications just need a few queries on the XML data and don’t want to upload the XML data into database. In Index Oracle Database 10g, you cannot create external tables that contain pre-defined XMLType column types. Glossary

List of Figures List of Tables

List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Schema Evolution PL/SQL

ISBN:0072229527 Markwhen V. Scardina, Ben Chang and Jinyu Wang XML schemas by evolve there are new requirements for the XML data. Your ability to reflect these changes in the McGraw-Hill/Osborne 2004 (600 pages) database is highly dependent on the©storage.

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

If you use relational tables, you can changetheir the table update the XML views to reflect the new emphasis on XML standards, usagestructure and best and practices. mapping from XML to relational tables. If you use CLOB XMLTypes, your new XML data can be directly inserted because this storage allows you to store XML conforming to different XML schemas. However, for XML Table of Contents Schema–based XMLTypes, evolution of their XML schemas is an expensive process because it requires updating of Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL the object-relational structure of the XMLTypes. In Oracle Database 10g, this type of evolution is limited to either Introduction performing export/import of the data or using the CopyEvolution() function in the DBMS_XMLSCHEMA package. Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Best Practices PL/SQL

ISBN:0072229527 by MarkXML V. Scardina, Chang and database, Jinyu Wang If you need to accept data andBen store it in the the first thing that you should consider is whether your application McGraw-Hill/Osborne 2004 (6008, pages) in the database. As we discussed in©Chapter you need to evaluate the pros and cons of the XML storage options and analy and updating ofThis thecomprehensive XML data. Additionally, you sometimes needtechnologies to choose awithin particular XMLXML-enabled storage model in order to support guide focuses on utilizing XML Oracle's products, with emphasis on XML standards, their usage and best practices. evolving XML schemas.

After selecting the right XML storage model for your application, the following sections provide some guidelines of what you ne Database 10g.

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Handling Document Type Definitions

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Although DTDs are not used to define the storage structure for XMLTypes, Oracle XML DB resolves all the DTD definitions an - Accessing XML with DOM, SAX, JAXB, and StAX inserted XML document. This is performed during the inserting process of XMLType when all the incoming XML documents ar Chapter 3 - Transforming XML with XSLT and XPath including external or internal entities defined in DTDs, are resolved. This means that all the entities are replaced with their actu Chapter 4 - Validating XML with DTDs and XML Schemas references are lost. Chapter 2

Chapter 5

- XML Operations with XQuery

Chapter 6 - XML RPCentity with SOAP If you would like Messaging to preserveand these references, you have to store the XML in CLOBs, instead of CLOB XMLTypes. You t Chapter from these 7 - CLOBs Putting It whenever All Together you with needXML to resolve Pipeline, allJSPs, the entities and XSQL and use the XML content. Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database Creating XML Schema–based XMLTypes

Chapter 9

- Storing XML Data

Chapter 10create - Generating and Retrieving XMLTypes XML You can XML Schema–based using the XMLType construction functions or the XMLType.CreateXML()func

Chapter these functions 11 - Searching to create XMLXML DataSchema–based XMLTypes, the XML documents have to contain the XML SchemaLocation at

not contain attributes. HowXML can Database you create an XML Schema–based XMLType without changing the original XML docume Chapter 12 - such Managing the Oracle Part III - Oracle XML for Java Developers

As you have seen in Chapter 8, you can use the XMLType.CreateSchemaBasedXML function and specify the URL of the XM

Chapter 13 - Getting Started with Oracle XML and Java

INSERT product(id, name, Chapter 14INTO - Building an XML-Powered Webdescription) Site VALUES('xdk', Kit', Chapter 15 - Creating a'XML Portal Developer's Site with XML and Web Services XMLTYPE('<DESCRIPTION><KEYWORD>xdk</KEYWORD> isAQ a set of Chapter 16 - Developing an XML Gateway Application with SOAP and standards-based utilities that helps to build <KEYWORD>XML</KEYWORD> applications. It contains XDK Java Part IV - Oracle XML for C Developers Components, XDK C Components and XDK C++ Components. Chapter 18 - Getting Started with Oracle XML and C </DESCRIPTION>').CreateSchemaBasedXML('http://xmlns.oracle.com/ Chapter 19 - Building an XML-Managed Application xml/content.xsd')); Chapter 17 - Developing XML-Based Reusable Components

Chapter 20 - Build an XML Database OCI Application

Chapter 21 http://xmlns.oracle.com/xml/content.xsd - Create an XML-Configured High-Performance Engine The URL is Transformation the registered URL of the XML schema, and it will be used to store the Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

Specifying Namespaces

Chapter 23 - Build an XML Database OCI C++ Application

Chapter 24 -XML Building an XMLhas Data-Retrieval Application If a stored document namespaces, all of the XML queries on the document have to be namespace-qualified because Part VI as - Oracle XML for Developers same <Element> inPL/SQL XML. Both the XMLType.existsNode()and the XMLType.extract() functions allow the user to specify

Chapter 25 - Getting Started with Oracle XML and PL/SQL as follows: Chapter 26 - Building PL/SQL Web Services

MEMBER FUNCTION existsNode(xpath in varchar2, nsmap in varchar2)

Chapter 27 - Extending XML Functionality with Java RETURN number PL/SQL deterministic Chapter 28FUNCTION - Putting It All Together MEMBER extract(xpath IN varchar2, nsmap IN varchar2) Appendix XML Standards Bodies and Open Specifications RETURN -XMLType deterministic Glossary Index

In this case, the XPath needs to use fully qualified XML names, which contain the element name and its namespace. For exam List of Figures with namespace declarations into XMLTypes as follows: List oftwo Tables CREATE TABLE temp (doc XMLType); List of Sidebars DECLARE v_temp XMLType; BEGIN v_temp:= XMLType.createXML('<foo xmlns="http://www.example.com" xmlns:xsd="http://www.w3c.org/2001/XMLSchema"> <foo_type xsd:type="date">03-11-1998</foo_type> </foo>'); INSERT INTO temp VALUES(v_temp);


END; To query the document, you can define the namespace and its prefix in the second parameter of the XMLType.extract() func Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & prefix, as shown in the following SQL query: PL/SQL SELECT a.doc.extract('/a:foo/a:foo_type', ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang 'xmlns:a="http://www.example.com"') McGraw-Hill/Osborne © 2004 (600 pages) FROM temp a; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with The result is

emphasis on XML standards, their usage and best practices.

<foo_type xmlns="http://www.example.com" xmlns:xsd="http://www.w3c.org/2001/XMLSchema" xsd:typ

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Note If you do not use the namespace-qualified name in the XPath after providing namespaces, you will get an ORA-3101

Introduction

Part I - have Oracle and the XML Standards If you multiple namespaces, you can list them in the second parameter of the XMLType.existsNode() and the XMLType

Chapter with white 1 -spaces, Introducing as shown XML in the following example: Chapter 2 a.doc.extract('/a:foo/a:lastupdate/@b:type', - Accessing XML with DOM, SAX, JAXB, and StAX SELECT Chapter 3

- Transforming XML with XSLT and XPath 'xmlns:a="http://www.example.com"

Chapter 4

- Validating XML with DTDs and XML Schemas xmlns:b="http://www.w3c.org/2001/XMLSchema"') AS result

Chapter FROM temp 5 - XML a; Operations with XQuery

RESULT Chapter 6

- XML Messaging and RPC with SOAP

---------------------------------------------------------------------------Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL date Part II - Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

by Mark V. Scardina, Changoptions and Jinyu The chapter discusses various XMLBen storage andWang the associated data loading strategies in OracleISBN:0072229527 Database McGraw-Hill/Osborne © 2004 (600 pages) 10g.Table 9-1 shows the relationships between the XML storage and the functionality offered in the XML dataloading utilities.This Youcomprehensive can choose one of these utilities or useXML the technologies SQL and PL/SQL to load XMLproducts, with guide focuses on utilizing within interfaces Oracle's XML-enabled on database. XML standards, their usage and best practices. documents intoemphasis the Oracle

Table XML Data-Storage and Data-Loading Utilities Table of 9-1: Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Utilities

XMLType Tables

XMLType Columns

SQL*Loader Command-line Limited Chapter 3 - Transforming XML with XSLT and XPath utility support Chapter 4 - Validating XML with DTDs and XML Schemas

Yes

Yes

Chapter 5 - XML with XQuery XML SQL UtilityOperations Command-line

Yes

Yes

Introduction

Functionality

Part I - Oracle and the XML Standards

Relational Storage with XMLType Views

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Yes

Chapter 6

- XML Messaging utilityand andRPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL programmatic

Part II - Oracle XML Management interfaces for in DBAs

Chapter 8

- Getting Started Javawith and the Oracle XML Database

Chapter 9

- Storing XML PL/SQL Data

Chapter 10 - Generating and Retrieving XML

TransX Utility

Command-line Yes utility and Chapter 12 - Managing the Oracle XML Database programmatic Part III - Oracle XML for Java Developers interfaces in Chapter 13 - Getting Started Javawith Oracle XML and Java

Yes

Yes

XSQL15 Servlet Command-line Chapter - Creating a Portal Site with XML Yes and Web Services Yes

Yes

Chapter 11 - Searching XML Data

Chapter 14 - Building an XML-Powered Web Site

program Chapter 16 - Developingutility, an XML Gateway Application with SOAP and AQ interfaces in Chapter 17 - Developing XML-Based Reusable Components Java and the Part IV - Oracle XML for C Developers HTTP Chapter 18 - Getting Started with Oracle XML and C interfaces Chapter 19 - Building an XML-Managed Application provided in the Chapter 20 - Build an XML Database OCI Application built-in action Chapter 21 - Create an XML-Configured High-Performance Transformation Engine handlers Part V - Oracle XML for C++ Developers

HTTP/WebDAV HTTP/WebDAV Chapter 22 - Getting Started with Oracle XMLNo and C++ folders Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services No FTP Interfaces FTP interfaces Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars

Yes, but the table has to be the default table created during the XML schema registration.

No

Yes, but the table has to be the default table created during the XML schema registration.

No


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 10:Database Generating and Retrieving XML PL/SQL

Overview

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

When data is incorporated emphasis on along XML standards, with its metadata their usage in XML, and best it is practices. more self-describing and portable and can be easily shared, transformed, and transported across applications and platforms. This has been the driving force in making XMLof a Contents widely accepted format for encapsulating data and in a standard protocol for delivering services across Table software components in business systems. As a result, the ways of managing XML data greatly influence the Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL architecture of modern databases. Introduction

Part I - Oracle and 10g the XML Standards Oracle Database provides the built-in support for XML, which greatly simplifies the retrieval of XML content and

Chapter 1 - Introducing the conversion betweenXML relational datasets and XML-formatted data. This chapter will cover the techniques to Chapter 2 the - Accessing XMLinwith DOM, SAX, JAXB, and StAX populate data stored object or relational tables into XML and to retrieve data from XML natively stored as Chapter 3 - Transforming XML with XSLT and XPath XMLTypes. The detailed description includes how you can create, transform, extract, and concatenate XMLTypes Chapter 4 - Validating XML with DTDs and XML Schemas into a preferred format. Chapter 5

- XML Operations with XQuery

The discussion by introducing the SOAP SQL/XML functions that allow you to create, access, and update XML with Chapter 6 - XML starts Messaging and RPC with

SQL statements. This set of standards-based methods bridges the gap between SQL and XML operations, enabling - Putting It All Together with XML Pipeline, JSPs, and XSQL you to leverage the XML functionality when working on relational data and to utilize the relational SQL functions Part II - Oracle XML Management for DBAs when dealing with XML operations. Through the examples, you will learn how this seamless integration of SQL and Chapter 8 - Getting Started with the Oracle XML Database XML in the Oracle XML Database 10g(Oracle XML DB) provides great flexibility and functionality for solving Chapter 9 - Storing XML Data business problems. Chapter 7

Chapter 10 - Generating and Retrieving XML

Chapter 11 -to Searching XML Data In addition the SQL/XML functions, the DBMS_XMLGEN PL/SQL package provides complementary functionality Chapter 12 XML. - Managing the Oracle to create This chapter will XML showDatabase you typical examples and illustrate how and when to use this package. Part III - Oracle XML for Java Developers

After the on howwith to create Chapter 13discussion - Getting Started OracleXML XML content and Javafrom SQL data, XML processing techniques, such as how to access,14update, andan transform XML content Chapter - Building XML-Powered Web Sitestored in XMLTypes, are included. We will explore how to create XMLType Views and use the XML DB Repository to publish XML documents.

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing XML Gateway Application with SOAP AQ approaches, and describe solutions to some In the “Best Practices” an section, we compare the database andand mid-tier Chapter 17problems - Developing XML-Based Reusable Components common when generating and retrieving XML data from the Oracle database. Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database XML Data & SQL: with Design,SQL Build & Manage XML Applications in Java, C, C++ & Generating XML from10g SQL XML Functions PL/SQL

by Mark Ben Chang Jinyu Wang To generate XML from V. theScardina, SQL data stored in and object or relational tables and process XML, Oracle XML ISBN:0072229527 DB provides support f © 2004 (600 pages) standard and aMcGraw-Hill/Osborne set of Oracle-provided SQL/XML functions. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

The SQL/XML emphasis standard on is part the ISO/IEC Organization XMLof standards, their(International usage and best practices. for Standardization/International Electrotechnical Co standard, which specifies the SQL standard for XML operations. Table 10-1 lists the SQL/XML functions and describes their fu Oracle Database 10g. Because currently the SQL/XML standard is still a working draft, the syntax of the SQL/XML functions is Table of Contents in future releases. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Table 10-1: ISO/IEC SQL/XML Functions

Part I - Oracle and the XML Standards

Chapter 1 - Introducing XML Function Name Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

XMLELEMENT()

Description

Returns an XML element in an XMLType when given element name, an optional list of XML attributes (XMLATTRIBUTES()), and an optional list of values a content of the new element. XMLELEMENT() can als other XML elements or XML fragments (XMLFOREST children.

Part II - Oracle XML Management for DBAs

XMLATTRIBUTES() Chapter 8 - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML XMLFOREST() Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

XMLCONCAT()

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services XMLAGG() Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Used within XMLELEMENT() to specify attributes for element.

Returns an XML fragment in an XMLType when given named expressions for the XML elements. Each expr specifies the name of an XML element and its conten

Returns an XML fragment in an XMLType by concate of XML elements/values.

Returns an XML fragment in an XMLType by aggrega fragments, with the option of XML element sorting.

Chapter 17 - Developing XML-Based Reusable Components Part Table IV 10-2 - Oracle listsXML the for Oracle-provided C Developers SQL/XML functions.

Chapter 18 - Getting Started with Oracle XML and C

Table 10-2: Oracle-Provided SQL/XML Functions Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

Function

Description

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers SYS_XMLGEN()

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

XMLSEQUENCE()

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

SYS_XMLAGG() Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together XMLCOLATTVAL() Appendix

- XML Standards Bodies and Open Specifications

Generates an XML document with the <?XML?> pro one scalar type, a user-defined object type, or an inst XMLType.

Returns a collection of XMLTypes in an XMLSEQUEN which is a VARRAY of XMLType instances in the dat

Aggregates XML elements from one scalar type, a us object type, or an instance of XMLType.

Generates a set of <column/> elements with the nam attributes specifying the column names or the name a

Glossary

UPDATEXML() Index List of Figures ListXMLTRANSFORM() of Tables List of Sidebars

EXTRACTVALUE()

Updates XML documents in XMLTypes using XPath expressions.

Applies XSL transformation on XML documents in XM

Returns scalar content, such as numbers or strings, w passed an XPath expression pointing to an XML elem only a single text child.

Note The EXTRACTVALUE() is covered in a later section, when we discuss techniques on retrieving XML. The XMLTRAN is not covered because XMLType.transform() provides the same functionality.

If you are familiar with SQL, it should not be difficult to use these SQL/XML functions in the SQL statements. The following is t


SELECT [XMLELEMENT |XMLATTRIBUTES |XMLFOREST|XMLCONCAT |XMLAGG|…] FROM table_name, [table (XMLSEQUENCE)] WHERE search_conditions Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Using XMLELEMENT(), XMLATTRIBUTES(), and XMLFOREST() functions, you can create XML elements, the attributes for t ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang XML document fragments. The XML elements and XML document fragments then can be concatenated and aggregated using McGraw-Hill/Osborne © 2004 (600 pages) and XMLAGG(). The XMLSEQUENCE() function is different from the other functions. It creates a collection of XMLType instan This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with be used to create temporary tables in the FROM clause of the SQL queries. emphasis on XML standards, their usage and best practices.

XMLELEMENT() and XMLATTRIBUTES()

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

XMLELEMENT() takes an element name and zero or more arguments that make up the element’s content to create the XML e instance of XMLType. You can also specify the collection of attributes for the element using XMLATTRIBUTES(). For example Part I - Oracle and the XML Standards HR sample schema, you can create an XML element by using the following SQL command: Introduction Chapter 1

- Introducing XML

SQL> SELECT - Accessing XML with DOM, SAX, JAXB, and StAX 2 XMLELEMENT("Employee", Chapter 3 - Transforming XML with XSLT and XPath 3 XMLATTRIBUTES(employee_id AS "empno", Chapter 4 - Validating XML with DTDs and XML Schemas 4 job_id AS "job"), Chapter 5 - XML Operations with XQuery 5 XMLELEMENT("Name",first_name||' '||last_name), Chapter XML hired Messaging 6 6 -'is onand ', RPC with SOAP Chapter 7 Putting It All Together with XML Pipeline, JSPs, and XSQL 7 hire_date Part8II - Oracle XML Management for DBAs )AS result Chapter 8 Getting Started with the Oracle XML Database 9 FROM employees Chapter 9 - Storing XML Data 10 WHERE rownum=1; Chapter 2

Chapter 10 - Generating and Retrieving XML

In line 2, EmployeeXML element Chapter 11an - Searching Data is defined with two attributes, empnoand job. The content of the attributes comes from the em

job_id 12 column in the employees table. Then, a child element of Employee is created, called Name, with its content coming fr Chapter - Managing the Oracle XML Database

concatenation thefor first_name and last_name columns. Additionally, you can add mixed content in the query; for example, ‘ Part III - Oracle of XML Java Developers

concatenated with the content the hire_date column in lines 6 and 7, and the text is inserted after the <Name> element. Th Chapter 13 - Getting Started withof Oracle XML and Java produces the following XML element with attributes, along with a child element with mixed content:

Chapter 14 - Building an XML-Powered Web Site

<Employee empno="100" job="AD_PRES"> Chapter 15 - Creating a Portal Site with XML and Web Services <Name>Steven King</Name>is hired on 17-JUN-87 Chapter 16 - Developing an XML Gateway Application with SOAP and AQ </Employee> Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Note that if the element name or attribute name is not specified, the table column name will be used by default.

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

SYS_XMLGEN()

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Different from XMLELEMENT(), SYS_XMLGEN() function allows creating the <?XML?> XML prolog and adding the XML Proc (PIs), such as XSLT stylesheet PI, to the created XML documents. For example, you can create an XML document with a prol Chapter 22 - Getting Started with Oracle XML and C++ SQL command: Part V - Oracle XML for C++ Developers

Chapter 23 - Build an XML Database OCI C++ Application

SELECT SYS_XMLGEN(XMLELEMENT("Employee", XMLATTRIBUTES(employee_id AS "empno", job_id AS "job"), Part VI - Oracle XML for PL/SQL Developers XMLELEMENT("Name",first_name||' '||last_name), Chapter 25 - Getting Started with Oracle XML and PL/SQL 'is hired on ', Chapter 26 - Building PL/SQL Web Services hire_date))AS result Chapter 27 - Extending PL/SQL XML Functionality with Java FROM EMPLOYEES Chapter - Putting It All Together WHERE 28 rownum=1; Chapter 24 - Building an XML Data-Retrieval Application

Appendix

- XML Standards Bodies and Open Specifications

Glossary Executing this query returns the following result: Index <?xml version="1.0"?> List of Figures <ROW> List <Employee of Tables empno="100" job="AD_PRES"> List of Sidebars <Name>Steven King</Name>is hired on 17-JUN-87

</Employee> </ROW>

The SYS_XMLGEN() requires taking one scalar value, a user-defined object type or an XMLType instance as the input. You c XMLFORMAT object to specify the XML formatting options (PIs, root tag, etc.) for the XML document: SELECT SYS_XMLGEN(XMLELEMENT("Employee", XMLATTRIBUTES(employee_id AS "empno", job_id AS "job"), XMLELEMENT("Name",first_name||' '||last_name),


'is hired on ', hire_date), XMLFORMAT.createformat('EmployeeList','NO_SCHEMA', Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & null,'http://www.oracle.com/','http://dburl', PL/SQL '<?xml-stylesheet href="htmlRend.xsl" type="text/xsl" ?>')) ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang FROM employees McGraw-Hill/Osborne © 2004 (600 pages) WHERE rownum <3; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

The XML created contains an XSL stylesheet PI and the default root element, the <ROW> element, is replaced by the <Emplo <?xml version="1.0"?> <?xml-stylesheet href="htmlRend.xsl" type="text/xsl" ?> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <EmployeeList> Introduction <Employee empno="100" job="AD_PRES"> Part I - Oracle and the XML Standards <Name>Steven King</Name>is hired on 17-JUN-87</Employee> Chapter 1 - Introducing XML </EmployeeList>

Table of Contents

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

XMLFOREST() - XML Operations with XQuery

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP The XMLFOREST() function produces an XML fragment that contains a set of XML elements. The following example adds add

Chapter 7 - Putting Itelement: All Together with XML Pipeline, JSPs, and XSQL to the <Employee> Part II - Oracle XML Management for DBAs

SELECT - Getting Started with the Oracle XML Database XMLELEMENT("Employee", Chapter 9 - Storing XML Data XMLATTRIBUTES(employee_id AS "empno", job_id AS "job"), Chapter 10 - Generating and Retrieving XML XMLELEMENT("Name",first_name||' '||last_name), Chapter 11hired - Searching XMLhire_date, Data 'is on ', Chapter 12 Managing the Oracle XML Database XMLFOREST(EMAIL, PHONE_NUMBER))AS result Part III Oracle XML for Java Developers FROM employees Chapter - Getting Started with Oracle XML and Java WHERE 13 rownum=1; Chapter 8

Chapter 14 - Building an XML-Powered Web Site

This produces the following Chapter 15 - Creating a Portal result: Site with XML and Web Services Chapter 16 - Developing an XMLjob="AD_PRES"> Gateway Application with SOAP and AQ <Employee empno="100" Chapter <Name>Steven 17 - Developing King</Name>is XML-Based Reusable hiredComponents on 17-JUN-87 Part <EMAIL>SKING</EMAIL> IV - Oracle XML for C Developers

<PHONE_NUMBER>515.123.4567</PHONE_NUMBER> Chapter 18 - Getting Started with Oracle XML and C </Employee> Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

Note that some of the characters allowed in SQL identifiers are not valid for XML element names. When element or attribute n specified as quoted aliases such as using XMLELEMENT(“<element_name>“) or using the AS clauses as we did for the XM Part V - Oracle XML for C++ Developers function, the fully escaped character mapping is used to map table column names to the XML element names, such as <EMA Chapter 22 - Getting Started with Oracle XML and C++ <PHONE_NUMBER> in the XMLFOREST() are fully escaped names from the corresponding table column names. The fully e Chapter 23 - Build an XML Database OCI C++ Application mapping will convert all of the invalid XML characters in the SQL names, such as the : character, to their Unicode representat Chapter 24 - Building an XML Data-Retrieval Application format starting with an x sign. For example, if the following object and table are created, where the object name contains a : ch Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Part VI - Oracle XML for PL/SQL Developers

CREATE TYPE mydesc AS OBJECT ("my:desc" VARCHAR(200)) / Chapter 26 - Building PL/SQL Web Services CREATE TABLE mydesc_tbl of mydesc Chapter 27 - Extending PL/SQL XML Functionality with Java / Chapter 28 - Putting It All Together INSERT INTO mydesc_tbl VALUES('fully escaped character mapping'); Chapter 25 - Getting Started with Oracle XML and PL/SQL

Appendix

- XML Standards Bodies and Open Specifications

Glossary After inserting the sample data, you can submit an SQL query as follows: Index SELECT XMLELEMENT("Test", XMLFOREST("my:desc")) FROM mydesc_tbl; List of Figures

It gives you the XML element <my_x003A_desc> with the SQL name fully escaped: List of Tables List of Sidebars <Test><my_x003A_desc>fully escaped character mapping</my_x003A_desc>

</Test>

Because: is not a legal character for the name of XML elements, it is escaped to be x003A, which is its Unicode representatio

If you need to keep the : character in the XML element/attribute names, you need to specify the name aliases for the XML elem to enable partially escaped character mapping, as shown in the following SQL query: SELECT XMLELEMENT("Test", XMLFOREST("my:desc" AS "my:desc")) FROM mydesc_tb


This allows you to create XML elements and attributes with namespaces as follows: SELECT XMLELEMENT("TEST", Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XMLATTRIBUTES('http://xmlns.oracle.com/xml/Employee.xsd' PL/SQL AS "xmlns:my"), XMLFOREST("my:desc" as "my:desc")) ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang FROM mydesc_tbl; McGraw-Hill/Osborne © 2004 (600 pages)

The result is

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

<TEST xmlns:my="http://xmlns.oracle.com/xml/Employee.xsd"> <my:desc>fully escaped character mapping</my:desc></TEST> Table of Contents

Oracle The XML Database document 10g XML defines & SQL—Design, a namespace Build prefix & Manage my forXML the <my:desc> Applications element. in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

XMLSEQUENCE()

Chapter 1

- Introducing XML

Chapter 2 - Accessing XML with DOM, SAX, and StAX The function XMLSEQUENCE() returns a JAXB, sequence of XMLTypes in XMLSEQUENCEType, which is a VARRAY of XMLType Chapter following 3 example - Transforming shows XML the output with XSLT of XMLSEQUENCE() and XPath when given a SQL cursor expression as the input: Chapter 4 XMLSEQUENCE( - Validating XML with DTDs and XML Schemas SELECT Chapter 5

- XML Operations with XQuery CURSOR(

Chapter 6

- XML Messaging and RPC with SOAP first_name, last_name SELECT employee_id, - Putting ItFROM All Together employees with XML where Pipeline, rownum JSPs, and <3)) XSQL AS result

Chapter 7

Part FROM II -dual; Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

The result Chapter 9 -isStoring XML Data XMLSEQUENCETYPE(XMLTYPE( <ROW> Chapter 10 - Generating and Retrieving XML <EMPLOYEE_ID>100</EMPLOYEE_ID> Chapter 11 - Searching XML Data <FIRST_NAME>Steven</FIRST_NAME> Chapter 12 - Managing the Oracle XML Database Part<LAST_NAME>King</LAST_NAME> III - Oracle XML for Java Developers

</ROW> Chapter 13 - Getting Started with Oracle XML and Java ),XMLTYPE( <ROW> <EMPLOYEE_ID>101</EMPLOYEE_ID> Chapter 15 - Creating a Portal Site with XML and Web Services <FIRST_NAME>Neena</FIRST_NAME> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <LAST_NAME>Kochhar</LAST_NAME> Chapter 17 - Developing XML-Based Reusable Components </ROW> Part IV - Oracle XML for C Developers )) Chapter 14 - Building an XML-Powered Web Site

Chapter 18 - Getting Started with Oracle XML and C

Chapter 19 -returns Building XML-Managed Application The query a an collection of XMLType instances containing the <EMPLOYEE_ID>, <FIRST_NAME>, and <LAST_NAME

Chapter 20 -<ROW> Build anelement XML Database Application Since the is usedOCI within each row of XMLTypes, you need to make sure it is included in the XPath expression Chapter the XML 21data - Create returned an XML-Configured as follows: High-Performance Transformation Engine Part V - Oracle XML for C++ Developers SELECT value(e).extract('/ROW/EMPLOYEE_ID').getClobVal()

Chapter 22 - Getting Started with Oracle XML and C++ FROM TABLE(SELECT XMLSEQUENCE( Chapter 23 - Build an XML Database OCI C++ Application CURSOR( Chapter 24 - Building anSELECT XML Data-Retrieval Application employee_id, first_name, last_name Part VI - Oracle XML forFROM PL/SQL Developerswhere employees

rownum <3))

Chapter 25 - Getting FROM dual) Started e; with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

The result Chapter 27 -isExtending PL/SQL XML Functionality with Java <EMPLOYEE_ID>100</EMPLOYEE_ID> Chapter 28 - Putting It All Together <EMPLOYEE_ID>101</EMPLOYEE_ID> Appendix - XML Standards Bodies and Open Specifications Glossary

In the first line of the preceding SQL query, the XPath expression /ROW/EMPLOYEE_ID is used to extract the employees’ IDs

Index

List of Figures

XMLCONCAT()

List of Tables

List of Sidebars

XMLCONCAT() takes an XMLSEQUENCEType or a number of XMLType instances and returns an XML fragment with all the content concatenated. For example, the following SQL concatenates all XML elements within an XML sequence: SELECT (XMLCONCAT( XMLSEQUENCE( CURSOR(SELECT * FROM employees WHERE rownum<3)))) FROM dual; You can also use XMLCONCAT() with a set of XMLTypes, as shown in the following SQL query:


SELECT XMLCONCAT(XMLELEMENT("Email",email), XMLELEMENT("Name", first_name||' '||last_name)) FROM employees Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & WHERE ROWNUM<3; PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

This function is useful when creating a single XML fragment from multiple XMLTypes.

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices. XMLAGG()

The XMLAGG() function aggregates all the XML elements returned by the SQL query into an XML document fragment and allo ORDER BY clause to order the XML values during the aggregation. The following SQL query returns all the employees ordere Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL first_name:

Table of Contents Introduction

SELECT XMLAGG(value(e) Part I - Oracle and the XML Standards ORDER BY EXTRACTVALUE(value(e),'/ROW/FIRST_NAME') DESC NULLS FIRST) - Introducing XML FROM TABLE(XMLSEQUENCE(CURSOR(SELECT first_name, last_name,salary Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX FROM employees))) e Chapter 3 - Transforming XML with XSLT and XPath WHERE EXTRACTVALUE(value(e), '/ROW/SALARY') BETWEEN 12000 AND 18000; Chapter 1

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 - XMLbetween Operations with XQuery and XMLAGG() is that XMLAGG() operates over the rows of data returned by the SQ The difference XMLCONCAT() Chapter 6 - XML Messaging and RPC with SOAP XMLCONCAT() doesn’t work across rows. Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

SYS_XMLAGG() - Getting Started with the Oracle XML Database

Chapter 8

Chapter 9 - Storing XML Data SYS_XMLAGG() provides similar functionality to XMLAGG() except that SYS_XMLAGG() adds an additional <ROWSET> root

Chapter - Generating XML?>10 prolog to makeand sureRetrieving the resultXML is a well-formed XML document. Like SYS_XMLGEN(), SYS_XMLAGG() can use the X

Chapter 11 -the Searching XML Data to specify output formats. However, you need to make sure the input of SYS_XMLAGG() is a scalar type, an object type or

Chapter instance. 12 Therefore, - Managingifthe multiple OracleXMLType XML Database objects are needed for SYS_XMLAGG(), you need to use XMLCONCAT() to concate Part XMLType III - Oracle objectXML instead for Java of passing Developers them directly to the SYS_XMLAGG():

Chapter 13SYS_XMLAGG(XMLCONCAT(value(e)), - Getting Started with Oracle XML and Java SELECT Chapter 14 -XMLFORMAT.createFormat('EmployeeList')) Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services FROM TABLE(XMLSEQUENCE(CURSOR(SELECT first_name, last_name,salary Chapter 16 - Developing an XML Gateway Application FROM employees))) with SOAP andeAQ

WHERE 17 EXTRACTVALUE(value(e), '/ROW/SALARY') BETWEEN 12000 AND 18000; Chapter - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

XMLCOLATTVAL()

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML function Databasecreates OCI Application The XMLCOLATTVAL() an XML fragment containing a set of <column> elements where the name attributes

Chapter the column 21 - names Create an or XML-Configured the name aliases High-Performance provided by SQLTransformation queries. For example, Engine the following SQL query returns three <column Part theirVname - Oracle attributes XML forcoming C++ Developers from the hire_date and job_id column names and the dept name alias:

Chapter 22XMLELEMENT("Employee", - Getting Started with Oracle XML and C++ SELECT Chapter 23 - Build an XML Database OCI'||last_name C++ Application AS "name"), XMLATTRIBUTES(first_name||' Chapter 24 - Building an XML Data-Retrieval XMLCOLATTVAL(hire_date, job_id, Application department_id AS "dept")) AS "result" Part VI -employees Oracle XML for FROM e PL/SQL Developers

Chapter WHERE 25 rownum=1 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

The result Chapter 27 -isExtending PL/SQL XML Functionality with Java <Employee name="Steven King"> Chapter 28 - Putting It All Together <column- XML name = "HIRE_DATE">17-JUN-87</column> Appendix Standards Bodies and Open Specifications <column name = "JOB_ID">AD_PRES</column> Glossary <column name = "dept">90</column> Index </Employee>

List of Figures List of Tables

This function is useful when table column names contain illegal XML characters.

List of Sidebars

UPDATEXML()

The UPDATEXML() function is a useful XML extension function that accepts an XMLType instance and a set of XPath expres pairs to update the XPath-referred elements or attributes with the provided values. It returns a new transient XMLType instanc original XMLType instance with appropriate XML nodes updated. The UPDATEXML() function offers multiple updates on the XML document and allows multiple namespace declarations:


SELECT UPDATEXML(column_name, 'XPath1', 'text1', …'XPathN', 'textN','Namespace1 NamespaceN') F Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

The following example illustrates how to use namespaces in an update: PL/SQL

SQL> SELECTbyUPDATEXML(XMLType( ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang 2 '<Employee xmlns:app1="www.example.com/ns1" McGraw-Hill/Osborne © 2004 (600 pages) xmlns:app2="www.example.com/ns2"> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with 3 <Name app1:type="Customer">Janet emphasis on XML standards, their usage Jones</Name> and best practices. 4 <Job app2:type="IT">Manager</Job> 5 <Salary app2:type="Hidden">12000</Salary> Table of Contents 6 <Commission app2:type="Hidden">3400</Commission> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL 7 </Employee>'), Introduction 8 '/Employee/Name/text()', 'Janet Lee', Part I - Oracle and the XML Standards 9 '/Employee/Name/@app1:type', 'Important Customer', Chapter 1 - Introducing XML 10 '/Employee/Job/@app2:type', 'Hidden', Chapter - Accessing XML with DOM, SAX, JAXB, and StAX 11 2'/Employee//*[@app2:type="Hidden"]',null, Chapter - Transforming XML with XSLT and XPath 12 3'xmlns:app1="www.example.com/ns1" Chapter - Validating XML with DTDs and XML Schemas AS result 13 4 xmlns:app2="www.example.com/ns2"') Chapter 5 - XML Operations with XQuery 14 FROM dual; Chapter 6

- XML Messaging and RPC with SOAP

The result Chapter 7 -isPutting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oraclexmlns:app1="www.example.com/ns1" XML Management for DBAs <Employee

xmlns:app2="www.example.com/ns2">

Chapter <Name 8 -app1:type="Important Getting Started with the Oracle Customer">Janet XML Database Lee</Name>

<Job/> Chapter 9 - Storing XML Data <Salary/> Chapter 10 - Generating and Retrieving XML <Commission/> Chapter 11 - Searching XML Data </Employee> Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

The input XML document contains two namespaces, the xmlns:app1=“www.example.com/ns1” and xmlns:app2=“www.e However, you don’t have to declare the namespaces for the UPDATEXML() unless the XML elements in the XPath expression Chapter 14 - Building an XML-Powered Web Site qualified by the namespaces. For example, you do not have to declare any namespace if you just need to update the /Employ Chapter 15 - Creating a Portal Site with XML and Web Services node to be Janet Lee. Chapter 13 - Getting Started with Oracle XML and Java

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter Note 17 When - Developing updating XML-Based the text content Reusable inComponents the XML elements, you should use the text() function in XPath expressions. Othe

Part IV - Oracle you want XML to forupdate C Developers the /Employee/Name element, you need to specify the XPath as /Employee/Name and the upd

Lee</Name>. Chapter 18 <Name>Janet - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

However, if XML elements in XPath need to be qualified by the namespaces, you have to declare the namespaces in UPDATE line 12 and line 13, where namespaces are delimited by whitespaces.

Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Part - Oracle XML for is C++ Developers TheVorder of updates determined by the order of the XPath expressions in the UPDATEXML() from left to right. Updates can

Chapter 22each - Getting Started update with Oracle XML on andthe C++ because successive is based result of the previous ones. Therefore, after updating the /Employee/Job/@

Chapter 23the - Build XML Database OCIthe C++ Application Hidden, next an update, which sets elements satisfied /Employee//*[@app2:type=“Hidden”] to be NULL, updates the < Chapter Building an XML Application addition24to-the <Salary> andData-Retrieval <Commission> elements. Part VI - Oracle XML for PL/SQL Developers

To update data Started stored in theOracle tables,XML youand canPL/SQL use UPDATEXML() in a SQL INSERT statement, as shown in this example: Chapter 25 -the Getting with UPDATE SETPL/SQL doc=UPDATEXML(doc, Chapter 26temp - Building Web Services Chapter '/a:foo/a:lastupdate/text()',SYSDATE, 27 - Extending PL/SQL XML Functionality with Java Chapter 'xmlns:a="http://www.example.com"'); 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

The result is

Glossary

<foo xmlns="http://www.example.com" xmlns:xsd="http://www.w3c.org/2001/XMLSchema"> Index <lastupdate xsd:type="date">12-MAY-03</lastupdate> </foo>

List of Figures List of Tables

List of we Sidebars Now have discussed the built-in SQL/XML functions in Oracle Database 10g to create XML elements, attributes, XML docu

and update XML documents. With these functions, you can create XML easily using SQL statements. In the next section, we XML functions that can also be used to create XML supporting more complex logic.


Oracle Database XML Data & SQL: with Design,DBM Build &XMLGEN Manage XML Applications in Java, C, C++ & Generating XML from10g SQL PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang andinJinyu Wang DBMS_XMLGEN is a PL/SQL package supplied Oracle Database 10g to generate XML in CLOBs or XMLTypes. © 2004 (600 pages) It is a C-basedMcGraw-Hill/Osborne implementation, which provides much better performance than the Java-based DBMS_XMLQUERY package in theThis Oracle8i and Oracle9i database. DBMS_XMLGEN provides functionality to the comprehensive guide focuses While on utilizing XML technologies withinsimilar Oracle's XML-enabled products, with emphasis XMLuseful standards, usagetoand best practices. SQL/XML functions, it is on most when their you need

Utilize the “fetching” interfaces in DBMS_XMLGEN for pagination

Table of Contents

OraclePerform Database 10g XML & SQL—Design, & Manage XML generation Applications in Java, C, C++ & PL/SQL PL/SQL processing during Build the XML document Introduction

DBMS_XMLGEN is not limited to PL/SQL statements. You can also call its functions directly from any SQL Part I - Oracle and the XML Standards statement DBMS_XMLGEN.GETXML() or DBMS_XMGEN.GETXMLTYPE(). In many cases, you will find that Chapter 1 -using Introducing XML this is easier than using the SQL/XML functions, as the input is simply a SQL statement. The following sections Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX providing typical examples describe how you can use this package. Chapter 3 some - Transforming XML withand XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

- XML Operations with XQuery Canonical Mapping

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

Unlike the DBMS_XMLGEN uses a canonical Chapter 7 -SQL/XML Putting It functions, All Together with XML Pipeline, JSPs, and XSQL mapping to map the SQL data to XML. The format exactly theManagement same formatfor used by the DBMS_XMLQUERY PL/SQL package or the XML SQL Utility (XSU) Part II - is Oracle XML DBAs Java packages. TheStarted following generates an XML document containing a set of employee records: Chapter 8 - Getting withexample the Oracle XML Database SQL> SET AUTOPRINT ON Chapter 9 - Storing XML Data SQL> SET LONG 100000 Chapter 10 - Generating and Retrieving XML SQL> VAR result CLOB Chapter 11 - Searching XML Data SQL> DECLARE Chapter 12 - Managing the Oracle XML Database DBMS_XMLGEN.CTXHANDLE; PartqryCtx III - Oracle XML for Java Developers BEGIN qryCtx := Chapter 14 - Building an XML-Powered Web Site DBMS_XMLGEN.NEWCONTEXT('SELECT employee_id AS "@id", Chapter 15 - Creating a Portal Site with XML and Web Services first_name AS "FirstName", Chapter 16 - Developing an XML Gateway Application with SOAP and AQ last_name AS "LastName", Chapter 17 - Developing XML-Based Reusable Components email AS "Email", Part IV - Oracle XML for C Developers phone_number AS "Phone" Chapter 18 - Getting Started with OracleFROM XML and C employees Chapter 19 - Building an XML-Managed Application WHERE salary > 20000'); Chapter 20 - Build an XML Database OCI Application DBMS_XMLGEN.SETROWSETTAG(qryCtx,'EMPLOYEES'); Chapter 21 - Create an XML-Configured High-Performance Transformation Engine DBMS_XMLGEN.SETROWTAG(qryCtx,'EMPLOYEE'); Part:result V - Oracle := XMLDBMS_XMLGEN.GETXML(qryCtx); for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++ DBMS_XMLGEN.CLOSECONTEXT(qryCtx); Chapter END; 23 - Build an XML Database OCI C++ Application Chapter 13 - Getting Started with Oracle XML and Java

Chapter 24 - Building an XML Data-Retrieval Application

TheVI result is XML for PL/SQL Developers Part - Oracle <?xml 25 version="1.0"?> Chapter - Getting Started with Oracle XML and PL/SQL <EMPLOYEES> Chapter 26 - Building PL/SQL Web Services <EMPLOYEE id = "100"> Chapter 27 - Extending PL/SQL XML Functionality with Java <FirstName>Steven</FirstName> Chapter 28 - Putting It All Together <LastName>King</LastName> Appendix - XML Standards Bodies and Open Specifications <Email>SKING</Email> <Phone>515.123.4567</Phone> Index </EMPLOYEE> List of Figures </EMPLOYEES> Glossary

List of Tables

List ofNote Sidebars In the example, the SQL*Plus command SET AUTOPRINT ON is used to automatically display the value

of the bind variables (the result variable in the CLOB data type). The canonical mapping uses the <ROW> element to enclose each row of data returned by the SQL query. The <ROW> elements are then included by the <ROWSET> element to create the XML document. In the example, the <ROWSET> or <ROW> element names are changed to EMPLOYEES and EMPLOYEE respectively by calling the DBMS_XMLGEN.SETROWSETTAG() and DBMS_XMLGEN.SETROWTAG() procedures.


Note By setting the parameters of DBMS_XMLGEN.SETROWSETTAG() and DBMS_XMLGEN.SETROWTAG() to NULL, you can suppress the <ROWSET> and <ROW> elements. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & However, suppressing the <ROWSET> element may result in no root element for the XML document and PL/SQL the following error: ORA-19336: Missing XML root element. ISBN:0072229527

by Mark V. Scardina, Ben Chang and Jinyu Wang © 2004 use (600 pages) By default, the McGraw-Hill/Osborne child elements of <ROW> the table column names as their element names. There is no PL/SQL

This comprehensive guide focuses on utilizing XML technologies Oracle's XML-enabled with procedure provided in the DBMS_XMLGEN package to customize the nameswithin of these elements, but, youproducts, can on XML standards, their usage and best practices. modify them viaemphasis the AS clause in the SQL query. In the example, the LastNameis set as the aliasfor the last_name column, and the employee_id column uses the alias @id. The difference between aliases with or Table of Contents without @ in the aliases, is that the column with an alias with @ is mapped to an XML attribute instead of an XML Oracle element. Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Print Formatting

Chapter 1

- Introducing XML

Chapter 2 - Accessing XMLyou with DOM, JAXB, formats and StAX Using DBMS_XMLGEN, can set SAX, the output using the following procedures: Chapter 3 - Transforming XML with XSLT and XPath PROCEDURE SETINDENTATIONWIDTH(ctx IN CTXHANDLE, width IN NUMBER); Chapter 4 - Validating XML with DTDs and XML IN Schemas PROCEDURE SETPRETTYPRINTING(ctx CTXHANDLE, pp IN BOOLEAN); Chapter 5

- XML Operations with XQuery

By default, is in “pretty” Chapter 6 - the XMLoutput Messaging and RPCprint withformat SOAP with all the whitespaces, indentations and linefeeds between the XML elements, you It can the number of whitespace characters used for indentation by calling Chapter 7 -and Putting Allset Together with XML Pipeline, JSPs, and XSQL DBMS_XMLGEN.SETINDENTATIONWIDTH(). By setting the second parameter of Part II - Oracle XML Management for DBAs DBMS_XMLGEN.SETPRETTYPRINTING() to be FALSE, you can to get the XML documents generated in Chapter 8 - Getting Started with the Oracle XML Database “compact” the whitespaces between the XML element tags stripped out, as shown in the following Chapter 9 -format Storingwith XMLallData example:

Chapter 10 - Generating and Retrieving XML

DECLARE Chapter 11 - Searching XML Data qryCtx Chapter 12 -DBMS_XMLGEN.CTXHANDLE; Managing the Oracle XML Database BEGIN Part III - Oracle XML for Java Developers qryCtx Chapter 13 -:= Getting Started with Oracle XML and Java DBMS_XMLGEN.NEWCONTEXT('SELECT employee_id AS "@id", first_name as "FirstName", Chapter 15 - Creating a Portal Site with XML and Web Services last_name as "LastName", Chapter 16 - Developing an XML Gateway Application with SOAP and AQ email as "Email", Chapter 17 - Developing XML-Based Reusable Components phone_number as "Phone" Part IV - Oracle XML for C Developers FROM employees Chapter 18 - Getting Started with Oracle XML and C WHERE salary > 20000'); Chapter 19 - Building an XML-Managed Application DBMS_XMLGEN.SETPRETTYPRINTING(qryCtx, FALSE); Chapter 20 - Build XML Database OCI Application :result := an DBMS_XMLGEN.GETXML(qryCtx); Chapter 21 - Create an XML-Configured High-Performance Transformation Engine DBMS_XMLGEN.CLOSECONTEXT(qryCtx); Part V Oracle XML for C++ Developers END; Chapter 14 - Building an XML-Powered Web Site

Chapter 22 - Getting Started with Oracle XML and C++

The result Chapter 23 -isBuild an XML Database OCI C++ Application Chapter - Building an XML Data-Retrieval Application <?xml 24 version="1.0"?> Part VI - Oracle XML for PL/SQL Developers <ROWSET><ROW><EMPLOYEE_ID>100</EMPLOYEE_ID>

Chapter <FIRST_NAME>Steven</FIRST_NAME><LAST_NAME>King</LAST_NAME> 25 - Getting Started with Oracle XML and PL/SQL

<EMAIL>SKING</EMAIL><PHONE_NUMBER>515.123.4567</PHONE_NUMBER> Chapter 26 - Building PL/SQL Web Services <HIRE_DATE>17-JUN-87</HIRE_DATE><JOB_ID>AD_PRES</JOB_ID> Chapter 27 - Extending PL/SQL XML Functionality with Java <SALARY>24000</SALARY><DEPARTMENT_ID>90</DEPARTMENT_ID> Chapter 28 - Putting It All Together </ROW></ROWSET> Appendix - XML Standards Bodies and Open Specifications Glossary

Though this output is not the pretty format that you can easily read, an XML parser considers the data to be equivalent.

Index

List of Figures

List ofNote Tables The output format customization is the new feature for the DBMS_XMLGEN package in Oracle Database List of Sidebars 10g.

Data Fetching When a large amount of data is returned by the SQL query, it is not efficient to generate a single huge XML document containing all the data. This will result in memory issues when performing DOM-based processing or transmitting the document to another user. The data “fetching” feature in DBMS_XMLGEN allows you to generate a set of small XML documents using the following procedures:


FUNCTION GETNUMROWSPROCESSED(ctx IN CTXHANDLE) RETURN NUMBER; PROCEDURE SETMAXROWS(ctx IN CTXHANDLE, maxRows IN NUMBER); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

Here is an example using these functions in a PL/SQL FOR...LOOP: PL/SQL

SQL> SET SERVEROUTPUT ON SIZE 1000000 ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang SQL> DECLARE McGraw-Hill/Osborne © 2004 (600 pages) qryCtx This DBMS_XMLGEN.CTXHANDLE; comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with res emphasis BOOLEAN; on XML standards, their usage and best practices. result XMLType; i NUMBER :=0; Table of Contents BEGIN Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL -- Create the query context Introduction qryCtx := DBMS_XMLGEN.NEWCONTEXT( Part I - Oracle and the XML Standards 'SELECT * FROM employees ORDER BY employee_id'); Chapter 1 - Introducing XML DBMS_XMLGEN.SETMAXROWS(qryCtx,10); Chapter 2 LOOP - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 - Transforming XML with XSLT and XPath result:= DBMS_XMLGEN.GETXMLTYPE(qryCtx); Chapter 4 - Validating XMLDBMS_XMLGEN.GETNUMROWSPROCESSED(qryCtx) with DTDs and XML Schemas EXIT WHEN =0; Chapter 5 - XML Operations with XQuery i :=i+1; Chapter 6 - XML MessagingXML and DB RPCResources with SOAP -- Create Chapter 7 - Putting res :=It All DBMS_XDB.CREATERESOURCE('/public/emp'||i||'.xml',result); Together with XML Pipeline, JSPs, and XSQL Part II - Oracle IFXML resManagement = FALSE for THEN DBAs DBMS_OUTPUT.PUT_LINE('Error creating XML DB resource'); Chapter 8 - Getting Started with the Oracle XML Database ELSE Chapter 9 - Storing XML Data DBMS_OUTPUT.PUT_LINE('/public/emp'||i||'.xml'||' is created'); Chapter 10 - Generating and Retrieving XML END IF; Chapter 11 - Searching XML Data LOOP;the Oracle XML Database Chapter 12END - Managing COMMIT; Part III - Oracle XML for Java Developers END; Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

The SQL query gets all the employees in order of their employee_id. By setting Max Rows to be 10, each XML

Chapter 15 -contains Creatingno a Portal Site with XML and Web document greater than ten records. TheServices DBMS_XMLGEN.GETNUMROWSPROCESSED() function Chapter 16 - Developing an XML Gateway Application with SOAP AQthe previous DBMS_XMLGEN.GETXML() calls. keeps track of the number of rows that get decremented by 10and from Chapter 17 loops - Developing XML-Basedthe Reusable Components Once the have completed, DBMS_XMLGEN.GETNUMROWSPROCESSED() returns zero, and the Part IV - Oracle XML for C Developers procedure exits.

Chapter 18 - Getting Started with Oracle XML and C

During 19 the-creation outputs, DBMS_XMLGEN.GETXMLTYPE() is used to return the query result in XMLType. Chapter Building of anthe XML-Managed Application This XMLType is an then used by DBMS_XDB.CREATERESOURCE() to create a resource file in the XML DB Chapter 20 - Build XML Database OCI Application Repository. After the files areHigh-Performance created, you canTransformation access the XML documents either through the Chapter 21 - Create an resource XML-Configured Engine

WebDAV/HTTP orfor theC++ FTPDevelopers interfaces. For example, when you type the following HTTP address in Internet Explorer: Part V - Oracle XML http://localhost:8080/public Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

A window pops up asking for login information. You can log in using any database username and its associated password. However, because the resource is created as a private resource by default, you need to log in as HR Part VI - Oracle XML for PL/SQL Developers user to access the generated files from HR user, as shown in Figure 10-1. Chapter 24 - Building an XML Data-Retrieval Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 - XML with XQuery Figure 10-1:Operations HTTP access of XDB (XML DB) repository Chapter 6

- XML Messaging and RPC with SOAP

From these interfaces, can easily the JSPs, files from the database server to other client systems. Chapter 7 - Putting It Allyou Together with download XML Pipeline, and XSQL Part II - Oracle XML Management for DBAs

Getting Started with the Oracle XML Database Using -REF Cursor

Chapter 8 Chapter 9

- Storing XML Data

Chapter In addition 10 -to Generating creating the andquery Retrieving context XML from SQL queries, DBMS_XMLGEN.NEWCONTEXT() allows you to create

the query based REF cursors. This is done by specifying a SYS_REFCURSOR as the initialization Chapter 11 context - Searching XMLonData parameter, shown the in the following example: Chapter 12 - as Managing Oracle XML Database Part III SET - Oracle XML for Java SQL> AUTOPRINT ON Developers

Chapter 13 - Getting with Oracle XML and Java SQL> VAR resultStarted CLOB; Chapter SQL> DECLARE 14 - Building an XML-Powered Web Site

NUMBER :=20000; Chapter salary 15 - Creating a Portal Site with XML and Web Services SYS_REFCURSOR; Chapter refcur 16 - Developing an XML Gateway Application with SOAP and AQ DBMS_XMLGEN.CTXHANDLE; Chapter qryCtx 17 - Developing XML-Based Reusable Components BEGIN Part IV - Oracle XML for C Developers OPEN FOR with Oracle XML and C Chapter 18 -refcur Getting Started * FROM employees WHERE salary> :1' USING salary; Chapter 19'SELECT - Building an XML-Managed Application qryCtx := DBMS_XMLGEN.NEWCONTEXT(refcur); :result := DBMS_XMLGEN.GETXML(qryCtx,DBMS_XMLGEN.NONE); Chapter 21 - Create an XML-Configured High-Performance Transformation Engine DBMS_XMLGEN.CLOSECONTEXT(qryCtx); Part V - Oracle XML for C++ Developers END; Chapter 20 - Build an XML Database OCI Application

Chapter 22 - Getting Started with Oracle XML and C++

Chapter - Build an you XMLneed Database OCI C++ This is 23 useful when to create XMLApplication from a result set returned by another PL/SQL process. Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Using Bind Variables

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 -you Building Web Services Whenever use aPL/SQL SQL query repeatedly by simply updating several variables, you should think about using bind Chapter 27 -because Extending PL/SQL XML the Functionality with Java variables, they eliminate need to reparse the SQL statement, thus saving processing time. In the Chapter 28example, - Putting It Together following weAllopen a SYS_REFCURSORfor the department_id in the department table and use it to find Appendix - XML Standards Bodies and OpenWhen Specifications all the employees within each department. creating the loop for each department_id, Glossary DBMS_XMLGEN.SETBINDVALUE() is used to set the bind variable for the SQL query, and Index DBMS_XMLGEN.CLEARBINDVALUE() is used to clear the bind variable data. List of Figures DECLARE List qryCtx of Tables DBMS_XMLGEN.CTXTYPE; List v_sql of Sidebars VARCHAR2(100);

v_clob CLOB; TYPE deptType IS RECORD (department_id NUMBER(4)); v_deprec deptType; v_refcur SYS_REFCURSOR; BEGIN qryCtx := DBMS_XMLGEN.NEWCONTEXT( 'SELECT * FROM employees WHERE department_id = :MID'); -- Open Ref Cursor


OPEN v_refcur FOR 'SELECT department_id FROM departments WHERE location_id = 1700'; -- Loop each department Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & LOOP PL/SQL -- Fetch variable. ISBN:0072229527 by from Mark V.cursor Scardina, Ben Chang and Jinyu Wang FETCH McGraw-Hill/Osborne v_refcur INTO v_deprec; © 2004 (600 pages) EXIT WHEN v_refcur%NOTFOUND; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with DBMS_XMLGEN.SETBINDVALUE( 'MID', emphasis on XML standards,qryCtx, their usage and bestv_deprec.department_id); practices. v_clob := DBMS_XMLGEN.GETXML( qryCtx ); INSERT INTO temp VALUES(v_clob); Table of Contents END LOOP; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL DBMS_XMLGEN.CLOSECONTEXT(qryCtx); Introduction EXCEPTION Part I - Oracle and the XML Standards WHEN OTHERS THEN Chapter DBMS_XMLGEN.CLOSECONTEXT(qryCtx); 1 - Introducing XML Chapter END; 2 - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

Querying V$SQL view in SYS user, canSchemas see how many times the SQL query is parsed and executed: Chapter 4 the - Validating XML with DTDs andwe XML Chapter 5 - XML parse_calls,executions Operations with XQuery SQL> SELECT Chapter FROM 6 - XML Messaging and RPC with SOAP v$sql Chapter WHERE 7 - Putting sql_text It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle LIKE XML 'SELECT Management * FROM for DBAs employees

WHERE department_id =%';

PARSE_CALLS EXECUTIONS Chapter 8 - Getting Started with the Oracle XML Database ------------------Chapter 9 - Storing XML Data 1 Chapter 10 - Generating and21 Retrieving XML Chapter 11 - Searching XML Data

Note The V$SQL view is one of the V$ views created on the dynamic performance tables, in which every parsed and stored SQL statement in the shared pool is presented as a row in the view. You need to run Part III - Oracle XML for Java Developers GRANT SELECT ON v_$sql TO HR before running the query on V$sql. Chapter 12 - Managing the Oracle XML Database

Chapter 13 - Getting Started with Oracle XML and Java

Chapter 14 -shows Building anthe XML-Powered Site The result that SQL queryWeb is executed 21 times but is only parsed once. This shows the value of using Chapter 15 - Creating a Portal Site with XML and Web Services bind variables in SQL. Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Dealing with Special Characters

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started XML and C Some characters—such aswith ‘, <,Oracle and >—are special characters in XML documents and must be in escaped format, Chapter 19 - Building an XML-Managed Application also known as character entities format. For example, the escaped format for ‘ is ', the escaped format for > Chapter is >,20 and - Build the escaped an XML Database format forOCI < isApplication <. By default, all special characters are escaped. For example, the

following query a ‘ character: Chapter 21SQL - Create ancontains XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers SELECT DBMS_XMLGEN.GETXML(

Chapter 22 -'SELECT Getting Started with Oracle XML and C++ AS result FROM dual') ''Don''''t escape me!'' Chapter 23 - Build an XML Database OCI C++ Application FROM dual; Chapter 24 - Building an XML Data-Retrieval Application

TheVI following generated with the ' escaped: Part - OracleXML XML document for PL/SQLisDevelopers Chapter <?xml 25 version="1.0"?> - Getting Started with Oracle XML and PL/SQL

<ROWSET> Chapter 26 - Building PL/SQL Web Services <ROW> Chapter 27 - Extending PL/SQL XML Functionality with Java <RESULT>Don't escape me!</RESULT> Chapter 28 - Putting It All Together </ROW> - XML Standards Bodies and Open Specifications Appendix </ROWSET> Glossary Index List of Figures

To avoid the character escaping, you can call the DBMS_XMLGEN.SETCONVERTSPECIALCHARS() procedure

List ofFALSE, Tables as in the following example: with List of Sidebars

DECLARE qryCtx DBMS_XMLGEN.CTXHANDLE; BEGIN qryCtx := DBMS_XMLGEN.NEWCONTEXT( 'SELECT ''Don''''t escape me!'' as result FROM dual'); DBMS_XMLGEN.SETCONVERTSPECIALCHARS(qryCtx, FALSE); :result := DBMS_XMLGEN.GETXML(qryCtx);


DBMS_XMLGEN.CLOSECONTEXT(qryCtx); END; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

The generatedPL/SQL XML document will have the following format:

<?xml version="1.0"?> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <ROWSET> McGraw-Hill/Osborne © 2004 (600 pages) <ROW> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <RESULT>Don't escape emphasis on XMLme!</RESULT> standards, their usage and best practices. </ROW> </ROWSET>

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL:SQL/XML Design, Build Functions & Manage XML Applications in Java, C, C++ & RetrievingOracle Using XMLType and PL/SQL

bydiscussed Mark V. Scardina, Ben Chang and JinyuXML Wang So far, we have various ways of generating from SQL data using the SQL/XML functionsISBN:0072229527 and the McGraw-Hill/Osborne © 2004 (600 pages) DBMS_XMLGEN package. In Oracle Database 10g, if you already have XML documents natively stored as XMLTypes, youThis cancomprehensive use the built-inguide XMLType member functions and the SQL/XML functions to retrieve and createwith focuses on utilizing XML technologies within Oracle's XML-enabled products, emphasis on XML usage and bestand practices. XML. Table 10-3 summarizes thestandards, XMLTypetheir member functions their respective XML processing functionalities.

Table XMLType Member Functions Table of 10-3: Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Name

Introduction Part XMLType() I - Oracle and the XML Standards

createXML() Chapter 1 - Introducing XML

Functionality

Create XMLTypes from XML data stored in VARCHAR2, CLOB, or other XMLTypes.

createSchemaBasedXML() Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX createNonSchemaBasedXML() Chapter 3 - Transforming XML with XSLT and XPath Chapter 4 - Validating XML with DTDs and XML Schemas existsNode()

Checks if the XML nodes or node sets specified by XPath exist. It returns 1 if nodes or node sets Chapter 6 - XML Messaging and RPC with SOAP are found; otherwise, it returns 0. Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL If the XPath string is NULL or the document is Part II - Oracle XML Management for DBAs empty, then a value of 0 is returned; otherwise, 1 Chapter 8 - Getting Started with the Oracle XML Database is returned. Chapter 5

- XML Operations with XQuery

Chapter 9

- Storing XML Data

extract()

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

Extracts nodes or node sets based on the XPath expression and returns an XMLType instance containing the resulting node(s).

isFragment() Part III - Oracle XML for Java Developers

Checks if the XMLType is an XML document fragment or a wellformed document. It returns 1 if the XMLType is Chapter 14 - Building an XML-Powered Web Site an XML document fragment or a well-formed Chapter 15 - Creating a Portal Site with XML and Web Services document. Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Otherwise, it returns 0. Determines if the XMLType instance corresponds Chapter 17 - Developing XML-Based Reusable Components to a well-formed document or a fragment. Returns Part IV - Oracle XML for C Developers 1 or 0 indicating if Chapter 18 - Getting Started with Oracle XML and C the XMLType instance contains a fragment or a Chapter 19 - Building an XML-Managed Application well-formed document. Chapter 13 - Getting Started with Oracle XML and Java

Chapter 20 - Build an XML Database OCI Application

getClobVal() Gets the CLOB, NUMBER, or String value in Chapter 21 - Create an XML-Configured High-Performance Transformation Engine getNumberVal() Part V - Oracle XML for C++ Developers getStringVal() Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application transform() Part VI - Oracle XML for PL/SQL Developers

VARCHAR2, respectively, from the XMLType. You can only use getNumberVal() when the content of XMLType is numeric. Transforms the XML content in XMLType with the XSL stylesheet specified.

Chapter 25 - Getting Started with Oracle XML and PL/SQL

toObject() Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java isSchemaBased()

Casts the XMLType to other object types.

Checks the XML schema–related information of XMLType. Appendix - XML Standards Bodies and Open Specifications If the XMLType is XML schema–based, getRootElement() Glossary getNamespace() isSchemaBased() Index returns TRUE. Then, getSchemaURL(), getRootElement(), and getNamespace() can be List of Figures used to find out the registered XML schema URL, List of Tables the defined root element and the namespace of List of Sidebars the root element for the XMLType. Chapter 28 - Putting It All Together getSchemaURL()


isSchemaValidate() Checks and updates the XML Schema validation isSchemaValid() status of XMLType. If the XMLType is valid Oracle Database 10g XML & SQL: Design,against Build &the Manage XML Applications in Java, C, C++ & schemaValidation() XML schema, then PL/SQL setSchemaValidate() isSchemaValidate() returns 1. The ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang isSchemaValid() function returns the validation McGraw-Hill/Osborne © 2004 (600 pages) status of the XMLType against the supplied XML This comprehensive guide focuses on utilizingschema.To XML technologies Oracle's XML-enabled updatewithin the status of the XMLType,products, with emphasis on XML standards, their usage and schemaValidation() best practices. validates the XMLType against an XML schema and updates the status to Table of Contents validated after the validation. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications Java, C, C++ & you PL/SQL If you validatedinthe XMLTypes, can update Introduction Part I - Oracle and the XML Standards

Chapter 1

the status through the setSchemaValidate() procedure.

- Introducing XML

Chapter Accessing withofDOM, SAX, JAXB, andin StAX We will2not- discuss allXML details the functions listed Table 10-3, because they are well covered by the online Chapter - Transforming XML with XSLT andGuide XPath. Instead, in the following section, we will explore frequently used manual,3Oracle XML Database Developer’s Chapter functionality 4 - Validating to help you XML solve withsome DTDsreal andproblems. XML Schemas Chapter 5

- XML Operations with XQuery

Both the SQL/XML extension functions and XMLType member functions can be used, along with SQL commands - XML Messaging and RPC with SOAP such as SELECT, UPDATE, and INSERT to perform XML operations. This section discusses how you can extract, Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL transform, and update the content when XML is stored natively in XMLTypes. Chapter 6

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

extract() andXML existsNode() Chapter 9 - Storing Data

Chapter 10 - Generating and Retrieving XML

The XMLType.extract() object member function extracts nodes or node sets based on the passed XPath expression and returns an XMLType instance containing the resulting node or nodes. You need to specify the table name alias Chapter 12 - Managing the Oracle XML Database to qualify the object. Otherwise, you will get an error message as follows: Chapter 11 - Searching XML Data

Part III - Oracle XML for Java Developers

SQL> SELECT description.extract('//KEYWORD').isFragment() Chapter 13 - Getting Started with Oracle XML and Java FROM product; SELECT description.extract('//KEYWORD').isFragment() FROM product Chapter 15 - Creating a Portal Site with XML and Web Services * Chapter 16 - Developing an XML Gateway Application with SOAP and AQ ERROR at line 1: Chapter 17 - Developing XML-Based Reusable Components ORA-00904: "DESCRIPTION"."EXTRACT": invalid identifier Chapter 14 - Building an XML-Powered Web Site

Part IV - Oracle XML for C Developers

Chapter 18 - Getting with XML and C contains a description XMLType column. In this example fromStarted Chapter 8, Oracle the product table Chapter 19 - Building an XML-Managed Application

There are SQL/XMLOCI extension functions with the same name as the XMLType member functions, Chapter 20 -corresponding Build an XML Database Application including EXISTSNODE(). They are functionally the same except that they take an XMLType as Chapter 21EXTRACT()and - Create an XML-Configured High-Performance Transformation Engine theirV first parameter and normally do not require the use of qualified names, as are needed by the XMLType member Part - Oracle XML for C++ Developers functions. following example illustrates using the EXTRACT() SQL/XML function: Chapter 22 -The Getting Started with Oracle XML and C++ SQL> SELECT FROM product; Chapter 23 - BuildEXTRACT(description,'//KEYWORD') an XML Database OCI C++ Application EXTRACT(DESCRIPTION,'//KEYWORD') Chapter 24 - Building an XML Data-Retrieval Application ---------------------------------------------------------------------------Part VI - Oracle XML for PL/SQL Developers <KEYWORD>xdk</KEYWORD> Chapter 25 - Getting Started with Oracle XML and PL/SQL <KEYWORD>XML</KEYWORD> Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

EXTRACTVALUE()

Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

EXTRACTVALUE()does not belong to the XMLType object. It is an Oracle-provided SQL/XML function that returns Glossary scalar content, such as numbers or strings, when passed an XPath expression. This function is quite convenient to Index

use because it automatically gets the value of the child text element of the specified XML node. However, make sure the XPath points to an XML element with only a single child text element, otherwise, you will get the following error:

List of Figures List of Tables

<DESCRIPTION>This Oracle XML Parser supports <KEY>DOM</KEY> and List of Sidebars <KEY>SAX</KEY> interfaces.</DESCRIPTION> SQL> SELECT EXTRACTVALUE(description,'//DESCRIPTION/text()') FROM product; SELECT EXTRACTVALUE(description,'//DESCRIPTION/text()') FROM product * ERROR at line 1: ORA-19025: EXTRACTVALUE returns value of only one node The EXTRACTVALUE() function always returns a VARCHAR2 by default for string values. Therefore, the node


value cannot be greater than 4K. If larger sizes are needed, you can use XMLType.extract() to get the document and use the XMLType getClobVal() to get the content out in CLOB. When the XMLType storage is based on an XML schema, at queryDatabase compile time, can automatically the appropriate based Oracle 10g EXTRACTVALUE() XML & SQL: Design, Build & Managereturn XML Applications in data Java,type C, C++ & on the XML schema information, such as in a CLOB, DATE, or NUMBER. PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Generating XML Schemas PL/SQL

Mark V. Scardina, Chang for andXML Jinyuand Wang XML schemas by and DTDs define theBen metadata can ensure both data and structural integrity.ISBN:0072229527 In Oracle Database McGraw-Hill/Osborne © 2004 (600 pages) 10g, the DBMS_XMLQUERY PL/SQL package and the XML SQL Utility (XSU) Java package support XML schema generation from simple SQL statements. DBMS_XMLSCHEMA can generate XML schemas from XML-enabled existing object types. with This comprehensive guide focuses on utilizing XML technologies withinonly Oracle's products, emphasis on XML standards, their usage and best practices.

Note DBMS_XMLGEN does not support XML schema or DTD generation.

Table of Contents Taking the employees table as an example and using DBMS_XMLQUERY, we can generate the corresponding XML schema Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

SET AUTOPRINT ON VAR result CLOB; Part I - Oracle and the XML Standards BEGIN Chapter 1 - Introducing XML :result:=DBMS_XMLQUERY.GETXML('SELECT employee_id AS "@id", Chapter 2 - Accessing XML with DOM, SAX, JAXB, and email, StAX department_id Chapter 3 - Transforming XML with XSLT andFROM XPathemployees WHERE rownum=1', Chapter 4 - Validating XML with DTDs and XML Schemas DBMS_XMLQUERY.SCHEMA); Chapter END; 5 - XML Operations with XQuery Introduction

Chapter 6

- XML Messaging and RPC with SOAP

The generated XMLItschema is with XML Pipeline, JSPs, and XSQL Chapter 7 - Putting All Together Part II - Oracle XML = Management <?xml version '1.0'?> for DBAs

Chapter <DOCUMENT 8 - Getting xmlns:xsd="http://www.w3.org/2001/XMLSchema"> Started with the Oracle XML Database

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> Chapter 9 - Storing XML Data <xsd:element Chapter 10 - Generatingname="ROWSET"> and Retrieving XML <xsd:complexType> Chapter 11 - Searching XML Data Chapter <xsd:sequence> 12 - Managing the Oracle XML Database

name="ROW" Part III - <xsd:element Oracle XML for Java Developers minOccurs="0"

maxOccurs="unbounded"> <xsd:complexType> Chapter 13 - Getting Started with Oracle XML and Java <xsd:sequence> Chapter 14 - Building an XML-Powered Web Site <xsd:element name="EMAIL" nillable="true" minOccurs="0"> Chapter 15 - Creating a Portal Site with XML and Web Services <xsd:simpleType> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <xsd:restriction base="xsd:string"> Chapter 17 - Developing XML-Based Reusable Components <xsd:maxLength value="25"/> Part IV - Oracle XML for C Developers </xsd:restriction> Chapter 18 - Getting Started with Oracle XML and C </xsd:simpleType> Chapter 19 - Building an XML-Managed Application </xsd:element> Chapter 20 - Build an XML Database OCI Application <xsd:element name="DEPARTMENT_ID" type="xsd:integer" nillable="true" minOccurs="0"/ Chapter 21 - Create an XML-Configured </xsd:sequence> High-Performance Transformation Engine Part V - Oracle XML for C++ Developers <xsd:attribute name="num" type="xsd:integer"/> Chapter 22 - Getting Started with Oracle XML and C++ <xsd:attribute name="id" type="xsd:integer"/> Chapter 23 - Build an XML Database OCI C++ Application </xsd:complexType> Chapter 24</xsd:element> - Building an XML Data-Retrieval Application Part VI - Oracle </xsd:sequence> XML for PL/SQL Developers Chapter </xsd:complexType> 25 - Getting Started with Oracle XML and PL/SQL </xsd:element> Chapter 26 - Building PL/SQL Web Services </xsd:schema> Chapter 27 - Extending PL/SQL XML Functionality with Java <ROWSET xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Chapter 28 - Putting It All Together xsi:noNamespaceSchemaLocation="#/DOCUMENT/xsd:schema[not(@targetNamespace)]"> Appendix - XML Standards Bodies and Open Specifications <ROW num="1" id="100"> Glossary <EMAIL>SKING</EMAIL> Index <DEPARTMENT_ID>90</DEPARTMENT_ID> List of Figures </ROW> List of Tables </ROWSET> List of Sidebars </DOCUMENT>

The generated XML schema maps database data types to the corresponding XML schema data types. In this case, VARCHAR2 maps to xsd:string and NUMBER maps to xsd:integer. The generated schema also includes the length constraints for the VARHAR2 columns using the xsd:maxLength for xsd:string. For table columns that can be NULL, the attributexsd:nillable=“true” is added. The generated XML documents specify the schema location using the special syntax in Oracle XML DB, which uses # to specify the current document followed by the XPath to the XML schema definition. Oracle XM schema processors are extended to validate the XML document using this “inline” XML schema location, though this is not


defined in the W3C XML Schema Recommendation.

To generate the DTDs, you can use DBMS_XMLQUERY.DTD as the second parameter for the DBMS_XMLQUERY.GETXML Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & function, as shown in the following example: PL/SQL SET AUTOPRINT ON V. Scardina, Ben Chang and Jinyu Wang ISBN:0072229527 by Mark VAR result McGraw-Hill/Osborne CLOB; © 2004 (600 pages) BEGIN This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with :result:=DBMS_XMLQUERY.GETXML('SELECT * and FROM emphasis on XML standards, their usage bestemployees practices. WHERE rownum=1', DBMS_XMLQUERY.DTD); Table of Contents END; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Introduction The XSU Java package provides similar interfaces to those provided by the DBMS_XMLQUERY package. Part I - Oracle and the XML Standards

Using DBMS_XMLSCHEMA, Chapter 1 - Introducing XML you can create the following object types and use them as parameters as in the following example: Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 OR - Transforming XML with XSLTAS andOBJECT XPath CREATE REPLACE TYPE EMP_T Chapter ( "@id" 4 - Validating NUMBER(6), XML with DTDs and XML Schemas

email VARCHAR2(25), Chapter 5 - XML Operations with XQuery department_id NUMBER(4)); Chapter 6 - XML Messaging and RPC with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

SELECT DBMS_XMLSCHEMA.GENERATESCHEMA('HR', Part II - Oracle XML Management for DBAs Chapter 8

'EMP_T') FROM dual;

- Getting Started with the Oracle XML Database

If there is any related object, you must create the corresponding object. Otherwise, you will get the following error:

Chapter 9

- Storing XML Data PLS-00382: expression is ofXML wrong type Chapter 10 - Generating and Retrieving Chapter 11 - Searching XML Data

Though using the DBMS_XMLSCHEMA package is complicated, it allows great flexibility in creating XML hierarchical structure The advantage of using DBMS_XMLQUERY is that you need to pass only in SQL queries. However, it generates limited types Part III - Oracle XML for Java Developers of XML schemas. Chapter 12 - Managing the Oracle XML Database

Chapter 13 - Getting Started with Oracle XML and Java

Chapter Note 14 If - Building the objects an XML-Powered belong to different Web Site user schemas, using DBMS_XMLQUERY.GETXML() or

Chapter 15 DBMS_XMLSCHEMA.GENERATESCHEMAS(), - Creating a Portal Site with XML and Web Servicesinstead of DBMS_XMLSCHEMA.GENERATESCHEMA(), will crea

XML an schemas. Chapter 16 multiple - Developing XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Creating XMLType Views PL/SQL

by Mark Scardina, Ben and Jinyu Wang relational or object-relational data in XML.ISBN:0072229527 An XMLType view is anV.efficient way of Chang encapsulating existing In Oracle © 2004 (600 pages) Database 10g,McGraw-Hill/Osborne you can use any SQL or PL/SQL functions that generate XMLTypes to create an XMLType view. There are two different ways of creating XMLType columns or rows. This comprehensive guide focuses on views—as utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

You can create a view where the XMLType is a single column, as shown in the following example using a SQL/XML statement:

Table of Contents

CREATE OR REPLACE VIEW employee_vw Oracle Database 10g XML & SQL—Design, Build & AS Manage XML Applications in Java, C, C++ & PL/SQL SELECT XMLELEMENT("Employee", Introduction Part I - Oracle and XMLATTRIBUTES(first_name||' the XML Standards

'||last_name AS "name"), XMLFOREST(salary, phone_number))AS result,employee_id Chapter 1 - Introducing XML FROM employees; Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 -run Transforming XML with XSLT and When you describe employee_vw, youXPath will see the following definition for the view: Chapter 4

- Validating XML with DTDs and XML Schemas

SQL> describe employee_vw; - XML Operations with XQuery Name Null? Type Chapter 6 - XML Messaging and RPC with SOAP ----------------------------------------- -------- -----------------------Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL RESULT SYS.XMLTYPE Part II Oracle XML Management for DBAs EMPLOYEE_ID NOT NULL NUMBER(6) Chapter 5

Chapter 8

- Getting Started with the Oracle XML Database

Chapter The other 9 -way Storing is to XML create Data an object XMLType view, where each row object is an XMLType instance and is

associated a unique OBJECT ID XML (OID). The resulting SYS_NC_ROWINFO$ is a virtual column referring to the Chapter 10 - with Generating and Retrieving XMLType in the object view or table: Chapter 11 -instance Searching XMLXMLType Data Chapter 12OR - Managing theVIEW Oracleemployee_vw XML Database OF XMLTYPE WITH OBJECT ID CREATE REPLACE Part III - Oracle XML for Java Developers (EXTRACT(SYS_NC_ROWINFO$,'/Employee/@empno').getNumberVal())

Chapter AS 13 - Getting Started with Oracle XML and Java

SELECT XMLELEMENT("Employee", Chapter 14 - Building an XML-Powered Web Site AS "empno"), Chapter 15 - Creating XMLATTRIBUTES(e.employee_id a Portal Site with XML and Web Services XMLFOREST(e.first_name, e.last_name, Chapter 16 - Developing an XML Gateway Application with SOAP and AQ e.job_id))AS result FROM employees e; XML-Based Reusable Components Chapter 17 - Developing Part IV - Oracle XML for C Developers

When creating XMLType object views, you need to specify the OBJECT ID via the OF XMLType WITH OBJECT ID syntax and assign the OBJECT ID by extracting a scalar value out of the XMLType. You can use the DEFAULT Chapter 19 - Building an XML-Managed Application keyword to ask the database to create a default OBJECT ID. However, this is not recommended, because it will Chapter 20 - Build an XML Database OCI Application generate a 16-byte ID that is difficult to use when referring to the data in the view. Chapter 18 - Getting Started with Oracle XML and C

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Part V you - Oracle for C++ Developers After haveXML created either view, you can query it as you would a relational table with XMLType columns or an

Chapter XMLType 22 -object Getting table: Started with Oracle XML and C++ Chapter 23*- Build XML Database OCI C++ROWNUM<2; Application SELECT FROManemployee_vw WHERE Chapter 24 - Building an XML Data-Retrieval Application

To optimize theXML queries on the XMLType object views to be able to use “query rewrite”, you can associate an XML Part VI - Oracle for PL/SQL Developers schema25with it through the following SQL statement: Chapter - Getting Started with Oracle XML and PL/SQL Chapter 26OR - Building PL/SQL Web Services CREATE REPLACE VIEW employee_vw OF XMLTYPE Chapter XMLSCHEMA 27 - Extending "http://xmlns.oracle.com/xml/employee.xsd" PL/SQL XML Functionality with Java ELEMENT "Employee"

WITH OBJECT ID It All Together Chapter 28 - Putting (EXTRACT(SYS_NC_ROWINFO$,'/Employee/@empno').getNumberVal()) Appendix - XML Standards Bodies and Open Specifications AS Glossary SELECT XMLELEMENT("Employee", Index XMLATTRIBUTES(e.employee_id AS "empno"), List of Figures XMLFOREST(e.first_name, e.last_name, e.job_id))AS result FROM employees e;

List of Tables

List of Sidebars

The advantage of using XMLType views is that you can have several views representing differing XML hierarchies with single data storage.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Processing XML PL/SQL

by Mark V. Scardina, Ben Chang and Jinyu Wang We have covered the basic techniques of generating XML from SQL data in object-relational tables and ISBN:0072229527 XMLTypes. 2004 (600 pages) In this section, McGraw-Hill/Osborne we discuss how you ©can process the XML documents before passing them to applications. Specifically, weThis discuss how to convert fragments intoXML XMLtechnologies documents within and how to useXML-enabled DBMS_XMLDOM to with comprehensive guide XML focuses on utilizing Oracle's products, on document XML standards, their usage and transformations best practices. are discussed in Chapter 26. create a DOM emphasis during XML generation. PL/SQL

Dealing with XML Fragments

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

XMLType operations may result in creating XMLTypes containing XML fragments instead of XML documents. Since Introduction youIcannot insert an XML fragment into XMLType columns or tables, you need to use the following function to check Part - Oracle and the XML Standards whether1 or- not the current Chapter Introducing XMLXML type is an XML fragment: Chapter 2 - Accessing with DOM, SAX, JAXB, and StAX SQL> INSERT INTO XML temp_emp Chapter SELECT 3 - Transforming XMLCONCAT(XMLELEMENT("Email",email), XML with XSLT and XPath Chapter 4

XMLELEMENT("Name", first_name||' '||last_name)) - Validating XML with DTDs and XML Schemas

employees Chapter FROM 5 - XML Operations with XQuery Chapter WHERE 6 - XMLROWNUM<3; Messaging and RPC with SOAP

insert temp_emp Chapter 7 into - Putting It All Together with XML Pipeline, JSPs, and XSQL * XML Management for DBAs Part II - Oracle ERROR 8at- Getting line 1: Chapter Started with the Oracle XML Database ORA-19010: Cannot insert XML fragments - Storing XML Data

Chapter 9

Chapter 10 - Generating and Retrieving XML

The following query checks if the result of the SQL/XML function is an XML document fragment:

Chapter 11 - Searching XML Data

SQL> SELECT XMLCONCAT(XMLELEMENT("Email",email), 2 XMLELEMENT("Name", first_name||' '||last_name)).isFragment() Part III - Oracle XML for Java Developers 3 FROM employees Chapter 13 - Getting Started with Oracle XML and Java 4 WHERE ROWNUM<2; Chapter 12 - Managing the Oracle XML Database

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services XMLCONCAT(XMLELEMENT("EMAIL",EMAIL), Chapter 16 - Developing an XML Gateway Application with SOAP and AQ XMLELEMENT("NAME",FIRST_NAME||''||LAST_NAME) Chapter 17 - Developing XML-Based Reusable Components ----------------------------------------------------------------------Part IV - Oracle XML for C Developers

1

Chapter 18 - Getting Started with Oracle XML and C

The result the preceding query shows that the XMLType is an XML fragment. Normally, such XML fragments do Chapter 19 -of Building an XML-Managed Application not meet single requirement for XML documents. Therefore, you need to create a well-formed XML Chapter 20the - Build an root XML element Database OCI Application document XMLELEMENT() before instering it intoTransformation XMLTypes as follows: Chapter 21 -using Create an XML-Configured High-Performance Engine Part INSERT V - Oracle INTOXML temp_emp for C++ Developers

SELECT Chapter 22XMLELEMENT"RESULT", - Getting Started with Oracle XML and C++ Chapter 23 -XMLCONCAT(XMLELEMENT("Email",email), Build an XML Database OCI C++ Application

first_name||' '||last_name))) Chapter 24 - Building an XMLELEMENT("Name", XML Data-Retrieval Application FROM Part VI -employees Oracle XML for PL/SQL Developers WHERE 25 ROWNUM<2; Chapter - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

DOM Editing

Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

As discussed in Chapter 2, the Document Object Model (DOM) is a set of standard APIs dealing with XML as a treeGlossary type memory object. You can use the DOM APIs to delete, insert, and update XML elements, nodes, and attributes. Index In Oracle Database 10g, you can use the DBMS_XMLDOM package to perform these functions. From Chapter 2, you should be already familiar with the DOM operations, so the following examples show how these are performed List of Tables from PL/SQL. List of Figures

List of Sidebars

Operating on XMLType DOM In Oracle Database 10g, you do not need to reparse an XML document if it is stored as an XMLType. There are two functions in the DBMS_XMLDOM package that directly support XMLType DOM operations: FUNCTION NEWDOMDOCUMENT(xmldoc IN SYS.XMLType) RETURN DOMDOCUMENT; FUNCTION GETXMLTYPE(doc IN DOMDOCUMENT) RETURN SYS.XMLType; As a result, you can call DOM functions by creating an XMLType, using its construction function, and then passing it


to DBMS_XMLDOM.NEWDOMDOCUMENT() as an input. After DOM processing, you can get the result in an XMLType by using the DBMS_XMLDOM.GETXMLTYPE() function. Here is an example of an update operation: CREATE OR REPLACE PROCEDURE updateXMLElement(p_doc IN OUTXML XMLTYPE, Oracle Database 10g XML & SQL: Design, Build & Manage Applications in Java, C, C++ & PL/SQL p_ename IN VARCHAR2, ISBN:0072229527 by Mark V. Scardina, Ben Changp_content and Jinyu Wang IN VARCHAR2) AS McGraw-Hill/Osborne © 2004 (600 pages) v_item NUMBER; v_doc DBMS_XMLDOM.DOMDOCUMENT; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. v_ndoc DBMS_XMLDOM.DOMNODE; v_nlist DBMS_XMLDOM.DOMNODELIST; DBMS_XMLDOM.DOMNODE; Table v_node of Contents v_elem DBMS_XMLDOM.DOMELEMENT; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL v_nelem DBMS_XMLDOM.DOMNODE; Introduction Part Iv_text - Oracle DBMS_XMLDOM.DOMTEXT; and the XML Standards v_ntext DBMS_XMLDOM.DOMNODE; Chapter 1 - Introducing XML BEGIN Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX -- Create DOM Object Chapter 3 - Transforming XML with XSLT and XPath v_doc := DBMS_XMLDOM.NEWDOMDOCUMENT(p_doc); Chapter 4 - Validating XML with DTDs and XML Schemas v_ndoc :=DBMS_XMLDOM.MAKENODE(DBMS_XMLDOM.GETDOCUMENTELEMENT(v_doc)); Chapter 5 - XML Operations with XQuery -- Select the DOM Nodes Chapter 6 - XML DBMS_XMLDOM.GETELEMENTSBYTAGNAME(v_doc,p_ename); Messaging and RPC with SOAP v_nlist:= Chapter 7 Putting It All Together with XML Pipeline, and XSQL IF DBMS_XMLDOM.GETLENGTH(v_nlist) > 0JSPs, THEN Part IIDBMS_OUTPUT.PUT_LINE('Update - Oracle XML Management for DBAs the: '||p_ename||' elements.'); Chapter 8 -v_item Getting Started with the Oracle XML Database FOR IN 0..DBMS_XMLDOM.GETLENGTH(v_nlist) LOOP Chapter 9v_node - Storing Data :=XML DBMS_XMLDOM.ITEM(v_nlist, v_item); Chapter 10 - Generating and Retrieving XML v_ntext := DBMS_XMLDOM.GETFIRSTCHILD(v_node); Chapter 11 DBMS_OUTPUT.PUT_LINE(DBMS_XMLDOM.GETNODEVALUE(v_ntext)); - Searching XML Data DBMS_XMLDOM.SETNODEVALUE(v_ntext, p_content); Chapter 12 - Managing the Oracle XML Database END LOOP; Part III - Oracle XML for Java Developers ELSE Chapter 13 - Getting Started with Oracle XML and Java element in the current Chapter DBMS_OUTPUT.PUT_LINE('No 14 - Building an XML-Powered Web'||p_ename||' Site document.'); Chapter 15 - Creating a Portal Site with XML and Web Services END Chapter 16IF; - Developing an XML Gateway Application with SOAP and AQ -Free resources Chapter 17 - Developing XML-Based Reusable Components DBMS_XMLDOM.FREEDOCUMENT(v_doc); Part IV - Oracle XML for C Developers EXCEPTION Chapter 18 - Getting Started with Oracle XML and C WHEN OTHERS THEN Chapter 19 - Building an XML-Managed Application DBMS_OUTPUT.PUT_LINE('Exceptions during the process'); Chapter 20 - Build an XML Database OCI Application END; Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting with Oracle XML and C++ In the example, the Started DBMS_XMLDOM.DOMDOCUMENT() creates the DOMDOCUMENT from the XMLType input Chapter - Build an of XML Database OCI C++ Application p_doc.23 Then, a set DOM operations is performed, which include using the Chapter DBMS_XMLDOM.GETELEMENTBYTAGNAME() 24 - Building an XML Data-Retrieval Application function to get the XML elements with name p_ename for the Part updates VI - Oracle and iterating XML foreach PL/SQL XMLDevelopers element item to update the content using the

DBMS_XMLDOM.SETNODEVALUE(). Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Next, the created procedure can be used to update the telephone number for an employee with EMPLOYEE_ID of 199. The original document contains the following:

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

<ROWSET>- XML Standards Bodies and Open Specifications Appendix <ROW> <EMPLOYEE_ID>199</EMPLOYEE_ID> Index … List of Figures <PHONE_NUMBER>650.507.9844</PHONE_NUMBER> List of Tables … List of Sidebars </ROW> Glossary

Then, run the updateXMLElement() function: DECLARE v_doc XMLType; BEGIN -- Create Sample XML Document SELECT XMLTYPE(DBMS_XMLGEN.GETXML('SELECT * FROM employees


WHERE employee_id=199')) INTO v_doc FROM dual; -- UpdateOracle the Element Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & updateXMLElement(v_doc,'PHONE_NUMBER','650.506.9181'); PL/SQL -- Print by out the ISBN:0072229527 Mark V. content Scardina, Ben Chang and Jinyu Wang SELECT v_doc.getClobVal() INTO :result FROM dual; McGraw-Hill/Osborne © 2004 (600 pages) END; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

The result is the XML document containing the updated phone number:

<ROWSET> <ROW> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <EMPLOYEE_ID>199</EMPLOYEE_ID> Introduction … Part I - Oracle and the XML Standards <PHONE_NUMBER>650.506.9181</PHONE_NUMBER> Chapter 1 - Introducing XML … Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX </ROW> Chapter 3 - Transforming XML with XSLT and XPath </ROWSET>

Table of Contents

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

If multiple were and selected, all of them would be updated. You can try the sample yourself by updating the Chapter 6 -employees XML Messaging RPC with SOAP WHERE in the SQL statement. Chapter 7 clause - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Appending XML Document Fragments Chapter 8 - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

If you have two XML documents and want to merge them together, you can use the following functions, which use DBMS_XMLDOM:

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

FUNCTION importNode(doc DOMDOCUMENT, importednode DOMNODE, deep BOOLEAN) RETURN DOMNODE; Part III - Oracle XML for Java Developers FUNCTION appendChild(n DOMNODE, newChild IN DOMNODE) RETURN DOMNODE; Chapter 12 - Managing the Oracle XML Database

Chapter 13 - Getting Started with Oracle XML and Java

Chapter 14 - Building an XML-Powered Web Site containing the department information and want to merge this For example, if you create one XML document Chapter 15 -with Creating a Portal Site XML andof Web document one containing thewith employees thisServices department, you could use the following code: Chapter 16 - Developing an ON XML Gateway Application with SOAP and AQ SQL> SET AUTOPRINT Chapter 17 - Developing XML-Based Reusable Components SQL> VAR RESULT CLOB Part IV -DECLARE Oracle XML for C Developers SQL>

Chapter 18 - Getting Started with Oracle XML and C v_tdoc XMLType; Chapter 19 - Building an XML-Managed Application v_tsubdoc XMLType; Chapter 20 - Build an XML Database OCI Application v_result CLOB; Chapter v_doc 21 -DBMS_XMLDOM.DOMDOCUMENT; Create an XML-Configured High-Performance Transformation Engine Partv_subdoc V - Oracle XML DBMS_XMLDOM.DOMDOCUMENT; for C++ Developers

v_doc_elem DBMS_XMLDOM.DOMELEMENT; Chapter 22 - Getting Started with Oracle XML and C++ v_subdoc_elem DBMS_XMLDOM.DOMELEMENT; Chapter 23 - Build an XML Database OCI C++ Application v_node DBMS_XMLDOM.DOMNODE; Chapter 24 - Building an XML Data-Retrieval Application DBMS_XMLDOM.DOMNODE; Partv_impnode VI - Oracle XML for PL/SQL Developers BEGIN 25 - Getting Started with Oracle XML and PL/SQL Chapter -- Create thePL/SQL Main Web XML Services document Chapter 26 - Building SELECT XMLType(DBMS_XMLGEN.GETXML('SELECT * FROM departments WHERE department_id =20')) Chapter 28 - Putting It All Together INTO v_tdoc FROM dual; Appendix - XML Standards Bodies and Open Specifications -- Create the Sub XML document Glossary SELECT XMLType(DBMS_XMLGEN.GETXML('SELECT * FROM employees Index WHERE department_id = 20')) List of Figures INTO v_tsubdoc from dual; Chapter 27 - Extending PL/SQL XML Functionality with Java

List of Tables List -of Sidebars Merge the documents

v_doc := DBMS_XMLDOM.NEWDOMDOCUMENT(v_tdoc); v_subdoc :=DBMS_XMLDOM.NEWDOMDOCUMENT(v_tsubdoc); v_doc_elem := DBMS_XMLDOM.GETDOCUMENTELEMENT(v_doc); v_subdoc_elem := DBMS_XMLDOM.GETDOCUMENTELEMENT(v_subdoc); v_impnode := DBMS_XMLDOM.IMPORTNODE(v_doc, DBMS_XMLDOM.MAKENODE(v_subdoc_elem), true) ; v_node := DBMS_XMLDOM.APPENDCHILD( DBMS_XMLDOM.MAKENODE(v_doc_elem), v_impnode);


--v_node := DBMS_XMLDOM.APPENDCHILD( -DBMS_XMLDOM.MAKENODE(v_doc_elem), -DBMS_XMLDOM.MAKENODE(v_subdoc_elem)); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & DBMS_LOB.CREATETEMPORARY(v_result,true,DBMS_LOB.SESSION); PL/SQL DBMS_XMLDOM.WRITETOCLOB(v_doc,v_result); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang SELECT v_result INTO :result dual; McGraw-Hill/Osborne © 2004 FROM (600 pages) DBMS_LOB.FREETEMPORARY(v_result); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with END; emphasis on XML standards, their usage and best practices. Table Contents This of example uses the DBMS_XMLDOM.IMPORTNODE() and DBMS_XMLDOM.APPENDCHILD() functions to Oracle 10g document. XML & SQL—Design, & Manage Applications in Java, C,to C++ PL/SQL from one createDatabase the merged This is theBuild suggested andXML standards-compliant way add&content Introduction document to another via the DOM. We explore the DBMS_XMLDOM package further in Chapter 26. Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Best Practices PL/SQL

bytoMark V. Scardina, Ben Chang JinyuXML Wang Before you start explore the technical detailsand of your application implementation, it is important toISBN:0072229527 ask McGraw-Hill/Osborne © 2004 (600 pages) yourself the following questions: This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

What information doon I need to deliver? their usage and best practices. emphasis XML standards, What is the format for the XML document?

Table of Contents

OracleAre Database there any 10glimits XML & toSQL—Design, the size of theBuild XML& document? Manage XML Applications in Java, C, C++ & PL/SQL Introduction

tierand canthe beXML used to create, process, and deliver the XML content? Part IWhich - Oracle Standards Chapter 1

- Introducing XML The answers to these questions will help you to make your design decisions.

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter First, for 3 point-to-point - Transforming communications, XML with XSLT and where XPath individual pairs of applications exchange data through their private

tunnels,4 encapsulating the with dataDTDs in XML is XML not aSchemas good choice because it introduces processing overhead from the Chapter - Validating XML and metadata. this needwith to share data in public, the proprietary data formats, such as the binary format, are Chapter 5 -Without XML Operations XQuery much more efficient and provide better Chapter 6 - XML Messaging and RPC withsecurity SOAP for the data transmission over the network. Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Second, when using XML, always make sure to pick the right data format. Also, avoid including presentation data in XML. It is a good practice to keep presentation data in the XSLT stylesheets.

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 - Storing Data Even though many XML people perceive the capability to create highly descriptive tag names as an advantage of XML, Chapter 10 - not Generating and in Retrieving XML XML documents are used for application processing and the size of the you should forget that, most cases, Chapter XML can 11 greatly - Searching impact XML onData the scalability of XML applications. XML documents need to be designed for efficient

application For example, the human-readable element name Employee_Salary could be replaced by Chapter 12 - processing. Managing the Oracle XML Database EmpSal, and certain empty elements that describe properties or context for the data can be replaced by XML Part III - Oracle XML for Java XML Developers attributes simplifyStarted the data access reduce document size. Chapter 13 to - Getting with Oracleand XML and Java Chapter 14 - Building an XML-Powered Web Site

As discussed earlier, whitespaces are used to format an XML document as human-readable. This creates additional overhead for most XML processing. Removing whitespaces in XML documents sometimes can reduce the DOM Chapter 16 - Developing an XML Gateway Application with SOAP and AQ object size 50 to 70 percent! Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 17 - Developing XML-Based Reusable Components

Part IV in - Oracle XML C Developers Third, addition to for creating a compact data format, you should also avoid generating large XML documents from

Chapter 18 - Getting Started with Oracle and C to deal with large tables, you should also split large XML SQL queries. Just as databases utilizeXML partitions Chapter documents 19 - Building containing an repeating XML-Managed subtrees Application or row sets into sets of smaller XML documents. Otherwise, your

application up running outOCI of memory or not being able to scale when deployed in production systems with Chapter 20 - may Buildend an XML Database Application high volumes of data transactions.High-Performance Transformation Engine Chapter 21 - Create an and XML-Configured Part V - Oracle XML for C++ Developers

Fourth, you should avoid overloading any application tier with XML processing. For example, sometimes XSL transformations are required before delivering the XML data. Depending on the nature of the XSL stylesheets and Chapter 23 - Build an XML Database OCI C++ Application the size of the input documents, you can perform the XSL transformation in database tier, in mid-tier application Chapter 24 - Building an XML Data-Retrieval Application servers or on the client side. Chapter 22 - Getting Started with Oracle XML and C++

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 -process Getting transforms Started withlarge Oracle XML and If the XSL amounts of PL/SQL data from the database, it is a good practice to run them in Chapter 26 -This Building PL/SQLyou Webcan Services database. is because easily leverage the high-performance data management in database, such as Chapter the lazy27DOM - Extending supportPL/SQL in the Oracle XML Functionality XML DB. Additionally, with Java transforming in database can facilitate sharing the

transformed resultsItbetween database applications. Chapter 28 - Putting All Together Appendix

- XML Standards Bodies and Open Specifications

If the XML documents are small but intensive processing is required, such as processing SOAP or other types of XML messages, the middle tier provides the advantage of scalability by offloading the database server and hence Index improving the overall system performance. Glossary

List of Figures

List Tables To of further offload the servers, some XML processing can even be performed on the client side. Now, through their List of Sidebars support for Java, PDAs and cell phones also provide XML support.

Caching XML is another way to save processing resources in servers. The Oracle database will cache the query results in its the shared pool. However, you can also simply store the result XML documents in CLOB tables for further use. Fifth, if certain XML SQL queries are frequently used, XML views can be used to eliminate retyping and parsing the SQL statements, thus saving time. Finally, though the built-in XML functions give you broad functionality in generating XML, you could implement


customized solutions with Oracle XML Developer’s Kit (Oracle XDK) APIs in C, C++, and Java when the built-in XML functionality cannot meet your business requirements. For example, since the SAX parsing is not available in the SQL/XML functions orDatabase any of the10g PL/SQL you can create mid-tier XML applications using in SAX APIs Oracle XML packages, & SQL: Design, Build & Manage Applications Java, C,from C++the & Oracle XDK to PL/SQL generate large XML documents as follows: ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang Connection by conn; McGraw-Hill/Osborne © 2004 (600 pages) String username = "sh"; String password = "sh"; guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with This comprehensive emphasis on XML standards, their usage and best practices. String thinConn = "jdbc:oracle:thin:@localhost:1521:ORCLX"; try { of Contents Table //Open a File and JDBC Connection Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL OutputStream out = new FileOutputStream("out.xml"); Introduction oracle.jdbc.driver.OracleDriver()); PartDriverManager.registerDriver(new I - Oracle and the XML Standards conn= DriverManager.getConnection(thinConn,username,password); Chapter 1 - Introducing XML // Create SAX Print Driver Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX XMLSAXSerializer sample = new XMLSAXSerializer(out); Chapter 3 - Transforming XML with XSLT and XPath // Using the OracleXMLQuery with SAX Output Chapter 4 - Validating XML with DTDs and XML Schemas OracleXMLQuery qry = new OracleXMLQuery(conn,"select * from sales"); Chapter 5 - XML Operations with XQuery qry.getXMLSAX(sample); Chapter 6 - XML Messaging and RPC with SOAP sample.flush(); Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL } Part IIcatch(Exception - Oracle XML Management ex) for DBAs Chapter 8 Getting Started with the Oracle XML Database { Chapter 9ex.printStackTrace(); - Storing XML Data Chapter } 10 - Generating and Retrieving XML

Chapter 11 - Searching XML Data

TheXMLSAXSerializer a SAXXML Content Handler in Oracle XDK that provides SAX output serialization with many Chapter 12 - Managing theisOracle Database options customize theJava output such as specifying “pretty” or “compact” formats, setting the encoding attribute in the Part III - to Oracle XML for Developers <?XML?> so on. In this example, the XMLSAXSerializer is registered to the Chapter 13 -prolog Gettingand Started with Oracle XML and Java

OracleXMLQuery.getXMLSAX() interface to receive SAX events for the XML created by the XML SQL Utility. It then serializes the output out.xml.

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 by Mark V. Bento Chang and XML Jinyufrom Wang This chapter illustrated theScardina, techniques produce various data sources in Oracle Database 10g. We © 2004 (600 pages) showed how toMcGraw-Hill/Osborne create XMLTypes from SQL data and how to extract, transform, aggregate, and concatenate XML data within SQL commands or PL/SQL This comprehensive guideprograms. focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

This functionality, natively provided in Oracle Database 10g, permits a single source of data to be presented in multiple XML formats appropriate to individual clients or applications. This opens up information-sharing possibilities, Table of Contents resulting in better web publishing and data exchange across applications. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 11:Database Searching XML Data PL/SQL

Overview

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

XML is a widelyemphasis acceptedonstandard XML standards, for enterprise their usage applications and besttopractices. exchange business data and publish data over the Internet. By storing XML data in Oracle Database 10g, you can create SQL indexes and enable users to efficiently search XML data. Oracle Database 10g provides two types of search on XML: the XPath-based search provided Table of Contents along with the XMLType functions, and the full text search using the Oracle database component, Oracle Text. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction The XPath-based searches are queries that are based on XPath expressions, which narrow down the scope of the Part I - Oracle and the XMLhierarchical Standards structure. Using XPath expressions, you can specify XML namespaces and search through the XML

Chapter 1 a- wide Introducing XML leverage range of datatype comparisons, such as string, number, and date comparisons. Though Oracle Text Chapter 2 does - Accessing XML with SAX, JAXB, StAX limited XPath and datatype support, you may need to rely currently not support XMLDOM, namespaces andand provides Chapter Transforming XML with XSLT and XPath on it for3its- scalable full text search capabilities, optimized content indexes, rich linguistic rules, and analysis. Chapter 4

- Validating XML with DTDs and XML Schemas

This chapter describes bothwith approaches, Chapter 5 - XML Operations XQuery and explains how to create indexes and ensure that your XML document searches efficient. Then, in RPC the “Best Practices” section, it explains how to choose between the two. Chapter 6 are - XML Messaging and with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


OracleSearches Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XPath-Based PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Wang Using XPath-based queries is straightforward. YouJinyu simply use the XPath expressions in XMLType functions to McGraw-Hill/Osborne © 2004 (600 pages)The following is an example product document in XML: specify the content retrieval from XML documents.

<Product> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML standards, their usage and best practices. <Name>XSLTemphasis Processor</Name> <Description lastupdate="03-07-2003"> Table of Contents <Whatis>XSLT Processor makes use of Oracle Database <Standard 10g XML type="W3C">XSLT</Standard> & SQL—Design, Build & Manage XML language Applications defined in Java, C, byC++ the& World PL/SQL Wide Web Consortium (<KEYWORD>W3C</KEYWORD>) to Introduction <Function>transform</Function> XML documents into other formats. Part I - Oracle and the XML Standards </Whatis> Chapter 1 - Introducing XML <OracleSupport>Oracle supports XSLT SQL, PL/SQL, JAVA and C/C++. Chapter 2 - Accessing XML with DOM, SAX, JAXB, andin StAX </OracleSupport> Chapter 3 - Transforming XML with XSLT and XPath </Description> Chapter 4 - Validating XML with DTDs and XML Schemas </Product> Chapter 5 - XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP To query the XML content, you can use the following XPath expressions:

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

1. What is the name of product?

Part II - Oracle XML Management for DBAs

Chapter XPath: 8 - Getting Started with the Oracle XML Database /Product/Name Chapter 9

- Storing XML Data

2. What are the W3C by the product? Chapter 10 - Generating andstandards Retrieving supported XML Chapter 11 - Searching XML Data

XPath:/Product//Standard[@type = “W3C”]

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

3. What is the description of the product, which is updated after March 1, 2003?

Chapter 13 - Getting Started with Oracle XML and Java

/Product/Description[@lastupdate >“03-01-2003”] Chapter XPath: 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

In Oracle Database 10g, these kinds of XPath expressions can be used within EXISTSNODE() to search the XML documents in XMLTypes.

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Searching the XML Document Using XPath

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

To illustrate how to use XPath in EXISTSNODE(), a table called product is created, which includes the product_id, the product name, and the description column:

Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

CREATE TABLE Part V - Oracle XMLproduct( for C++ Developers product_id NUMBER Chapter 22 - Getting Started PRIMARY with OracleKEY, XML and C++ name VARCHAR2(200), description XMLType);

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Thedescription is defined as an XMLType column to store the product descriptions in XML. The description

Chapter - Getting with Oracle XML PL/SQL column25 uses CLOBStarted as its storage, which byand default holds up to 4GB of text. After the table is created, you can insert Chapter 26 - Building Web Services new product recordsPL/SQL as follows: Chapter 27 - Extending PL/SQL XML Functionality with Java

INSERT INTO product(product_id, name, description) VALUES(1, 'XSLT Processor', XMLType('<Description> Appendix - XML Standards Bodies and Open Specifications <Whatis>Based on the <Standard type="W3C">XSLT</Standard> standard Glossary defined by the World Wide Web Consortium (<KEYWORD>W3C</KEYWORD>), Index XSLT Processors <Function>transform</Function> XML documents into List other of Figures formats.</Whatis> List <OracleSupport>Oracle of Tables supports XSLT in SQL, PL/SQL, JAVA and List of Sidebars C/C++.</OracleSupport> <ProductDetails> <Product name="XSLT for C"> <Description>XSLT for C in Oracle XDK 10g provides the high-performance XSLT Virtual Machine, which compiles the XSL Stylesheets and performs the XSLT transformation using the fixed memory stack.</Description> <Developer> <First_Name>John</First_Name> <Last_Name>Smith</Last_Name> Chapter 28 - Putting It All Together


<Email>John.Smith@oracle.com</Email> </Developer> </Product> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & </ProductDetails> PL/SQL </Description>')); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

INSERT INTOThis product(product_id, name, description) comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with VALUES(2, emphasis 'XSQL', onXMLType('<Description> XML standards, their usage and best practices. <Whatis>XSQL produces dynamic XML documents based on one or more SQL queries and can optionally apply <Standard type="W3C">XSL</Standard> Table of Contents Stylesheets to <Function>transform</Function> XML documents. Its Java Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Servlet interface provides rich HTTP management functionality, such as Introduction Cookies, <Standard type="W3C">HTTP</Standard> session parameters Part I - Oracle and the XML Standards etc.</Whatis> Chapter 1 - Introducing XML command-line utility, run-time Servlet engine and <OracleSupport>Java Chapter 2 - Accessing with DOM, SAX, JAXB, and are StAX provided.</OracleSupport> extensible Java XML development framework Chapter 3 - Transforming XML with XSLT and XPath <ProductDetails> Chapter 4 - Validating XML with for DTDsJava"> and XML Schemas <Product name="XSQL Chapter 5 - XML Operations with XQuery <Description>XSQL for Java support FOP serialization</Description> Chapter <Developer> 6 - XML Messaging and RPC with SOAP Chapter 7<First_Name>Richard</First_Name> - Putting It All Together with XML Pipeline, JSPs, and XSQL <Last_Name>Lee</Last_Name> Part II - Oracle XML Management for DBAs Chapter 8<Email>Richard.Lee@oracle.com</Email> - Getting Started with the Oracle XML Database Chapter </Developer> 9 - Storing XML Data </Product> Chapter 10 - Generating and Retrieving XML </ProductDetails> Chapter 11 - Searching XML Data </Description>')); Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

You can use the EXISTSNODE() function to search the product descriptions as follows:

Chapter 13 - Getting Started with Oracle XML and Java

SQL> SELECT product_id, name 2 FROM product Chapter 15 - Creating a Portal Site with XML and Web Services 3 WHERE EXISTSNODE(description, Chapter 16 - Developing an XML Gateway Application with SOAP and AQ '//*[contains(.,"HTTP") and contains(.,"SQL")]')>0; Chapter 17 - Developing XML-Based Reusable Components PRODUCT_ID NAME Part IV - Oracle XML for C Developers ---------- ----------------------------------Chapter 18 - Getting 2 XSQLStarted with Oracle XML and C Chapter 14 - Building an XML-Powered Web Site

Chapter 19 - Building an XML-Managed Application Chapter The EXISTSNODE() 20 - Build an XML function Database takesOCI an Application XMLType as the first parameter and an XPath expression as the second

parameter. the XPath expression, the XPath function Transformation contains(string1,string2) is used to handle the string Chapter 21 - In Create an XML-Configured High-Performance Engine matching. TheXML contains() returns TRUE if the first string argument (string1)contains the substring equal to Part V - Oracle for C++function Developers the second argument (string2). According theC++ XPath standard, you can add andororlogic operators between Chapter 22 - Getting Started with Oracle XML to and twocontains() functions. In the preceding example, the XPath-based query returns all products that contain both Chapter 23 - Build an XML Database OCI C++ Application HTTP and in the description. Application Chapter 24 -SQL Building anproduct XML Data-Retrieval Part VI - Oracle XML for PL/SQL Developers

Note that all the text in XPath expressions is case sensitive and that all the logic predicates in XPath, such as and and or, have to be in lowercase. For example, the following query produces an ORA-31013: Invalid XPath Chapter 26 - Building PL/SQL Web Services Expression error because AND is used instead of and in the logic predicates: Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 27 - Extending PL/SQL XML Functionality with Java

SQL> SELECT product_id, name 2 FROM product Appendix - XML Standards Bodies and Open Specifications 3 WHERE EXISTSNODE(description, Glossary '//*[contains(.,"HTTP") AND contains(.,"SQL")]')>0; IndexFROM product List of Figures * List of Tables ERROR at line 2: List of Sidebars Invalid XPath expression ORA-31013: Chapter 28 - Putting It All Together

Because the XPath expressions are case sensitive, sql and SQL are treated as different strings. As a result, the following query will not return the products containing the word SQL in their description: SELECT product_id, name FROM product WHERE EXISTSNODE(description,'//*[contains(.,"HTTP") and contains(.,"sql")]')>0;


To make the search case insensitive, you can enumerate all the possible combinations of the characters in a word. For example, the following query will return all the products whose description contains either SQL or sql: SELECT product_id, name 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle Database PL/SQL FROM product ISBN:0072229527 by Mark (description, V. Scardina, Ben Chang and Jinyu Wang WHERE EXISTSNODE McGraw-Hill/Osborne (600 pages) '//*[contains(.,"HTTP") and© 2004 ( contains(.,"SQL") or contains(.,"sql"))]')>0; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

However, covering all the possible combinations is annoying. In Oracle Database 10g, you can instead use the ora:contains() function, which provides case-insensitive text searches. Another reason to use ora:contains() is Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL that the contains() XPath function does not have word semantics. It performs only consecutive character-byIntroduction character comparisons. This may result in unexpected query results, as shown in the following example. After the Part I - Oracle and the XML Standards <OracleSupport> element in the product description of the XSQL Servlet has been updated, as follows:

Table of Contents

Chapter 1

- Introducing XML

SQL> UPDATE product SET description=UPDATEXML(description, - Accessing XML with DOM, SAX, JAXB, and StAX '/Description/OracleSupport', Chapter 3 - Transforming XML with XSLT and XPath '<OracleSupport>Oracle XSQL provides Java command-line utility, Chapter 4 - Validating XML with DTDs and XML Schemas run-time Servlet engine and an extensible Java development framework. Chapter 5 - XML Operations with XQuery </OracleSupport>') Chapter 6 - XML Messaging and RPC with SOAP WHERE product_id=2; Chapter 2

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle Management DBAs a query on theXML updated productfor table will return the following result:

Chapter 8 - Getting Started with the Oracle XML Database SQL> SELECT product_id, name Chapter 9 product - Storing XML Data FROM Chapter 10 -EXISTSNODE(description, Generating and Retrieving XML WHERE Chapter 11 - Searching XML Data '//OracleSupport[contains(.,"SQL")]')>0; Chapter 12 - Managing PRODUCT_ID NAME the Oracle XML Database Part III - Oracle ----------------------------------XML for Java Developers ----------

Chapter 13 - Getting 1 XSLTStarted Processor with Oracle XML and Java

2 XSQLan XML-Powered Web Site Chapter 14 - Building Chapter 15 - Creating a Portal Site with XML and Web Services

This query result is not anticipated! The reason that the contains()function returns TRUE is that in the <OracleSupport> element of the product description for XSQL Servlet, the string XSQL contains SQL as a Chapter 17 - Developing XML-Based Reusable Components substring. Using ora:contains() instead, with its support for word semantics, gives an accurate text search result, Part IV - Oracle XML for C Developers as shown in the following example: Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 18 - Getting Started with Oracle XML and C

SQL> SELECT product_id, nameApplication Chapter 19 - Building an XML-Managed FROM product WHERE EXISTSNODE(description, Chapter 21 - Create an XML-Configured High-Performance Transformation Engine '//OracleSupport[ora:contains(.,"SQL")>0]', Part V - Oracle XML for C++ Developers 'xmlns:ora="http://xmlns.oracle.com/xdb"')>0; Chapter 20 - Build an XML Database OCI Application

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application

PRODUCT_ID NAME ---------- ----------------------------------Part VI - Oracle XML for PL/SQL Developers 1 XSLT Processor Chapter 24 - Building an XML Data-Retrieval Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 Database - Building PL/SQL Services In Oracle 10g, theWeb ora:contains() function can be used at any place in the XPath expressions and can Chapter leverage 27the - Extending full text search PL/SQLfunctionality XML Functionality in Oracle withText, Java such as word stemming, fuzzy matching, proximity

searching, searching Chapter 28 - specifying Putting It All Togetherpolicies, and so on. For example, the following query uses word stemming to query the product descriptions: Appendix - XML Standards Bodies and Open Specifications Glossary SQL> SELECT product_id, name Index FROM product

WHERE EXISTSNODE(description, '//*[ora:contains(.,"$base")>0]', List of Figures List of Tables

'xmlns:ora="http://xmlns.oracle.com/xdb"')>0;

List of Sidebars

PRODUCT_ID NAME ---------- ----------------------------------1 XSLT Processor 2 XSQL

Though the word base is not shown in the XML document, the product is returned because the word based has the same word stem.


In Oracle Database 10g, the EXISTSNODE() function can be used in the WHERE clause of SQL queries along with any other SQL predicates or combinations of itself. Here is one example: SELECT product_id, name 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle Database PL/SQL FROM product ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang WHERE EXISTSNODE(description, '//OracleSupport[ora:contains(.,"sql")>0]', McGraw-Hill/Osborne © 2004 (600 pages) 'xmlns:ora="http://xmlns.oracle.com/xdb"')>0 AND EXISTSNODE(description,'//Standard[@type="W3C"]')>0; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

This example specifies the query for What are the Oracle products that support W3C standards and provide SQL interfaces? Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

How XPath-Based Searching Works

Introduction

Part I - Oracle and the XML Standards

When you an XPath Chapter 1 -specify Introducing XML expression in EXISTSNODE(), the Oracle XML DB evaluates the XPath expressions and executes queries based on the XMLType storage. - Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 2

Chapter - Transforming with XSLT XPath If XML 3is stored in CLOB XML XMLTypes, theand Oracle XML DB functionally evaluates the XPath expressions by building Chapter 4 tree - Validating XMLdocument with DTDs in and XML Schemas the DOM of the XML memory and resolves the XPath programmatically using the methods Chapter 5 by - XML Operations with XQuery provided DOM. If a CTXXPATH index is created, the XML DB engine first uses the CTXXPATH index to get the Chapter 6 of - XML Messaging RPC then with performs SOAP superset the result data and set and DOM-based functional evaluation. If the ora:contains() function is Chapter Puttingexpressions, It All Together with XML Pipeline, JSPs, used in7the- XPath the selected XML data willand be XSQL loaded into memory for additional full text-search Part II - Oracle XML Management for DBAs analysis.

Chapter 8

- Getting Started with the Oracle XML Database

If XML 9is stored in XML Schema-based XMLTypes, the Oracle XML DB first rewrites the XPath expressions into Chapter - Storing XML Data equivalent SQL statements. Then, based on the object-relational (O-R) data structures, it utilizes whichever index is Chapter 10 - Generating and Retrieving XML available to access the data in the object tables. This query-translation process is called the query rewrite of XPathChapter 11 - Searching XML Data based queries. Because of the query rewrite process, the XML data retrieval can be as fast as accessing the SQL Chapter 12 - Managing the Oracle XML Database data. Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle and Java In the Oracle XML DB, query rewrite is XML a different process than the query rewrite widely used in data warehouse Chapter 14 - Building an XML-Powered Web applications, where users do not need theSite query rewrite privileges and do not need to create materialized views or Chapter 15 tables. - Creating Portal Siteyou with XML and Web summary To a make sure understand the Services execution process, the following example creates another table Chapter that stores 16 - the Developing product an descriptions XML Gateway in XML Application Schema-based with SOAP XMLTypes. and AQ First, you need to register an XML schema: Chapter BEGIN 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers DBMS_XMLSCHEMA.REGISTERSCHEMA('product.xsd',

Chapter 18 - Getting Started with Oracle XMLencoding="UTF-8"?> and C '<?xml version="1.0" Chapter 19 - Building an XML-Managed Application <xs:schema xmlns:xdb="http://xmlns.oracle.com/xdb" Chapter xmlns:xs="http://www.w3.org/2001/XMLSchema" 20 - Build an XML Database OCI Application Chapter 21elementFormDefault="qualified"> - Create an XML-Configured High-Performance Transformation Engine

<xs:element Part V - Oracle XMLname="Description"> for C++ Developers <xs:complexType xdb:SQLType="DESCRIPTION_TYPE"> Chapter 22 - Getting Started with Oracle XML and C++ <xs:sequence> Chapter 23 - Build an XML Database OCI C++ Application <xs:element xdb:SQLName="WHATIS" Chapter 24 - Building anname="Whatis" XML Data-Retrieval Application xdb:SQLType="WHATIS_TYPE"> Part VI - Oracle XML for PL/SQL Developers mixed="true"> Chapter <xs:complexType 25 - Getting Started with Oracle XML and PL/SQL <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="Function" type="xs:string"/> Chapter 27 - Extending PL/SQL XML Functionality with Java <xs:element name="KEYWORD" type="xs:string"/> Chapter 28 - Putting It All Together <xs:element name="Standard"> Appendix - XML Standards Bodies and Open Specifications <xs:complexType> Glossary <xs:simpleContent> Index <xs:extension base="xs:string"> List of Figures <xs:attribute name="type" type="xs:string" use="required"/> List of Tables </xs:extension> List of Sidebars </xs:simpleContent> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> <xs:element name="OracleSupport" type="xs:string"/> </xs:sequence> <xs:attribute name="name" type="xs:string" use="required"/> Chapter 26 - Building PL/SQL Web Services


</xs:complexType> </xs:element> </xs:schema>', TRUE, TRUE, FALSE,FALSE); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & END; PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

After you have registered the XML schema, you can create a product table by specifying the structured XMLType McGraw-Hill/Osborne © 2004 (600 pages) storage for the description column:

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

CREATE TABLE product( emphasis on XML standards, their usage and best practices. product_id NUMBER PRIMARY KEY, name VARCHAR2(200), Table of Contents description XMLType) Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XMLTYPE COLUMN description ELEMENT "product.xsd#Description"; Introduction

Part - Oracle thethe XML Standards YouI then canand insert same set of data into the table as shown in the previous examples, except that you need to

Chapter - Introducing XML use the1XMLType.CreateSchemaBasedXML() function to specify the registered XML schema URLs during data Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX insertions: Chapter 3 INTO - Transforming XML with XSLT andname, XPath description) VALUES(1, 'XSLT INSERT product(product_id, Chapter 4 Validating XML with DTDs and XML Schemas Processor', XMLType('…').CreateSchemaBasedXML('product.xsd')); Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Looking7 at-the following query: Chapter Putting It All XPath Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management SELECT product_id, name for DBAs

Chapter 8 - Getting Started with the Oracle XML Database FROM product Chapter WHERE 9EXISTSNODE(description, - Storing XML Data '/Description[@name="XSQL"]')>0; Chapter 10 - Generating and Retrieving XML

The Oracle XML DB parses and rewrites the XPath query to a SQL query that looks like the following: Chapter 11 - Searching XML Data SELECT Chapter 12VALUE(description) - Managing the Oracle XML Database FROM p for Java Developers Part III product - Oracle XML WHERE 13 description.XMLDATA.name='XSLT'; Chapter - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Note In the object-relational storage of XMLTypes, XMLDATA refers to the root element of the XML document in the XMLType, and SYS_NC_ROWINFO$ represents the XMLType object.

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 17 -not Developing XML-Based Reusable Components However, all XPath-based queries can be rewritten. In Oracle Database 10g, if the XPath expression contains Part - Oracle XML for Developers the IV following items, theCquery cannot be rewritten:

Chapter 18 - Getting Started with Oracle XML and C

All 19 XPath functions except not(),floor(), ceiling(),substring(),string-length(), and translate() Chapter - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

XPath variable references

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part VAny - Oracle for the C++ Developers axes XML except child and attribute axes

Chapter 22 - Getting Started with Oracle XML and C++

Recursive type withOCI descendent axis Chapter 23 - Build an definitions XML Database C++ Application Chapter 24 - Building an XML Data-Retrieval Application

UNION operators

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started withofOracle XML andcontains PL/SQL the following elements and the XPath expression includes If the registered XML schema an XMLType Chapter 26 - Building PL/SQL Web nodes under these elements, theServices query also cannot be successfully rewritten: Chapter 27 - Extending PL/SQL XML Functionality with Java

Elements containing open content, namely ANY content Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications Elements mapped to SQL CLOBs

Glossary

Index The advantage of query rewrite is that it enables the use of B*Tree or other indexes on the XML data to speed up

theofquery response. Without query rewrite, the XPath queries require in-memory construction of the XML object tree List Figures andofprogrammatic evaluation through the object tree traversal. List Tables List of Sidebars

Note Like the other Oracle-provided extension functions that are under the Oracle XML DB namespace (http://xmlns.oracle.com/xdb), such as ora:upper(),ora:lower(),ora:to_date(), ora:to_number() and ora:like(), the ora:contains() function is rewritten to a SQL query. Additionally, it uses the CONTEXT index if available, and the XML element or attribute used by ora:contains() is an object in the O-R tables of the XMLType.

Optimizing XPath-Based Queries Using Indexes


To speed up XPath-based queries, you can create indexes on XML documents. There are four main types of indexes available in Oracle Database 10gfor XMLTypes: B*Tree indexes, bitmap indexes, function-based indexes, and CTXXPATH indexes. The following sections how to use them. XML Applications in Java, C, C++ & Oracle Database 10g XML & SQL:discuss Design, Build & Manage PL/SQL

B*Tree Indexes by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

If an XML document is stored in O-R XMLTypes, you can create B*Tree indexes on the XML content. Since XPathThis comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with based queries emphasis are rewritten to SQL queries, B*Tree indexes can speed up all rewritten SQL queries. In the following on XML standards, their usage and best practices. example, a B*Tree index is created on the name attribute of the <Description> element, and the EXPLAIN PLAN command is run to examine the query execution plan:

Table of Contents

SQL> CREATE UNIQUE INDEX name_idx ON product(description.xmldata."name"); Index created. Introduction SQL> EXPLAIN PLAN FOR Part I - Oracle and the XML Standards SELECT count(*) Chapter 1 - Introducing XML FROM product x Chapter WHERE 2 - Accessing XML with DOM, SAX, JAXB, and StAX x.description.EXISTSNODE( '/Description[@name="XSLT"]')=1; Chapter 3 - Transforming XML with XSLT and XPath Explained. Chapter 4 - Validating XML with DTDs and XML Schemas SQL> @d:\oracle\rdbms\admin\utlxpls Chapter 5 - XML Operations with XQuery PLAN_TABLE_OUTPUT Chapter 6 - XML Messaging and RPC with SOAP ----------------------------------------------------------------------Chapter |Id | 7Operation - Putting It All Together|with Name XML Pipeline, |Rows JSPs, | Bytes and XSQL | Cost (%CPU)| Time | Part ----------------------------------------------------------------------II - Oracle XML Management for DBAs | 0 |SELECT STATEMENT | 1 | 496 | 3 (34) |00:00:01| Chapter 8 - Getting Started with the |Oracle XML Database | 1 | SORT AGGREGATE | | 1 | 496 | | | Chapter 9 - Storing XML Data | 2 | TABLE ACCESS | | | | | | Chapter 10 - Generating and Retrieving XML | | BY INDEX ROWID | PRODUCT| 1 | 496 | 3 (34) |00:00:01| Chapter 11 - Searching XML Data |*3 | 12 - Managing INDEX UNIQUE SCAN|NAME_IDX| 1 | | 2 (50)|00:00:01| Chapter the Oracle XML Database Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Part III - Oracle XML for Java Developers

Predicate Information (identified by operation id): --------------------------------------------------Chapter 14 - Building an XML-Powered Web Site 3 - access("X"."SYS_NC00010$"='XSLT') Chapter 13 - Getting Started with Oracle XML and Java

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

14 rows selected.

Chapter 17 - Developing XML-Based Reusable Components Part - Oracle XML forSCAN C Developers TheIV INDEX UNIQUE that uses the NAME_IDX shows that the created B*Tree index is used when executing

Chapter 18 - Getting Started with Oracle XML and C the XPath-based query. Chapter 19 - Building an XML-Managed Application

Bitmap Chapter 20 -Indexes Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Bitmap indexes store theDevelopers index keys in a bitmap instead of the list of ROWIDs, as in B*Tree indexes. Each bit in Part V - Oracle XML forall C++

the bitmap corresponds to a possible ROWID. If the bit is set, it means that the row with the corresponding ROWIDs contains the key value. A mapping function converts the bit position to the actual ROWID, so the bitmap index Chapter 23 - Build an XML Database OCI C++ Application provides the same functionality as a regular index even though it internally uses a different representation. Chapter 22 - Getting Started with Oracle XML and C++

Chapter 24 - Building an XML Data-Retrieval Application

Part VInumber - Oracleof XML for PL/SQL Developers If the different key values is small, bitmap indexes are space efficient. For XML documents, you can

Chapter 25 - Getting Started with Oracle XML and containing PL/SQL create bitmap indexes on those XML elements a high duplication of data. In the following example, a Chapter - Building PL/SQL Web Services bitmap 26 index is created for the types attribute in the <Standard> element: Chapter 27 - Extending PL/SQL XML bitmap_idx Functionality with SQL> CREATE BITMAP INDEX ON Java Chapter 28 - Putting It All Together product(description.existsNode('/Description/Whatis/Standard@type')); Appendix - XML Standards Bodies and Open Specifications Index created. Glossary Index

Then, you can run the following EXPLAIN PLAN command to examine the query execution details: List of Figures List SQL> of Tables EXPLAIN PLAN FOR

/*+ index(x bitmap_idx) */ count(*) FROM product x ListSELECT of Sidebars WHERE x.description.EXISTSNODE('/Description/Whatis/Standard@type')=1; Explained. SQL> @d:\oracle\rdbms\admin\utlxpls PLAN_TABLE_OUTPUT -----------------------------------------------------------------------| Id | Operation | Name |Rows|Bytes|Cost (%CPU)| Time | ------------------------------------------------------------------------


| 0 |SELECT STATEMENT | | 1 | 496 | 69 |00:00:01| | 1 | SORT AGGREGATE | | 1 | 496 | | | |*2 | TABLE ACCESS BY | | | | | | Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & | | INDEX ROWID | PRODUCT | 4 | 496 | 69 |00:00:01| PL/SQL | 3 | BITMAP CONVERSION | Wang | | | | ISBN:0072229527 by Mark V. Scardina, Ben|Chang and Jinyu | | TOMcGraw-Hill/Osborne ROWIDS | | | | | | © 2004 (600 pages) | 4 | BITMAP INDEX FULL SCAN|BITMAP_IDX| | | | | This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with ------------------------------------------------------------------------emphasis on XML standards, their usage and best practices. Predicate Information (identified by operation id): --------------------------------------------------Table of Contents 2 - filter(EXISTSNODE(SYS_MAKEXML('0602BCF5CB2048E2BBA19796753F5D49', Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL 2812,X."SYS_NC00004$",X."SYS_NC00007$"), Introduction '/Description/Whatis/Standard@type')=1) Part I - Oracle and the XML Standards 16 rows selected. Chapter 1

- Introducing XML

Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX The BITMAP INDEX FULL SCAN that uses the BITMAP_IDX shows that the created bitmap index is used when Chapter executing 3 -the Transforming XPath-based XML query. with XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

Function-Based Indexes Chapter 5 - XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP

A function-based index is created based on the values returned by function expressions. After the values are - Putting It All Together with XML Pipeline, JSPs, and XSQL computed and stored, SQL queries using the functions in their WHERE clauses will be sped up by use of the index. Part II - Oracle XML Management for DBAs The function used for building the index can be either an arithmetic expression or an expression that contains a Chapter 8 - Getting Started with the Oracle XML Database PL/SQL function, a C callout, or a SQL function. Chapter 7

Chapter 9

- Storing XML Data

Chapter 10 - Generating Retrieving XML cannot be used on O-R XMLTypes because of the previously discussed In the Oracle XML DB, and when query rewrite Chapter limitations, 11 - you Searching can create XML Data a function-based index using XMLType functions. The following example creates a

function-based index and the EXPLAIN PLAN command is run to examine the query execution plan: Chapter 12 - Managing the Oracle XML Database Part III CREATE - Oracle XML for Java Developers SQL> INDEX fidx_existnode

ON PRODUCT(

Chapter 13 - Getting Started with Oracle XML and Java EXTRACT(description,'/Description/Whatis/Function').getStringVal()); Chapter - Building an XML-Powered Web Site Index 14 created. Chapter 15 - Creating a Portal Site with XML and Web Services

SQL> EXPLAIN PLAN an FOR Chapter 16 - Developing XML Gateway Application with SOAP and AQ count(*) Chapter SELECT 17 - Developing XML-Based Reusable Components Part IV -FROM Oracleproduct XML for CxDevelopers

EXTRACT(description, Chapter WHERE 18 - Getting Started with Oracle XML and C '/Description/Whatis/Function').getStringVal()='transform'; Chapter 19 - Building an XML-Managed Application Explained. Chapter 20 - Build an XML Database OCI Application SQL> @d:\oracle\rdbms\admin\utlxpls PLAN_TABLE_OUTPUT Part V - Oracle XML for C++ Developers ----------------------------------------------------------------------Chapter 22 - Getting Started with Oracle XML and C++ | Id | Operation | Name |Rows|Bytes|Cost (%CPU)| Time | Chapter 23 - Build an XML Database OCI C++ Application -----------------------------------------------------------------------Chapter 24 - Building an XML Data-Retrieval Application | 0 |SELECT STATEMENT | | 1 | 496 | 2 (50) | 00:00:01| Part VI - Oracle XML for PL/SQL Developers | 1 | SORT AGGREGATE | | 1 | 496 | | | Chapter 25 - Getting Started with Oracle XML and PL/SQL |* 2| INDEX RANGE SCAN| FIDX_EXISTNODE | 1 |496 | 2 (50)| 00:00:01 | Chapter 26 - Building PL/SQL Web Services -----------------------------------------------------------------------Chapter 27 - Extending PL/SQL XML Functionalityby with Java Predicate Information (identified operation id): Chapter 28 - Putting It All Together --------------------------------------------------Appendix - XML Standards Bodies and Open Specifications 2 - access((EXTRACT(SYS_MAKEXML('1279EA6100D34050A95214274890C924', Glossary 3065,X."SYS_NC00004$",X."SYS_NC00007$"),'/Description/Whatis/Function')) Index ='transform') Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

List of Figures

15ofrows List Tablesselected. List of Sidebars

The INDEX RANGE SCAN that uses the FIDX_EXISTNODE shows that the created function-based index is used when executing the XPath-based query.

CTXXPATH Indexes To improve the performance of XPath-based searches, CTXXPATH index was introduced in Oracle9i R2 for XMLTypes, which serves primarily as a content filter for EXISTSNODE(). When CTXXPATH index is used by EXISTSNODE(), a superset of the results of the XPath expression is returned, as in the following query:


SELECT product_id, name FROM product WHERE EXISTSNODE(description, Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL '/Description[@name="XSLT"]/OracleSupport[ora:contains(.,"SQL")>0]', ISBN:0072229527 by Mark'xmlns:ora="http://xmlns.oracle.com/xdb"')>0; V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

The CTXXPATH index can’t returnguide the results foronthe complete query since can’t process ora:contains(), This comprehensive focuses utilizing XMLXPath technologies withinitOracle's XML-enabled products, with but it can filter emphasis the content all thetheir documents containing the path /Description/[@name=“XSLT”]. Based onand XMLreturn standards, usage and best practices. on the superset returned by the CTXXPATH index, EXISTSNODE() then processes a significantly reduced number of XML documents. Table of Contents Oracle Database 10g XML & index SQL—Design, & Manage Applications Java, C, by C++ & PL/SQL Creating the CTXXPATH is similarBuild to creating the XML CONTEXT indexinprovided Oracle Text. For example, you Introduction can create a CTXXPATH index on the description column of the product table as follows: Part I - Oracle and the XML Standards

CREATE INDEX ctxxpath_idx ON product(description)

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX INDEXTYPE IS CTXSYS.CTXXPATH;

Chapter 3

- Transforming XML with XSLT and XPath

Chapter withthe DTDs and XML Schemas As with4the- Validating CONTEXTXML index, CTXXPATH index requires index synchronizations after insert and update DML Chapter operations. 5 - XML Additionally, Operations it supports with XQuery only XPath without XML namespaces. If the XPath expression contains

namespaces, theMessaging CTXXPATH will not be used for XPath functions, numerical range operators, arithmetic Chapter 6 - XML andindex RPC with SOAP operators, XPathItaxes. The usewith of the index depends on the database optimizers. For example, Chapter 7 -or Putting All Together XMLCTXXPATH Pipeline, JSPs, andalso XSQL if the Based (CBO) Part II Cost - Oracle XMLOptimizer Management fordecides DBAs that the CTXXPATH index is too expensive to use, it also will not be used by8 the EXISTSNODE() function. In order let the database optimizers properly estimate the cost, you can use Chapter - Getting Started with the Oracle XML to Database the ANALYZE command or the DBMS_STATS package. Chapter 9 - Storing XML Data Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Full Text Search PL/SQL

ISBN:0072229527 by Mark Scardina, Ben Chang Jinyu Wang Oracle Text, known as V. Oracle interMedia Text and in Oracle8i, provides the full text search functionality that allows users McGraw-Hill/Osborne © 2004 (600 pages) to quickly find the documents that contain certain words or phrases.

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

To utilize the full text search functionality Oracle Text, you can create a CONTEXT index provided by Oracle Text emphasis on XML standards,intheir usage and best practices. and specify searches in SQL using the CONTAINS() function. For example, you can create a CONTEXT index on thedescription column of the product table as follows:

Table of Contents

CREATE INDEX10g desc_idx ON product(description) Oracle Database XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL INDEXTYPE IS CTXSYS.CONTEXT; Introduction Part I - Oracle and the XML Standards

The CONTEXT index type is specified by the INDEXTYPE clause. After the CONTEXT index is created, you can - Introducing XML submit a SQL query as follows:

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

SELECT name FROM product WHERE CONTAINS(description, 'XSLT')>0;

Chapter 4 argument - Validating XMLCONTAINS() with DTDs and XML Schemas The first of the function is the column being searched, and the second argument includes Chapter 5 - words XML Operations with XQuery the search or phrases. The CONTAINS() function returns a number for each row in the table, indicating how Chapter XML Messaging and the RPCquery. with SOAP closely 6the- document matches If the returned number is greater than zero, the document matches the Chapter 7 -a Putting It Allexample Together with returns XML Pipeline, JSPs,ofand XSQL query. As result, the query the name every product containing XSLT in its description. Part II - Oracle XML Management for DBAs

By default, CONTEXT does not provide transactional support for the DML operations, including data Chapter 8 - the Getting Started index with the Oracle XML Database insertions updates. You need to synchronize the CONTEXT index to ensure that the index is up-to-date. Chapter 9 -and Storing XML Data Chapter 10 - Generating and Retrieving XML

In Oracle Database 10g, a new index property called TRANSACTIONAL is introduced for the CONTEXT index to provide transactional support, as shown in the following example:

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database

CREATE INDEX desc_idx ON product(description) INDEXTYPE IS CTXSYS.CONTEXT Chapter 13 - Getting Started with Oracle XML and Java PARAMETERS('TRANSACTIONAL'); Part III - Oracle XML for Java Developers

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with and Web Services property turned on. In addition to processing the if the CONTEXT index is created with XML the TRANSACTIONAL Chapter 16 - Developing XMLCONTEXT Gateway Application SOAP and function AQ synchronized ROWIDs an in the index, thewith CONTAINS() does in-memory indexing and processing Chapter - Developing XML-Based Reusable Components for the 17 updated or inserted ROWIDs that have not yet been synchronized. You still need to synchronize the index to Part IVthe - Oracle XML for C Developers bring pending ROWIDs into the CONTEXT index for better performance.

Chapter 18 - Getting Started with Oracle XML and C

In summary, the following is the basicApplication procedure for using the full text search functionality provided by Oracle Text: Chapter 19 - Building an XML-Managed 1. Create a CONTEXT index on VARCHAR2, Chapter 20 - Build an XML Database OCI Application CLOB, BLOB, BFILE, UriType, or XMLType columns. Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

2. Query table-indexed columns using the CONTAINS() function in SQL.

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle C++ Synchronize the CONTEXT index afterXML DMLand operations and optimize the index regularly to ensure better Chapter 23 - Build an XML Database OCI C++ Application performance. Chapter 24 - Building an XML Data-Retrieval Application

WeVI will- discuss the for CONTEXT index optimization in the following sections. Part Oracle XML PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

Note Oracle Text provides a transaction-based index called the CTXCAT index. However, normally it is not used for indexing XML documents because it supports only CHAR and VARCHAR2 columns and has limited Chapter 27 - Extending PL/SQL XML Functionality with Java support for structured document search. Chapter 26 - Building PL/SQL Web Services Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Searching XML Using Oracle Text

Glossary Index

In searching XML, you often want to use the structure of the XML document to restrict the search. In Oracle Text, document sections are used to define and add structure information from the XML document to the CONTEXT List of Tables index. Each document section is defined based on the start tag/end tag of the XML elements or on certain XPath List of Sidebars detections. During indexing, the CONTEXT index stores the document sections for every indexed token. This allows users to specify the scope of the text search either by using XPath expressions with INPATH/HASPATH operators or by using XML element names with the WITHIN operator. List of Figures

Oracle Text provides three types of document section for XML documents: AUTO_SECTION_GROUP, PATH_SECTION_GROUP, and XML_SECTION_GROUP. Each section group is an object that consists of a collection of tags that should be indexed and a section type specification that indicates the format of the document and how to parse the format.


Both AUTO_SECTION_GROUP and XML_SECTION_GROUP index the document based on the element/attribute names. The difference between the two is that AUTO_SECTION_GROUP indexes every XML tag whereas XML_SECTION_GROUP indexes only the&tags in Design, its tag collection. PATH_SECTION_GROUP indexes the & Oracle Database 10g XML SQL: Build & Manage XML Applications in Java, all C, C++ element tags and attributes while maintaining the XPath information. PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Note Using AUTO_SECTION_GROUP in Oracle Database 10g is not recommended, because its searching McGraw-Hill/Osborne © 2004 (600 pages) functionality can be fully covered by the PATH_SECTION_GROUP index.

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Using PATH_SECTION_GROUP

Table of Contents PATH_SECTION_GROUP is the default section group for XMLTypes. Since PATH_SECTION_GROUP indexes all Oracle the sections Database in the 10g XML XML & document, SQL—Design, thereBuild is no&need Manage to declare XML Applications the document in Java, sections C, C++ to&bePL/SQL indexed. Therefore,

users normally use the default instance of PATH_SECTION_GROUP provided by Oracle Text to create the index. Introduction ThisI default PATH_SECTION_GROUP contains the predefined full text search preferences. For Part - Oracleinstance and the of XML Standards example, can createXML a CONTEXT index called product_idx with PATH_SECTION_GROUP as follows: Chapter 1 you - Introducing Chapter 2 INDEX - Accessing XML with DOM, JAXB, and StAX CREATE product_idx ON SAX, product(description) Chapter INDEXTYPE 3 - Transforming IS CTXSYS.CONTEXT XML with XSLT and XPath

PARAMETERS('SECTION GROUP Chapter 4 - Validating XML with DTDsCTXSYS.PATH_SECTION_GROUP'); and XML Schemas Chapter 5

- XML Operations with XQuery

With PATH_SECTION_GROUP, you can use the WITHIN operator, but you can additionally choose from two more- XML Messaging and RPC with SOAP powerful operators, the HASPATH or INPATH operators, to incorporate a subset of XPath expressions within the Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL CONTAINS() function. HASPATH returns TRUE if the specified XPath exists in the XML document, and INPATH Part II - Oracle XML Management for DBAs returns TRUE if the text specified exists in the XML content selected out by the XPath expressions. Here are Chapter 8 - Getting Started with the Oracle XML Database examples of both operators in action: Chapter 6

Chapter 9

- Storing XML Data

SQL> SELECT product_id, name FROM product Chapter 11 - Searching XML Data WHERE CONTAINS(description,'SQL INPATH(/Description/ Chapter 12 - Managing the Oracle XML Database OracleSupport)')>0; Part III - Oracle XML for Java Developers PRODUCT_Id NAME Chapter 13 - Getting Started with Oracle XML and Java ---------------------------------------------------------------------Chapter 14 - Building an XML-Powered Web Site 1 XSLT Processor Chapter 15 - Creating a Portal Site name with XML and Web Services SQL> SELECT product_id, Chapter 16product - Developing an XML Gateway Application with SOAP and AQ FROM Chapter 17 -CONTAINS(description, Developing XML-Based Reusable Components WHERE Part IV - Oracle XML'HASPATH(/Description//Standard[@type="W3C"])')>0; for C Developers Chapter 10 - Generating and Retrieving XML

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application PRODUCT_ID NAME Chapter ---------------------------------------------------------------------20 - Build an XML Database OCI Application

2 XSQL Chapter 21 - Create an XML-Configured High-Performance Transformation Engine 1 XML XSLT Processor Part V - Oracle for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++

The first SQL query uses INPATH to limit the <OracleSupport> element to be a direct child of the root element, <Description>, which contains the word SQL. The HASPATH operator in the second query is used to evaluate the Chapter 24 - Building an XML Data-Retrieval Application XPath expression and return TRUE if the XPath /Description//Standard[@type=“W3C”] exists in the XML Part VI - Oracle XML for PL/SQL Developers document. Chapter 23 - Build an XML Database OCI C++ Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 26 The - Building PL/SQL Web Services Note text used in XPath is case sensitive; for example, INPATH(//Product) is different from Chapter 27 INPATH(//product). - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

Using XML_SECTION_GROUP Appendix - XML Standards Bodies and Open Specifications Glossary

The CONTEXT index in PATH_SECTION_GROUP is easy to use, but it can be expensive because it indexes all the document sections in the XML document, including those whose content will not be searched. To avoid the List of Figures overhead, you can use XML_SECTION_GROUP to specify a limited number of document sections based on the List of Tables XML elements. For example, you can create an instance of XML_SECTION_GROUPcalled productGroup and List of Sidebars limit the index on one document section called whatis_sec containing content from the <Whatis> element: Index

EXEC CTX_DDL.CREATE_SECTION_GROUP('productGroup','XML_SECTION_GROUP'); EXEC CTX_DDL.ADD_ZONE_SECTION('productGroup','whatis_sec','Whatis'); Then, you can create a CONTEXT index using the productGroup: CREATE INDEX desc_xml_idx ON product(description) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('SECTION GROUP productGroup');


The SQL query can use the WITHIN operator to specify the document section: SELECT name Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & FROM product PL/SQL WHERE CONTAINS(description, 'java WITHIN whatis_sec')>0; by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

You can also add new zone section named orasupport_sec the tag name the <OracleSupport> Thisacomprehensive guide focuses on utilizing XMLusing technologies within of Oracle's XML-enabled products, with emphasis XML standards, their usage and best practices. element by rebuilding theonindex: ALTER INDEX desc_xml_idx REBUILD Table of Contents PARAMETERS ('ADD ZONE SECTION orasupport_sec TAG OracleSupport'); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

However, the following SQL query will not return any rows: Introduction Part SELECT I - Oracle name and the XML Standards

FROM product Chapter 1 - Introducing XML WHERE 2CONTAINS(description, 'java WITHIN orasupport_sec')>0; Chapter - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

This is because the rebuild process only modifies the index metadata, and does not rebuild the index in any way. - Validating XML with DTDs and XML Schemas This means that these section updates do not affect any indexed documents. To include the existing documents in Chapter 5 - XML Operations with XQuery the index with the new sections, you need to manually mark the documents for re-indexing or simply drop and reChapter 6 - XML Messaging and RPC with SOAP create the index. Chapter 4

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs XML_SECTION_GROUP is efficient. However, when the element names In contrast to PATH_SECTION_GROUP,

Chapter - Getting Started with the Oracle XML Database are not8unique in the XML document, you cannot create zone sections to differentiate these elements in the full text Chapter searches. 9 - Storing XML Data Chapter 10 - Generating and Retrieving XML

Synchronizing the Chapter 11 - Searching XMLIndex Data Chapter 12 - Managing the Oracle XML Database

Unlike the B*Tree index, where the database maintains the index on the basis of DML transactions, the CONTEXT index is not updated after the DML transactions, including the data insertions and updates. Instead, only the Chapter 13 - Getting Started with Oracle XML and Java ROWIDs of the updated or inserted table records are kept for later index synchronization. Therefore, if there are any Chapter 14 - Building an XML-Powered Web Site inserts or updates of documents in the base table, you need to synchronize the CONTEXT index for the records to Chapter 15 - Creating a Portal Site with XML and Web Services be part of the searching content. Part III - Oracle XML for Java Developers

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter Note 17 The - Developing CONTEXT XML-Based index transactionally Reusable Components supports data deletion operations. Part IV - Oracle XML for C Developers

You can whether synchronization is and needed Chapter 18decide - Getting Started with Oracle XML C by reviewing the CTX_USER_PENDING view, where all

ROWIDs related to DML operations are stored. For example, if the product table is updated, you can see new entries in the CTX_USER_PENDING view:

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application

SQL> UPDATE product SET Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Partdescription=updateXML(description,'/Description/OracleSupport', V - Oracle XML for C++ Developers

'<OracleSupport>Oracle XSQLXML provides Chapter 22 - Getting Started with Oracle and C++ command-line utility, run-time Servlet engine and extensible Java development framework </OracleSupport>') Chapter 24 - Building an XML Data-Retrieval Application WHERE product_id=2; Part VI - Oracle XML for PL/SQL Developers 1 row updated. Chapter 23 - Build an XML Database OCI C++ Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

SQL> SELECT pnd_index_name, pnd_rowid, TO_CHAR(pnd_timestamp, 'dd-mon-yyyy') timestamp Chapter 28CTX_USER_PENDING; - Putting It All Together FROM Chapter 27 - Extending PL/SQL XML Functionality with Java Appendix

- XML Standards Bodies and Open Specifications

Glossary PND_INDEX_NAME

PND_ROWID

TIMESTAMP

Index ------------------------------ ------------------ ----------List of Figures PRODUCT_IDX AAAK6jAAEAAAAbsAAB 09-aug-2003 List of Tables List of Sidebars

You can synchronize your index manually by calling the CTX_DDL.SYNC_INDEX() procedure. In order to have the execution privilege on the CTX_DDL PL/SQL package, you need to have the CTXAPP role granted by the CTXSYS user: GRANT ctxapp TO &user_name; The following example synchronizes the product_idx index using 2MB of memory: SQL> BEGIN 2 CTX_DDL.SYNC_INDEX('product_idx', '2M');


3 END; 4 / PL/SQL procedure successfully completed. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

SQL> SELECTbypnd_index_name, pnd_rowid, TO_CHAR(pnd_timestamp, ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang 'dd-mon-yyyy') timestamp FROM CTX_USER_PENDING; McGraw-Hill/Osborne © 2004 (600 pages) no rows selected This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

After index synchronization, the CTX_USER_PENDING view will not have any entries. Table of Contents Alternatively, you can run CTX_DDL.SYNC_INDEX() automatically at regular intervals using the Oracle DBMS_JOB.SUBMIT() Database 10g XML procedure. & SQL—Design, Oracle Build Text & Manage includesXML a SQL Applications script youincan Java, use C,to C++ do this: & PL/SQL Introduction $ORACLE_HOME/ctx/sample/script/drjobdml.sql Part I - Oracle and the XML Standards

Chapter 1 - Introducing XML $ORACLE_HOME/ctx/sample/script/drbgdml.sql Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

To use3this- Transforming script, you must theXSLT owner of XPath the index and you must have execution privileges on the CTX_DDL Chapter XMLbe with and package. You must also set the JOB_QUEUE_PROCESSES parameter in the Oracle initialization file. For example, Chapter 4 - Validating XML with DTDs and XML Schemas to set the index synchronization to run every 360 minutes on product_idx, you can issue the following command in Chapter 5 - XML Operations with XQuery SQL*Plus: Chapter 6 - XML Messaging and RPC with SOAP SQL> @drjobdml 360; Chapter 7 - Putting Itproduct_idx All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

You need to properly choose an interval for CONTEXT index synchronization. This is because synchronizing the - Getting Started with the Oracle XML Database CONTEXT indexes right after each data insertion or update may result in index fragmentation, which may Chapter 9 - Storing XML Data dramatically reduce the performance of the full text search queries. Chapter 8

Chapter 10 - Generating and Retrieving XML

Chapter 11 - Searching XML frequent Data If the application requires synchronization of the CONTEXT index or even requires the transactional update Chapter 12 - Managing theyou Oracle Database of the CONTEXT index, thenXML need to schedule additional regular CONTEXT index optimization to ensure high Part III - Oracle XML for Java Developers performance.

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

How Oracle Text Search Works

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16the - Developing an XML Gateway Application withworks SOAP helps and AQ Knowing details of how searching with Oracle Text you build better searches. This is particularly Chapter useful when 17 - Developing you want to XML-Based know whyReusable the data Components is selected. This section discusses those features that help you Part understand IV - Oracle theXML search for C process. Developers

Chapter 18 - Getting Started with Oracle XML and C

Whenever the CONTEXT index is created, all the XML documents are analyzed and a set of tables is created to store the indexed tokens. For example, along with the product_idx index, the following index tables are created:

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application

SQL> SELECT table_name FROM High-Performance user_tables Transformation Engine Chapter 21 - Create an XML-Configured table_name LIKE '%PRODUCT_IDX%'; Part VWHERE - Oracle XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++

TABLE_NAME -----------------------------Chapter 24 - Building an XML Data-Retrieval Application DR$PRODUCT_IDX$I Part VI - Oracle XML for PL/SQL Developers DR$PRODUCT_IDX$K Chapter 25 - Getting Started with Oracle XML and PL/SQL DR$PRODUCT_IDX$N Chapter 26 - Building PL/SQL Web Services DR$PRODUCT_IDX$R Chapter 23 - Build an XML Database OCI C++ Application

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All creates Togetherfour tables automatically. These tables start with the DR$ prefix and end with the The Oracle Text engine Appendix XML$K, Standards Bodies and Open Specifications suffix to be- $I, $N, or $R. Between the prefix and suffix is the index name. Glossary

The DR$<INDEX NAME>$Kand DR$<INDEX NAME>$R tables store the mapping of the row information from the Index

internal document identifiers (DOCIDs) to external ROWID values. The database optimizer (Cost Based Optimizer) determines the type of lookup. For functional lookups, the $K table is used. For indexed lookups, the $R table is List of Tables used. Hence, you can easily find out whether a functional or indexed lookup is used by examining the SQL trace and List of Sidebars looking for the $K or $R tables. List of Figures

The $N tableis used to maintain information for the deleted rows and the $I table is the one that stores all the tokens indexed by Oracle Text. The search queries will look up all the tokens stored in the $I table before returning the result. The following is the schema of the $I table: SQL> DESC DR$product_idx$I; Name Null? Type --------------- ------------------- -------- ----------------


TOKEN_TEXT NOT NULL VARCHAR2(64) TOKEN_TYPE NOT NULL NUMBER(3) TOKEN_FIRST NOT NULL NUMBER(10) Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & TOKEN_LASTPL/SQL NOT NULL NUMBER(10) TOKEN_COUNT ISBN:0072229527 by Mark V. Scardina, Ben Chang andNOT JinyuNULL Wang NUMBER(10) TOKEN_INFOMcGraw-Hill/Osborne © 2004 (600 pages) BLOB This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

The TOKEN_TEXT column stores the tokens and the TOKEN_INFO column stores the information about the row emphasis on XML standards, their usage and best practices. and word positions where the token occurs. Table of Contents To ensure the preferred content is indexed by Oracle Text, you can use the following command to check the $I Oracle table:Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction SELECT TOKEN_TEXT FROM DR$product_idx$I Part I - Oracle and the XML Standards WHERE TOKEN_TEXT LIKE 'XSLT';

Chapter 1

- Introducing XML

This SQL checks whether the word is indexed Chapter 2 query - Accessing XML with DOM, SAX, XSLT JAXB, and StAX by the CONTEXT index called product_idx. Chapter 3

- Transforming XML with XSLT and XPath

Sometimes an indexing operation might fail or not complete successfully. When the system encounters an error - Validating XML with DTDs and XML Schemas indexing a row, it logs the error in an Oracle Text view. You can view these errors for specific users using the Chapter 5 - XML Operations with XQuery CTX_USER_INDEX_ERRORS view or query the CTXSYS errors for all users using the CTX_INDEX_ERRORS Chapter 6 - XML Messaging and RPC with SOAP view. For example, to view the most recent index errors of the current logged in user, you can issue the following Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL SQL command: Chapter 4

Part II - Oracle XML Management for DBAs

SELECT err_timestamp, err_text - Getting Started with the Oracle XML Database FROM ctx_user_index_errors Chapter 9 - Storing XML Data ORDER BY err_timestamp DESC; Chapter 8

Chapter 10 - Generating and Retrieving XML

Chapter 11the - Searching XML Data To clear view of errors, you can issue the following command: Chapter 12FROM - Managing the Oracle XML Database DELETE CTX_USER_INDEX_ERRORS; Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

Optimizing Oracle Text Searches

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services

We have discussed that you need to optimize the CONTEXT index after multiple index synchronizations. This is because index synchronization may result in index fragmentation that adversely affects query performance.

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Part IV - Oracle Developers Additionally, in XML orderfor to Cimprove query response time, when many rows are deleted from the base table, you need to

Chapter optimize 18the - Getting CONTEXT Started index with inOracle FULL mode. XML and This C is because the old data in the index table is marked only as

deleted19 but is not cleaned up immediately. Because the old data takes up space and can cause extra overhead at Chapter - Building an XML-Managed Application query time, you must remove this data from the index by optimizing the index in FULL mode. This is called garbage Chapter 20 - Build an XML Database OCI Application collection. in FULL mode for garbage collection is also necessary Chapter 21 -Optimizing Create an XML-Configured High-Performance Transformation Enginewhen you have had frequent updates or deletions the for base table. If you rarely delete or update data from a table, you can use the OPTIMIZE FAST Part V - OracletoXML C++ Developers option. 22 Otherwise, should OPTIMIZE Chapter - Getting you Started withuse Oracle XML andFULL. C++ Chapter 23 - Build an XML Database OCI C++ Application

You can also optimize the index in TOKEN mode, where you specify a specific token to be optimized. You can use this mode to optimize index tokens that are frequently searched, without spending time optimizing tokens that are Part VI - Oracle XML for PL/SQL Developers rarely referenced. For example, you can specify that only the token “Functionality” in the product descriptionbe Chapter 25 -inGetting Started Oracle XML token and PL/SQL optimized the index if youwith know that this is updated and queried frequently. To optimize an index in TOKEN Chapter 26 Building PL/SQL Web Services mode, you can use CTX_DDL.OPTIMIZE_INDEX() as follows: Chapter 24 - Building an XML Data-Retrieval Application

Chapter 27 - Extending PL/SQL XML Functionality with Java

BEGIN CTX_DDL.OPTIMIZE_INDEX('product_idx','token', Appendix - XML Standards Bodies and Open Specifications TOKEN=>'Functionality'); Glossary END; Chapter 28 - Putting It All Together

Index

Anof optimized List Figures token can improve its query response time. Again, the tokens can be found in the $I table. List of Tables

To help you decide whether to optimize your index, you can create a statistical report on your index using the CTX_REPORT.INDEX_STATS() procedure. The report includes information on the optimal row fragmentation, a list of the most fragmented tokens, and the amount of garbage data in your index. Although this report might take a long time to run for large indexes, it really helps.

List of Sidebars

Advanced Text Searches Oracle Text provides many full text search features. This section discusses techniques on how to return scores that reflect the relevance of the query and returned records, how to leverage the full text search on XML documents in


the XML DB Repository, and how to set up categories for XML document searching.

Using Scores Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

When you issue a full text search query, Oracle Text returns a relevance score for each document returned. The ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang score is between 1 and 10. The higher the score, the more relevant the document is to the query. The score can be McGraw-Hill/Osborne © 2004 (600 pages) selected using the SCORE() operator with a label of 1: This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

SQL> SELECTemphasis score(1) AS standards, score, product_id, on XML their usage and name best practices. FROM product WHERE CONTAINS(description,'W3C INPATH(//Standard/@type)',1)>0;

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

SCORE PRODUCT_ID NAME ---------------------------------------------------------------Part I - Oracle and the XML Standards 6 2 XSQL Chapter 1 - Introducing XML 3 1 XSLT Processor Introduction

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 use - Transforming with XSLT and XPath You can these scoresXML to order the returned documents by showing the most relevant documents first. Chapter 4

- Validating XML with DTDs and XML Schemas

Searching XML in thewith Oracle Chapter 5 - XML Operations XQueryXML DB Repository Chapter 6

- XML Messaging and RPC with SOAP

To add full text search for XML files stored in the Oracle XML DB repository, you can create a CONTEXT index - Putting It All Together with XML Pipeline, JSPs, and XSQL using a subtype of the UriType called XDBUriType.

Chapter 7

Part II - Oracle XML Management for DBAs

Chapter 8 Additionally, - Getting Started withcreate the Oracle XML Database Note you can CONTEXT indexes on files in HTTP server, FTP server, and OS file systems Chapter 9 using - Storing Data or its subtypes such as the HTTPUriType. the XML UriType Chapter 10 - Generating and Retrieving XML

For example, you can XML create a table with an XDBUriType column containing the Oracle XML DB repository URIs Chapter 11 - Searching Data pointing12to-the files stored the XML repository. For example, the XML DB repository URI of the xdbconfig.xml Chapter Managing the Oracle XMLDB Database file is Part III/xdbconfig.xml: - Oracle XML for Java Developers CREATE myconfig(url SYS.XDBURITYPE); Chapter 13TABLE - Getting Started with Oracle XML and Java INSERT myconfig VALUES(SYS.XDBURITYPE.CREATEURI('/xdbconfig.xml')); Chapter 14INTO - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

Then, you can create a CONTEXT index on this column:

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

CREATE config_idx ONReusable myconfig(url) Chapter 17INDEX - Developing XML-Based ComponentsINDEXTYPE IS CTXSYS.CONTEXT; Part IV - Oracle XML for C Developers

After the index is created, you can use the following SQL CONTAINS query to search the content:

Chapter 18 - Getting Started with Oracle XML and C

SELECT FROM myconfig WHEREApplication CONTAINS(url, 'http')>0; Chapter 19*- Building an XML-Managed Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Category-Based Searching

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ you can classify the documents and establish the document When searching a large number of XML documents, Chapter Build anaXML Database OCI In C++ Application routing 23 by -creating CTXRULE index. Oracle Database 10g, you can build a CTXRULE index based on your XML Chapter 24 -queries. Building an XML Data-Retrieval Application document Part VI - Oracle XML for PL/SQL Developers

The first is to create tableOracle of queries that PL/SQL defines the classifications. For example, you can create a Chapter 25step - Getting Starteda with XML and QUERY_CAT table to hold the Chapter 26 - Building PL/SQL Webcategory Servicesname and query text: Chapter CREATE 27TABLE - Extending QUERY_CAT PL/SQL XML ( Functionality with Java

query_id NUMBERIt All PRIMARY Chapter 28 - Putting TogetherKEY, category- XML VARCHAR2(30), Appendix Standards Bodies and Open Specifications query VARCHAR2(2000)); Glossary Index

You then can populate the table with the classifications and the queries that define each category. For example, consider a classification for the subjects XML and SQL:

List of Figures List of Tables

INSERT INTO QUERY_CAT VALUES(1, 'XML Product', 'xml'); INSERT INTO QUERY_CAT VALUES(2, 'SQL', 'ABOUT(sql)');

List of Sidebars

You can create the CTXRULE index as follows: CREATE INDEX ctxrule_idx ON query_cat(query) INDEXTYPE IS CTXSYS.CTXRULE; After a CTXRULE index is created on the query set, you can use the MATCHES() function to classify the XML documents. In the following example, a product_route table is created to store results of the document


classification: create table product_route (product_idOracle number, Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL category varchar2(30)); by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

The following PL/SQL code populates the (600 product_route table using MATCHES(): McGraw-Hill/Osborne © 2004 pages) DECLARE This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. CURSOR p_desc IS SELECT product_id, description FROM product; BEGIN FORof item IN p_desc LOOP Table Contents FOR c1 IN (SELECT category Build & Manage XML Applications in Java, C, C++ & PL/SQL Oracle Database 10g XML & SQL—Design, FROM query_cat Introduction Part I - Oracle and WHERE the XMLMATCHES(query,item.description.getStringVal())>0) Standards LOOP Chapter 1 - Introducing XML INSERT INTO product_route(product_id, category) Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX VALUES (item.product_id, c1.category); Chapter 3 - Transforming XML with XSLT and XPath END LOOP; Chapter 4 - Validating XML with DTDs and XML Schemas END LOOP; Chapter 5 - XML Operations with XQuery END; Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7 -functionality, Putting It Allyou Together with XML Pipeline, JSPs, into and a XSQL Using this can classify XML documents number of predefined categories. Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Best Practices PL/SQL

ISBN:0072229527 Mark V. Scardina, Ben Chang Jinyu Wang process. You should regularly monitor the Optimizing the by performance of searches can beand a trial-and-error © 2004 (600 pages) performance toMcGraw-Hill/Osborne establish a plan for maintaining the indexes. The following are some tips to maximize the query performance. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

When to Use XPath-Based Searches

Table of Contents

Oracle You should Database not 10g overuse XML &XPath-based SQL—Design, queries Build &on Manage XML documents XML Applications unlessinyou Java, canC,ensure C++ &that PL/SQL the query rewrite is

performed properly. Without query rewrite, the in-memory building of DOM trees or text analysis for ora:contains() Introduction canIbe very expensive andStandards prevent you from searching large numbers of XML documents. Part - Oracle and the XML Chapter 1

- Introducing XML

In addition, you should know that without ora:contains(),XPath-based queries are limited to matching substrings - Accessing XML with DOM, SAX, JAXB, and StAX and may result in unexpected results.

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

Chapter Validating XML withand DTDs and XMLindexes Schemas Finally,4the- CTXXPATH index functional are both very useful for XPath-based searches when the query Chapter - XMLbe Operations with XQuery rewrite 5cannot used. Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL When to Use Oracle Text Searches

Part II - Oracle XML Management for DBAs

Chapter 8 - to Getting Started with the Oracle Compared XPath-based queries, OracleXML TextDatabase performs linguistic analysis and provides rich full text search Chapter 9 that - Storing XML Data features go beyond substring matching. For example, it allows you to create a concise abstract, called gist, for Chapter 10 - Generating and Retrieving XML the indexed XML documents: Chapter 11TABLE - Searching XML Data CREATE ctx_gist (query_id

NUMBER,

Chapter 12 - Managing the Oraclepov XML Database VARCHAR2(80), Part III - Oracle XML for Java Developers gist

CLOB);

Chapter 13 - Getting Started with Oracle XML and Java Chapter BEGIN 14 - Building an XML-Powered Web Site Chapter FOR 15 item - Creating IN (SELECT a Portal Site product_id with XML and FROM Web product) Services LOOP

CTX_DOC.GIST('product_idx',item.product_id,'CTX_GIST',1,'P', Chapter 16 - Developing an XML Gateway Application with SOAP and AQ pov =>'GENERIC', =>Components 1); Chapter 17 - Developing numParagraphs XML-Based Reusable LOOP;XML for C Developers PartEND IV - Oracle END; 18 - Getting Started with Oracle XML and C Chapter Chapter 19 - Building an XML-Managed Application

This example uses the CTX_DOC.GIST() procedure to generate gists for the product descriptions, specifying the size of the gist to be no more than one paragraph and inserting the created abstracts into a gist table called Chapter 21 - Create an XML-Configured High-Performance Transformation Engine ctx_gist. Chapter 20 - Build an XML Database OCI Application Part V - Oracle XML for C++ Developers

Chapter - Getting Started Oracle for XML and C++ Oracle 22 Text provides betterwith scalability the searches on XML documents that cannot use query rewrite by Chapter 23 - Build an XML OCIoverhead C++ Application substantially reducing theDatabase processing introduced by XML DOM tree creation and traversal, and the inChapter memory24text - Building analysisanfor XML ora:contains(). Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Additionally, OracleStarted Text can deal with XML a variety of documents from various sources in multiple languages. The Chapter 25 - Getting with Oracle and PL/SQL

document formats include Microsoft Word, PDF, Microsoft Excel, and HTML files. These documents can be stored inside the Oracle database as well as outside the database and accessed over HTTP, FTP, or from file servers. Chapter 27 - Extending PL/SQL XML Functionality with Java This, therefore, allows you to build Oracle Text indexes to optimally search XML documents stored both inside and Chapter 28 - Putting It All Together outside the database. Chapter 26 - Building PL/SQL Web Services

Appendix

- XML Standards Bodies and Open Specifications

Glossary

When to Use Oracle Text Partitioned Indexes

Index

List of Figures

Table partitioning is good to use when dealing with a large number of XML data sets. In Oracle9i, Oracle Text introduced the Local Partitioned Index, which is a partitioned index on a partitioned table with a one-to-one mapping List of Sidebars of index partitions to table partitions. This virtually splits up a large table and the CONTEXT index into a set of smaller tables and indexes. It allows you to use local partitioned indexes instead of a global index. List of Tables

For document systems, in which a large amount of new data is inserted every day, it is not practical to refresh the Oracle Text index for all the data, because that can take a long time. The local partitioned index makes the index more manageable, because after the DML operations you need to rebuild only the partition with the data changes, not the whole index. On the other hand, with the local partitioning, index partitions can be synchronized in parallel, thus increasing


uptime. Finally, because the local partitioned CONTEXT index takes advantage of partition pruning and partition iteration to Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & filter out the ROWIDs of the other partitions, it can provide faster mixed and sorted queries. PL/SQL by Mark V. Scardina, Bennot Chang and local Jinyu partitions. Wang Note The CTXXPATH index does support

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 by Mark V. Scardina, Chang and Jinyu Wang This chapter discussed two types ofBen searching strategies on XML documents: the XPath-based search using McGraw-Hill/Osborne 2004 the (600CTXXPATH pages) EXISTSNODE() with ora:contains()© and index, and the full text search using Oracle Text.

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Both approaches can beon used other SQL the EXISTSNODE() search provides better emphasis XMLwith standards, theirpredicates. usage and However, best practices. datatype comparisons and supports many XML native features such as namespaces, XPath functions, and entities. The EXISTSNODE() search also uses the XML schema to rewrite the XPath-based queries if the XMLType is stored Table of Contents in XML schema–based XMLType objects, which can greatly speed up the search process. CTXSYS.CTXXPATH Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL index and ora:contains()function leverage the full text search functionality within XPath-based queries and Introduction enhance the searching capability of EXISTSNODE(). Part I - Oracle and the XML Standards

Chapter - Introducing Oracle 1Text, although it XML supports only limited XML features and XPath syntax, has a powerful text-analysis and Chapter 2 searching - Accessing XML withfor DOM, SAX,document JAXB, andmanagement StAX linguistic capability an XML system. These features include the use of a Chapter thesaurus, 3 - the Transforming use of custom XML with lexes, XSLT andand the XPath use of word stems and wildcards on indexes. Chapter 4

- Validating XML with DTDs and XML Schemas

After reading this chapter, you should have a better understanding of Oracle Text and XPath-based queries, which - XML Operations with XQuery you can use to search XML documents. The next step is to explore XPath functionality and the rich full text search Chapter 6 - XML Messaging and RPC with SOAP feature in Oracle Text on your own to make your searches more accurate and intelligent. Chapter 5 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 12:Database Managing the Oracle XML Database PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

This chapter covers Oracle XML Database 10g management topics, beginning with looking at the components that McGraw-Hill/Osborne © 2004 (600 pages) are installed. Then, it explores how to configure the Oracle XML Database (Oracle XML DB) to ensure functionality This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with for XML applications. Finally, it shows configurations for user privileges and permissions to secure XML data and emphasis on XML standards, their usage and best practices. operations in the Oracle database. Table of Contents

Installed Oracle XML DB Components

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction After installing Oracle XML Database 10g, the XDB and ANONYMOUS users and an XDBADMIN role are created. Part - Oracle the XMLto Standards TheI XDB userand is created maintain the PL/SQL packages, datatypes, and system object registries for Oracle XML

Chapter 1 ANONYMOUS - Introducing XML DB. The user is created to allow for unauthenticated access of the Oracle XML DB Repository Chapter - Accessing XML server with DOM, SAX, JAXB, and StAXThe XDBADMIN role is granted to all the DBA users by through2 the built-in HTTP in the Oracle database. Chapter Transforming XSLTOracle and XPath default 3so -that DBA usersXML canwith perform XML DB administration operations, such as registering global XML Chapter 4 - Validating XML with DTDs and XML Schemas schemas. Chapter 5

- XML Operations with XQuery

Note ANONYMOUS created Chapter 6 The - XML Messaging anduser RPCis with SOAPwith the account LOCKED. Unless you need unauthenticated access to the Oracle XML DB Repository, do not unlock the ANONYMOUS user; doing so will create a security - Putting It All Together with XML Pipeline, JSPs, and XSQL hole. Part II - Oracle XML Management for DBAs Chapter 7

Chapter 8 - lists Getting XMLtables Database Table 12-1 the Started Oracle with XML the DB Oracle directory that are created to manage registered XML schemas, XMLType Chapter XML Data tables, 9and- Storing views. These tables can be viewed from SQL*Plus or Oracle Enterprise Manager. Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XMLDB Data Table 12-1: Oracle XML Dictionary Tables Chapter 12 - Managing the Oracle XML Database

Directory Name Part III - Oracle XML for Java Developers

Description

Chapter 13 - Getting Started with Oracle XML and Java DBA_XML_SCHEMAS

All registered XML schemas in the Oracle XML DB

Chapter 14 - Building an XML-Powered Web Site

USER_XML_SCHEMAS All registered XML schemas owned by the current Chapter 15 - Creating a Portal Site with XML and Web Services userand AQ Chapter 16 - Developing an XML Gateway Application with SOAP Chapter 17 - Developing XML-Based Reusable Components ALL_XML_SCHEMAS Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

DBA_XML_TABLES

Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application USER_XML_TABLES

All registered XML schemas usable by the current user All XMLType tables in the Oracle XML DB All XMLType tables owned by the current user

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

ALL_XML_TABLES

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ DBA_XML_TAB_COLS Chapter 23 - Build an XML Database OCI C++ Application

USER_XML_TAB_COLS

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL ALL_XML_TAB_COLS Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

DBA_XML_VIEWS

Chapter 28 - Putting It All Together

All XMLType tables usable by the current user All XMLType table columns in the Oracle XML DB All XMLType table columns in tables owned by the current user All XMLType table columns in tables usable by the current user All XMLType views in the Oracle XML DB

USER_XML_VIEWS Appendix - XML Standards Bodies and Open Specifications All XMLType views owned by the current user Glossary

ALL_XML_VIEWS

Index

All XMLType views usable by the current user

ListDBA_XML_VIEW_COLS of Figures

All XMLType view columns in the Oracle XML DB

List of Tables

USER_XML_VIEW_COLS

All XMLType view columns in views owned by the current user

ALL_XML_VIEW_COLS

All XMLType view columns in views usable by the current user

List of Sidebars

All Oracle XML DB PL/SQL packages and the new XML data types, including XMLType and Oracle XML DB URI types, are installed with Oracle XML DB. Table 12-2 lists major PL/SQL packages, XML datatypes and their function descriptions. All the definition files are stored in the ORACLE_HOME/rdbms/ADMINdirectory.


Table 12-2: PL/SQL Package Specifications and Functionality Package Name File Build & Manage XML Functionality Oracle Database 10g XMLDefinition & SQL: Design, Applications in Java, C, C++ & PL/SQL

XMLType dbmsxmlt.sql by Mark V. Scardina, Ben Chang and Jinyu Wang XMLSequenceType McGraw-Hill/Osborne © 2004 (600 pages) XMLGenFormatType

New XML data types

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices. UriType dbmsuri.sql Oracle XML DB URI datatypes DBUriType FTPUriType Table of Contents XDBUriType Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL HTTPUriType Introduction UriFactory Part I - Oracle and the XML Standards Chapter 1 - Introducing XML DBMS_XMLGEN

dbmsxml.sql

Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX DBMS_XMLSTORE Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

DBMS_XMLDOM

dbmsxmld.sql

DBMS_XMLPARSER dbmsxmlp.sql Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database DBMS_XSLPROCESSOR dbmsxsl.sql

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

PL/SQL packages generating XML from SQL queries and storing XML into relational tables via a canonical mapping PL/SQL DOM XML parsing API PL/SQL XML parser interface with support of XMLType PL/SQL XSL processor with support for XPath XML data extraction from DOM

Chapter 11 - Searching XML Data

DBMS_XMLSCHEMA dbmsxsch.sql Chapter 12 - Managing the Oracle XML Database

PL/SQL XML Schema support

Part III - Oracle XML for Java Developers DBMS_XDB

PL/SQL APIs to access and manage resource and data in Oracle XML DB Repository

dbmsxdb.sql

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

DBMS_XDBZ

dbmsxdbz.sql

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

XML DB security support

Chapter 17 - Developing XML-Based Reusable Components DBMS_XDBT dbmsxdbt.sql

PL/SQL package to set up an Oracle Text ConText index on Chapter 18 - Getting Started with Oracle XML and C the Oracle XML DB Repository hierarchy, create default Chapter 19 - Building an XML-Managed Application preferences, and set up Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engineautomatic synchronization of the CONTEXT index Part V - Oracle XML for C++ Developers Part IV - Oracle XML for C Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

Note The corresponding PL/SQL package implementations are in the files with names starting with prvt followed by the letters after dbms in the name of the definition file. For example, the package body of Part VI - Oracle XML for PL/SQL Developers DBMS_ XDBT is in the prvtxdbt.sql file. Chapter 24 - Building an XML Data-Retrieval Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 26 - Building PL/SQL Web Services If you need to reinstall Oracle XML DB, you can go to the $ORACLE_HOME/rdbms/admindirectory on UNIX and Chapter the%ORACLE_HOME%/rdbms/admin 27 - Extending PL/SQL XML Functionality directorywith on Java Windows, connect to the Oracle database as SYS user, and

follow these steps: It All Together Chapter 28 - Putting Appendix XML Bodies andand Open Specifications 1. Log- in to Standards a SQL*Plus session connect as the SYS user with SYSDBA privileges: Glossary

> sqlplus "SYS/<sys_password> as SYSDBA"

Index List of 2. Figures Run catnoqm.sql: List of Tables SQL> @catnoqm List of Sidebars

This step drops the XDB user, and all information in the Oracle XML DB Repository will be lost as will all information in the schema-based XMLType tables and columns. 3. Shut down and restart the database: SQL> shutdown immediate; SQL> startup 4. Runcatqm.sqlscript and specify the password (such as XDBPW), the default tablespace (such as XDB),


4. and the temporary tablespace (TEMP) for the XDB user: SQL> @catqm XDBPW XDB TEMP Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

5. Runcatxdbj.sql PL/SQL to install the XML DB Java packages: by Mark V. Scardina, Ben Chang and Jinyu Wang SQL> @catxdbj

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10gXML XML & DB SQL: Design, Build & Manage XML Applications in Java, C, C++ & Configuring the Oracle PL/SQL

ISBN:0072229527 by Oracle Mark V.XML Scardina, Bencan Chang and the Jinyu Wang To configure the DB, you update xdbconfig.xml file using the DOM PL/SQL APIs and McGraw-Hill/Osborne © 2004 (600 pages) DBMS_XDB package or the graphical interface provided in Oracle Enterprise Manager (OEM). The OEM allows you to insert, remove, update the content of the XML elements in technologies xdbconfig.xml. In this section, we discuss the Thisor comprehensive guide focuses on utilizing XML within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. PL/SQL operations.

Understanding xdbconfig.xml

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Thexdbconfig.xmlfile is an XML file that is stored as a resource in the Oracle XML DB Repository. It conforms to Introduction the IXML schema /sys/schemas/PUBLIC/xmlns.oracle.com/xdb/ xdbconfig.xsd in the Oracle XML DB Part - Oracle and defined the XMLin Standards Repository It has the following data structure: Chapter 1 - File. Introducing XML Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <xdbconfig> Chapter <sysconfig> 3 - Transforming ... </sysconfig> XML with XSLT and XPath

<userconfig> ... XML </userconfig> Chapter 4 - Validating with DTDs and XML Schemas </xdbconfig> Chapter 5 - XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

The top-level <xdbconfig> tag contains two sections:

Part II - Oracle XMLLists Management for DBAs <sysconfig> all the system-specific setups and the built-in parameters.

Chapter 8

- Getting Started with the Oracle XML Database

<userconfig> all parameters that allow users to customize the setups. Chapter 9 - Storing Lists XML Data Chapter 10 - Generating and Retrieving XML

The <sysconfig> section contains the following content:

Chapter 11 - Searching XML Data

<sysconfig> Chapter 12 - Managing the Oracle XML Database General parameters Part III - Oracle XML for Java Developers <protocolconfig> ... with </protocolconfig> Chapter 13 - Getting Started Oracle XML and Java </sysconfig>

Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

It stores the general parameters that apply to the Oracle XML DB; for example, the maximum age for an access

Chapter Developing an XML Gateway Application with SOAP and AQ and so on. In <sysconfig>, the protocol control 16 list-(ACL), whether Oracle XML DB should be case sensitive, Chapter 17 - Developing XML-Based Components parameters are grouped inside theReusable <protocolconfig> tag, which has the following data structure: Part IV - Oracle XML for C Developers

<protocolconfig> <common> ... </common> Chapter 19 - Building an XML-Managed Application <httpconfig> ... </httpconfig> Chapter 20 - Build... an XML Database OCI Application <ftpconfig> </ftpconfig> Chapter 21 Create an XML-Configured High-Performance Transformation Engine </protocolconfig> Chapter 18 - Getting Started with Oracle XML and C

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

The <common> stores theOCI parameters that apply to all protocols, such as MIME type information. The Chapter 23 - Build element an XML Database C++ Application HTTP- 24 and- Building FTP-specific parameters are stored under the sections <httpconfig> and <ftpconfig>,respectively. Chapter an XML Data-Retrieval Application TheVI <httpconfig> contains the <webappconfig> element for web-based application configurations, Part - Oracle XMLsection for PL/SQL Developers including icon name andwith display name the applications, and a list of servlets in Oracle XML DB. Chapter 25the - Getting Started Oracle XMLfor and PL/SQL Chapter 26 - Building PL/SQL Web Services

Configuring xdbconfig.xml

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

In SQL*Plus, youStandards can use DBMS_XMLDB.CFG_GET() to retrieve the current content of xdbconfig.xmlas follows: Appendix - XML Bodies and Open Specifications Glossary VAR out CLOB

SET AUTOPRINT ON Index ListBEGIN of Figures

:= DBMS_XDB.CFG_GET().GETCLOBVAL(); List:out of Tables END; List of Sidebars Note To be able to see the content, you need to run SET LONG 100000 to increase the size of the display buffer for SQL*Plus. The DBMS_XDB.CFG_GET() function returns a copy of the xdbconfig.xmlconfiguration as an XMLType and it automatically commits after each execution: DBMS_XDB.CFG_GET() RETURN SYS.XMLTYPE


If you have many parameters to update in the xdbconfig.xmlfile, you can use the DBMS_ XDB.CFG_UPDATE() function. It replaces the content of the xdbconfig.xmlfile with the content in the input XMLType: DBMS_XDB.CFG_UPDATE(newconfig Oracle Database 10g XMLSYS.XMLTYPE) & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

After the configuration you need to call the DBMS_XDB.CFG_ REFRESH() function to ISBN:0072229527 by Mark parameters V. Scardina, are Benupdated, Chang and Jinyu Wang make sure the McGraw-Hill/Osborne Oracle XML DB picks© up the new updated configuration: 2004 (600 pages) DBMS_XDB.CFG_REFRESH(); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

For example, if you need to configure the port numbers for Oracle XML DB HTTP and FTP servers to use other than the default values (HTTP: 8080, FTP: 2100), you can follow these steps: Table of Contents 1. Database Log in to10g a SQL*Plus session andBuild connect as theXML XDB user (assuming theC,password for XDB user is Oracle XML & SQL—Design, & Manage Applications in Java, C++ & PL/SQL xdbpw): Introduction Part I - Oracle and thexdb/xdbpw XML Standards > sqlplus

Chapter 1

- Introducing XML

2. Call update HTTP port: Chapter 2 - DBMS_XDB.CFG_UPDATE() Accessing XML with DOM, SAX, to JAXB, and the StAX Chapter 3 DECLARE - Transforming XML with XSLT and XPath

XMLType; Chapter config 4 - Validating XML with DTDs and XML Schemas Chapter BEGIN 5 - XML Operations with XQuery

:= DBMS_XDB.CFG_GET(); Chapter config 6 - XML Messaging and RPC with SOAP UPDATEXML(config, Chapter SELECT 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL '/xdbconfig/sysconfig/protocolconfig/httpconfig/http-port/text()', Part II - Oracle XML Management for DBAs Chapter 8081, 8 - Getting Started with the Oracle XML Database

'/xdbconfig/sysconfig/protocolconfig/ftpconfig/ftp-port/text()', - Storing XML Data 2121) into config Chapter 10 - Generating and Retrieving XML FROM DUAL; Chapter 11 - Searching XML Data DBMS_XDB.CFG_UPDATE(config); Chapter 12 - Managing the Oracle XML Database END; Chapter 9

Part III - Oracle XML for Java Developers

Chapter 13 - DBMS_XDB.CFG_REFRESH() Getting Started with Oracle XML and Java the Oracle XML DB picks up the new settings: 3. Call to ensure Chapter 14 - Building an XML-Powered Web Site

SQL> EXEC DBMS_XDB.CFG_REFRESH();

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 4. To 17 -check Developing the HTTP XML-Based and FTP Reusable port numbers, Components you can use the following SQL query: Part IV - Oracle XML for C Developers SELECT

Chapter 18 - Getting Started with Oracle XML and C EXTRACTVALUE(DBMS_XDB.CFG_GET(), Chapter 19 - Building an XML-Managed Application '/xdbconfig/sysconfig/protocolconfig/httpconfig/http-port/text()') Chapter AS 20 -httpport, Build an XML Database OCI Application Chapter EXTRACTVALUE(DBMS_XDB.CFG_GET(), 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle '/xdbconfig/sysconfig/protocolconfig/ftpconfig/ftp-port/text()') XML for C++ Developers

Chapter AS 22 -ftpport Getting Started with Oracle XML and C++

dual; Chapter FROM 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Normally, you just need to update the content in the configuration file. However, sometimes you need to insert a new element into this file. For example, if you want the Oracle XML DB Repository to properly handle Scalar Vector Chapter 26 - Building PL/SQL Web Services Graphics (SVG) files, you need to add a new MIME entry in xdbconfig.xml,as follows: Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 27 - Extending PL/SQL XML Functionality with Java

<mime-mapping xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"> Appendix - XML Standards Bodies and Open Specifications <extension>svg</extension> Glossary <mime-type>image/svg+xml</mime-type> Index </mime-mapping> Chapter 28 - Putting It All Together

List of Figures List of Tables

List of Sidebars Since the current UPDATEXML() function does not append new XML child elements, you need to update the

content of <mime-mappings>,which includes all the MIME mapping definitions. In such cases, using the DOM API in PL/SQL provides efficient XML updates: CREATE OR REPLACE PROCEDURE AddNewElement(p_xpath IN VARCHAR2, p_content IN VARCHAR2, p_namespace IN VARCHAR2) AS v_config XMLType; v_mimemap XMLType; v_doc DBMS_XMLDOM.DOMDocument;


v_doc_elem dbms_xmldom.DOMElement; v_xsl DBMS_XSLPROCESSOR.Processor; v_subdoc dbms_xmldom.DOMDocument; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & v_subdoc_elem dbms_xmldom.DOMElement; PL/SQL v_node dbms_xmldom.DOMNode; ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang v_impnode dbms_xmldom.DOMNode; McGraw-Hill/Osborne © 2004 (600 pages) BEGIN This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with v_mimemap := XMLType.createXML(p_content); emphasis on XML standards, their usage and best practices. v_config := DBMS_XDB.CFG_GET(); v_doc := DBMS_XMLDOM.newDOMDocument(v_config); Table of Contents v_doc_elem := DBMS_XMLDOM.getDocumentElement(v_doc); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL v_node := DBMS_XSLPROCESSOR.selectSingleNode(DBMS_XMLDOM.makeNode(v_doc), Introduction p_xpath, p_namespace); Part I - Oracle and the XML Standards v_subdoc :=DBMS_XMLDOM.newDOMDocument(v_mimemap); Chapter 1 - Introducing XML v_subdoc_elem := DBMS_XMLDOM.getDocumentElement(v_subdoc); Chapter 2 Accessing XML with DOM, SAX, JAXB, and StAX v_impnode := DBMS_XMLDOM.importNode(v_doc, Chapter 3 - Transforming XML with XSLT and XPath true); DBMS_XMLDOM.makeNode(v_subdoc_elem), Chapter 4 := - Validating XML with DTDs and XML Schemas v_impnode); v_node DBMS_XMLDOM.appendChild(v_node, Chapter 5 - XML Operations with XQuery DBMS_XDB.CFG_UPDATE(v_config); Chapter END; 6 - XML Messaging and RPC with SOAP / Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Using this procedure, we can add a new MIME mapping for SVG files: Chapter 9 - Storing XML Data BEGIN Chapter 10 - Generating and Retrieving XML AddNewElement( Chapter 11 - Searching XML Data '/xdbconfig/sysconfig/protocolconfig/common/extension-mappings/ Chapter 12 - Managing the Oracle XML Database mime-mappings', '<mime-mapping Part III - Oracle XML for Java Developers

xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"> <extension>svgjinyu</extension> Chapter 13 - Getting Started with Oracle XML and Java <mime-type>image/svg+xml</mime-type></mime-mapping>', Chapter 14 - Building an XML-Powered Web Site 'xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"'); Chapter 15 - Creating a Portal Site with XML and Web Services END; Chapter 16 - Developing an XML Gateway Application with SOAP and AQ / Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Security Management PL/SQL

ISBN:0072229527 Mark V. 10g, Scardina, Benshould Chang be andset Jinyu Wang In Oracle XML by Database security up to protect against unauthorized access of data and any XML © 2004 (600 operations. pages) processes thatMcGraw-Hill/Osborne could affect database system

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Protecting Data in the Oracle XML DB Repository

Table Contents The of security for the Oracle XML DB resources is based on an ACL, which is a standard security mechanism used in Oracle Java, Database Windows10g NT,XML and&other SQL—Design, systems. Build The ACL & Manage maintains XML a Applications list of objectlevel in Java,restrictions C, C++ & PL/SQL on database users or

roles to access the resources in the Oracle XML DB Repository hierarchy. Introduction Part I - Oracle and the XML Standards

Before a user performs an operation or method on a resource, a check of privileges for the user on the resource - Introducing XML takes place. The set of privileges checked depends on the operation or method performed. For example, to update Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX the Oracle XML DB configurations, READ and WRITE privileges are needed for the xdbconfig.xmlresource. Chapter 1 Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4 - Validating XMLby with XML Schemas Data access is controlled theDTDs ACLand document that specifies the database users, roles, and groups who are able to Chapter - XMLresources. OperationsThe withdefault XQueryACL includes the following: access5certain Chapter 6

- XML Messaging and RPC with SOAP

all_all_acl.xml Grants all privileges to all users JSPs, and XSQL Chapter 7 - Putting It All Together with XML Pipeline, Part II - Oracle XML Management for DBAs

all_owner_acl.xml Grants all privileges to owner/creator user

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 - Storing Grants XML Data ro_all_acl.xml read privileges to all users Chapter 10 - Generating and Retrieving XML

The DBMS_XDBZ PL/SQL package provides the APIs to check and update the ACL in the Oracle XML DB Chapter 11 - Searching XML Data Repository. The following example shows how you can create a user group and set up the ACL for the group to Chapter 12 - Managing the Oracle XML Database access Oracle DB Repository. Part III -the Oracle XMLXML for Java Developers The access privilege for each principal, who can be a user or a role, is stored in access control entries (ACEs) in the ACL:

Chapter 13 - Getting Started with Oracle XML and Java

CREATE USER1 IDENTIFIED USER1; Chapter 14 -USER Building an XML-Powered WebBY Site GRANT 15 CONNECT, Chapter - Creating RESOURCE a Portal Site TO withUSER1; XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

CREATE USER USER2 IDENTIFIED BY USER2; GRANT CONNECT, RESOURCE TO USER2; Part IV - Oracle XML for C Developers

Chapter 17 - Developing XML-Based Reusable Components Chapter 18 - Getting Started with Oracle XML and C

CREATE ROLE DEMOGROUP NOT IDENTIFIED; GRANT CONNECT, RESOURCE to DEMOGROUP;

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

GRANT DEMOGROUP to USER1; GRANT DEMOGROUP to USER2;

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter By default, 24 - all Building file and andirectory XML Data-Retrieval resources created Application by a user are accessible to all database users. To limit these Part users VI to - Oracle the group, XML for DEMOGROUP, PL/SQL Developers you first need to create a new ACL resource file and store it in the Oracle XML

DB Repository as the file /sys/acls/all_demogroup_ Chapter 25 - Getting Started with Oracle XML and PL/SQLacl.xml. The file looks like the following: Chapter - Building PL/SQL Web Services privileges to OWNER only" <acl 26 description="Private:All Chapter 27 - Extending PL/SQL XML Functionality with Java xmlns="http://xmlns.oracle.com/xdb/acl.xsd" Chapter xmlns:dav="DAV:" 28 - Putting It All Together

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Appendix - XML Standards Bodies and Open Specifications xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd Glossary http://xmlns.oracle.com/xdb/acl.xsd"> <ace> List of Figures List of<principal>DEMOGROUP</principal> Tables <grant>true</grant> List of Sidebars <privilege> <all/> </privilege> </ace> </acl> Index

The preceding ACL specifies grants of all privileges to the owner of the document using the ACE elements. Each ACE element specifies access privileges for a given principal using values set for the elements described in Table


12-3. Table 12-3: Access Entry OracleControl Database 10gDefinitions XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Element

PL/SQL

Description

<principal>

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) Specifies the principal (user or group).

<grant>

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Boolean value that specifies whether the emphasis on XML standards, their usage and A best practices.

ISBN:0072229527

principal has been granted access to the resource. A value of true specifies that the access is Table of Contents granted. A value of false specifies that access is Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL denied. Introduction

<privilege> Part I - Oracle and the XML Standards Chapter 1

Specifies the privileges granted to the principal.

- Introducing XML

To have resources work with, youJAXB, can connect as USER1 and create a folder in the Oracle XML DB Chapter 2 some - Accessing XMLto with DOM, SAX, and StAX Repository User1: Chapter 3 - for Transforming XML with XSLT and XPath DECLARE Chapter 4 - Validating XML with DTDs and XML Schemas retval Chapter 5 BOOLEAN; - XML Operations with XQuery BEGIN 6 Chapter

- XML Messaging and RPC with SOAP

retval DBMS_XDB.createfolder('/public/folder1'); Chapter 7 := - Putting It All Together with XML Pipeline, JSPs, and XSQL retval := DBMS_XDB.createResource('/public/folder1/doc1.xml', Part II - Oracle XML Management for DBAs

XML

Type('<xml1/>')); Chapter 8 - Getting Started with the Oracle XML Database END; / - Storing XML Data

Chapter 9

Chapter 10 - Generating and Retrieving XML

To confirm that User1 and User2 can currently view this resource, either use your FTP client to see the

Chapter 11 - Searching XMLorData /public/folder1 directory execute the following query while connected as each user: Chapter 12 - Managing the Oracle XML Database

SELECT count(*) from RESOURCE_VIEW;

Part III - Oracle XML for Java Developers

Chapter 13can - Getting Started Oracleresources XML and Java Now you restrict accesswith to these by changing the ACL file to all_all_acl.xml by executing the Chapter 14command: - Building an XML-Powered Web Site following Chapter 15 - Creating a Portal Site with XML and Web Services

BEGIN

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ DBMS_XDB.SetACL('/public/folder1', Chapter 17 - Developing XML-Based Reusable Components '/sys/acls/all_all_acl.xml'); Part IV - Oracle XML for C Developers COMMIT;

Chapter END; 18 / - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

Once again check an for XML-Configured resource accessHigh-Performance and count and you will see that User2 Chapter 21 - Create Transformation Engine has fewer resources and no access to /public/folder1. If role/group ownership is in effect, both users could have the same number of accessible Part V - Oracle XML for C++ Developers resources. canStarted do this with by switching theand ACL file again to all_demogroup_acl.xmlby executing the following Chapter 22 - You Getting Oracle XML C++ connected SYS: Chapter 23 - as Build an XML Database OCI C++ Application BEGIN Chapter 24 - Building an XML Data-Retrieval Application DBMS_XDB.SetACL('/public/folder1', Part VI - Oracle XML for PL/SQL Developers '/sys/acls/all_demogroup_acl.xml'); Chapter 25 - Getting Started with Oracle XML and PL/SQL COMMIT; Chapter 26 - Building PL/SQL Web Services END; 27 - Extending PL/SQL XML Functionality with Java Chapter /

Chapter 28 - Putting It All Together Appendix

XML Standards Bodies and Open Specifications Using the -same query, USER1 and USER2 now have the same number of accessible resources:

Glossary

SELECT count(*) from RESOURCE_VIEW;

Index

List of Figures List of Tables Each DBMS_XDB security management method takes a path (resource_path, abspath, or acl_path) as a parameter. List ofcan Sidebars You then use any or all of the following DBMS_XDB methods to perform security management tasks:

getAclDocument() ACLCheckPrivileges() checkPrivileges() getPrivileges()


changePrivileges() setACL()

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

Oracle XML DBPL/SQL ACLs are cached for very fast evaluation. When a transaction that modifies an ACL is committed, ISBN:0072229527 by Mark V. Scardina, Chang and Jinyu Wang the modified ACL is picked up after Ben the time-out specified in the Oracle XML DB configuration file. The XPath for this McGraw-Hill/Osborne © 2004 (600 pages) configuration parameter is /xdbconfig/sysconfig/ acl-max-age. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Securing DBUri Operations

Table of servlet Contents DBUri security is handled by Oracle Database 10g by using roles. When users log in to the servlet, they use Oracle Database username 10g XML & and SQL—Design, Manage Applications in Java, C++ & PL/SQL their database password.Build The &servlet willXML check to make sure the C, user logging in belongs to one of Introduction the roles specified in the configuration file. The roles that are allowed to access the servlet are specified in the Part I - Oracle and tag. the XML Standards security-role-ref By default, the servlet is available to the special role authenticatedUser. Any user with a valid

Chapter 1 username - Introducing database andXML password belongs to this role and thus can use the servlet. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

The parameter updated inXML thewith following Chapter 3 - Transforming XSLT example and XPathrestricting the list of authenticated users can be changed to restrict access to any role(s) in the database. To change from the default authenticated-user role to a role that you have Chapter 4 - Validating XML with DTDs and XML Schemas created, for example, servlet-users, run the following connected as a user with XDBADMIN role: Chapter 5 - XML Operations with XQuery DECLARE Chapter 6 - XML Messaging and RPC with SOAP doc XMLType; Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL doc2 Part II -XMLType; Oracle XML Management for DBAs doc3 XMLType; Chapter 8 - Getting Started with the Oracle XML Database BEGIN - Storing XML Data doc := dbms_xdb.cfg_get(); Chapter 10 - Generating and Retrieving XML select updateXML(doc, '/xdbconfig/sysconfig/protocolconfig/httpconfig/webappconfig Chapter 11 - Searching XML Data /servletconfig/servlet-list/servlet[servlet-name="DBUriServlet"] Chapter 12 - Managing the Oracle XML Database /security-role-ref/role-name/text()', 'servlet-users') into doc2 Part III - Oracle XML for Java Developers from dual; Chapter 13 - Getting Started with Oracle XML and Java select updateXML(doc2, '/xdbconfig/sysconfig/protocolconfig/httpconfig/webappconfig Chapter 14 - Building an XML-Powered Web Site /servletconfig/servlet-list/servlet[servlet-name="DBUriServlet"] Chapter 15 - Creating a Portal Site with XML and Web Services /security-role-ref/role-link/text()', 'servlet-users') into doc3 Chapter 16 - Developing an XML Gateway Application with SOAP and AQ from dual; Chapter 17 - Developing XML-Based Reusable Components DBMS_XDB.CFG_UPDATE(doc3); Part IV - Oracle XML for C Developers COMMIT; Chapter END; 18 - Getting Started with Oracle XML and C Chapter / 19 - Building an XML-Managed Application Chapter 9

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 V. Scardina, Bencan Chang and Jinyu Wang XML DB to ensure the proper functionality In this chapter,by weMark discussed how you manage the Oracle and McGraw-Hill/Osborne © 2004In(600 security protection for stored resources. thepages) samples, we also provided the utility package that simplifies update operations to the xdbconfig.xml to manage resources. This comprehensivefile guide focuses these on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Part III: Oracle Oracle XML for Java Developers PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Chapter List

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Chapter 13: Getting Started with Oracle XML and Java

Table of Contents

OracleChapter Database XML &an SQL—Design, Build & Manage 14:10g Building XML-Powered Web Site XML Applications in Java, C, C++ & PL/SQL Introduction

Portal Site with XML and Web Services Part IChapter - Oracle 15: andCreating the XML aStandards Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 16: Developing an XML Gateway Application with SOAP and AQ

Chapter 3 - Transforming XMLXML-Based with XSLT and XPath Components Chapter 17: Developing Reusable Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 13:Database Getting Started with Oracle XML and Java PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

The previous chapters introduced the overall XML functionality provided by the Oracle XDK and Oracle Database McGraw-Hill/Osborne © 2004 (600 pages) 10g. Over the next several chapters, you will learn how to actually develop applications in Java with these products This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with by exploring sample applications derived from actual Oracle customer use cases. To get the greatest benefit from emphasis on XML standards, their usage and best practices. the following chapters, you need to be familiar with the Oracle XDK Java libraries, the JDK environment (both within and without the database), and how to use the XDK with Oracle JDeveloper 10g. This chapter provides a general Table of Contents overview of these topics. This chapter supplements the Getting_Started_Java.html documentation provided with Oracle Database XMLthe & SQL—Design, Build & Manage XML Applications Java, C,distribution C++ & PL/SQL the Oracle XDK10g within $XDK_HOME\xdk\doc\java directory either ininthe OTN or in the Oracle XML Introduction Application Developer’s Guide included with the Oracle Database 10g release. Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML The Oracle XDK Java Libraries

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 you - Transforming XMLthe with XSLTXDK and XPath Although learned about Oracle functionality in the previous chapters, you may not know where all the Chapter 4 - Validating withbecause DTDs and Schemas XDK components are XML stored, theXML XDK is packaged within a set of JAR files that combine functions. The Chapter XDK components 5 - XML Operations are delivered with in XQuery the \lib directory of the OTN distribution and the ORACLE_HOME\lib directory.

There is6 an additional JAR and called orai18n.jar Chapter - XML Messaging RPC with SOAP in the corresponding ORACLE_HOME\jlib directories. The following is a functional description each. with XML Pipeline, JSPs, and XSQL Chapter 7 - Putting It All of Together Part II - Oracle XML Management for DBAs

- Getting Started with the Oracle XML Database xmlparserv2.jar

Chapter 8 Chapter 9

- Storing XML Data

Thexmlparserv2.jar is and much more than its name implies, though it started life in Oracle8i as simply the DOM and Chapter 10 - Generating Retrieving XML SAX interfaces. In Oracle Chapter 11 - Searching XML XDK Data 10g, this library contains those classes as well as the XML Schema processor classes, Processor classes, XML compression classes, JAXP classes, W3C interfaces for DOM and SAX, Chapter 12XSLT - Managing the Oracle XML Database andIII utility functionality the XMLSAXSerializer and asynchronous DOM Builder. Part - Oracle XML forsuch Java as Developers Chapter 13 - Getting Started with Oracle XML and Java

xml.jar

Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

Thexml.jar is a new library for Oracle XDK 10g andwith is anSOAP attempt Chapter 16 - Developing an XML Gateway Application and to AQconsolidate a number of JARs. It includes all the classes from oraclexsql.jar, xsqlserializers.jar, xmlcomp.jar, xmlcomp2.jar, and transx.zip,as well as the Chapter 17 - Developing XML-Based Reusable Components newIV JAXB andXML Pipeline classes. This greatly simplifies your CLASSPATH. You might wonder why Part - Oracle for CProcessor Developers xmlparserv2.jar is Started not included as well. The answer is that this JAR has been around since the start and has so Chapter 18 - Getting with Oracle XML and C many products depending on it that it would be too great a risk to existing code to collapse it.

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application

xschema.jar

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Although XML Schema classes areXML already contained in the xmlparserv2.jar, the xschema.jaris still included Chapter 22 the - Getting Started with Oracle and C++ for backward compatibility reasons. In previous versions, these classes have resided in this JAR; however, it will eventually disappear. Therefore, you should ignore this JAR for all new development.

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

oraclexsql.jar and xsqlserializers.jar

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Theoraclexsql.jar contains most of the XSQL Servlet classes needed to deploy XSQL pages. If, however, you want to create serialized output, such as PDFs, you need the xsqlserializers.jar because it contains these Chapter 28 - Putting It All Together serializer classes. Both of these JARs have been superceded by the xml.jarand are only included for backward Appendix - XML Standards Bodies and Open Specifications compatibility. You should not continue to use them in new development. Chapter 27 - Extending PL/SQL XML Functionality with Java

Glossary Index

xmlcomp.jar, xmlcomp2.jar, xmldemo.jar, and jdev-rt.zip

List of Figures List of Tables

Thexmlcomp.jar contains the XML JavaBeans that do not depend on the database, while the xmlcomp2.jar contains the JavaBeans that do, and thus depends on xdb.jar, which is the library that includes the Java classes that support the XML DB functionality. These JARs are included only for backward compatibility, because their classes are now included in xml.jar.

List of Sidebars

Thexmlcomp.jar contains the DOMBuilder, XSLTransformer, DBAccess, XSDValidator, and XMLDiffer Beans, while the xmlcomp2.jarcontains only the XMLDBAccess and XMLCompress Beans. You will not find future XML JavaBeans in these JARs, so you should not use them for new development. You also won’t find the visual Beans that were in previous releases. The XMLTreeView, XMLTransformPanel, XMLSourceView, and DBViewer Beans are now considered demos and are included in the xmldemo.jar.Thejdev-rt.zipis used when working with the demos


within the JDeveloper IDE.

xsu12.jar Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 by Mark the V. Scardina, Ben implement Chang and the Jinyu Wang Thexsu12.jarcontains classes that XML SQL Utility’s Java functionality. These classes also McGraw-Hill/Osborne © 2004 (600 pages) have a dependency on the xdb.jarfor XMLType access.

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

classgen.jar

Table of Contents contains the Class Generator for Java classes. In Oracle XDK 10g, only the run-time classes are Theclassgen.jar Oracle included, Database as the10g JAXB XMLClass & SQL—Design, Generator Build included & Manage in xml.jar XMLhas Applications superceded in Java, theirC, functionality. C++ & PL/SQL Only Oracle9i

applications that cannot be rewritten should continue to use this JAR. Introduction Part I - Oracle and the XML Standards

xdb.jar- Introducing XML

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter Thexdb.jar 3 - Transforming contains the classes XML withthat XSLT areand needed XPathby xml.jarand xmlcom2.jarto access XMLTypes. It also

includes SPI and XDBServlet classes to access the XML DB Repository, and the XMLType DOM classes for Chapter 4 the - Validating XML with DTDs and XML Schemas direct manipulation of the XMLType DOM tree. Note that this is not as complete a DOM implementation as in Chapter 5 - XML Operations with XQuery xmlparserv2.jar and thus will bewith covered Chapter 6 - XML Messaging andnot RPC SOAPin this book. Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

xmlmesg.jar

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Thexmlmesg.jar is only necessary for development that requires non-U.S. English error messages that are Chapter 9 - Storing XML Data available by default in all theRetrieving other JARs. Chapter 10 - Generating and XMLThis JAR contains 27 additional translations and can simply be added to your CLASSPATH. The selected language will be based on your Java Locale setting. Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

transx.zip

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

Thetransx.zip archive the TransX Utility classes. This archive has been supplanted by xml.jar and is Chapter 14 - Building an contains XML-Powered Web Site retained15only for backward New Chapter - Creating a Portalcompatibility. Site with XML anddevelopment Web Servicesshould use the classes from xml.jar. Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

orai18n.jar

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Theorai18n.jar contains thewith Oracle National Language Supported (NLS) character set encodings. Distinct from the Chapter 18 - Getting Started Oracle XML and C previous it resides in the XDK_HOME/xdk/jlib directory for OTN distributions and ORACLE_HOME/jlib for Chapter 19JARs, - Building an XML-Managed Application Oracle 20 Database 10g. You will need it to support the normalization functions in XPath and on XSLT output for the Chapter - Build an XML Database OCI Application proper collations.

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

classes12.jar and ojdbc14.jar

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

Theclasses12.jar are theApplication Oracle JDBC drivers for Java 1.2/1.3 and 1.4, respectively. These JARs Chapter 24 - Buildingand an ojdbc14.jar XML Data-Retrieval alsoVIdepend upon their character set support when additional character sets beyond UTF-8, Part - Oracle XMLorai18n.jar for PL/SQLfor Developers

ISO8859-1, and JA16SJIS are required. These JARs are not part of the XDK distribution on OTN but are in the ORACLE_HOME\jdbc\lib directory of the database.

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending XML Functionality with Java XDK classes so that you can understand which ones are Figure 13-1 illustrates PL/SQL the dependencies between these Chapter 28when - Putting It All Together required in your CLASSPATH. Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars

Figure 13-1: XDK library dependencies


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & The JDK Environment PL/SQL

by supports Mark V. Scardina, Bensupported Chang andJDK Jinyu Wang The Oracle XDK all currently and JRE versions at the time of this writing— JDKISBN:0072229527 1.2, 1.3, McGraw-Hill/Osborne 2004 (600 and 1.4 and their associated JREs. ©Oracle 10gpages) products, including the database, application server, and XDK, no longer support This JDKcomprehensive 1.1 because ofguide Sun’sfocuses de-support of thatXML version. This can also be said for the JDBC products, drivers, aswith on utilizing technologies within Oracle's XML-enabled on XML standards, their usage andJVM best is practices. the 1.1 versionemphasis is no longer supplied. The Oracle JServer its own special implementation and has unique requirements that were discussed in Chapter 8. Table of Contents

Setting Up the JDK Environment

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

There is nothing about setting up your Java environment for developing with the Oracle XDK and Oracle Part I - Oracle andspecial the XML Standards Database You should Chapter 1 -10g. Introducing XMLnote that when installing an Oracle Home, no changes are made to your CLASSPATH settings2 even though significant JavaSAX, functionality is being Chapter - Accessing XML with DOM, JAXB, and StAX used. This is because Oracle Java applications are invoked3 with their required CLASSPATHs the command line or in a script. Chapter - Transforming XML with XSLT andon XPath Chapter 4

- Validating XML with DTDs and XML Schemas

While the Oracle database requires you to manually set the CLASSPATH, the OTN XDK distribution supplies an XML Operations with XQuery env.bat file-on Windows and an env.csh file on UNIX to automate the setup of your environment and serve as a Chapter 6 Messaging and RPC with template forXML customizations. These files SOAP need certain variables set in order to create a working environment. Tables Chapter 7 Putting It All Together with XML Pipeline,and JSPs, and respectively, XSQL 13-1 and 13-2 provide the definitions on Windows UNIX, for the various JDK versions. Chapter 5

Part II - Oracle XML Management for DBAs

Chapter 8 - Getting Started the Oracle XML Database Table 13-1: Windows XDKwith Environment Variables for env.bat Chapter 9

- Storing XML Data

Variable Chapter 10 - Name Generating andValues Retrieving XML

Customize

Chapter 11 - Searching XML Installation Data %INSTALL_ROOT% root of XDK, which is the directory we refer to as

NO

Chapter 12 - Managing the Oracle XML Database %XDK_HOME%. Part III - Oracle XML for Java Developers

%JAVA_HOME% where Chapter 13 - Getting StartedDirectory with Oracle XMLthe andJava Java SDK, Standard Edition is

YES

installed. Web Site Chapter 14 - Building an XML-Powered Path linked to the Java SDK needs to be modified. Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ %CLASSPATHJ% For 1.2 and 1.3:

YES

Chapter 17 - Developing XML-Based Reusable Components CLASSPATHJ=%ORACLE_HOME%\jdbc\lib\classes12.jar; Part IV - Oracle XML for C Developers %ORACLE_HOME%\jdbc\lib\orai18n.jar

Chapter 18 - Getting StartedFor with1.2 Oracle and 1.3: XML and C

CLASSPATHJ=%ORACLE_HOME%\jdbc\lib\ojdbc14.jar; Chapter 19 - Building an XML-Managed Application %ORACLE_HOME%\jdbc\lib\orai18n.jar Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

%PATH%

PATH=%JAVA_HOME%\bin;%ORACLE_HOME%\bin; %PATH%;%INSTALL_ROOT%\bin

Part V - Oracle XML for C++ Developers

NO

Chapter 22 - Getting Started with Oracle XML and C++

%CLASSPATH% %CLASSPATHJ%;%INSTALL_ROOT%\lib\xmlparserv2.jar; Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML%INSTALL_ROOT%\lib\xsu12.jar; Data-Retrieval Application %INSTALL_ROOT%\lib\xml.jar; Part VI - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Table 13-2: UNIX XDK Environment Variables forJava env.csh Chapter 27 - Extending PL/SQL XML Functionality with Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars

NO


Variable Name

Values

Customize

$INSTALL_ROOT Installation root&ofSQL: XDK,Design, which isBuild the directory weXML referApplications to NO in Java, C, C++ & Oracle Database 10g XML & Manage PL/SQL as $XDK_HOME. by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

$JAVA_HOME Directory where the Java SDK, Standard Edition is YES McGraw-Hill/Osborne © 2004 (600 pages) installed. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Pathstandards, linked to the Java SDK needs to be modified. emphasis on XML their usage and best practices. $CLASSPATHJ

For 1.2 and 1.3: YES CLASSPATHJ=${ORACLE_HOME}\jdbc\lib\classes12.jar; ${ORACLE_HOME}\jdbc\lib\orai18n.jar Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL For 1.2 and 1.3: Introduction CLASSPATHJ=${ORACLE_HOME}\jdbc\lib\ojdbc14.jar; Part I - Oracle and the XML Standards Chapter 1 - Introducing XML${ORACLE_HOME}\jdbc\lib\orai18n.jar

Table of Contents

Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX $PATH PATH=$JAVA_HOME\bin; Chapter 3

- Transforming XML with XSLT and XPath $PATH;${INSTALL_ROOT}\bin

Chapter 4

- Validating XML with DTDs and XML Schemas

NO

$CLASSPATH .;$CLASSPATHJ;${INSTALL_ROOT}\lib\xmlparserv2.jar; - XML Operations with XQuery ${INSTALL_ROOT}\lib\xsu12.jar; Chapter 6 - XML Messaging and RPC with SOAP ${INSTALL_ROOT}\lib\xml.jar;

NO

Part II - Oracle XML Management for DBAs $LD_LIBRARY_PATH For OCI JDBC connections:

NO

Chapter 5 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 8

- Getting Started with ${ORACLE_HOME}/lib:${LD_ the Oracle XML Database

Chapter 9

LIBRARY_PATH} - Storing XML Data

Chapter 10 - Generating and Retrieving XML

Usingenv.bat as an example, Chapter 11 - Searching XML Dataif you have %JAVA_HOME% and %ORACLE_HOME% set up in your environment and you12use JDK 1.4,the which is suggested for use with Oracle XDK 10g, you can simply go to the Chapter - Managing Oracle XML Database %XDK_HOME%/bin directory and run env.bat. The batch file will set the PATH environment variable so that you Part III - Oracle XML for Java Developers can run13 the command-line provided along with the XDK. Additionally, the batch file sets the Java Chapter - Getting Started executables with Oracle XML and Java CLASSPATH variable, which includes ojdbc14.jar, orai18n.jar,xmlparserv2.jar,xml.jar,xmlmesg.jar,xsu12.jar, Chapter 14 - Building an XML-Powered Web Site and oraclexsql.jar.

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML JDeveloper & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Using theOracle XDKDatabase with Oracle PL/SQL

ISBN:0072229527 by Mark Scardina, Chang and Jinyu Wang Oracle JDeveloper hasV. added moreBen XML functionality with each release. At the time of this writing, Oracle McGraw-Hill/Osborne © 2004so (600 pages) JDeveloper 10g has just been released, this section is current to that version. Every version has included the Oracle XDK’s Java libraries, and each them integrated. Regardless of the version you are with This comprehensive guideversion focuseshas on seen utilizing XMLbetter technologies within Oracle's XML-enabled products, emphasis XML standards, their usage andspecifically best practices. using, the content in thison section will be applicable unless stated otherwise.

Setting Up an XDK Environment

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Each Java project in JDeveloper has a set of properties that can be accessed by right-clicking the project filename in Introduction the INavigator and selecting Part - Oracle window and the XML StandardsProject Properties. Project files are identified by a .jpr extension. Select Libraries display the dialog Chapter 1 to - Introducing XML box shown in Figure 13-2. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

Figure 13-2: Selecting your project properties’ libraries

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Components Since Oracle JDeveloper includes Reusable the Oracle XDK’s Java libraries, you already have entries for them. Should you Part Oracle XMLversions, for C Developers wishIVto- add newer you can easily add them by clicking New orEditand defining a different library name

Chapter 18 - Getting with Oracle XML the and path C from existing ones. Started While you will not have to the source code, you can download the Javadocs for the Chapter 19 - Building XML-Managed newer libraries from an OTN and provideApplication their path for easy use within the IDE. Chapter 20 - Build an XML Database OCI Application

The other of the dialog box is to indicate what libraries areEngine missing when compiling or deploying a Chapter 21 -use Create anLibraries XML-Configured High-Performance Transformation project. This isXML especially for imported projects. Missing libraries will be indicated in red and you can resolve Part V - Oracle for C++true Developers them simply by either adding a new oneXML or editing it so that it refers to the local library. Chapter 22 - Getting Started with Oracle and C++ Chapter 23 - Build an XML Database OCI C++ Application

Setting Up a Database Connection

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

JDeveloper has theStarted functionality to connect to aPL/SQL database for run-time access; however, this connection must be Chapter 25 - Getting with Oracle XML and configured can use it. Access to this configuration is not intuitive, so the following are the Chapter 26 - globally Buildingbefore PL/SQLyou Web Services

instructions. However, before you start you should have a database instance running and the user ID, password, and optionally the role you want to use to connect.

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

Standards Bodies and Open Specifications Types of- XML JDBC Drivers

Glossary

Index One additional important preparation step is to ensure that JDeveloper knows about the Oracle Database 10g JDBC List of Figures drivers. This is important because, starting in this release, the naming convention has changed. JDeveloper comes List configured of Tablesfor version 9 JDBC drivers, which, while they will work against Oracle Database 10g, will have poorer

performance List of Sidebarsand will not have support for all the features. The following sections describe the JDBC drivers included in your ORACLE_HOME/jdbc/lib directory along with their dependencies and purpose. JDBC Thin Driver 10.1.0.2.0 This is a 100 percent Java driver designed for client applications, midtier servers, and applets. It is contained within classes12.jar for use with JDK 1.2 and 1.3 and contained within ojdbc14.jar for use with 1.4. If you require complete NLS support for objects and collection types, you also need orai18n.jar. This driver will not support XMLType on the client. The connection string is


Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@<database>", "my_user", "my_password"); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

where <database> is either a string of the form host:port:sid, a SQL*NET name-value pair, or a serviceISBN:0072229527 name. by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) JDBC OCI Driver 10.1.0.2.0

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their and best practices. This is the “thick” Java driver that utilizes OCI tousage provide client-side full datatype support, including XMLType. It is contained within classes12.jar for use with JDK 1.2 and 1.3 and contained within ojdbc14.jar for use with 1.4. If you require complete NLS support for objects and collection types, you also need orai18n.jar. On Windows, you Table of Contents also need to have in your PATH to locate the needed C libraries. connection string is Oracle Database 10gORACLE_HOME\bin XML & SQL—Design, Build & Manage XML Applications in Java, C, C++The & PL/SQL

Connection conn = DriverManager.getConnection( Introduction "jdbc:oracle:oci:@<database>", Part I - Oracle and the XML Standards "my_user", "my_password");

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

where <database> is either an entry in tnsnames.ora or a SQL*NET name-value pair.

Chapter 4 - Validating XML with DTDs10.1.0.2.0 and XML Schemas JDBC Server-Side Internal Driver Chapter 5

- XML Operations with XQuery

This is 6the-internal JDBC driver thatwith runsSOAP in the OJVM in the database. It is also known as the kprb JDBC driver. All Chapter XML Messaging and RPC classes7and libraries already loaded forPipeline, it to workJSPs, supporting all data types. The connection string is Chapter - Putting It are All Together with XML and XSQL Part II - Oracle XML for DBAs Connection connManagement = DriverManager.getConnection(

Chapter 8

- Getting Started with the "jdbc:oracle:kprb:"); Oracle XML Database

Chapter 9

- Storing XML Data

Note that trailing “;”and is necessary. Chapter 10 the - Generating Retrieving XML Chapter 11 - Searching XML Data

Creating a Database Connection

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

To create a database connection, first select File | New to open the New Gallerydialog box. Expand the General

Chapter 13and - Getting with Oracle XML and Java 13-3. In the list of items on the right side, double-click category selectStarted Connections, as shown in Figure Chapter 14 -Connection. Building an XML-Powered Site Database This starts theWeb Database Connection Wizard. The same wizard can also be triggered from Chapter 15 - Creating a Portal with XML and Services the Connection Navigator, bySite right-clicking the Web Database Connection node and selecting the New Database Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Connection shortcut menu. Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Figure 13-3: JDeveloper database connection selection Glossary Index List of Figures Select OK on the first wizard page to go to Step 1, which allows you to name the connection (for example, List of Tables DBConnection10g). At this point, the Connection Type drop-down list box enables you to select the type of JDBC List of Sidebars driver you want to use. To use either the thin or thick JDBC driver, select Oracle (JDBC), which takes you to the

Authenticationstep to enter your login information (e.g., SYS, ORACLE, SYSDBA). Check Deploy Password to avoid the password prompt each time you connect. Click Next to go to the Connectionstep, where you select either the thin or oci8 (thick) driver along with the Hostname, JDBC Port, and SID(e.g., localhost, 1521, ORCL). Select Next to go to the final Test step, which lets you test the JDBC connection. If your setup is correct, you will see “Success!” displayed; otherwise, you will see the error you need to correct. Even if you plan to use the thick driver to get full XMLType support, if you get an error, we suggest that you try the thin connection because that will confirm that your database parameters and strings are correct.


When you create connections using Oracle’s JDBC/OCI drivers, be aware of the following platform-specific requirements: Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

You must have the required native libraries (DLL files on Windows, and SO/SL files on UNIX). With the Oracle PL/SQL thick driverby(JDBC/OCI), the version of theand JDBC driver must match the version of the Oracle Home.ISBN:0072229527 For Mark V. Scardina, Ben Chang Jinyu Wang example, the Oracle JDBC Driver version 10.1.0 requires that the Oracle Home contain version 10.1.0 of the McGraw-Hill/Osborne © 2004 (600 pages) ocijdbc10.dll, as well as the Oracle Network software and supporting libraries, message files, encodings, etc., This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with within an Oracle Home. If you are connecting to a local database that is a different version from the JDBC driver emphasis on XML standards, their usage and best practices. you are using, then you must install the Oracle client software into a separate Oracle Home, and connect via the Oracle Net Listener.

Table of Contents

OracleYou Database 10g XML SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL must place the &ORACLE_HOME directory in which the client-side files for the required native libraries Introduction reside in your PATH environment variable. On Windows, you need the %ORACLE_HOME%\bin directory in Part Iwhich - Oracle the XMLDLL Standards theand client-side files reside in your PATH environment variable. If you have multiple Oracle Homes

Chapter 1 - Introducing XML installed on your machine, use the Oracle Home Switch utility to choose the correct Oracle Home. On UNIX, you Chapter need 2 the - Accessing $ORACLE_HOME/lib XML with DOM, directory SAX, JAXB, in which and StAX the client-side SO/SL files reside in your PATH environment

variable. Chapter 3 - Transforming XML with XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

If your Oracle Home for the OCI driver is not the same as the Oracle Home in which JDeveloper is installed, you - XML Operations with XQuery must either set the ORACLE_HOME environment variable or edit /jdev/bin/jdev.conf with a line similar to the Chapter 6 - XML Messaging and RPC with SOAP following, replacing the path shown with the full path to your Oracle Home: Chapter 5 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML “AddNativeCodePath Management for DBAsC:\ORACLE\ORA10\BIN” On Windows:

Chapter 8

- Getting Started with the Oracle XML Database

On9UNIX: “AddNativeCodePath /u01/app/oracle/product/10.1.0/lib” Chapter - Storing XML Data Chapter 10 - Generating and Retrieving XML

This command allows JDeveloper to properly update the java.library.path in which the Java VM searches for shared libraries. Connections set up this way are available globally and are automatically available to your projects.

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Creating an XDK Component Palette

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Oracle XDK 10g includes a collection of XML JavaBeans that can be easily integrated into JDeveloper as an XDK palette. You can add pages to the Component Palette to group your XDK JavaBeans components, or you can add Chapter 16 - Developing an XML Gateway Application with SOAP and AQ components to existing pages. Once you add JavaBeans to the palette, you can insert them into any file you have Chapter Reusable open in17 the- Developing UI Editor byXML-Based selecting them fromComponents the Component Palette. Chapter 15 - Creating a Portal Site with XML and Web Services

Part IV - Oracle XML for C Developers

Chapter The XDK 18 JavaBeans - Getting Started are contained with Oracle in xml.jar XML andand C xmlparserv2.jar; therefore, you need to first make sure

JDeveloper knows about these JARs.Application Select Tools | Manage Libraries to display a listing of User Libraries, Addin Chapter 19 - Building an XML-Managed Libraries, System Libraries. Selecting any one will allow you to add a new library to the list by clicking New. Chapter 20 and - Build an XML Database OCI Application EnterXDK for Library Name and edit the Class Path to point to the location at, for example, Chapter 21 -Components Create an XML-Configured High-Performance Transformation Engine C:\oracle\ora10\lib\xml.jar. the Source Path and Doc Path blank unless you downloaded the Javadocs from Part V - Oracle XML for C++ Leave Developers OTN. Click and Started you arewith done. Chapter 22 - OK Getting Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

To create an XDK JavaBeans Component Palette, follow these steps:

Chapter 24 - Building an XML Data-Retrieval Application

the main select Tools | Configure Palette to open the Configure Component Palette dialog box. Part 1. VI -From Oracle XML formenu, PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

2. Click Add to open the New Palette Page dialog box.

Chapter 26 - Building PL/SQL Web Services

Chapter 3. Enter 27 - Extending a page name, PL/SQL such XMLas Functionality XDK JavaBeans, with Java and click OK.You now see your new entry highlighted in the

Component Palette dialog box. Chapter Configure 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

4. Click Add on the Components side, and an Add JavaBeans dialog box will appear with a picklist of register libraries.

Glossary Index

List of 5. Figures Select XDK Components, and for the filter, select JavaBeans with BeanInfo Only from the Filter drop-down List of Tables list. Expanding the oracle.xml class tree displays the list shown in Figure 13-4. List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Figure 13-4: Adding a JavaBeans XDK Components list

Chapter 6. You 7 - can Putting nowItselect All Together the DBAccess, with XML XSDValidator, Pipeline, JSPs, and XMLDiffer, XSQL XMLDBAccess, and XMLCompress Part II - JavaBeans Oracle XML by Management clicking each for and DBAs then clicking OK.

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Note Although you can select multiple Beans by holding down the CTRL key, the associated Bean images will not be correctly assigned.

Chapter 10 - Generating and Retrieving XML

Chapter 11 -have Searching XML Data Once you completed these, you can add the DOMBuilder and XSLTransformer JavaBeans from Chapter 12 - Managing theyou Oracle XMLJavaBeans, Database as shown in Figure 13-5. xmlparserv2.jar, giving seven Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

Figure 13-5: XDK Component Palette Part VI - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

This palette now is available whenever you activate the Component Palette from View | Component Palette for all Java programs. You can drag and drop its components onto Swing or AWT panels when using the UI Designer of Chapter 27 - Extending PL/SQL XML Functionality with Java JDeveloper. Chapter 26 - Building PL/SQL Web Services Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 by Mark V.through Scardina, Chang Jinyu Wang This chapter walked you theBen basics of and getting your Java development environment configured and set up for McGraw-Hill/Osborne 2004 (600 either command-line development or© using thepages) Oracle JDeveloper IDE. It also introduced you to the JDK and JDBC driver configurations and requirements you will use in the following chapters. InOracle's those chapters, you products, will learn with This comprehensive guidethat focuses on utilizing XML technologies within XML-enabled emphasis on XML standards, their usage and abest practices. how to build real Java XML-enabled applications covering range of solution scenarios.

Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 14:Database Building an XML-Powered Web Site PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Throughout this book, we have presented the wide range of Oracle products that have become XML-enabled, and McGraw-Hill/Osborne © 2004 (600 pages) we have introduced many of the XML standards. In this chapter, we will explore the development and deployment of This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with a real-world application that uses these standards with the Oracle XDK and the new XML features of Oracle emphasis on XML standards, their usage and best practices. Database 10g. In this application, we explore the important capabilities of XSLT, the XSQL Servlet, the XML SQL Utility, Oracle Text, and the XML data types and operators in Oracle Database 10g. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

An XML-Enabled FAQ Web Site

Introduction

Part I - Oracle and the XML A frequent requirement forStandards companies that maintain a web presence is to have a support area for their products.

Chapter 1 may - Introducing XML This area range from simple electronic versions of their owner’s manuals to a moderated discussion forum. A Chapter - Accessing XML with SAX, and StAX asked questions) section for each product. popular2support area feature is DOM, to have anJAXB, FAQ (frequently Chapter 3

- Transforming XML with XSLT and XPath

Visitors4to -the site will XML be able see and all the FAQ subject areas on the home page and can also search and select Chapter Validating withtoDTDs XML Schemas from the frequently viewed FAQs. Whenever the list of FAQs appears, users can see the answers as well as Chapter 5 most - XML Operations with XQuery find related FAQs by following Chapter 6 - XML Messaging andthe RPCpresented with SOAPlinks. Inside each FAQ answer are links to an online glossary for technical or special terms. This functionality will be described in detail later in the chapter. - Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 7

Part II - Oracle XML Management for DBAs

As you no doubt have realized, the Oracle XML-enabled products and components are quite extensive and include

Chapter 8 - Getting Started with theprogramming Oracle XML Database components in the quite disparate languages of C, C++, PL/SQL, and Java. However, underneath

Chapter - Storing Data they all9provide XMLXML functionality that is programming-language independent. This gives rise to an awkward model Chapter 10 - Generating and Retrieving XMLmany questions that are XML-based are equally applicable across all the for providing technical support, because Chapter Searching XML Data XDKs, 11 yet-there are many language-specific questions that only make sense in only one XDK. Therefore, providing Chapter 12 -XML Managing the that Oracle Database an Oracle FAQ site canXML store all questions within a database and designing the schema in a way that Part III can - Oracle XML for Developers FAQs be tagged asJava relevant for one or more of the languages as well as the XML-enabled database features is

Chapter a basic13 requirement - Getting Started for thiswith site.Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Besides simply displaying a listing of FAQs per XML component and feature, users would expect a full text search facility. Since we plan to store the FAQs in the Oracle XML database, we can take advantage of Oracle Text Chapter 16 - Developing an XML Gateway Application with SOAP and AQ (formerly interMedia Text) search engine with its XML support. We also need a mechanism for submitting FAQs, Chapter 17 - Developing XML-Based Reusable Components which can be provided by FTP access to the Oracle XML DB repository. Chapter 15 - Creating a Portal Site with XML and Web Services

Part IV - Oracle XML for C Developers

Chapter - Getting Started with Oracle XML and C In most18 cases, the content for web sites is delivered from HTML pages stored in file systems on servers. For this Chapter 19 - Building an XML-Managed application, we will deliver as much ofApplication the content as possible from the database. This will give us maximum Chapter 20 - Build an XML Database Application manageability of the content while OCI at the same time demonstrating most of the Oracle XML database functionality. Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & DesigningOracle the Database Framework PL/SQL

ISBN:0072229527 Mark Scardina, Ben Chang and as Jinyu This applicationbywill useV.the Oracle XML database its Wang repository for the FAQs. We will create this storage by McGraw-Hill/Osborne © 2004 pages) that will then create the underlying objects and indexes that will registering an FAQ XML schema with the (600 database store the XML.This Additionally, we willguide create SQL tables to manage the categorization and glossary functionality of the comprehensive focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. site.

Once the database schema is designed, we will set up the application using the XSQL Servlet as the back end and an Internet browser as the front end. We will create a set of XSQL XML pages that will use the XML SQL Utility to Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL submit queries via JDBC and then create a set of XSL stylesheets using the XDK’s XSLT Processor to transform Introduction the result into HTML that is returned to the browser. To support paging of the FAQs, we will create an XSQL custom Part I - Oracle and the XML Standards action handler in Java.

Table of Contents

Chapter 1

- Introducing XML

Chapter 2 - Accessing XMLfunctionality, with DOM, SAX, JAXB, and StAX Text in the database. Since it has been enhanced with To implement the search we will use Oracle Chapter XML support, 3 - Transforming we will be able XML to with submit XSLTqueries and XPath as either text expressions or XPaths. To extend the functionality of

term searching, we willXML implement a glossary will be accessible through links in the content of FAQ answers. Chapter 4 - Validating with DTDs and XMLthat Schemas Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Creating the FAQ Database PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang Since this is a database-backed application, you will need to design a database schema to store the FAQs and their McGraw-Hill/Osborne © 2004 FAQs (600 pages) metadata. Obviously, since the individual will be XML documents, there can also be an XML schema that describes theirThis format. As you learned Chapter you canXML register this XML schema, andXML-enabled the XML database willwith comprehensive guideinfocuses on8,utilizing technologies within Oracle's products, emphasis on XML their usage andyou best practices. create the database schema for standards, you. On the other hand, can start with the database schema and generate an XML schema using the XML SQL Utility introduced in Chapter 10. In this application, you will create the FAQ storage with of anContents FAQ schema and create metadata tables using SQL to improve search performance and extend the Table functionality of the Oracle Database 10g site. XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & DesigningOracle the Database FAQ Schema PL/SQL

ISBN:0072229527 by Mark Chang and Jinyu Wang Many developers feel itV.is Scardina, easier to Ben design an XML schema from a sample instance XML document, whereas other McGraw-Hill/Osborne 2004 a (600 pages) developers design the XML schema©from data-modeling perspective. In either case, you need to start by enumerating the data types that you will focuses need. From the FAQ site requirements, youOracle's can determine the types and with This comprehensive guide on utilizing XML technologies within XML-enabled products, their usage and best practices. their content asemphasis set forthon in XML Tablestandards, 14-1.

Table XML Datatypes Needed to Describe FAQ Table of 14-1: Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

XML TYPE

Introduction

Part FAQ I - Oracle and the XML Standards

Description

Database Type

Complex type of entire FAQ document

OBJECT

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 6

- XML Messaging and RPC with SOAP

TITLE

Simple type string with restricted length to specify an Chapter 4 - Validating XML with DTDs and FAQ XML Schemas question for one-line Chapter 5 - XML Operations with XQuery display

VARCHAR2

QUESTION Mixed content toand support Chapter 7 - Putting It All Together with XML Pipeline, JSPs, XSQL

OBJECT

Chapter 8 - Getting Started with the OracleMixed XML Database ANSWER content to support

OBJECT

keyword and code markup Part II - Oracle XML Management for DBAs Chapter 9

- Storing XML Data

keyword and code markup

Chapter 10 - Generating and Retrieving XML

CATEGORY

Chapter 11 - Searching XML Data

String describing component type

VARCHAR2

String describing language type

VARCHAR2

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers LANGUAGE

Chapter 13 - Getting Started with Oracle XML and Java

PARAGRAPH

Mixed content of text, code, keywords, and links

Chapter 14 - Building an XML-Powered Web Site

OBJECT

Chapter 15 - Creating a Portal Site with XML and Web Services

CODE16 - Developing an XML Gateway Application String for embedded source Chapter with SOAP and AQ

VARCHAR2

code Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

KEYWORD

String for identifying glossary terms

Chapter 18 - Getting Started with Oracle XML and C

VARCHAR2

Chapter 19 - Building an XML-Managed Application

LINK 20 - Build an XML Database OCI Application Complex type of two strings for Chapter

OBJECT

hrefs and type Transformation Engine Chapter 21 - Create an XML-Configured High-Performance Part V - Oracle XML for C++ Developers

SAMPLE

Complex type of two strings for

VARCHAR2

Chapter 22 - Getting Started with Oracle XML andand C++ hrefs type Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

Note evenXML though LANGUAGE and CATEGORY each will be a specific list, they have not been identified as Part VIthat - Oracle for PL/SQL Developers such in25 the- schema. While the do and this PL/SQL has the consequence of limiting the storage model, the selection Chapter Getting Started withchoice Oracle to XML can be 26 handled on the insertWeb sideServices by presenting a list of languages or categories when the FAQ is generated. It is Chapter - Building PL/SQL important to unnecessarily constrain your storage, because doing so limits extensibility. In this case, regardless Chapter 27 not - Extending PL/SQL XML Functionality with Java of whether is It a finite list, the selections are stored as strings in a column and any index created would Chapter 28 - there Putting All Together accommodate additional strings with negligible impact. - XML Standards Bodies and Open Specifications

Appendix

Glossary Besides the actual FAQ content, the site maintenance would benefit from additional metadata about the FAQ, such Index as the following: List of Figures

With List of these Tablestypes enumerated, you can design an XML schema that takes into account what types are needed within other types. For example, you would like <ANSWER> to be able to contain <PARAGRAPH>,<KEYWORD>, and List of Sidebars <CODE> elements, and you would like the metadata information, such as the status,id, and lastupdate, to be attributes instead of child elements of <FAQ>. Taking these dependencies into account, you could produce the following FAQ XML schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <!-- Defile the CONTENT_TYPE-->


<xs:complexType name="CONTENT_TYPE" mixed="true" xdb:SQLType="CLOB" <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="CODE" type="xs:string"/> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <xs:element name="PARAGRAPH" nillable="true"> PL/SQL <xs:complexType mixed="true"> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <xs:choice minOccurs="0" maxOccurs="unbounded"> McGraw-Hill/Osborne © 2004 (600 pages) <xs:element name="LINK" nillable="true"> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <xs:complexType emphasis on XMLmixed="true"> standards, their usage and best practices. <xs:attribute name="href" type="xs:string"/> <xs:attribute name="type" type="xs:string"/> Table of Contents </xs:complexType> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL </xs:element> Introduction <xs:element name="KEYWORD" type="xs:string"/> Part I - Oracle and the XML Standards <xs:element name="CODE" type="xs:string"/> Chapter </xs:choice> 1 - Introducing XML Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX </xs:complexType> Chapter 3 - Transforming XML with XSLT and XPath </xs:element> Chapter 4 - Validating XML with DTDs and XML Schemas <xs:any processContents="skip"/> Chapter 5 - XML Operations with XQuery </xs:choice> Chapter </xs:complexType> 6 - XML Messaging and RPC with SOAP <!-- 7Define Chapter - PuttingFAQ It AllElement Together --> with XML Pipeline, JSPs, and XSQL <xs:element name="FAQ" xdb:maintainDOM="false" xdb:defaultTable="FAQ"> Part II - Oracle XML Management for DBAs <xs:complexType> Chapter 8 - Getting Started with the Oracle XML Database <xs:sequence> Chapter 9 - Storing XML Data <xs:element xdb:SQLName="TITLE"> Chapter 10 - Generatingname="TITLE" and Retrieving XML <xs:simpleType> Chapter 11 - Searching XML Data <xs:restriction base="xs:string"> Chapter 12 - Managing the Oracle XML Database <xs:maxLength value="100"/> Part III - Oracle XML for Java Developers </xs:restriction> Chapter 13 - Getting Started with Oracle XML and Java </xs:simpleType> Chapter 14 - Building an XML-Powered Web Site </xs:element> Chapter 15 - Creating a Portal Site with XML and Web Services <xs:element name="QUESTION" type="CONTENT_TYPE" nillable="true" Chapter 16 - Developing an XML Gateway Application with SOAP and AQ xdb:SQLName="QUESTION"/> Chapter 17 - Developingname="ANSWER" XML-Based Reusable Components <xs:element type="CONTENT_TYPE" xdb:SQLName="ANSWER"/> Part IV<xs:element - Oracle XML forname="CATEGORY" C Developers type="xs:string" xdb:SQLType="VARCHAR2" Chapter 18 - Getting Started with Oracle XML and C xdb:SQLName="CATEGORY"/> Chapter 19 Building XML-Managed Application <xs:elementanname="LANGUAGE" type="xs:string" minOccurs="0" Chapter 20 - Build an XML Database OCI Application xdb:SQLType="VARCHAR2" xdb:SQLName="LANGUAGE"/> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine </xs:element> Part</xs:sequence> V - Oracle XML for C++ Developers Chapter <xs:attribute 22 - Getting Started name="id" with Oracle type="xs:positiveInteger" XML and C++ default="0001" xdb:SQLType="NUMBER" xdb:SQLName="ID"/> Chapter 23 - Build an XML Database OCI C++ Application <xs:attribute type="xs:date" default="2003-03-11" Chapter 24 - Building an name="lastupdate" XML Data-Retrieval Application xdb:SQLType="DATE" xdb:SQLName="LASTUPDATE"/> Part VI - Oracle XML for PL/SQL Developers <xs:attribute name="status" default="pending" Chapter 25 - Getting Started with Oracle XMLtype="xs:string" and PL/SQL xdb:SQLType="VARCHAR2" xdb:SQLName="STATUS"/> Chapter 26 - Building PL/SQL Web Services </xs:complexType> Chapter 27 - Extending PL/SQL XML Functionality with Java </xs:element> Chapter 28 - Putting It All Together </xs:schema> Appendix

- XML Standards Bodies and Open Specifications

Glossary Index There are several points to note about this schema. First, there are attributes with the name xdb:SQLType that are List of Figures used to tell the registration process to which database type XML types should be mapped and xdb:SQLName to List of Tables specify the column or object name. List of Sidebars

Next, note that a type called CONTENT_TYPEis defined and is used in both the definition of QUESTION and ANSWER elements. This is a useful technique when you are using the same XML datatype for more than one element definition. Also to add content flexibility within these types, <xs:anyprocessContents="skip"> is added. This tells the XML schema processor in the Oracle XML DB to ignore any elements within <QUESTION> or <ANSWER> other than the <CODE> and <PARAGRAPH> elements. Finally, note the attribute within the FAQ element, xdb:maintainDOM="false".This is a special notation to the XML database that specifies that it is not important for this application to have these documents stored with all white


space, comments, processing instructions, etc. preserved. This lets the XML database create only the necessary objects and indexes to retrieve the content, thereby improving performance. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

Creating aPL/SQL Database User

by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages) Before proceeding with the database operations, you need to create a user with the appropriate privileges to store, query, and search FAQs using Oracle XML DB. To create, in thistechnologies case, an xdkus you XML-enabled need to use the This comprehensive guide focuses on utilizing XML withinuser, Oracle's products, with emphasis on XML standards, theirthe usage and best practices. sys/password logon as SYSDBA and execute following commands from SQLPlus:

CREATE USER xdkus IDENTIFIED BY xdkus Table of Contents DEFAULT TABLESPACE users Oracle TEMPORARY Database TABLESPACE 10g XML & SQL—Design, temp; Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Then, makeand sure user has the necessary privileges to access the resources needed, such as the Oracle Text Part I - to Oracle thethis XML Standards index and XML DB Chapter 1 -Oracle Introducing XMLrepository, execute the following: GRANT 2CONNECT, TO xdkus; Chapter - AccessingRESOURCE XML with DOM, SAX, JAXB, and StAX GRANT 3ctxapp TO xdkus; Chapter - Transforming XML with XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

- XML Operations with XQuery Registering the FAQ Schema

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

Now that have It theAllFAQ schema, to register it with the XML database to create the database schema. Chapter 7 you - Putting Together withyou XMLneed Pipeline, JSPs, and XSQL While can XML use Management the FTP or WebDAV Part II -you Oracle for DBAsinterface to load the XML schema file to the Oracle XML DB repository, as discussed Chapter 8, wewith simply theXML file Database into the /public directory. You can do this from SQL, connected as Chapter 8 -inGetting Started thecopy Oracle XDKUS/XDKUS, using DBMS_XMLSCHEMA.registerURI() function that takes an XML DB repository URI path Chapter 9 - Storing XML the Data from which retrieve the file XML as follows: Chapter 10 - to Generating andschema Retrieving begin 11 - Searching XML Data Chapter Chapter 12 - Managing the Oracle XML Database PartDBMS_XMLSCHEMA.registerURI('http://localhost:8080/public/faq.xsd', III - Oracle XML for Java Developers

'/public/faq.xsd',TRUE,TRUE,FALSE,TRUE); Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

end; /

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 this - Developing XML-Based Note that file is being retrievedReusable from theComponents /public directory; however, this is a directory inside the Oracle XML DB Part IV - Oracle for Clocal Developers repository and XML not your file system. There are two important reasons to store the schema in the database.

Chapter 18 -documents Getting Started with Oracle XMLcharacter and C First, XML are sensitive to the encoding they were created in. This cannot be overridden by Chapter 19 -the Building an XML-Managed Applicationas that attribute is only a hint to the parser if it can’t determine it specifying encoding in the XML declaration, Chapter 20first - Build XMLBy Database Application from the few an bytes. storing OCI the schema in the database, the encoding is converted, if necessary, to the Chapter 21 encoding, - Create anthus XML-Configured Engine database ensuring theHigh-Performance document will be Transformation successfully parsed. Part V - Oracle XML for C++ Developers

Note error stating unexpected was found when < was expected at the start of the file Chapter 22 An - Getting Startedthat withan Oracle XML andcharacter C++ means the document has an incompatible encoding. Chapter 23 usually - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

The other reason to use the repository is that you can be assured the schema will always be available as a link without the need to configure proxies or firewalls and instantly retrievable for validation.

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter You can 26easily - Building storePL/SQL the FAQ Web schema Services by using FTP or creating a WebDAV folder under Windows. With the XML

database launch Internet Explorer andwith select File | Open. Enter http://localhost:8080/public/, check the Chapter 27 running, - Extending PL/SQL XML Functionality Java Open As Folder check box, and then click OK. You will now see the /public directory in the XML database Chapter 28 Web - Putting It All Together repository -and copy faq.xsd it. Open Now you can register the schema. Appendix XMLcan Standards Bodies to and Specifications Glossary

Loading the FAQs

Index

List of Figures

Now you have created the database schema, you can store the FAQs. But first, to prevent duplicate FAQs, you List of that Tables canofcreate a SQL unique constraint on the value of <TITLE>. This can be done from SQL with the following: List Sidebars ALTER TABLE faq ADD CONSTRAINT TITLE_IS_UNIQUE UNIQUE(xmldata."TITLE"); As discussed in the previous chapter, the XMLDATA refers to the XML Type Object storing the FAQs and XMLDATA. "TITLE" can be used to refer to its child TITLE element. To load Glossary.xml, the database directory XMLDIR is created using BFILE, by using the sys/password logon as


SYSDBA and executing the following commands from SQLPlus: CREATE DIRECTORY XMLDIR AS '&os_directory'; GRANT READ Oracle ON DIRECTORY xdkus; Database XMLDIR 10g XMLTO & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

At this point you of uploading FAQs FTP or using web folders that use WebDAV as xdkus ISBN:0072229527 byhave Markan V. option Scardina, Ben Changthe and Jinyuvia Wang user. When attempting to use FTP, ©you should use a client that permits copying files by generating successive PUT McGraw-Hill/Osborne 2004 (600 pages) commands. Since XML database’s server only supports the basic set of FTP commands, multiple file This the comprehensive guideFTP focuses on utilizing XML technologies within Oracle's XML-enabled products, with operations andemphasis wildcard on expansions are nottheir available. XML standards, usage and best practices. You can also create new directories or just use an existing directory in the repository to load the FAQs. However, to ensure the FAQs are stored in the default table created by the XML schema registration, which is called FAQ, the Oracle Database 10gattribute XML & SQL—Design, & Manage XML Applications in Java,URL C, C++ & Oracle PL/SQL XML DB. In this schemaLocation in each FAQBuild has to be the registered XML schema in the Introduction example, it is xsi:noNamespaceSchemaLocation="http://localhost:8080/public/faq.xsd". Therefore, each FAQ Part I -look Oracle XML Standards must likeand the the following:

Table of Contents

Chapter 1

- Introducing XML

<FAQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - Accessing XML with DOM, SAX, JAXB, and StAX xsi:noNamespaceSchemaLocation="http://localhost:8080/public/faq.xsd" Chapter id="0001" 3 - Transforming XML with XSLT and XPath lastupdate="2002-02-26">…</FAQ> Chapter 2 Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter Once you 5 -have XML the Operations files loaded, with XQuery you can confirm their successful storage by issuing this command from SQL*Plus: Chapter 6 - XML COUNT(1) Messaging and RPCFAQ; with SOAP SQL> SELECT FROM Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL COUNT(1) Part II - Oracle XML Management for DBAs ----------

Chapter 8 108 - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

Now that XML andXML database Chapter 11 the - Searching Data schema is designed and the data loaded, you can turn to interfacing the database to the web site using the XSQL Servlet from the XDK.

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Build & Manage XML Applications in Java, C, C++ & Connecting the FAQ Web Site toDesign, the XML Database PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang The XSQL servlet, introduced in Oracle8i and refined in Oracle9i and Oracle Database 10g, provides a robust and © 2004 (600 flexible platformMcGraw-Hill/Osborne for this type of application. Wepages) will use it in the following ways:

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

To generate the content from data stored inusage the database emphasis on XML standards, their and best practices. To provide a keyword search interface

Table of Contents

OracleTo Database display the 10g results XML & SQL—Design, from the various Build queries & Manage in the XML browser Applications using an in Java, interactive C, C++ interface & PL/SQL Introduction

manage connections Part ITo - Oracle andthe thedatabase XML Standards Chapter 1

- Introducing XML Figure 14-1 illustrates the FAQ web site’s home page, which is dynamically generated from the XSQL Servlet using

Chapter 2 - Accessing a combination of XMLXML and with XSLDOM, files. SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Figure 14-1: FAQ web site

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Building the XSQL Home Page

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

From previous chapters, you know that the elements of an XSQLpage consist of the following sections:

Part V - Oracle XML for C++ Developers

<?xml version="1.0" encoding='UTF-8'?> <!-- Stylesheet PIs --> Chapter 23 - Build an XML Database OCI C++ Application <!-- Database Connection --> Chapter 24 - Building an XML Data-Retrieval Application <!-- XSQL code and database queries --> Chapter 22 - Getting Started with Oracle XML and C++

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 -toGetting Started withto Oracle XML and PL/SQL However, allow the web site be modular and extensible, we will be parameterizing the XSQL pages where their Chapter content26 will- Building be addedPL/SQL using Web XML Services files passed as an HTTP parameter. The following is the index.xsql page that will Chapter 27the - Extending PL/SQL XML Functionality with Java serve as base module: Chapter - Putting It All Together <?xml 28 version="1.0"?> Appendix - XML Standards Bodies and Open Specifications <?xml-stylesheet type="text/xsl" media="msie" href="xsl/xdkus.xsl"?> Glossary <?xml-stylesheet type="text/xsl" media="mozilla" Index

href="xsl/xdkus_ns.xsl"?>

List of Figures <page xmlns:xsql="urn:oracle-xsql"> List<content> of Tables

name="pagename" exists="yes"> List <xsql:if-param of Sidebars <xsql:include-xsql reparse="yes" href="{@pagename}.xsql"/> </xsql:if-param> <xsql:if-param name="pagename" exists="no"> <xsql:include-xsql reparse="yes" href="list.xsql?cat=all& lang=all"/> </xsql:if-param> </content> </page>


Note that it uses the <xsql:if-param> element introduced in Oracle Database 10g XDK to conditionally include XML files. The first <xsql:if-param> element is called if a pagename parameter supplying the filename of an XSQL page Oracle XML & SQL: Design, Build & Manage XML Applications in Java, C++ & as is passed in, while theDatabase second is 10g called when no parameter is supplied. Therefore, when this page is firstC,invoked, PL/SQL shown in Figure 14-1, the list.xsqlpage is included with parameters that specify the query should return all FAQs ISBN:0072229527 by Mark languages. V. Scardina, Ben Chang and Jinyu Wang across allprogramming McGraw-Hill/Osborne © 2004 (600 pages)

Also included are <?xml-stylesheet?> processing instructions. These differ byOracle's the media and href products, attributes with Thistwo comprehensive guide focuses on utilizing XML technologies within XML-enabled that the XSQL emphasis Servlet uses on XML to perform standards, the appropriate their usage and stylesheet best practices. transformation for the requesting browser.

Creating the FAQ List

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Thelist.xsqlpage is the one that queries the database, returning XML from which the HTML page is created after Introduction the Istylesheet processing. To create this page, you need to specify the database queries that will be submitted as Part - Oracle and the XML Standards well as 1the- connection for JDBC access. Chapter Introducing information XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 4

- Validating XML with DTDs and XML Schemas

You can begin by setting up the database connection. The following element declares the title of the page, the XSQL Chapter 3 - Transforming XML with XSLT and XPath namespace, and the alias for the database connection located in the XSQLConfig.xmlfile: <page title="Oracle XML FAQ Demo" connection="xdkus" id="1" xmlns:xsql= - XML Operations with XQuery "urn:oracle-xsql">

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part - Oracle XML for DBAs file that will be used to connect to the database is as follows: TheII xdkus entry in Management the XSQLConfig.xml

Chapter 8

- Getting Started with the Oracle XML Database <connection name="xdkus"> Chapter 9<username>xdkus</username> - Storing XML Data Chapter 10 - Generating and Retrieving XML <password>xdkus</password> Chapter 11 - Searching XML Data <dburl>jdbc:oracle:thin:@localhost:1521:orcl</dburl> Chapter 12 - Managing the Oracle XML Database <driver>oracle.jdbc.driver.OracleDriver</driver> Part III - Oracle XML for Java Developers </connection> Chapter 13 - Getting Started with Oracle XML and Java

Since the are an stored as complete Chapter 14 FAQs - Building XML-Powered WebXML Site documents, if you want to produce an initial summary listing, as shown inFigure1514-1, you need to extract theXML information of displaying the entire document. Although applying a Chapter - Creating a Portal Site with and Webinstead Services stylesheet each returned FAQ could Application do this, it would be very inefficient and doesn’t leverage the power of the Chapter 16 -on Developing an XML Gateway with SOAP and AQ XML database. Instead, you can use XPaths as illustrated in the following SQL query to retrieve only the data required: Part IV - Oracle XML for C Developers Chapter 17 - Developing XML-Based Reusable Components

SELECT as title, Chapter 18extractValue(value(x),'/FAQ/TITLE') - Getting Started with Oracle XML and C extractValue(value(x),'/FAQ/@status') as status, Chapter 19 - Building an XML-Managed Application as id Chapter 20 - Build an XMLextractValue(value(x),'/FAQ/@id') Database OCI Application FROM faq x order by id Part V - Oracle XML for C++ Developers

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Chapter 22 - Getting Started with Oracle XML and C++

Retrieving the IDs for each FAQ allows you to use them to construct a link to the full question and answer. This can

Chapter 23in- the Build an XML XSL Database OCI included C++ Application be done following template within list.xsl: Chapter 24 - Building an XML Data-Retrieval Application

<xsl:for-each select="page/ROWSET/ROW"> <tr> Chapter 25 - Getting Started with Oracle XML and PL/SQL <xsl:attribute name="class"> Chapter 26 - Building PL/SQL Web Services <xsl:choose> Chapter 27 - Extending PL/SQL XML Functionality <xsl:when test="position() mod with 2 = Java 1">rowodd</xsl:when> Chapter 28 - Putting test="position() It All Together <xsl:when mod 2 = 0">roweven</xsl:when> Appendix - XML Standards Bodies and Open Specifications </xsl:choose> Glossary </xsl:attribute> Index <td> List of<xsl:value-of Figures select="ID"/>:</td> List<td> of Tables href="showAnswer.xsql?id={ID}" List<a of Sidebars Onclick="NewWindow('showAnswer.xsql?id={ID}','{ID}','600','400', 'yes'); return false;"> <xsl:value-of select="TITLE"/> </a> <xsl:if test="STATUS ='hot'"> <img src="/xdkus/images/{STATUS}.gif"/> </xsl:if> Part VI - Oracle XML for PL/SQL Developers


</td> </tr> </xsl:for-each> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

This template does several things. First, it produces the alternating row colors in the table by using <xsl:choose> to McGraw-Hill/Osborne © 2004 (600 pages) add a CSS attribute ROWODD orROWEVEN. It then makes a link of <TITLE> using JavaScript to pass the FAQ This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with ID to showanswer.xsql to display a new window with the answer. Finally, to indicate popular FAQs, the template emphasis on XML standards, their usage and best practices. adds the hot.gif image. Table of Contents

Filtering the FAQ List

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Since the FAQs are categorized by programming language and component, you will want to retrieve only relevant FAQs. You can do this by passing parameters into a query. The XSQL Servlet facilitates your capability to do this, Chapter 1 - Introducing XML as illustrated in the following section from list.xsql: Part I - Oracle and the XML Standards

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

<xsql:if-param name="lang" not-equals="all"> Chapter 3 - Transforming XML with XSLT and XPath <xsql:action handler="oracle.xml.sample.xsql.portal.Paging" Chapter 4 - Validating XML with DTDs and XML Schemas rows-per-page="15" url-pagename="index.xsql?pagename=list& Chapter 5 - XML Operations with XQuery cat={@cat}&lang={@lang}&"> Chapter 6 - XML Messaging and RPC with SOAP <![CDATA[ Chapter 7 - Putting It Allcount(1) Together with XML Pipeline, JSPs, and XSQL SELECT Part II - OracleFROM XML Management for DBAs faq x Chapter 8 - Getting Started with the Oracle XML Database where extractValue(value(x),'/FAQ/LANGUAGE/text()') ='{@lang}' Chapter 9 - Storing Data and XML extractValue(value(x),'/FAQ/CATEGORY/text()') ='{@cat}' Chapter 10]]> - Generating and Retrieving XML Chapter </xsql:action> 11 - Searching XML Data <xsql:query max-rows="{@paging-max}"> Chapter 12 - Managing skip-rows="{@paging-skip}" the Oracle XML Database Part III - <![CDATA[ Oracle XML for Java Developers SELECT extractValue(value(x),'/FAQ/TITLE') as title, Chapter 13 - Getting Started with Oracle XML and Java extractValue(value(x),'/FAQ/@status') as status, Chapter 14 - Building an XML-Powered Web Site extractValue(value(x),'/FAQ/@id') as id Chapter 15 - Creating a Portal Site with XML and Web Services FROM faqan x XML Gateway Application with SOAP and AQ Chapter 16 - Developing where extractValue(value(x),'/FAQ/LANGUAGE/text()') ='{@lang}' Chapter 17 - Developing XML-Based Reusable Components and extractValue(value(x),'/FAQ/CATEGORY/text()') ='{@cat}' Part IV - Oracle XML for C Developers order by id Chapter 18 - Getting Started with Oracle XML and C ]]> Chapter 19 - Building an XML-Managed Application </xsql:query> Chapter 20 - Build an XML Database OCI Application </xsql:if-param> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Part V -again, Oracle<xsql:if-param> XML for C++ Developers Once is used to be able to switch in another application section. Once the category

Chapter 22 -@cat, Getting Started with Oracle XML and @lang, C++ parameter, and the language parameter, are initialized by selecting from the pick lists, the queries are Chapter 23 -and Build an XML Database C++ Application populated submitted. The first OCI query returns the FAQ count that is used for pagination and the second query Chapter returns24 the- list Building of FAQs. an XML Note Data-Retrieval that you can Application use XPaths in both sections of the query and that, when used in the Part predicate, VI - Oracle text()XML is appended for PL/SQL in Developers order to perform the string match.

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Adding Pagination to10g theXML FAQ Listing PL/SQL

Mark V. Scardina, Benyou Chang and Jinyu Since there arebyover a hundred FAQs, obviously willWang not want to return all of them at once. You can ISBN:0072229527 set up McGraw-Hill/Osborne © 2004 (600 pages) pagination in an XSQL custom action handler that calls a Java class. In this case, we have created paging.java, which accepts This parameters from theguide XSQL page on to set up the number of rowswithin per page, rows-per-page, the URL for comprehensive focuses utilizing XML technologies Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. the page to invoke, url-pagename, the next page parameter name, p, and the parameters to pass in the URL, urlparams. The following is a Java code fragment that performs the pagination: Table of Contents public class Paging extends XSQLActionHandlerImpl { Oracle private Database static 10g XMLfinal & SQL—Design, String Build PAGE_PARAM_NAME & Manage XML Applications = "p"; in Java, C, C++ & PL/SQL

private static final String ROWSPERPAGE Introduction final String Partprivate I - Oracle static and the XML Standards

TARGETPAGEARGS private static final String PAGENAME Chapter 1 - Introducing XML Chapter 2

= "rows-per-page"; = "url-params"; = "url-pagename";

- Accessing XML with DOM, SAX, JAXB, and StAX

public void handleAction(Node Chapter 3 - Transforming XML with XSLT androot) XPath throws SQLException { XSQLPageRequest req = getPageRequest(); Chapter 4 - Validating XML with DTDs and XML Schemas Element actElt = getActionElement(); Chapter 5 - XML Operations with XQuery // Get the count query from the action element content Chapter 6 - XML Messaging and RPC with SOAP String query = getActionElementContent(); Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL // Get the number of rows per page, defaulting to 10 Part II - Oracle XML Management for DBAs long pageSize = longVal(getAttributeAllowingParam(ROWSPERPAGE,actElt) Chapter 8 - Getting Started with the Oracle XML Database ,10); Chapter 9 - Storing XML Data long totalRows = longVal(firstColumnOfFirstRow(root,query),0); Chapter 10 - Generating andlongVal(variableValue(PAGE_PARAM_NAME,actElt),1); Retrieving XML long curPage = Chapter 11 Searching XML Data // Get the name of the current page to use as the target Chapter 12 - Managing the Oracle Database //String pageName = XML curPageName(req); Part III Oracle XML for Java Developers // Get any URL param names that need to be echoed into paging URL's Chapter 13 - Getting Started = with Oracle XML and Java String pageArgs getAttributeAllowingParam(TARGETPAGEARGS,actElt); Chapter 14 Building an XML-Powered Web Site String pageName = getAttributeAllowingParam(PAGENAME,actElt); Chapter // 15Calculate - Creating a Portal the total Site withnumber XML andof Web pages Services long totalPages = totalRows / pageSize; Chapter 16 - Developing an XML Gateway Application with SOAP and AQ long fract = totalRows % pageSize; Chapter 17 - Developing XML-Based Reusable Components if (fract > 0) totalPages++; Part IV - Oracle XML for C Developers // sure current pageXML is and between 1 < cur < totalPages Chapter 18Make - Getting Started with Oracle C if (curPage < 1) curPage = 1;if (curPage > totalPages) Chapter 19 - Building an XML-Managed Application curPage = totalPages; Chapter 20 - Build an XML Database OCI Application // Create the <paging> fragment to add to the "data page" Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Document d = actElt.getOwnerDocument(); Part V - Oracle XML for C++ Developers Element e = d.createElement("paging"); Chapter 22 - Getting Started with Oracle XML and C++ root.appendChild(e); Chapter 23 - Build an XML Database OCI C++ Application addResultElement(e,"total-rows",Long.toString(totalRows)); Chapter 24 - Building an XML Data-Retrieval Application addResultElement(e,"total-pages",Long.toString(totalPages)); Part VI - Oracle XML for PL/SQL Developers addResultElement(e,"current-page",Long.toString(curPage)); Chapter 25 - Getting Started with Oracle XML and PL/SQL if (curPage < totalPages) Chapter 26 -addResultElement(e,"next-page",Long.toString(curPage+1)); Building PL/SQL Web Services Chapter 27 if Extending (curPagePL/SQL > 1)XML Functionality with Java Chapter 28 -addResultElement(e,"prev-page",Long.toString(curPage-1)); Putting It All Together Appendix addResultElement(e,"target-page",pageName); - XML Standards Bodies and Open Specifications Glossary if (pageArgs != null && !pageArgs.equals("")) Index addResultElement(e,"target-args",expandedUrlParams(pageArgs, List of Figures actElt)); // Set to page-level parameters that the <xsql:query> can use List of Tables req.setPageParam("paging-skip", List of Sidebars Long.toString((curPage-1)*pageSize)); req.setPageParam("paging-max",Long.toString(pageSize)); } // Get the name of the current page from the current page's URI private String curPageName(XSQLPageRequest req) { String thisPage = req.getSourceDocumentURI();; int pos = thisPage.lastIndexOf('/'); if (pos >=0) thisPage = thisPage.substring(pos+1);


} }

pos = thisPage.indexOf('?'); if (pos >=0) thisPage = thisPage.substring(0,pos-1); return Oracle thisPage; Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

This class is invoked by the <xsql:action handler> element, as in the following example from list.xsql: emphasis on XML standards, their usage and best practices. <xsql:action handler="oracle.xml.sample.xsql.portal.Paging" rows-per-page="15" url-pagename="index.xsql? Table of Contents pagename=list&cat={@cat}&lang={@lang}&"> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <![CDATA[ Introduction SELECT count(1) FROM faq Part I - Oracle and the XML Standards ]]> Chapter 1 - Introducing XML </xsql:action> Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 this - Transforming XPath Invoking element will XML passwith the XSLT three and parameters to the pagingclass that will compute the total number of 15Chapter row pages 4 - from Validating the total XML number with DTDs of FAQs. and XML This Schemas class will also set the paging-skip and paging-max parameters that

will be used in the following with query to retrieve the correct set of questions: Chapter 5 - XML Operations XQuery Chapter 6 - XML Messaging and RPC with SOAP <xsql:query skip-rows="{@paging-skip}" max-rows="{@paging-max}"> Chapter 7<![CDATA[ - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs SELECT extractValue(value(x),'/FAQ/TITLE')

as title,

Chapter 8

- Getting Started extractValue(value(x),'/FAQ/@status') with the Oracle XML Database as status,

Chapter 9

extractValue(value(x),'/FAQ/@id') as id - Storing XML Data

FROM faq Chapter 10 - Generating and x Retrieving XML order XML by Data id Chapter 11 - Searching Chapter 12 -]]> Managing the Oracle XML Database

</xsql:query> Part III - Oracle XML for Java Developers Chapter 13 - Getting Started with Oracle XML and Java

Now all that you need to do is create a Next link that increments the p parameter to display successive FAQ pages. This is done by creating the following link to pass a new set of parameters to index.xsql and subsequently list.xsql:

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services

http://localhost:8988/xdkus/app_faq/index.xsql? pagename=list&cat=all&lang=all&p=2

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Part IV time - Oracle for C Developers Each p is XML incremented, a new set of 15 FAQs is displayed until the maximum is reached.

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Displaying theDatabase FAQ and Answers PL/SQL

by Markyou V. Scardina, Chang and Jinyu In a previous section, saw how Ben the link is created to Wang invoke the showanswer.xsqlpage that displaysISBN:0072229527 the FAQ. McGraw-Hill/Osborne © 2004 (600This pages) Now we will discuss how this actually works. page is invoked by passing the selected FAQ id as a parameter in the following URL: This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. http://localhost:8988/xdkus/app_faq/showAnswer.xsql?id=16

Figure shows the XML transformed into the HTML display of the output. Table of 14-2 Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Figure 14-2: FAQ answer in HTML

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter Theidis19 then - Building passedan into XML-Managed the followingApplication query to retrieve the FAQ data: Chapter 20 - Build an XML Database OCI Application <xsql:include-xml> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <![CDATA[ Part V - Oracle XML for C++ Developers select xmlelement("FAQ",

Chapter 22 - Getting Started with Oracle XML and C++ xmlforest(extract(value(x),'/FAQ/ANSWER') as answer, Chapter 23 - Build an XML Database extract(value(x),'/FAQ/TITLE/text()') OCI C++ Application as title,

extract(value(x),'/FAQ/QUESTION') as question, Chapter 24 - Building an XML Data-Retrieval Application extract(value(x),'/FAQ/@id') Part VI - Oracle XML for PL/SQL Developers

as id)).getClobVal()

faq x with Oracle XML and PL/SQL Chapter 25 -from Getting Started extractValue(value(x),'/FAQ/@id')='{@id}' Chapter where 26 - Building PL/SQL Web Services ]]> Chapter 27 - Extending PL/SQL XML Functionality with Java </xsql:include-xml> Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

If you examine this query, you’ll see that it uses the SQL/XML extensions in the database to construct a new XML document. To simply include the XML output from SQL/XML queries, you can use <xsql:include-xml> instead of Index <xsql:query> as it doesn’t add the <ROWSET> and <ROW> elements. The following is an example of this List of Figures document before it is transformed into HTML by the showAnswer.xsl stylesheet: Glossary

List of Tables

<page id="1"> <FAQ> <ANSWER> <ANSWER> <PARAGRAPH> You should be able to set the <KEYWORD>encoding</KEYWORD> declaration in XML PI using the DBMS_XMLQUERY.setEncodingTag() procedure, which will not do the encoding conversion.</PARAGRAPH> <PARAGRAPH> As data is returned in <KEYWORD>CLOB</KEYWORD>,

List of Sidebars


the XML data will always be converted to <KEYWORD>UCS2</KEYWORD> ( <KEYWORD>AL16UTF16</KEYWORD> ) encoding by database if the database is in multibyte or the database character set if the Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & database is in single byte. When you store the query result PL/SQL to files, you V.should take care and of Jinyu the Wang characterset conversion ISBN:0072229527 by Mark Scardina, Ben Chang to makeMcGraw-Hill/Osborne sure there is no conflict between the actual coding and © 2004 (600 pages) encoding declaration. </PARAGRAPH> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with </ANSWER>emphasis on XML standards, their usage and best practices. </ANSWER> <TITLE>How can I set the encoding the output of the XSU query?</TITLE> Table of Contents <QUESTION> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <QUESTION> Introduction <PARAGRAPH>One of my customers executes a query using XSU on a Part I - Oracle and the XML Standards table with diacritical characters, gets the result in a CLOB, Chapter 1 puts - Introducing and it in XML a file. It works fine, but he needs to modify the Chapter 2 Accessing XML with SAX, JAXB, and StAX encoding, modify theDOM, line:</PARAGRAPH> Chapter 3 - Transforming XML with XSLT?></CODE> and XPath to <CODE><?xml version="1.0" <CODE><?xml version="1.0" Chapter 4 - Validating XML with DTDs and XML Schemas encoding="iso-8859-1" ?></CODE> Chapter 5 - XML Operations <PARAGRAPH>How can with he XQuery do that?</PARAGRAPH> Chapter </QUESTION> 6 - XML Messaging and RPC with SOAP </QUESTION> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part<ID>2</ID> II - Oracle XML Management for DBAs </FAQ> Chapter 8 - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

Note that the four top-level elements, <ANSWER>, <TITLE>, <QUESTION>, and <ID>, were retrieved using the extract()function passing in the respective XPaths.

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database

Part III - Oracle XML for Java Developers To display this FAQ in HTML, you need to apply a stylesheet. This is done for you by including a stylesheet

Chapter 13 - instruction Getting Started with Oracle XML and processing in showanswer.xsql andJava having the XSQL Servlet apply it for you. The following is in our Chapter 14 - Building an XML-Powered Web Site example: Chapter 15 - Creating a Portal Site with XML and Web Services <?xml-stylesheet type="text/xsl" href="xsl/showAnswer.xsl" ?> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

This stylesheet is quite XML-Based long because it sets Components up tables, but it is useful to examine the templates that actually operate Chapter 17 - Developing Reusable overIVthe input FAQ XML document. First, the <PARAGRAPH> sections need to be formatted. This is done with the Part - Oracle XML for C Developers identity18 transform introduced in Chapter Chapter - Gettingtemplate, Started with Oracle XML and C 3, as follows: Chapter 19 - Buildingmatch="PARAGRAPH"> an XML-Managed Application <xsl:template Chapter <p> 20 - Build an XML Database OCI Application

<xsl:apply-templates select="*|@*|comment()|processing-instruction() Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V |text()"/> - Oracle XML for C++ Developers

</p> 22 - Getting Started with Oracle XML and C++ Chapter </xsl:template> Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

Next, the <CODE> elements need to be presented in a fixed font. This is accomplished with the following template:

Part VI - Oracle XML for PL/SQL Developers

<xsl:template Chapter 25 - Gettingmatch="CODE"> Started with Oracle XML and PL/SQL <pre> Chapter 26 - Building PL/SQL Web Services <xsl:value-of select="."/> </pre> Chapter 28 - Putting It All Together </xsl:template>

Chapter 27 - Extending PL/SQL XML Functionality with Java Appendix

- XML Standards Bodies and Open Specifications

Glossary Next, turning to the main sections of the answer, these will be formatted in the main template of the stylesheet. First, Index we see that the FAQ title has special formatting. This is done with the following section, which uses a CSS class to List of Figures provide the special formatting: List of Tables <tr valign="top"> List<th of Sidebars class="portletTitle">

<xsl:value-of disable-output-escaping="yes" select="page/FAQ/TITLE"/> </th> </tr> Note Throughout these examples, you will see that CSS classes are used to provide formatting. You should adopt this technique, because it makes your stylesheets easier to build, and the formatting is reusable. Next, we see that the answer is identified with Answer: and a different background color. The following section


shows how this is done: <tr bgcolor="#F0F0F0"> <td width="100%"> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <b>Answer: </b> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <br/> McGraw-Hill/Osborne © 2004 (600 pages) <xsl:apply-templates select="page/FAQ/ANSWER/ANSWER"/> </td> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. </tr> Table of Contents

Finally, you need to add navigational controls to this page, such as Back and Close. You can do this by adding JavaScript commands to the template as follows:

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

<tr> Part I - Oracle and the XML Standards <td> 1 Chapter

- Introducing XML

<img src="images/r_arrow.gif" width="8" height="9"/> - Accessing XML with DOM, SAX, JAXB, and StAX <a href="#" onClick="history.back()">Back</a> Chapter 3 - Transforming XML with XSLT and XPath </td> Chapter 4 - Validating XML with DTDs and XML Schemas <td align="right"> Chapter 5 - XML Operations with XQuery <img src="images/r_arrow.gif" width="8" height="9"/> Chapter 6 - XML Messaging and RPC with SOAP <a href="#" onClick="self.close()">Close</a> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL </td> Part II </tr> Oracle XML Management for DBAs Chapter 2

Chapter 8

- Getting Started with the Oracle XML Database

Chapter Note that 9 both - Storing the text XMLof Data the commands and an arrow graphic are inserted when the template is applied. Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Creating aOracle Glossary PL/SQL

ISBN:0072229527 by in Mark Scardina, Chang Jinyu Wang that displays definitions of important technical A useful function anyV.FAQ site is Ben to have anand online glossary terms McGraw-Hill/Osborne © 2004 (600 pages) when users click on the corresponding words. You can implement this feature in your FAQ site by marking up terms as <KEYWORD> and then creating links dynamically XSLTwithin to retrieve their definitions products, from a with Thiselements comprehensive guide focuses on utilizing XML through technologies Oracle's XML-enabled emphasis on XMLIn standards, their we usage andalready best practices. glossary table in the database. this example, have created a glossary file in XML format that can be used.

Table of Contents

Creating the Glossary Schema

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

FirstI you needand to create a Standards glossary table in the database in which to store the definitions. It is not important that the Part - Oracle the XML glossary is stored as XML; therefore, you can create a simple table as follows: Chapter 1 data - Introducing XML Chapter 2 TABLE - Accessing XML with DOM, SAX, JAXB, and StAX CREATE GLOSSARY( Chapter ID NUMBER, 3 - Transforming XML with XSLT and XPath

NAME 4VARCHAR2(30), Chapter - Validating XML with DTDs and XML Schemas CONTENT VARCHAR2(4000) Chapter 5 - XML Operations with XQuery ); 6 Chapter

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

CREATE SEQUENCE glossary_seq START Part II - Oracle XML Management for DBAs Chapter 8

WITH 100;

- Getting Started with the Oracle XML Database

CREATE or replace TRIGGER glossary_insert - Storing XML Data BEFORE INSERT ON glossary Chapter 10 - Generating and Retrieving XML FOR EACH ROW Chapter 11 - Searching XML Data BEGIN Chapter 12 - Managing the Oracle XML Database select glossary_seq.nextval into :new.id from dual; Part III - Oracle XML for Java Developers END; Chapter 13 - Getting Started with Oracle XML and Java / Chapter 14 - Building an XML-Powered Web Site show errors; Chapter 9

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

This SQL createsXML-Based a simple three-column table to store the ID, NAME, and CONTENT for each term. It also Chapter 17 script - Developing Reusable Components creates a sequence and a trigger to update the sequence so that the IDs are generated automatically every time a Part IV - Oracle XML for C Developers new entry inserted. Chapter 18 -isGetting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Loading the Glossary

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

TheVsupplied file isDevelopers called glossary.xml and will be loaded directly into the table using the Part - Oracle glossary XML for C++ DBMS_XMLSave available inXML the database. Chapter 22 - Gettingpackage Started with Oracle and C++ The XML format for the glossary data is provided in the required Chapter 23canonical - Build anform: XML Database OCI C++ Application Chapter <ROW num="1"> 24 - Building an XML Data-Retrieval Application Part <NAME>API</NAME> VI - Oracle XML for PL/SQL Developers

<CONTENT>(Application Chapter 25 - Getting Started withProgram Oracle XMLInterface) and PL/SQL A set of public programmatic interfaces that consist of a language and message format to communicate Chapter 26 - Building PL/SQL Web Services with operating system or otherwith programmatic environment such as Chapter 27an - Extending PL/SQL XML Functionality Java databases, Chapter 28 - PuttingWeb It Allservers, Together JVMs, etc.

These messages typically call functions and methods available for application development. Appendix - XML Standards Bodies and Open Specifications </CONTENT> Glossary </ROW> Index

List All of of Figures these entries are contained within a <ROWSET> root element that will permit the entire document to be List of Tables inserted at one time. The following PL/SQL script performs the insert: List of Sidebars

DECLARE insCtx DBMS_XMLSave.ctxType; rows NUMBER; BEGIN insCtx := DBMS_XMLSave.newContext('GLOSSARY'); rows := DBMS_XMLSave.insertXML(insCtx, FileToClob('glossary.xml')); DBMS_XMLSave.closeContext(insCtx); DBMS_OUTPUT.put_line(rows||' of data in glossary have been updated.');


END; / show errors; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Note that even though a num="" attribute is included in the file, this is not used to index the entry. This is because ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang attributes are not mapped by DBMS_XMLSAVE nor by DBMS_XMLSTORE or McGraw-Hill/Osborne © 2004 (600 pages) oracle.xml.sql.query.OracleXMLQuery() for data insertions. The CREATE SEQUENCE command ends up This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with creating the IDemphasis to retrieveonthe item. In order to do the insertion, you need to first set the context to your table, in this XML standards, their usage and best practices. case GLOSSARY. Then you can populate the rows in the table by using insertXML(), which accepts a CLOB that was populated using FiletoCLOB() to load glossary.xml.All that is left to do is to close the context, thus Table of Contents committing the changes. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Linking to the Glossary

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML Now that the glossary is loaded, you just need to be able to associate keywords within <KEYWORD> elements in

Chapter 2 - with Accessing XML with DOM, SAX, JAXB, StAXyou need to query the retrieved FAQ answer for keywords. your FAQs the glossary and insert links. To and do this, Chapter - Transforming XML with with XSLTthe andfollowing XPath code: This is 3done in showAnswer.xsql Chapter 4

- Validating XML with DTDs and XML Schemas

<page> - XML Operations with XQuery <GLOSSARY> Chapter 6 - XML Messaging and RPC with SOAP <xsql:query> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL <![CDATA[ Part II Oracle XML Management DBAs SELECT name, id FROM for glossary Chapter 8 Getting Started with the Oracle XML Database WHERE name in ( Chapter SELECT 9 - Storing XML Data extractValue(value(e), 'KEYWORD') FROM faq p, Chapter 10 -table(xmlsequence(p.extract('/FAQ//KEYWORD'))) Generating and Retrieving XML e Chapter WHERE 11 - Searching p.xmldata.id={@id}) XML Data ]]> </xsql:query> Chapter 12 - Managing the Oracle XML Database </GLOSSARY> Part III - Oracle XML for Java Developers </page> Chapter 13 - Getting Started with Oracle XML and Java Chapter 5

Chapter 14 - Building an XML-Powered Web Site

The query first uses the EXTRACT('/FAQ//KEYWORD') function to get the <KEYWORD> elements in the FAQ. Then using XMLSEQUENCE() and TABLE(), a table is created containing the set of <KEYWORD> elements in Chapter 16 - Developing an XML Gateway Application with SOAP and AQ XMLType. This table is then used to create a collection of values of keywords using EXTRACTVALUE() and only Chapter 17 - Developing XML-Based Reusable Components the NAME and ID for each glossary item are returned by the query. Chapter 15 - Creating a Portal Site with XML and Web Services

Part IV - Oracle XML for C Developers

Chapter 18 you - Getting Started Oracle XML C IDs associated with the keywords found anywhere in the FAQ, as Note that are only tryingwith to retrieve the and set of Chapter 19 by - Building an XML-Managed Application specified the double-slash (//) in front of KEYWORD in p.extract(). Don’t confuse the two IDs specified in the Chapter query: the 20 -one Build in an theXML SELECT Database is the OCI glossary Application ID and the one in the predicate is the FAQ ID. An example of the

actual query outputan is XML-Configured as follows: Chapter 21 - Create High-Performance Transformation Engine Part V - Oracle XML for C++ Developers <GLOSSARY>

Chapter 22 - Getting Started with Oracle XML and C++ <ROWSET> Chapter 23num="1"> - Build an XML Database OCI C++ Application <ROW Chapter <NAME>CLASSPATH</NAME> 24 - Building an XML Data-Retrieval Application Part VI <ID>113</ID> - Oracle XML for PL/SQL Developers

</ROW> Chapter 25 - Getting Started with Oracle XML and PL/SQL </ROWSET> Chapter 26 - Building PL/SQL Web Services </GLOSSARY> Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

In this case, one keyword was found and it has 113 as its ID. Only those keywords that have glossary entries are - XML Standards Bodies and Open Specifications returned.

Appendix Glossary

Index With the keyword IDs retrieved, the remaining task is to create a link in the HTML page. This is done in a template in List of Figures showAnswer.xsl as follows: List of Tables <xsl:template match="KEYWORD"> List<xsl:variable of Sidebars name="content">

<xsl:value-of select="./text()"/> </xsl:variable> <xsl:variable name="glossary"> <xsl:value-of select="/page/GLOSSARY/ROWSET/ROW[NAME/text()= $content]/ID"/> </xsl:variable> <xsl:choose> <xsl:when test="$glossary">


<a href="showGlossary.xsql?id={$glossary}"> <xsl:value-of select="."/> </a> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & </xsl:when> PL/SQL <xsl:otherwise> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <b> McGraw-Hill/Osborne © 2004 (600 pages) <xsl:value-of select="."/> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with </b> emphasis on XML standards, their usage and best practices. </xsl:otherwise> </xsl:choose> Table of Contents </xsl:template> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle the XML Standards Because this and template is complex, we will examine it closely. First, variables are used, because you need to pass in

Chapter 1 - Introducing the ID dynamically to theXML link. These variables are used together. The content variable is simply the keyword. This is Chapter 2 - Accessing XML with DOM, SAX, JAXB,the and StAX that selects the ID. then reused in the glossary variable to create XPath Chapter 3

- Transforming XML with XSLT and XPath

The functional portion XML of the template is aXML choice between two formatting actions. If there is an instance of the Chapter 4 - Validating with DTDs and Schemas

glossary variable, then the test in <xsl:when> returns true and a link is created that passes the ID to a new page, - XML Operations with XQuery showGlossary.xsql, to display the glossary item. If the test fails, then the <xsl:otherwise> section is executed, Chapter 6 - XML Messaging and RPC with SOAP formatting the keyword in bold. This formatting flags these keywords for inclusion in the glossary. Chapter 5 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Displaying the Glossary Definitions - Getting Started with the Oracle XML Database

Chapter 8 Chapter 9

- Storing XML Data

Now that the links to keywords in the FAQ answers are added, we can turn to examine how the page displaying the definition is created. As specified by the following example link, this is once again performed by an XSQL page:

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

http://localhost:8988/xdkus/app_faq/showGlossary.xsql?id=100 Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Theshowglossary.xsql page is very simple, as shown here:

Chapter 13 - Getting Started with Oracle XML and Java

<?xml version="1.0" encoding='UTF-8'?> <?xml-stylesheet type="text/xsl" href="xsl/showGlossary.xsl" ?> Chapter 15 - Creating a Portal Site with XML and Web Services <page id="1" connection="xdkus" xmlns:xsql="urn:oracle-xsql"> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <xsql:query> Chapter 17 - Developing XML-Based Reusable Components <![CDATA[ Part IV - Oracle XML for C Developers SELECT NAME, CONTENT Chapter 18 - Getting Started with Oracle XML and C FROM GLOSSARY Chapter 19WHERE - Building an XML-Managed Application id={@id} Chapter 20 Build an XML Database OCI Application ]]> Chapter 21 Create an </xsql:query> XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers </page> Chapter 14 - Building an XML-Powered Web Site

Chapter 22 - Getting Started with Oracle XML and C++

This page executes one query retrieve the NAME and CONTENT from the GLOSSARY table and apply Chapter 23 -simply Build an XML Database OCItoC++ Application theshowGlossary.xsl stylesheet to convert to HTML. The following is the XML output for CLASSPATH: Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers <?xml version="1.0" encoding="UTF-8"

?>

Chapter <?xml-stylesheet 25 - Getting Started type="text/xsl" with Oracle XML and href="xsl/showGlossary.xsl" PL/SQL ?>

<page 26 id="1"> Chapter - Building PL/SQL Web Services <ROWSET> Chapter 27 - Extending PL/SQL XML Functionality with Java <ROW Chapter 28num="1"> - Putting It All Together <NAME>CLASSPATH</NAME> Appendix - XML Standards Bodies and Open Specifications <CONTENT>The operating system environmental variable that the JVM uses Glossary to find the classes it needs to run applications.</CONTENT> </ROW> List of Figures </ROWSET> List of Tables </page> Index

List of Sidebars

This stylesheet incorporates the same types of transformations discussed previously for showAnswer.xsl in the section“Displaying the FAQ and Answers.”


SearchingOracle the Database FAQs 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Changthe andability Jinyuto Wang No FAQ site would be fully functional without perform text searches. This site uses the Oracle Text 2004 (600 pages) search engine McGraw-Hill/Osborne to search XML either©as content or structurally using XPaths. The index.xsql page combines these text searches with searches to focuses create aonsingle result, evidenced within by the Oracle's followingXML-enabled sample query for all with This category comprehensive guide utilizing XMLas technologies products, emphasis on XML standards, their usage and best practices. Java components that reference DOM:

http://localhost:8988/xdkus/app_faq/index.xsql? Table of Contents pagename=search&search=DOM&cat=all&lang=JAVA Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

This URL links to a new XSQL page, search.xsql, that performs a direct search instead of the browse action Introduction discussed previously. ThisStandards page has all the same elements as list.xsql except that it takes an additional parameter, Part I - Oracle and the XML search,1 and it has an additional predicate, as shown in the following query: Chapter - Introducing XML <xsql:query skip-rows="{@paging-skip}" max-rows="{@paging-max}"> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <![CDATA[ Chapter 3 - Transforming XML with XSLT and XPath SELECT extractValue(value(x),'/FAQ/TITLE') as title, Chapter 4 - Validating XML with DTDs and XML Schemas extractValue(value(x),'/FAQ/@id') as id - XML Operations with XQuery FROM faq x Chapter 6 - XML Messaging and RPC with SOAP where extractValue(value(x),'/FAQ/LANGUAGE/text()') ='{@lang}' Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL and contains(value(x),'{@search}')>0 Part II - Oracle XML Management for DBAs order by id Chapter 8 - Getting Started with the Oracle XML Database ]]> Chapter 9 - Storing XML Data </xsql:query> Chapter 5

Chapter 10 - Generating and Retrieving XML

Chapter 11 the - Searching XML CONTAINS() Data Note that Oracle Text function is now added to the WHERE clause to narrow the selection Chapter - Managing the Oracle process12further. The output fromXML this Database page will again be a list of FAQs that is displayed using the identical paging Part - Oracle for Javaearlier. Developers andIII listing codeXML discussed

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 Scardina, Ben Chang and Jinyu Wang In this chapter by youMark haveV.seen how to create a content management and web publishing application utilizing Oracle McGraw-Hill/Osborne © 2004 (600 pages) including the powerful functionality of the XSQL Servlet. We XML DB 10g features and Oracle XDK components, have combinedThis XML documents, XML and XSLT with JavaScript, SQL XML-enabled to create a compelling comprehensive guideSchema, focuses on utilizing XML Java, technologies withinand Oracle's products, with emphasis on XML standards, their and bestsophisticated practices. application. Using this application as a base, weusage will add more features in Chapter 15, transforming it into a portal site.

Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 15:Database Creating a Portal Site with XML and Web PL/SQL ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang Services McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide on dynamic utilizing XML technologies within Oracle's XML-enabled products, with Web sites are moving from static sets offocuses pages to personalized portals of information. Oracle has obviously emphasis on XML standards, their usage and best practices. recognized this movement, as demonstrated by its sophisticated Oracle Portal product, but what isn’t often realized is that this functionality can be set up on a smaller scale with the XML technology offered in the Oracle XDK and Table ContentsIn this chapter, you will take the FAQ web site put together in the previous chapter and add Portal XMLof database. Oracle Database 10g XML & include SQL—Design, Build & Manage XML Applications in Java, C++ &areas, PL/SQL functionality to it. This will building a login area, dynamic page areas, webC,service and a customization Introduction area. Part I - Oracle and the XML Standards

- Introducing XML Designing the Framework

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter The idea 3 behind - Transforming this portal XML sitewith is toXSLT buildand it toXPath serve the purposes of a development team who can use it as a home

page for documentation, tips,DTDs latestand developments, Chapter 4 all - Validating XML with XML Schemasstatus, and FAQs. This site needs to leverage the previously introduced of modularity so that the site can continually be customized and expanded as needed. This Chapter 5 - concept XML Operations with XQuery framework of a setand of XSQL pages that were called from each other with appropriate parameters to alter Chapter 6 - consists XML Messaging RPC with SOAP behavior display It dynamic content. we are going introduce Chapter 7 or - Putting All Together withWhat XML Pipeline, JSPs,to and XSQL now is how to combine this modularity into single pages whose content is supplied by several XSQL pages firing at once. Part II -container Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

Figure 15-1 shows what the finished site will look like. As you can see, it contains new areas that were not on the Chapter 9 - Storing XML Data FAQ site. Reviewing clockwise, you’ll note a new What’s New area (where the FAQ list was) that has links to the Chapter 10 - Generating and Retrieving XMLten links at a time. Next is a new login area for XDK users, with the latest interesting XML articles, displaying Chapter 11 Searching XML Data requisite Name and Password fields. This area serves as the major user action area of the page and is handled by a Chapter 12XSQL - Managing Oracle Database separate page. the It also will XML be used as a role-specific link area after a successful login. Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter Figure 27 - Extending 15-1: Finished PL/SQL Oracle XML XML Functionality Development with Java Group portal site Chapter 28 - Putting It All Together

Below the -login is the Bodies Hot Topics area,Specifications which appears as a list of links but actually is dynamically generated Appendix XML area Standards and Open

from a web service that is supplied by the Oracle Technology Network (OTN) site. The web service provider, employing a push model, keeps this area current; you will include it on your site by using another XSQL page. Below Index the Hot Topics area is a Hot Links area, which is actually populated by XML content from a file. Finally, the left-hand List of Figures bar serves as a static area that repopulates the center area when its links are clicked with content from queries List of Tables executed by the series of XSQL pages linked here. Glossary

List of Sidebars

You will also be creating an administrative page to facilitate adding users, content, links, etc. This will be a separate role based upon the permission level of the user login, using the page illustrated in Figure 15-2. Note that the login area has specific links for this role and that the left-hand bar now displays administrative tasks, such as inserting or updating a news item, adding links, and approving new users.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4 - Validating XML withGroup DTDs and XML Schemas Figure 5-2: Development portal administrative page Chapter 5

- XML Operations with XQuery

Chapter Turning6to-how XMLthis Messaging web siteand is designed, RPC with SOAP an XSQL container page is used to call additional XSQL pages to populate

the areas, shown following listing index.xsql: Chapter 7 -as Putting It in Allthe Together with XML for Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs <?xml version="1.0"?>

Chapter 8 - Getting Started with the Oracle XML Database <?xml-stylesheet type="text/xsl" media="msie" href="xsl/xdkus.xsl"?> Chapter 9 - Storing XMLtype="text/xsl" Data <?xml-stylesheet media="mozilla" Chapter href="xsl/xdkus_ns.xsl"?> 10 - Generating and Retrieving XML

<page 11 xmlns:xsql="urn:oracle-xsql"> Chapter - Searching XML Data <login> Chapter 12 - Managing the Oracle XML Database <xsql:include-xsql reparse="yes" Part III - Oracle XML for Java Developers

href="login.xsql"/>

</login> Chapter 13 - Getting Started with Oracle XML and Java <nav> Chapter 14 - Building an XML-Powered Web Site <xsql:include-xml href="xml/nav.xml"/> Chapter 15 - Creating a Portal Site with XML and Web Services </nav> <link> Chapter 17 - Developing XML-Based Reusable Components <xsql:include-xml href="xml/link.xml"/> Part IV - Oracle XML for C Developers </link> Chapter 18 - Getting Started with Oracle XML and C <content> Chapter 19 - Building an XML-Managed Application <xsql:if-param name="appname" exists="yes"> Chapter 20 - Build an XML Database OCI Application <xsql:include-xsql reparse="yes" href="app_{@appname}/index.xsql"/> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine </xsql:if-param> Part V - Oracle XML for C++ Developers <xsql:if-param name="appname" exists="no"> Chapter 22 - Getting Started with Oracle XML and C++ <xsql:if-param name="pagename" exists="yes"> Chapter 23 -<xsql:include-xsql Build an XML Database OCI C++ Application href="{@pagename}.xsql"/> reparse="yes" Chapter 24 - Building an XML Data-Retrieval Application </xsql:if-param> Part VI - Oracle XML for PL/SQL Developers <xsql:if-param name="pagename" exists="no"> Chapter 25 -<xsql:include-xsql Getting Started with Oracle XML and PL/SQL href="app_news/news.xsql? reparse="yes" Chapter 26 - Building cat=xdk"/> PL/SQL Web Services Chapter 27</xsql:if-param> - Extending PL/SQL XML Functionality with Java </xsql:if-param> Chapter 28 - Putting It All Together </content> Appendix - XML Standards Bodies and Open Specifications <topic> Glossary <xsql:include-xsql href="app_news/otnnews.xsql"/> Index </topic> List of Figures </page> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

List of Tables

List of Sidebars Examining this listing, you will see the familiar XSLT stylesheet entries to account for the different behavior between

Netscape and Internet Explorer, this distinction being made by using the media attribute of the <?xml-stylesheet?> processing instruction. You then see element groups defining the different areas of the page, as follows: <login> Calls login.xsqlto populate the login area. <nav> Loads nav.xml to populate the left-hand navigation bar. <link> Loads link.xml to populate the Hot Links area.


<content> Calls specify XSQL pages depending on the appname and pagemane input. By default, it calls news.xsqlto populate the What’s New section as well as iteratively calling the paging engine as described in theprevious chapter to create10g pages Oracle Database XMLof&entries. SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

<topic> Calls otnnews.xsql to populate the Hot Topics area.

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) This page demonstrates retrieving content not only from the database but also from a file system and a web service,

This comprehensive focuses onthat utilizing XMLimplement technologies within Oracle's XML-enabled products, with thus demonstrating a broad range guide of functionality you can with this architecture. We will discuss each on XML standards, their usage and best practices. of these forms emphasis of retrieval in the following sections. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & DesigningOracle the Database Static and Dynamic Areas PL/SQL

ISBN:0072229527 Mark Scardina, Ben Chang Jinyu content Wang areas with their data and links. In this discussion, In this section, by you will V. see how to populate theand various a McGraw-Hill/Osborne © 2004 static area is one that gets its content from(600 thepages) local file system, and a dynamic area is one that is populated from a remote source This where the content isguide unknown to on theutilizing web server request time. In this example, this dynamic comprehensive focuses XML at technologies within Oracle's XML-enabled products, with on XML standards, theirservices. usage andFor best practices. content will be emphasis from database queries and web ease of development and the ability to support multiple browsers, all content will be delivered in XML, and the XSQL servlet will apply the appropriate XSLT stylesheet to produce HTML or another device-appropriate markup language such as WML. Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Creating the Dynamic Areas

Introduction

Part I - Oracle and the XML Standards

For this1sample page, there Chapter - Introducing XML are two dynamic areas: What’s New and Hot Topics. The What’s New area is created by retrieving listings from while theand HotStAX Topics area is generated from a web service offered on OTN. Chapter 2 - Accessing XMLthe withdatabase, DOM, SAX, JAXB, Chapter 3

- Transforming XML with XSLT and XPath

Creating- Validating the What’s New Section XML with DTDs and XML Schemas

Chapter 4 Chapter 5

- XML Operations with XQuery This section uses the same techniques introduced in Chapter 14 for retrieving and displaying FAQs. Therefore, the

Chapter 6 is- to XML Messaging and RPCschema with SOAP first task define the database for these news items. Instead of registering an XML schema, the

Chapter 7 schema - Putting will It All with Pipeline, JSPs, and database beTogether created as a XML NEWS table where theXSQL data will be stored relationally but retrieved as XML. Part - Oracle SQL XML Management TheIIfollowing script createsfor thisDBAs table:

Chapter 8

- Getting Started with the Oracle XML Database

CREATE TABLE NEWS( Chapter 9 - Storing XML Data news_id NUMBER PRIMARY KEY, Chapter 10 - Generating and Retrieving XML title VARCHAR2(100), Chapter 11 Searching XML Data notes VARCHAR2(200), Chapter 12 Managing the Oracle XML Database link VARCHAR2(200), Partcreatetime III - Oracle XML for Java Developers DATE, Chapter 13 - Getting Started with Oracle XML and Java category VARCHAR2(10), Chapter 14 Building an XML-Powered Web Site status varchar2(10) Chapter ); 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

CREATE WITH 1; Chapter 17SEQUENCE - Developingnews_seq XML-BasedSTART Reusable Components Part IV - Oracle XML for C Developers

CREATE replace TRIGGER news_insert Chapter 18or - Getting Started with Oracle XML and C BEFORE Chapter 19INSERT - BuildingON an news XML-Managed Application FOR EACH ROW an XML Database OCI Application Chapter 20 - Build BEGIN select news_seq.nextval into :new.news_id from dual; Part V - Oracle XML for C++ Developers END; Chapter 22 - Getting Started with Oracle XML and C++ / Chapter 23 - Build an XML Database OCI C++ Application show errors;

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Chapter 24 - Building an XML Data-Retrieval Application

Part VI you - Oracle XML forto PL/SQL Developers such as title, notes, and a link, these columns are created as Since would want store information

Chapter 25 - Getting Started withcolumn Oracle XML andlimited PL/SQL VARCHAR2. The size of each is also to the number of characters that you can reasonably display in Chapter 26Additionally, - Building PL/SQL Webabout Services a listing. metadata the entry can be added, such as the date, category, and publication status. Chapter PL/SQL XMLIDs Functionality withwhich Java will be useful in creating a link for retrieval of the entry for Finally,27 you- Extending will need to generate for the items, Chapter updating. 28 These - Putting IDs It are All Together generated by the NEWS_SEQ trigger created in the second part of the script. Appendix

- XML Standards Bodies and Open Specifications

Now that the schema is created, we can examine the XSQL page that retrieves its contents. The following fragment does this retrieval from the main index.xsql page:

Glossary Index

<content> List of Figures name="pagename" exists="yes"> List <xsql:if-param of Tables <xsql:include-xsql reparse="yes" href="{@pagename}.xsql"/> </xsql:if-param> <xsql:if-param name="pagename" exists="no"> <xsql:include-xsql reparse="yes" href="app_news/news.xsql?cat=xdk"/> </xsql:if-param> </content>

List of Sidebars

As in the FAQ listing, the first iteration of this section is without a pagename,so the first xsql:if-param> will be


skipped and the second one executed by calling the app_news/index.xsql page with a category parameter of xdk. Taking a look at this page in the following listing, you’ll see that it has its own stylesheet, news.xsl, to handle the specific formatting of the XML. It 10g also XML uses&the xdkus database theApplications XSQLConfig.xml file C, and calls& Oracle Database SQL: Design, Buildconnection & Manage in XML in Java, C++ the same Paging.java PL/SQLclass used for the FAQs, located in the package oracle.xml.sample.xsql.portal. ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <?xml version="1.0"?> McGraw-Hill/Osborne © 2004 (600 pages) <?xml-stylesheet type="text/xsl" href="xsl/news.xsl"?> <page id="1" title="News XDK" connection="xdkus" xmlns:xsql="urn:oracle-xsql"> This comprehensiveof guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. <xsql:action handler="oracle.xml.sample.xsql.portal.Paging" rows-per-page="10" url-pagename="index.xsql?cat={@cat}&"> <![CDATA[ Table of Contents SELECT Oracle Database 10g XML & count(1) SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL FROM news Introduction where category='{@cat}' Part I - Oracle and the XML Standards ]]> Chapter 1 - Introducing XML </xsql:action> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <xsql:query rowset-element="NEWS" row-element="NEWS_ITEM" Chapter 3 - Transforming XML with XSLT and XPath skip-rows="{@paging-skip}" max-rows="{@paging-max}"> Chapter 4 - Validating XML with DTDs and XML Schemas <![CDATA[ Chapter 5 - XML Operations with XQuery SELECT news_id as id,title,link,status, Chapter 6 - XML MessagingTO_CHAR(createtime,'Month and RPC with SOAP DD,YYYY') as time, notes as note Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL FROM news Part II - Oracle XML Management for DBAs where category='{@cat}' Chapter 8 - Getting Started with the Oracle XML Database ORDER BY createtime DESC Chapter 9 - Storing ]]> XML Data Chapter 10 - Generating and Retrieving XML </xsql:query> Chapter </page> 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database

Taking look atXML the for queries, the first one simply generates the overall count of items. The second one uses the Part III -aOracle Java Developers capability the XML SQL Utility to encapsulate the result in XML. The following is an example result returned in Chapter 13 of - Getting Started with Oracle XML and Java XML:

Chapter 14 - Building an XML-Powered Web Site

<page> Chapter 15 - Creating a Portal Site with XML and Web Services … Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <NEWS> Chapter 17 - Developing XML-Based Reusable Components <NEWS_ITEM num="4"> Part IV - Oracle XML for C Developers <ID>124</ID> <TITLE>XDK eSeminar</TITLE> Chapter 19 - Building an XML-Managed Application <LINK>http://ilearning.oracle.com/ilearn/en/learner/jsp/ Chapter 20 - Build an XML Database OCI Application offering_details_home.jsp?classid=58377231</LINK> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <STATUS>new</STATUS> Part V - Oracle XML for C++ Developers <TIME>July 05,2003</TIME> Chapter 22 - Getting Started with Oracle XML and C++ <NOTE>Overview of the XML standards support by the Oracle XDK and an Chapter 23 - Build an XML Database OCI in-depth discussion on C++ the Application XML features.</NOTE> Chapter 24 Building an XML Data-Retrieval Application </NEWS_ITEM> Part VI - Oracle XML for PL/SQL Developers </NEWS> Chapter 25 - Getting Started with Oracle XML and PL/SQL … Chapter 26 - Building PL/SQL Web Services </page> Chapter 18 - Getting Started with Oracle XML and C

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

This result- isXML then processed by the stylesheet to create the entry, as shown in this fragment: Appendix Standards Bodies andnews.xsl Open Specifications <xsl:for-each select="page/NEWS/NEWS_ITEM"> Glossary <tr> Index width="10" align="right" valign="top"> List <td of Figures List of<img Tablessrc="images/r_arrow.gif" width="10" height="10"/> List </td> of Sidebars

<td colspan="2" width="600" align="left" class="fbox"> <a href="{LINK}" target="_new" class="fbox"> <xsl:value-of select="TITLE"/></a> <xsl:if test="STATUS[text()!='']"> <img src="/xdkus/images/{STATUS}.gif"/> </xsl:if> <xsl:text>(</xsl:text><xsl:value-of select="TIME"/><xsl:text>)</xsl:text> </td>


</tr> <tr> <td width="10"><xsl:text> </xsl:text></td> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <td colspan="2" PL/SQL width="600" class="footnt"> <xsl:value-of ISBN:0072229527 by Mark select="NOTE"/> V. Scardina, Ben Chang and Jinyu Wang </td> McGraw-Hill/Osborne © 2004 (600 pages) </tr> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with </xsl:for-each> emphasis on XML standards, their usage and best practices. Of note is the <xsl:if> element, which tests for a value in the <STATUS> element. If found, an icon corresponding

Table Contents to itsofvalue is displayed. This is accomplished by using {STATUS} in the XPath to construct the name of the image. Oracle Database 10g XML result, & SQL—Design, Build &beManage XML Applications C, C++ & PL/SQL the HREF Looking at our example new.gif would chosen. This techniquein is Java, also used to construct Introduction attribute for the link to the news item. Part I - Oracle and the XML Standards

Notice 1that- the XSL statement Chapter Introducing XML Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <img src="/xdkus/images/{STATUS}.gif"/> Chapter 3

- Transforming XML with XSLT and XPath

is equivalent to Chapter 4 - Validating XML with DTDs and XML Schemas <img> 5 Chapter

- XML Operations with XQuery

<xsl:attribute name="src"> Chapter 6 - XML Messaging and RPC with SOAP <xsl:text>/xdkus/images/</xsl:text><xsl:value-of select="STATUS"/> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle<xsl:text>.gif</xsl:text> XML Management for DBAs

</xsl:attribute> Chapter 8 - Getting Started with the Oracle XML Database </img> Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

but is easier to write, read, and maintain.

Chapter 11 - Searching XML Data

Chapter - Managing Oracle Database Finally,12 different CSS the classes areXML used to vary the formatting and text size of the <TITLE> and <NOTE> values, as Part III -inOracle XML for Java Developers shown the stylesheet, where the class attribute of some <td> elements takes the values fbox and footn.

Chapter 13 - Getting Started with Oracle XML and Java

Creating the Hot AreaWeb Site Chapter 14 - Building anTopics XML-Powered Chapter 15 - Creating a Portal Site with XML and Web Services

Up to this point, the content on the site has been supplied locally. Web services provide the advantage of supplying changing content without requiring maintenance on your part. For this area, you’ll use a web service provided by Chapter 17 - Developing XML-Based Reusable Components OTN as an XML document sent as the payload of a SOAP message. This XML service, while of a Really Simple Part IV - Oracle XML for C Developers Syndication (RSS) type, has a Web Services Description Language (WSDL) service description available at Chapter 18 - Getting Started with Oracle XML and C http://otn.oracle.com/ws/oracle.otn.ws.news.OTNNews?WSDL. These services are available from a variety of Chapter 19 - Building an XML-Managed Application web sites, from retailers such as amazon.com to personal blogs. Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 20 - Build an XML Database OCI Application

Chapter To connect 21 - Create this service an XML-Configured to the site, youHigh-Performance need to create aTransformation Java class—usually Enginecalled a stub, or a proxy—to generate Part the Vrequest - Oracle and XML receive for C++ theDevelopers XML response that can then be transformed into HTML by a stylesheet. This class,

acting as needs to call the method available at oracle.otn.ws.news.OTNNews. You can Chapter 22 a- SOAP Gettingclient, Started with Oracle XMLgetRSS and C++ set up an handler to invoke the class from within an XSQL page. In this case, the following Chapter 23 XSQL - Build custom an XML action Database OCI C++ Application section24 from the main page calls the otnnews.xsqlpage, invoking the service: Chapter - Building anindex.xsql XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers <topic>

Chapter <xsql:include-xsql 25 - Getting Started href="app_news/otnnews.xsql"/> with Oracle XML and PL/SQL

</topic> Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

Theotnnews.xsqlpage is very simple, as shown in the following section, but needs to be its own page in order for the otnnews.xsl stylesheet to be applied:

Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

<?xml version="1.0"?> Glossary <?xml-stylesheet type="text/xsl" href="xsl/otnnews.xsl"?> Index <xsql:action xmlns:xsql="urn:oracle-xsql" handler="oracle.xml.sample.xsql.portal.OTNNewsStub"/>

List of Figures List of Tables

List Sidebars the OTNNewsStub.javaclass, you need to use the Oracle SOAP implementation that is part of the To of implement

XDK. The following are the code fragments. First, you need to initialize an HTTP connection: public OTNNewsStub() { m_httpConnection = new OracleSOAPHTTPConnection();} Next, you need to set up the connection session and properties: public void setMaintainSession(boolean maintainSession)


{ m_httpConnection.setMaintainSession(maintainSession); } public boolean getMaintainSession() Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & { PL/SQL return m_httpConnection.getMaintainSession(); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang } public voidMcGraw-Hill/Osborne setTransportProperties(Properties props) © 2004 (600 pages) { This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with m_httpConnection.setProperties(props); } best practices. emphasis on XML standards, their usage and public Properties getTransportProperties() { Table of Contents return m_httpConnection.getProperties(); } Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - you Oracle andtothe XML the Standards Then, need create method to invoke the web service:

Chapter 1

- Introducing XML public void getRss(Node root)

Chapter { 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 - Transforming XML= with XSLT and XPath String resultVal null; Chapter try 4

- Validating XML with DTDs and XML Schemas

Chapter {5

- XML Operations with XQuery

Chapter 6 - XML Messaging RPC with SOAP of the service //Initialize theand URL location Chapter URL 7 -endpointURL Putting It All Together = newwith XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management URL("http://otn.oracle.com/ws/oracle.otn.ws.news.OTNNews"); for DBAs

//Build theStarted call. Chapter 8 - Getting with the Oracle XML Database Call call =XML new Call(); Chapter 9 - Storing Data //Associate Chapter 10 - Generatingconnection and Retrievingwith XML call call.setSOAPTransport(m_httpConnection); Chapter 11 - Searching XML Data // the call (i.e. targetObjectURI, methodName, etc.) Chapter 12configure - Managing the Oracle XML Database call.setTargetObjectURI("oracle.otn.ws.news.OTNNews"); Part III - Oracle XML for Java Developers call.setMethodName("getRss"); call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); Chapter 14 - Building an XML-Powered Web Site //Make the call Chapter 15 - Creating a Portal Site with XML and Web Services Response response = call.invoke(endpointURL, ""); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ if (!response.generatedFault()) Chapter 17 - Developing XML-Based Reusable Components { Part IV - Oracle XML for C Developers Parameter result = response.getReturnValue(); Chapter 18 - Getting Started with Oracle XML and C resultVal = (String)result.getValue(); Chapter 19 Building an XML-Managed Application DOMParser p=new DOMParser(); Chapter 20 Build an XML Database OCI Application p.parse(new ByteArrayInputStream(returnVal.getBytes())); Chapter 21 Create an XML-Configured High-Performance XMLDocument doc = p.getDocument(); Transformation Engine Part V - Oracle XML for C++ Developers appendCopyOfSecondaryDocument(root, doc); Chapter // 22 -return Getting Started with Oracle XML and C++ doc.getDocumentElement(); Chapter } 23 - Build an XML Database OCI C++ Application else { } Chapter 24…- Building an XML Data-Retrieval Application catch { … )XML for PL/SQL Developers Part VI - Oracle Chapter 13 - Getting Started with Oracle XML and Java

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Finally, you need to connect up the XSQL plumbing to call the service and return the data:

Chapter 26 - Building PL/SQL Web Services

public handleAction(Node root)with Java Chapter 27void - Extending PL/SQL XML Functionality { 28 - Putting It All Together Chapter //Initialize theBodies returned data Appendix - XML Standards and Open Specifications String m_title=null; String m_question=null; Index String m_answer=null; List of Figures String m_category=null; List of Tables String m_language=null; List of Sidebars String m_path = null; if(getPageRequest().getRequestType().equals("Servlet")) { // Get the XSQL Page Request XSQLServletPageRequest xspr = (XSQLServletPageRequest)getPageRequest(); HttpServletRequest req = xspr.getHttpServletRequest(); // Call the Web Service getRss(root); } Glossary


} Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

Upon invoking PL/SQL getRSS(), an XML document is returned, as shown in the following listing:

<rss version="0.91"> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <channel> McGraw-Hill/Osborne © 2004 (600 pages) <title>Oracle Technologyguide News</title> This comprehensive focuses on utilizing XML technologies within Oracle's XML-enabled products, with <link>http://otn.oracle.com</link> emphasis on XML standards, their usage and best practices. <description>Oracle Technology News</description> <language>en-us</language> Table of Contents <copyright>Copyright 2002, Oracle Corporation. All rights reserved</copyright> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <managingEditor>otn_us@oracle.com</managingEditor> Introduction <webmaster>otn_us@oracle.com</webmaster> Part I - Oracle and the XML Standards <textinput> Chapter 1 - Introducing XML <title>Search OTN</title> Chapter 2 - Accessing XML withyour DOM, search SAX, JAXB, and StAX <description>Enter terms</description> Chapter 3 - Transforming XML with XSLT and XPath <name>keyword</name> Chapter 4 - Validating XML with DTDs and XML Schemas <link>http://otn.oracle.com/ws/searchwrapper</link> Chapter 5 - XML Operations with XQuery </textinput> Chapter 6 - XML Messaging and RPC with SOAP <image> Chapter <title>Oracle 7 - Putting It AllTechnology Together withNetwork</title> XML Pipeline, JSPs, and XSQL Part II <url>http://otn.oracle.com/otn116x65_center.gif</url> - Oracle XML Management for DBAs <link>otn.oracle.com</link> Chapter 8 - Getting Started with the Oracle XML Database <width>116</width> Chapter 9 - Storing XML Data <height>65</height> Chapter 10 - Generating and Retrieving XML <description>Developer news from Oracle Technology Network.</description> Chapter 11 - Searching XML Data </image> Chapter 12 - Managing the Oracle XML Database num="1"> Part<item III - Oracle XML for Java Developers <title>New Oracle Portal Development Kit (PDK)</title> Chapter 13 - Getting Started with Oracle XML and Java <link>http://otn.oracle.com/products/iportal/files/pdk105ea/index.html</link> Chapter 14 - Building an XML-Powered Web Site <description><a href=\"/products/iportal/index2.htm? Chapter 15 - Creating a Portal Site with XML and Web Services Info&/products/iportal/files/pdk105ea/index.html\">The Oracle Portal Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Development Kit (PDK)</a> is the pre-eminent resource for developing Chapter 17 - Developing XML-Based Reusable Components portlets. It contains utilities and articles that assist in every step Part IV - Oracle XML for C Developers of portlet development. This release of the PDK illustrates how to extend Chapter 18 -<a Getting Started with Oracle XML and C the href=\"/products/iportal/\"> Oracle Portal</a> and includes the Chapter 19 Building an XML-Managed Application JPDK utilities for building portlets in Java.</description> Chapter 20 - Build an XML Database OCI Application </item> Chapter ... 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers </channel> Chapter 22 - Getting Started with Oracle XML and C++ </rss> Chapter 23 - Build an XML Database OCI C++ Application

For the24 purpose of this site, Data-Retrieval you are only interested in displaying the title and link for a subset of items. Therefore, a Chapter - Building an XML Application veryVIsimple stylesheet, otnnews.xsl, is all that is required: Part - Oracle XML for PL/SQL Developers <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> Chapter 25 - Getting Started with Oracle XML and PL/SQL <xsl:template Chapter 26 - Buildingmatch="/"> PL/SQL Web Services <top_topics> Chapter 27 - Extending PL/SQL XML Functionality with Java <topic name="OTN News"> Chapter 28 - Putting It All Together <link -uri="{rss/channel/item[1]/link}"><xsl:value-of Appendix XML Standards Bodies and Open Specifications select="rss/channel/item[1]/title"/></link> <link uri="{rss/channel/item[2]/link}"><xsl:value-of Index select="rss/channel/item[2]/title"/></link> List of Figures </topic> List of Tables </top_topics> List of Sidebars </xsl:template> </xsl:stylesheet> Glossary

As you can see, this stylesheet retrieves the values of <title> and <link> of the first two items and creates a small XML document that is returned to the calling index.xsql page to be converted into HTML by the included topic.xsl that creates the Hot Topics area. These links are created in the same way as the News items previously discussed.


Creating the Static Areas For the portal page, there are two10g areas that will beDesign, populated from XML files: theApplications left-hand navigation bar, which&is Oracle Database XML & SQL: Build & Manage XML in Java, C, C++ PL/SQL a constant across pages, and the Hot Links area, a set of links that is easy to update and maintain. by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

To retrieve XML from a file on the local system running the XSQL servlet, you simply use the <xsql:include-xml> McGraw-Hill/Osborne © 2004 (600 pages) element, as in This the following example from index.xsql: comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. <nav> <xsql:include-xml href="xml/nav.xml"/> </nav> Table of Contents <link> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <xsql:include-xml href="xml/link.xml"/> Introduction </link> Part I - Oracle and the XML Standards Chapter 1

- Introducing XML Each of these files contains <link> elements made up of the URI, descriptive text, and optional status, as follows:

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 4

- Validating XML with DTDs and XML Schemas

<link status="new" uri="/xdkus/app_release/index.xsql?pagename=beta&rel=beta"> Chapter 3 - Transforming XML with XSLT and XPath XDK v10 Beta</link> Chapter 5 - XML Operations with These links are transformed intoXQuery HTML by associated stylesheets that extract each part. Here is a simple template Chapter - XML Messaging and RPC with SOAP section6that performs this transformation: Chapter 7 - Putting select="link"> It All Together with XML Pipeline, JSPs, and XSQL <xsl:for-each Part II -bgcolor="#f7f7e7"> Oracle XML Management for DBAs <tr

Chapter <td> 8

- Getting Started with the Oracle XML Database

Chapter 9 src="/xdkus/images/r_arrow.gif" - Storing XML Data <img width="10" height="10"/> Chapter 10 - Generating and Retrieving XML <xsl:choose> Chapter 11 - Searching XML Data <xsl:when test="./@uri"> Chapter <a 12href="{./@uri}" - Managing the Oracleclass="navs"> XML Database Part III <xsl:value-of - Oracle XML for Java select="./text()"/> Developers

</a> Chapter 13 - Getting Started with Oracle XML and Java <xsl:if test="@status"> Chapter 14 - Building an XML-Powered Web Site <img src="/xdkus/images/{@status}.gif"/> Chapter 15 - Creating a Portal Site with XML and Web Services </xsl:if> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ </xsl:when> Chapter 17 - Developing XML-Based Reusable Components Part<xsl:otherwise> IV - Oracle XML for C Developers

<xsl:value-of select="./@name"/> </xsl:otherwise> Chapter 19 - Building an XML-Managed Application </xsl:choose> Chapter 20 - Build an XML Database OCI Application </td> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine </tr> Part V - Oracle XML for C++ Developers </xsl:for-each> Chapter 18 - Getting Started with Oracle XML and C

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 this - Building an XML Data-Retrieval Note that template is conditional basedApplication upon finding a uri attribute in the link element and turning it into an Part VI href - Oracle XML PL/SQL Developers HTML using thefor link’s text value as the new HTML href text. As before, an image is optionally added based

Chapter upon finding 25 - Getting a status Started attribute. with The Oracle <xsl:otherwise> XML and PL/SQLelement selects the value of the name attribute that could be

used as26subdivision text. Web Services Chapter - Building PL/SQL Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Adding the Portal Functionality PL/SQL

ISBN:0072229527 by Mark V. Scardina, Chang and Jinyu Wang The characteristic that separates a Ben portal site from a normal web site is its ability to be personalized for the specific 2004 (600 pages) user. This can McGraw-Hill/Osborne be done by creating a© login area that, once successfully accessed, retrieves a profile that results in a version of the site is customized to the user.onInutilizing this section, we will define that customization based on roles. with Thisthat comprehensive guide focuses XML technologies within Oracle's XML-enabled products,

emphasis on XML standards, their usage and best practices.

To set up this personalization feature, you need to first define a database schema for the user information, create a form to sign up new users, create an administrative page to approve users and assign roles, and create a login area Table of Contents for users to sign in. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Creating the User Schema

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

To define the database schema, you first must determine what information is required to identify the user uniquely - Accessing XML with DOM, SAX, JAXB, and StAX and what information that you want to maintain for each user. For this application, you will store the following Chapter 3 - Transforming XML with XSLT and XPath information for each user: Chapter 2 Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 - XML Operations with XQuery user_id Generated primary key Chapter 6

- XML Messaging and RPC with SOAP

uname User login Chapter 7 - Putting It Allname Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

first_name User’s first name

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 - Storing XMLlast Data last_name User’s name Chapter 10 - Generating and Retrieving XML

email e-mail address Chapter 11 -User’s Searching XML Data Chapter 12 - Managing the Oracle XML Database

password User’s password

Part III - Oracle XML for Java Developers

Chapter 13User’s - Getting with Oracle XML and Java role roleStarted (user, admin, manager, developer) Chapter 14 - Building an XML-Powered Web Site

status approval Chapter 15 - User’s Creating a Portal status Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

register_date User’s registration date

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle Date XML for C Developers last_visit of user’s last visit

Chapter 18 - Getting Started with Oracle XML and C

comments Notes the user Chapter 19 - Building an regarding XML-Managed Application Chapter 20 - Build an XML Database OCI Application

All of these values can be stored in a single USERS table because there is no data that requires nesting. You can create this table by using the following SQL script:

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

CREATE TABLE USERS( user_id VARCHAR2(20) PRIMARY KEY, Chapter 23 - Build an XML Database OCI C++ Application uname varchar2(20), Chapter 24 - Building an XML Data-Retrieval Application first_name VARCHAR2(100), Part VI - Oracle XML for PL/SQL Developers last_name VARCHAR2(100), Chapter 25 - Getting Started with Oracle XML and PL/SQL email VARCHAR2(200), Chapter 26 - Building PL/SQL Web Services password varchar2(20), Chapter 27 Extending PL/SQL XML Functionality with Java role VARCHAR2(10), Chapter 28 -varchar2(20), Putting It All Together status Appendix - XML Standards register_date DATE,Bodies and Open Specifications Glossary last_visit date, Index comments varchar2(4000) ); of Figures List ALTER TABLE USERS List of Tables ADD CONSTRAINT CK_ROLE List of Sidebars CHECK (role IN ('user', 'admin', 'manager', 'developer')); Chapter 22 - Getting Started with Oracle XML and C++

CREATE SEQUENCE users_seq START WITH 100; CREATE or replace TRIGGER users_insert BEFORE INSERT ON users FOR EACH ROW BEGIN


select users_seq.nextval into :new.user_id from dual; select sysdate into :new.register_date from dual; select 'pending' into :new.status from dual; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & END; PL/SQL / ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang show errors; McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Note that you need to define a trigger to handle the following: emphasis on XML standards, their usage and best practices. Inserting the user_id from a sequence Table of Contents

registration date& and time from Build the database date and time OracleThe Database 10g XML SQL—Design, & Managecurrent XML Applications in Java, C, C++ & PL/SQL Introduction

Addingpending into the status column as an initial value

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Creating the Login - Accessing XML withArea DOM, SAX, JAXB, and StAX

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

Before discussing how to create the user application form, we will discuss how to add the login area to the main - Validating XML with DTDs and XML Schemas page. Referring to this page, you see the following section that adds the area:

Chapter 4 Chapter 5

- XML Operations with XQuery

<login> - XML Messaging and RPC with SOAP <xsql:include-xsql reparse="yes" href="login.xsql"/> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL </login> Chapter 6

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 - Storing XML Data to create the box and provide the functionality. This is the most sophisticated XSQL This element calls login.xsql Chapter 10 - Generating and Retrieving file presented, so we will examine it inXML detail: Chapter - Searching XML Data <?xml 11 version="1.0"?> Chapter 12 - Managing the Oracle XML Database <?xml-stylesheet type="text/xsl" media="msie" href="xsl/login.xsl"?> Part III - Oracle XML fortype="text/xsl" Java Developers <?xml-stylesheet

media="mozilla" href="xsl/login_ns.xsl"?>

Chapter - Getting Started with Oracle XML and Java <page 13 connection="xdkus" xmlns:xsql="urn:oracle-xsql"> Chapter 14 - Building an name="action" XML-Powered Web Site <xsql:if-param equals="login"> Chapter 15 - Creating a Portal Site with XML and Web Services <xsql:set-session-param name="usr" ignore-empty-value="no">select uname Chapter from 16 - Developing users an XML Gateway Application with SOAP and AQ

where uname='{@logusr}' and password='{@passwd}'</xsql:set-session-param> Chapter 17 - Developing XML-Based Reusable Components Part</xsql:if-param> IV - Oracle XML for C Developers

<xsql:if-param name="action" Chapter 18 - Getting Started with Oracle XMLequals="logout"> and C <xsql:set-session-param name="usr" value=" "/> Chapter 19 - Building an XML-Managed Application </xsql:if-param> Chapter 20 - Build an XML Database OCI Application <xsql:if-param name="usr" High-Performance not-equals=" "> Chapter 21 - Create an XML-Configured Transformation Engine <xsql:query> Part V - Oracle XML for C++ Developers select first_name ||', '|| last_name as name, role from users Chapter 23 - Build an XML Database OCI C++ Application where uname='{@usr}'</xsql:query> Chapter 24 - Building an XML Data-Retrieval Application <xsql:dml commit="yes"> Part VI - Oracle XML for PL/SQL Developers update users set last_visit=sysdate where uname='{@usr}' Chapter 25 - Getting Started with Oracle XML and PL/SQL </xsql:dml> Chapter 26 - Building PL/SQL Web Services <xsql:set-session-param name="role" ignore-empty-value="no"> Chapter select 27 - Extending role PL/SQL XML Functionality with Java Chapter from 28 - Putting usersIt All Together Appendixwhere - XMLuname='{@usr}'</xsql:set-session-param> Standards Bodies and Open Specifications Glossary </xsql:if-param> Index <xsql:if-param name="usr" exists="no"> List of Figures <backtohome/> List </xsql:if-param> of Tables name="usr"/> List <xsql:include-param of Sidebars <xsql:include-param name="action"/> <xsql:include-xml href="xml/nav_login.xml"/> </page> Chapter 22 - Getting Started with Oracle XML and C++

This page has a number of conditional sections based upon both the way it is called and the parameters passed. The first set of conditions defines a Login and Logout action. Intrinsic in handling a Login action is the ability to set up a session. This is accomplished using the <xsql:set-session-param> element and insuring that a unameis return by setting the attribute, ignore-empty-value,equal to no. This initializes usr, which then satisfies the


conditionnot-equals=" " permitting the query inside<xsql:query> to be executed as well as inserting the current date using the <xsql:dml> element content. Finally, the nav_login.xml page is included as follows: <nav_bar> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <category name="admin"> ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang <linkbyuri="/xdkus/admin/index.xsql?pagename=news">Administration</link> © 2004 (600 pages) <linkMcGraw-Hill/Osborne uri="/xdkus/app_document/doc.xsql?pagename=xdk_perf">Performance test</link> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML standards, their usage and best practices. <linkemphasis uri="/xdkus/app_customer/index.xsql">Customer Reference</link> <link status="new" uri="/xdkus/app_document/doc.xsql? pagename=schemamapping">SchemaMapping</link> Table of Contents </category> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <category name="manager"> Introduction Part I -<link Oracle uri="/xdkus/app_document/doc.xsql?pagename=xdk_perf">Performance and the XML Standards Test</link> Chapter 1 - Introducing XML <link uri="/xdkus/app_customer/index.xsql">Customer Reference</link> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <link status="new" uri="/xdkus/app_document/doc.xsql? Chapter 3 - Transforming XML with XSLT and XPath pagename=schemamapping">SchemaMapping</link> Chapter 4 - Validating XML with DTDs and XML Schemas </category> Chapter 5 - XML Operations with XQuery <category name="user"> Chapter 6 - XML Messaging and RPC with SOAP <link uri="/xdkus/app_customer/index.xsql">Customer Reference</link> Chapter 7 Putting It All Together with XML Pipeline, JSPs, and XSQL <link uri="/xdkus/app_document/doc.xsql?pagename=xdk_perf">Performance Part II -Test</link> Oracle XML Management for DBAs Chapter 8 - Getting Started with the Oracle XML Database </category> Chapter 9 - Storing XML Data <category name="developer"> Chapter <link 10 - Generating and Retrieving XML uri="/xdkus/app_document/doc.xsql?pagename=xdk_perf">Performance Chapter 11 - Searching Test</link> XML Data <link uri="/xdkus/app_customer/index.xsql">Customer Reference</link> Chapter 12 - Managing the Oracle XML Database </category> Part III - Oracle XML for Java Developers </nav_bar> Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

The stylesheet declared at the top of the Login page then selects the proper category based upon the role specified in the name attribute of the <category> element. This illustrates how you can mix file-based dynamic content with Chapter 16 - Developing an XML Gateway Application with SOAP and AQ database content. Obviously, these roles and links could also be retrieved from the database. Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 17 - Developing XML-Based Reusable Components

Part IV - the Oracle XML for Cpage Developers Finally, Login XSQL handles the conditions of Logout by nulling usr, which returns the user to the home

Chapter 18well - Getting Started with Oracle andlogin C page, as as conditions where partsXML of the are missing. Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

Creating the User Application Form

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part - Oracle XML for C++itDevelopers TheVXSQL Servlet makes easy to create web forms that are designed for submitting data into a database. The full

Chapter 22input - Getting with Oracle C++ the finished form displayed within the center window. range of typesStarted is available. FigureXML 15-3and shows Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars

Figure 15-3: User application form This form is created by passing the name of the XSQL page to index.xsql and refreshing the page. In this case, the


URL is http://localhost:8988/xdkus/index.xsql?pagename=register. Referring to the code in the index.xsqlpage, the existence of the pagename parameter causes its value to be used Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & to identify the XSQL page that is to be loaded. In this case, it is register.xsql, which is as follows: PL/SQL <?xml version="1.0"?> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <page id="1" title="XDK User Registration" connection="xdkus" McGraw-Hill/Osborne © 2004 (600 pages) xmlns:xsql="urn:oracle-xsql"> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <xsql:include-xml emphasis on href="xml/register.xml"/> XML standards, their usage and best practices. </page> Table of Contents

This page includes an XHTML fragment—located in the document named register.xml—that adds the form and its

Oracle Database 10gThis XMLform & SQL—Design, Buildmethod & Manage Applications in Java, C, C++the & PL/SQL associated fields. uses the POST andXML another XSQL page to submit data as follows: Introduction

<form method="post" action="registerAction.xsql" name="adduser"> <table width="60%" border="0"> Chapter 1 - Introducing XML <tr> <td>First Name:</td> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <td><input type="text" name="FIRST_NAME" size="70"/></td> Chapter 3 - Transforming XML with XSLT and XPath </tr> Chapter 4 - Validating XML with DTDs and XML Schemas <tr><td>Last Name:</td> Chapter 5 XML Operations with XQuery <td><input type="text" name="LAST_NAME" size="70"/></td> Chapter 6 - XML Messaging and RPC with SOAP </tr> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL <tr><td>Role:</td> Part II - Oracle XML Management for DBAs <td><select name="ROLE"> Chapter <option 8 - Getting value="user" Started with the selected="selected">XDK Oracle XML Database User</option> <option value="manager">XDK Management User</option> Chapter 9 - Storing XML Data value="admin">XDK Chapter <option 10 - Generating and Retrieving XML Administrator</option> <option value="developer">XDK Development User</option> Chapter 11 - Searching XML Data </select> Chapter 12 - Managing the Oracle XML Database </td> Part III - Oracle XML for Java Developers </tr> Chapter 13 - Getting Started with Oracle XML and Java <tr><td>Email:</td> Chapter 14 - Building an XML-Powered Web Site <td><input type="text" name="EMAIL" size="70"/></td> Chapter 15 - Creating a Portal Site with XML and Web Services </tr> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <tr><td valign="top">Comments:</td> Chapter 17 - Developing XML-Based Reusable Components <td><textarea name="COMMENTS" cols="55" rows="5">Please tell us more Part IV - Oracle XML for C Developers about how you use XML and the Oracle XDK...</textarea> Chapter 18 - Getting Started with Oracle XML and C </td> Chapter 19 - Building an XML-Managed Application </tr> Chapter 20 - Build an XML Database OCI Application <tr><td valign="top" height="8"> </td> Chapter 21 Create an XML-Configured High-Performance Transformation Engine <td height="8"><input type="submit" name="Submit" value="Submit"/></td> Part</tr> V - Oracle XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++ </table> Chapter 23 - Build an XML Database OCI C++ Application </form> Part I - Oracle and the XML Standards

Chapter 24 - Building an XML Data-Retrieval Application

ThisVIform usesXML a combination <input> and <select> elements to build a set of parameters to pass to the Part - Oracle for PL/SQLof Developers registerAction.xsql page. with This Oracle page handles insert into the database as follows: Chapter 25 - Getting Started XML andthe PL/SQL <?xml 26 version="1.0"?> Chapter - Building PL/SQL Web Services <?xml-stylesheet type="text/xsl" media="mozilla" href="xsl/registerAction.xsl"?> Chapter 27 - Extending PL/SQL XML Functionality with Java <page 28 title="Add XDK User" connection="xdkus" xmlns:xsql="urn:oracle-xsql"> Chapter - Putting It Allnew Together <xsql:insert-request date-format="MM/dd/yyyy" table="USERS" Appendix - XML Standards Bodies and Open Specifications Glossary

transform="xsl/generateXML.xsl"/>

</page> Index List of Figures

This XSQL page has two stylesheet references. The registerAction.xslstylesheet simply transforms the output as

List Tables hasofbeen done previously. However, the following generateXML.xsl stylesheet performs a different function. When List of Sidebars used as part of the <xsql:insert-request> element, it creates the XML document from the form’s data passed as

parameters and passes it into a SQL query as follows: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="/"> <ROWSET> <ROW>


<xsl:copy-of select="request/parameters//*[name() !='Submit' and name() !='table' and name() !='keycolmn']"/> </ROW> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & </ROWSET>PL/SQL </xsl:template> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <xsl:template match="node()|@*"> McGraw-Hill/Osborne © 2004 (600 pages) <!– Copy the current node –> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <xsl:copy> emphasis on XML standards, their usage and best practices. <!– Including any attributes it has and any child nodes –> <xsl:apply-templates select="@*|node()"/> Table of Contents </xsl:copy> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL </xsl:template> Introduction </xsl:stylesheet> Part I - Oracle and the XML Standards

Chapter - Introducing XML After an1 application is successfully submitted, it is useful to send an e-mail acknowledgement. Since this depends Chapter - Accessing XML with DOM, SAX, andan StAX upon a2successful database insertion, youJAXB, can use INSERT TRIGGER command to generate not only a Chapter notification 3 - to Transforming the user butXML alsowith a copy XSLTtoand theXPath administrator to act upon. The Oracle database provides the

UTL_SMTP package, XML which canDTDs be used to write PL/SQL procedures to send e-mails inside a PL/SQL trigger. The Chapter 4 - Validating with and XML Schemas procedure included in thewith provided sample code for this chapter. The following is the SQL that can be added to Chapter 5 -isXML Operations XQuery the previously defined users_insert trigger: Chapter 6 - XML Messaging and RPC with SOAP Chapter sendEmail_pkg.send_email('smtp.foo.com', 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle 'xdkadmin@foo.com', XML Management for'XDK DBAs Product

Management<xdkadmin@foo.com>',

Chapter 8:new.email, - Getting Started with the Oracle XML Database

null, 'XDK.US Registration', Chapter 9'John.Smith@foo.com', - Storing XML Data 'Thanks forand your registration. We will review the request and Chapter 10 - Generating Retrieving XML get back toXML you soon.'); Chapter 11 - Searching Data Chapter 12 - Managing the Oracle XML Database

Once the administrator receives the mail, there must be a way to approve the user’s application. This is done by creating a new form that is populated by the inserted data. This will be described in the next section.

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Creating an Administration Page PL/SQL

ISBN:0072229527 by Mark V.page Scardina, Chang Jinyu The user administration needsBen to be ableand to list theWang users and their status as well as provide a method to McGraw-Hill/Osborne © 2004 (600 pages) 15-4 shows a listing of users and their status retrieved by retrieve a specific user record and update it. Figure passingusers as a comprehensive pagename parameter to index.xsql linked Approve within Application. This guide focuses on utilizing XMLfrom technologies Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

Figure 15-4: Listing XDK XML users and their status Chapter 12 - Managing the of Oracle Database Part III - Oracle XML for Java Developers

This users.xsqlpage uses the same paging techniques as discussed earlier but executes the following query:

Chapter 13 - Getting Started with Oracle XML and Java

<xsql:query skip-rows="{@paging-skip}" max-rows="{@paging-max}"> Chapter 14 - Building an XML-Powered Web Site <![CDATA[ SELECT user_id, first_name,last_name, role,status,last_visit, Chapter 16 - Developing an XML Gateway Application with SOAP and AQ TO_CHAR(register_date,'Month DD,YYYY') as register_date,email Chapter 17 - Developing XML-Based Reusable Components FROM users Part IV - Oracle XML for C Developers ORDER BY status desc, first_name Chapter 18 - Getting Started with Oracle XML and C ]]> Chapter 19 - Building an XML-Managed Application </xsql:query> Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured Enginelinks as follows: The results are returned in XML to be High-Performance transformed into aTransformation list with user record Part V - Oracle XML for C++ Developers

<xsl:template name ="news_content" match="/">

Chapter - Getting Started with Oracle XML and C++ <page 22 title="XDK News Updates"> Chapter 23 - Build an XML Database OCI C++ Application <table width="100%" border="0"> Chapter <tr> 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQLalign="right" Developers <td width="10"

valign="top">

Chapter 25 - Getting Started with Oracle XML and PL/SQL width="10" height="10"/> <img src="images/d_arrow.gif" Chapter 26</td> - Building PL/SQL Web Services Chapter 27<td> - Extending PL/SQL XML Functionality with Java

<b>XDK Chapter 28 - Putting It All Users:</b> Together -</td> XML Standards Bodies and Open Specifications <td> <xsl:apply-templates select="page/paging"/> Glossary </td> Index </tr> List of Figures Appendix

List of Tables

<xsl:for-each select="page/ROWSET/ROW"> <tr> <td width="10" align="right" valign="top"> <img src="images/r_arrow.gif" width="10" height="10"/> </td> <td colspan="2" width="600" align="left" class="fbox"> <a href="index.xsql?pagename=generateForm& table=USERS&updateid={USER_ID}&u datecolmn=user_id" class="fbox">

List of Sidebars


<xsl:value-of select="FIRST_NAME"/>, <xsl:value-of select="LAST_NAME"/></a> (<xsl:value-of select="ROLE"/>):<xsl:value-of select="EMAIL"/> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <xsl:text> (</xsl:text><xsl:value-of PL/SQL select="STATUS"/><xsl:text>)</xsl:text> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang </td> McGraw-Hill/Osborne © 2004 (600 pages) </tr> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <tr> emphasis on XML standards, their usage and best practices. <td width="10"><xsl:text> </xsl:text></td> <td colspan="2" width="600" class="footnt"> Table of Contents Registered on:<xsl:value-of select="REGISTER_DATE"/>. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <xsl:value-of select="COMMENTS"/> Introduction </td> Part I - Oracle and the XML Standards </tr> Chapter </xsl:for-each> 1 - Introducing XML Chapter </table> 2 - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 - Transforming XML with XSLT and XPath </page> Chapter 4 - Validating XML with DTDs and XML Schemas </xsl:template> Chapter 5 - XML Operations with XQuery </xsl:stylesheet> Chapter 6

- XML Messaging and RPC with SOAP

After this is retrieved, the administrator then JSPs, selectand a pending Chapter 7 list - Putting It All Together with XML can Pipeline, XSQL application and be presented with a new form thatIIhas all theXML userManagement information ready for update, as shown in Figure 15-5. Part - Oracle for DBAs Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

Figure 15-5: Update form for users

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 is - Building Application This form retrievedanbyXML theData-Retrieval following link calling the generateForm.xsql page: Part VI - Oracle XML for PL/SQL Developers

http://localhost:8988/xdkus/admin/index.xsql?pagename=generateForm &table=USERS&updateid=440&updatecolmn=user_id

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Chapter 27demonstrates - Extending PL/SQL XMLto Functionality with Javaat the same time you are passing in a pagename value. The This link the ability pass in parameters Chapter 28 - Putting All Together form created by thisItpage is as follows: Appendix - XML Standards Bodies and Open Specifications <?xml version="1.0"?> Glossary <?xml-stylesheet type="text/xsl" media="mozilla" href="xsl/generateForm.xsl"?> Index <page title="Insert New XDK Release" connection="xdkadmin" List of Figures xmlns:xsql="urn:oracle-xsql"> List <xsql:include-param of Tables name="table" value="{@table}"/> List <xsql:include-param of Sidebars name="updateid" value="{@updateid}"/>

<xsql:include-param name="updatecolmn" value="{@updatecolmn}"/> <xsql:query>select column_name as name, data_type as type, data_length as length, NULLABLE from user_tab_columns where table_name=upper('{@table}') </xsql:query> <xsql:if-param name="updateid" exists="yes">


<data> <xsql:query date-format="MM/dd/yyyy"> select * from {@table} Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & wherePL/SQL {@updatecolmn}='{@updateid}' </xsql:query> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang </data>McGraw-Hill/Osborne © 2004 (600 pages) </xsql:if-param> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with </page> emphasis on XML standards, their usage and best practices. Table Note of Contents Since the page allows users to update the content of the SQL WHERE clause, it should not be Oracle Database 10g XML & SQL—Design, Build verification. & Manage XML in Java, C++ types & PL/SQL accessable without proper security It isApplications also suggested thatC,these of administration Introductionpages should be hosted separately from the public XSQL pages and preferably on a machine behind a Part I - Oracle and the XML Standards firewall.

Chapter 1

- Introducing XML

Note that page uses different connection Chapter 2 this - Accessing XMLawith DOM,database SAX, JAXB, and StAX alias, xdkadmin, because you need to have administrative database to perform updates The query also returns an XML document that is Chapter 3 privileges - Transforming XML with XSLT and and maintenance. XPath transformed to HTML XML by generateForm.xsl in Schemas the same way as the user application form, with the distinction that Chapter 4 - Validating with DTDs and XML the fields are populated with the results of the query. This allows the administrator to assign a username and a - XML Operations with XQuery password.

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7 - Putting It All Together with XMLonly Pipeline, and but XSQL Once again, the form submission can not insertJSPs, the data also deliver an e-mail to the user that his Part II - Oracle Management for DBAs application wasXML accepted and include the login information using an INSERT trigger.

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 Mark V. Scardina, and Jinyu Wang In this chapter,by you learned how youBen canChang extend the XSQL Servlet along with the XML database to create McGraw-Hill/Osborne © 2004 (600 pages) You have combined XML documents, XSLT stylesheets, AQ, sophisticated portal sites with powerful functionality. and SQL triggers create a usefulguide site that youon can easily XML extend. Finally, you have seen how this site’sproducts, modular with Thistocomprehensive focuses utilizing technologies within Oracle's XML-enabled emphasis on XML standards, their usage andfiles, best fits practices. structure, consisting of associated XML, XSL, and XSQL within this framework.

Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 16:Database Developing an XML Gateway Application with PL/SQL ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang SOAP and AQ McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses of on choice utilizingfor XML technologies within Oracle's have XML-enabled products, While XML generally has become the language e-business, many companies not adopted it, with emphasis on XML standards, their usage and best practices. typically because they perceive that adding this functionality to currently working applications is difficult. Many applications still depend on manually keying in data, such as a purchase order (PO), and businesses neither want Table of Contents nor can afford to have two entirely different applications to perform the same function differing only in their input Oracle Database 10g XMLmany & SQL—Design, Manage XML Applications in simply Java, C, C++to&extend PL/SQLtheir presence by methods. Additionally, companies Build have&brick-and-mortar stores and want Introduction plugging in the Internet application into exiting applications. In this chapter, you will build an application that provides Part thisIfunctionality - Oracle andby the leveraging XML Standards the Oracle XDK, Oracle Streams Advanced Queuing (AQ), and Oracle XML Database 10g. 1 - Introducing XML Chapter Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

- Transforming XML with XSLT and XPath Designing the Framework

Chapter 3 Chapter 4

- Validating XML with DTDs and XML Schemas

For the5example scenario inwith this XQuery chapter, assume that you work for a widget business that has a perfectly Chapter - XML Operations satisfactory order-entry application. This SOAP application works as follows: When a clerk receives a PO via mail or the Chapter 6 - XML Messaging and RPC with phone, 7the- clerk types information form provided by XSQL the order-entry application, which in turn creates a Chapter Putting It Allthe Together with into XML aPipeline, JSPs, and database entryXML for each PO. Thisfor application has been working fine for years and the company has no interest in Part II - Oracle Management DBAs rewriting deploying a new it does want to begin using the Internet to accept orders. Chapter 8 it-or Getting Started withone; the however, Oracle XML Database Chapter 9

- Storing XML Data This company has several requirements that this new functionality must satisfy. First, the company does business

Chapter 10 - Generating and Retrieving XML with a wide range of companies and organizations, including the government, but is not big enough to require

Chapter 11 - to Searching XML Data customers use a particular format for the PO. The information the company needs to capture is quite simple: the Chapter 12 - Bill Managing the Oracle Database and Items ordered. Optionally, a customer can specify which carrier to customer’s To Address, ShipXML To Address, Part - Oraclethe XML for Java Developers useIII to deliver order. In the past, the widget company’s clerks extracted this information from a variety of POs,

Chapter - Getting Started with Oracle XML and Java but now13this must be handled electronically. Therefore, the application has to be able to extract information from Chapter - Building an XML-Powered Site confirmations, notifications, etc., need to be generated and sent POs in 14 various schemas. Second, theWeb requisite Chapter electronically. 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

To implement this application, you will be using a little-known but very useful and robust feature of the Oracle database called Oracle Streams Advanced Queuing(AQ). This feature, which was developed to implement Part IV - Oracle XML for C Developers replication, provides a rich and secure messaging infrastructure to connect the database to the outside world. AQ is Chapter 18 - Getting Started with Oracle XML and C capable of natively understanding SOAP messages, as discussed in Chapter 6, and you will be using that capability Chapter 19 - Building an XML-Managed Application in this chapter. You will also be using new interfaces within the Oracle XDK XML Schema processor. Chapter 17 - Developing XML-Based Reusable Components

Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

A Conventional Solution

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

A conventional way to design this application would be to have companies supply an XML schema for their POs when they open an account. Each company’s XML schema would then be used to validate the POs received from Chapter 24 - Building an XML Data-Retrieval Application that company via SOAP messages. Once validated, the PO would then need to be transformed into an XML Part VI - Oracle XML for PL/SQL Developers document that is compliant with your database schema, before the data could be inserted into database tables. This Chapter 25 - Getting Started with Oracle XML and PL/SQL would involve designing an XSL stylesheet that is specific to each PO type, which would then be applied to a DOM Chapter 26 - Building PL/SQL Web Services of the PO. Chapter 23 - Build an XML Database OCI C++ Application

Chapter 27 - Extending PL/SQL XML Functionality with Java

The conventional presents a number of issues. First, it involves creating a stylesheet for every PO type Chapter 28 - Puttingapproach It All Together and updating those stylesheets whenever are changes. Secondly, XSLT requires building DOM for the entire Appendix - XML Standards Bodies and Openthere Specifications PO, which can be expensive because it generally requires up to ten times the memory of the original PO text file. Glossary Finally, for every PO, your application must load and parse its schema to validate it, and then load and parse its Index stylesheet to transform it. These operations take both time and memory, thus degrading performance and scalability. List of Figures List of Tables

You may be wondering why you cannot use the native capability of the XML database to register these PO schemas

List Sidebars andofdirectly insert them into the database. There are several reasons why you can’t:

You need to use the existing database schema, because that application still needs to work. Registering a PO schema would create a new database schema that would be difficult to integrate into the old one. There is also the problem of dealing with any changes in companies’ XML schemas over time. Your company is not big enough to dictate which schema customers must use. You are going to need to process POs from a variety of customers and companies; this would mean registering


PO schemas for each, which would quickly become a nightmare for the DBA. Oracle Database 10g XMLSolution & SQL: Design, Build & Manage XML Applications in Java, C, C++ & A Stream-Based One-Step PL/SQL

ISBN:0072229527 by Mark V. Scardina, Chang andonJinyu WangXML and then on defining an approach to transform The previous, conventional solutionBen focused first the input it McGraw-Hill/Osborne © 2004 (600 pages) into a compatible database format. An alternative is to start with the XML requirements for your database schema and build the system from there. First, you knowon which information you need within from each PO XML-enabled for your application to with This comprehensive guide focuses utilizing XML technologies Oracle's products, on XML standards, usage best practices. work. Any otheremphasis information in the PO is nottheir useful, as and it cannot be consumed by your application. Therefore, validating the entire PO is unnecessary and may actually cause you to reject a PO that has an error in a portion that you don’t even use. Instead, your design needs to validate only the data that your application requires. It also needs Table of Contents to extract only the data. This canBuild be done in one processing stepinby using 10g. Oracle Database 10gneeded XML & SQL—Design, & Manage XML Applications Java, C, Oracle C++ & XDK PL/SQL

Introduction

Figure 16-1 shows the process flow of the application. First, note that it uses SAX-based processing, thus eliminating expensive DOM construction. Second, only the XML Schema processor is employed. This processor is Chapter 1 - Introducing XML unique in its ability to perform XML Schema validation using SAX and expose the status of its validator through Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX starts validating once it finds a type that is included in the APIs. When an XML document is validated, the processor Chapter 3 - Transforming XML with and XPath XML schema, and can ignore partsXSLT it knows nothing about. What makes this design effective is that the XML Chapter Validating XMLone withassociated DTDs and XML schema4 is-not simply the with Schemas the submitted PO. Instead, it is a master schema that includes only Chapter 5 - XML within, XQuery those types you Operations are interested but from every customer and company you do business with. Therefore, you need Chapter RPC with SOAP to load 6and- XML parseMessaging only one and schema at initialization time, with every type being a very quick hash table lookup. Part I - Oracle and the XML Standards

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Figure 16-1: Stream-based XML processing solution

Chapter 20 - Build an XML Database OCI Application

Chapter 21 your - Create an XML-Configured Now that application can do veryHigh-Performance efficient streamingTransformation validation, youEngine need to handle the transformation into your Part V - Oracle XML for C++ Developers database schema–compatible format. This can be done by communicating with the processor during validation and

Chapter adding 22 annotations - Getting Started to the schema with Oracle types XML to indicate and C++the necessary transformation. As the gateway processor gets

events 23 from its SAX handler, it queries the schema processor to find out whether validation has started. If it hasn’t Chapter - Build an XML Database OCI C++ Application started,24 the parsed content just skipped.Application If it has, it buffers the content from the type until it receives a successful Chapter - Building an XML is Data-Retrieval validation response after the last element of the type. It then queries the schema processor for the type annotation Part VI - Oracle XML for PL/SQL Developers that tells type Started of transformation needs toPL/SQL perform to make the type acceptable to the database. Finally, it Chapter 25it-the Getting with Oracleit XML and marks off type from its list ofServices required types for a complete PO. Once all types are satisfied, the document is Chapter 26 that - Building PL/SQL Web inserted27into your database forXML further processing. Chapter - Extending PL/SQL Functionality with Java Chapter 28 - Putting It All Together

Interfacing - XML Standards to theBodies Internet and Open Specifications

Appendix Glossary

Now that you know how the processing is done, you need to be able to receive and send messages using the Index

Internet. To do this, you will use AQ’s capability to receive and unpack SOAP messages, send confirmations, perform workflow within its message queue, and send e-mail responses. Figure 16-2 shows the entire system.

List of Figures List of Tables

List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents

16-2: PO messaging gateway architecture OracleFigure Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

SOAP messages that contain POs are sent across the Internet to your company, where they pass through the firewall and are received by the AQ servlet that unwraps the PO and places it in its queue. Once a PO is received, it Chapter 1 - Introducing XML triggers the validation and gateway process that either rejects or transforms and inserts the data. For this Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX deployment, you will be using Oracle JVM, which is a Java VM that runs within the Oracle database. This application Chapter 3 - Transforming with XSLT tier and by XPath easily could be built to runXML in the middle using the XDK’s SOAP implementation and inserting data using Chapter 4 Validating XML with DTDs and XML Schemas JDBC. Part I - Oracle and the XML Standards

Chapter 5

- XML Operations with XQuery

It is important to Messaging note that this satisfies Chapter 6 - XML anddesign RPC with SOAP the requirement to maintain the existing database schema and application providing a high-performance and scalable Chapter 7 - while Putting It All Together with XML Pipeline, JSPs, andInternet XSQL gateway. Thus, your company can painlessly expand its business to a whole new range of customers. Part II - Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Creating the Framework PL/SQL

ISBN:0072229527 by Markcompany V. Scardina, Ben has Chang Jinyuapplication Wang Because your widget already an and existing that must be maintained, you first need to set up McGraw-Hill/Osborne © 2004 pages) the database schema, after which you can(600 begin configuring AQ and the SOAP service for your application. This will provide the framework for the application. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

Creating the Database Schema

Table of Contents

Oracle Instead Database of using10g XMLType XML & SQL—Design, functionality that Builddidn’t & Manage exist when XML Applications your original inapplication Java, C, C++ was& written, PL/SQL you will continue

to use relational storage. This type of storage is not complicated, because your company has very straightforward Introduction requirements. Butthe before create the database schema, you need to create the administrator after logging in as Part I - Oracle and XMLyou Standards SYSDBA, follows: XML Chapter 1 -as Introducing Chapter 2 USER - Accessing XML with DOM, SAX, BY JAXB, and StAX CREATE poadmin IDENTIFIED poadmin Chapter DEFAULT 3 - Transforming tablespace XML USERS; with XSLT and XPath

GRANT 4CONNECT, RESOURCE TO poadmin; Chapter - Validating XML with DTDs and XML Schemas -- Grant AQ Privileges Chapter 5 - XML Operations with XQuery GRANT 6aq_administrator_role TOSOAP poadmin; Chapter - XML Messaging and RPC with GRANT 7execute Chapter - Putting ON It Alldbms_aqadm Together withTO XMLpoadmin; Pipeline, JSPs, and XSQL / II - Oracle XML Management for DBAs Part Chapter 8

- Getting Started with the Oracle XML Database

Don’t worry about the AQ privileges, as these will be discussed later. Recalling the schema description, the following Chapter 9 - Storing XML Data SQL script will create your database schema: Chapter 10 - Generating and Retrieving XML

CREATE TABLE PO( po_id raw(16) PRIMARY KEY, Chapter 12 - Managing the Oracle XML Database sendby_csname VARCHAR2(50), Part III - Oracle XML for Java Developers sendby_street VARCHAR2(100), Chapter 13 - Getting Started with Oracle XML and Java sendby_city VARCHAR2(200), Chapter 14 - Building an XML-Powered Web Site sendby_state VARCHAR2(20), Chapter 15 - Creating a Portal Site with XML and Web Services sendby_zip VARCHAR2(20), Chapter 16 - Developing VARCHAR2(30), an XML Gateway Application with SOAP and AQ sendby_country Chapter 17 - Developing XML-Based Reusable Components shipping_csname VARCHAR2(50), Partshipping_street IV - Oracle XML for CVARCHAR2(100), Developers Chapter 18 - Getting Started with Oracle XML and C shipping_city VARCHAR2(200), Chapter 19 - Building an VARCHAR2(20), XML-Managed Application shipping_state Chapter shipping_zip 20 - Build an XML VARCHAR2(20), Database OCI Application shipping_country VARCHAR2(30), Chapter 21 - Create an XML-Configured High-Performance Transformation Engine VARCHAR2(50), Partbilling_csname V - Oracle XML for C++ Developers billing_street VARCHAR2(100), Chapter 22 - Getting Started with Oracle XML and C++ billing_city VARCHAR2(200), Chapter 23 - Build an XML Database OCI C++ Application billing_state Chapter 24 - Building anVARCHAR2(20), XML Data-Retrieval Application billing_zip Part VI - Oracle XMLVARCHAR2(20), for PL/SQL Developers billing_country VARCHAR2(30) Chapter 25 - Getting Started with Oracle XML and PL/SQL ); Chapter 26 - Building PL/SQL Web Services CREATE TABLE LineItems( Chapter 27 - Extending PL/SQL XML Functionality with Java po_id raw(16), Chapter 28 - Putting It All Together product_id VARCHAR2(10) Appendix - XML Standards Bodies and Open Specifications ); Glossary CREATE TABLE LineItem( Index product_id VARCHAR2(10) primary key, List product_name of Figures VARCHAR2(10), List product_quantity of Tables NUMBER(30), List product_price of Sidebars VARCHAR2(20) ); CREATE SEQUENCE poobj_seq START WITH 1; / Chapter 11 - Searching XML Data

This script defines three different addresses: SENDBY for the shipper, SHIPPING for the destination, and BILLING for the invoice. A LINEITEMS table is created to associate the individual PO with its lineitems stored in the LINEITEM table.


Since there are multiple tables, you have to manage a single PO insertion as a multitable insert. This requires additional code and the creation of several objects and an object view. These objects link the columns together into types, and the Oracle object view Database defines 10g theXML relationship & SQL: Design, betweenBuild the tables & Manage in a way XML that Applications they can bein queried Java, C, as C++ one & PL/SQL table. The following SQL script creates the first objects you need: Mark V. Scardina, Ben Chang and Jinyu Wang CREATE TYPEbyaddress_typ AS OBJECT( McGraw-Hill/Osborne © 2004 (600 pages) customer_name VARCHAR2(50), This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with street VARCHAR2(100), emphasis on XML standards, their usage and best practices. city VARCHAR2(200), state VARCHAR2(20), Table of Contents zip VARCHAR2(20), Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL country VARCHAR2(30) Introduction ); Part / I - Oracle and the XML Standards CREATE lineitem_typ AS OBJECT( Chapter 1 TYPE - Introducing XML product_id VARCHAR2(10), Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX product_name VARCHAR2(10), Chapter 3 - Transforming XML with XSLT and XPath product_quantity Chapter 4 - Validating XMLNUMBER(30), with DTDs and XML Schemas product_price VARCHAR2(20) Chapter 5 - XML Operations with XQuery ); Chapter 6 - XML Messaging and RPC with SOAP / Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL CREATE TYPE lineitem_list AS TABLE OF lineitem_typ; Part II - Oracle XML Management for DBAs / Chapter 8 - Getting Started with the Oracle XML Database CREATE TYPE po_typ AS OBJECT( Chapter 9 - Storing XML Data po_id raw(16), Chapter 10 - Generating and Retrieving XML sendby_addr address_typ, Chapter 11 - Searching XML Data shipping_addr address_typ, Chapter 12 Managing the Oracle XML Database billing_addr address_typ, Part III Oracle XML for Java Developers lineitems lineitem_list Chapter 13 Getting Started with Oracle XML and Java ); Chapter 14 Building an XML-Powered Web Site /

ISBN:0072229527

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Note that final po_typ object isReusable made upComponents of the four object types. This provides the linkage you need to treat the Chapter 17 the - Developing XML-Based entire as a XML single insert. Now you can create a PO view to represent the XML structure of the PO, as Part IV PO - Oracle fordocument C Developers follows:18 - Getting Started with Oracle XML and C Chapter CREATE REPLACE VIEW purchaseorder Chapter 19OR - Building an XML-Managed Application OF po_typ WITH OBJECT (po_id) ASOCI Application Chapter 20 - BuildOID an XML Database select po_id, Chapter 21 - Create an address_typ(sendby_csname, XML-Configured High-Performance Transformation Engine sendby_street, sendby_city, Chapter 22 - Getting Started with Oracle XML and C++ sendby_state, Chapter 23 - Build an XML Database OCI C++ Application sendby_zip, Chapter 24 - Building an XML Data-Retrieval Application sendby_country), Part VI - Oracle XML for PL/SQL Developers address_typ(shipping_csname, Chapter 25 - Getting Started with Oracle XML and PL/SQL shipping_street, Chapter 26 - Building PL/SQL Web Services shipping_city, Chapter 27 - Extending PL/SQL XML Functionality with Java shipping_state, Chapter 28 - Putting It All Together shipping_zip, Appendix - XML Standards Bodies and Open Specifications shipping_country), Glossary address_typ(billing_csname, Index billing_street, List of Figures billing_city, List of Tables billing_state, billing_zip, List of Sidebars billing_country), cast(multiset( select lineitem.product_id, product_name, product_quantity, product_price from lineitem, lineitems where lineitems.po_id=po.po_id and lineitem.product_id=lineitems.product_id ) as lineitem_list Part V - Oracle XML for C++ Developers


) lineitems from po; /

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

With the database schema created, you need to add one more piece of code to perform inserts. This function is ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang called an INSTEAD OF trigger and is executed by the database in place of the normal DML operation. In this case, McGraw-Hill/Osborne © 2004 (600 pages) because you need to perform inserts, you need to create an INSTEAD OF INSERT trigger, as follows: This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

CREATE TRIGGER purchaseorder_insert_trigger emphasis on XML standards, their usage and best practices. INSTEAD OF INSERT ON purchaseorder FOR EACH ROW Table of Contents DECLARE Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL v_lineitems lineitem_list; Introduction v_lineitem lineitem_typ; Part I - Oracle and the XML Standards v_id RAW(16); Chapter 1 - Introducing XML v_num number; Chapter BEGIN 2 - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 - Transforming XML with XSLT and XPath ---------------------------------------------------------------------------Chapter - Validating DTDs and XML Schemas -- 4Insert intoXML POwith table Chapter 5 - XML Operations with XQuery ---------------------------------------------------------------------------Chapter 6 - XML Messaging and RPCv_id with SOAP SELECT current_id into from poid where rownum=1; Chapter INSERT 7 - Putting INTO Itpo All Together with XML Pipeline, JSPs, and XSQL Part II -values Oracle XML (v_id, Management for DBAs :new.sendby_addr.customer_name, Chapter 8 - Getting Started with the Oracle XML Database :new.sendby_addr.street, Chapter 9 - Storing XML Data Chapter 10 - Generating :new.sendby_addr.city, and Retrieving XML :new.sendby_addr.state, Chapter 11 - Searching XML Data :new.sendby_addr.zip, Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for:new.sendby_addr.country, Java Developers :new.shipping_addr.customer_name, Chapter 13 - Getting Started with Oracle XML and Java :new.shipping_addr.street, Chapter 14 - Building an XML-Powered Web Site :new.shipping_addr.city, Chapter 15 - Creating a Portal Site with XML and Web Services :new.shipping_addr.state, Chapter 16 - Developing an XML Gateway Application with SOAP and AQ :new.shipping_addr.zip, Chapter 17 - Developing XML-Based Reusable Components :new.shipping_addr.country, Part IV - Oracle XML for C Developers :new.billing_addr.customer_name, Chapter 18 - Getting Started with Oracle XML and C :new.billing_addr.street, Chapter 19 - Building an :new.billing_addr.city, XML-Managed Application Chapter 20 - Build an XML Database OCI Application :new.billing_addr.state, Chapter 21 - Create an XML-Configured High-Performance Transformation Engine :new.billing_addr.zip, Part V - Oracle XML for C++ Developers :new.billing_addr.country); Chapter 22 - Getting Started with Oracle XML and C++ ---------------------------------------------------------------------------Chapter -- 23 Insert - Build an into XMLLineItem Database OCI and C++ LineItems Application table ---------------------------------------------------------------------------Chapter 24 - Building an XML Data-Retrieval Application v_lineitems :=PL/SQL :new.lineitems; Part VI - Oracle XML for Developers FOR in 1..v_lineitems.count loop Chapter 25i- Getting Started with Oracle XML and PL/SQL := v_lineitems(i); Chapter v_lineitem 26 - Building PL/SQL Web Services count(1) v_num FROM lineitem Chapter SELECT 27 - Extending PL/SQLINTO XML Functionality with Java WHERE product_id = v_lineitem.product_id; Chapter 28 - Putting It All Together IF v_num = 0 THEN Appendix - XML Standards Bodies and Open Specifications INSERT INTO lineitem Glossary VALUES(v_lineitem.product_id, Index v_lineitem.product_name, List of Figures v_lineitem.product_quantity, List of Tables v_lineitem.product_price); List of Sidebars END IF; INSERT INTO lineitems VALUES(v_id, v_lineitem.product_id); END LOOP; END; / SHOW ERRORS;

The first thing to note is that you attach the trigger to the view, not to the object. The reason you do this is that you


are inserting the data in an XML document using XSU, and you must insert into a compliant structure. Next, since there is an ID relationship that is not conveyed within the document, you need to declare variables to store the calculated result. The same holds10g trueXML for the master-detail relationship in theXML LINEITEMS and LINEITEM Oracle Database & SQL: Design, Build & Manage Applications in Java, C, C++ & relationship. The actual SQL code is identical to what you would use to insert into these objects manually. PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Creating the XML Purchase Orders

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their and best Now that you have the database schema set upusage to accept XMLpractices. POs in addition to keyed-in ones, you need to create a valid XML PO. You can generate an XML schema for the PO by using XSU’s capability to generate a schema from the object view. The following query will generate an XML schema for the po_typobject: Table of Contents Oracle SET LONG Database 10000; 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

SELECT DBMS_XMLSCHEMA.generateschema('POUSER', 'PO_TYP').getClobVal() Introduction FROM DUAL;and the XML Standards Part I - Oracle Chapter 1

- Introducing XML

This query- generates the following schema: Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 2

<?xml 3version="1.0"?> Chapter - Transforming XML with XSLT and XPath <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" Chapter 4 - Validating XML with DTDs and XML Schemas xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Chapter 5 - XML Operations with XQuery xmlns:xdb="http://xmlns.oracle.com/xdb" - XML Messaging and RPC with SOAP xsi:schemaLocation="http://xmlns.oracle.com/xdb Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL http://xmlns.oracle.com/xdb/XDBSchema.xsd"> Part II - Oracle XML Management for DBAs <xsd:element name="PO_TYP" type="PO_TYPType" xdb:SQLType="PO_TYP" Chapter 8 - Getting Started with the Oracle XML Database xdb:SQLSchema="POUSER"/> Chapter 9 - Storing XML Data <xsd:complexType name="PO_TYPType" xdb:SQLType="PO_TYP" Chapter 10 - Generating and Retrieving XML xdb:SQLSchema="POUSER" xdb:maintainDOM="false"> Chapter 11 - Searching XML Data <xsd:sequence> Chapter 12 - Managing name="PO_ID" the Oracle XML Database <xsd:element type="xsd:hexBinary" xdb:SQLName="PO_ID" Part III Oracle XML for Java Developers xdb:SQLType="RAW"/> Chapter 13 - Getting Started with Oracle XML and type="ADDRESS_TYPType" Java <xsd:element name="SENDBY_ADDR" Chapter 14 Building an XML-Powered Web Site xdb:SQLName="SENDBY_ADDR" xdb:SQLSchema="POUSER" Chapter 15 - Creating a Portal Site with XML and Web Services xdb:SQLType="ADDRESS_TYP"/> Chapter <xsd:element 16 - Developingname="SHIPPING_ADDR" an XML Gateway Applicationtype="ADDRESS_TYPType" with SOAP and AQ xdb:SQLName="SHIPPING_ADDR" xdb:SQLSchema="POUSER" Chapter 17 - Developing XML-Based Reusable Components xdb:SQLType="ADDRESS_TYP"/> Part IV - Oracle XML for C Developers <xsd:element name="BILLING_ADDR" Chapter 18 - Getting Started with Oracle XML and Ctype="ADDRESS_TYPType" xdb:SQLName="BILLING_ADDR" xdb:SQLSchema="POUSER" Chapter 19 - Building an XML-Managed Application xdb:SQLType="ADDRESS_TYP"/> Chapter 20 - Build an XML Database OCI Application <xsd:element type="LINEITEM_TYPType" Chapter 21 - Create an name="LINEITEMS" XML-Configured High-Performance Transformation Engine maxOccurs="unbounded" minOccurs="0" xdb:SQLName="LINEITEMS" Part V - Oracle XML for C++ Developers xdb:SQLCollType="LINEITEM_LIST" xdb:SQLType="LINEITEM_TYP" Chapter 22 - Getting Started with Oracle XML and C++ xdb:SQLSchema="POUSER" xdb:SQLCollSchema="POUSER"/> Chapter 23 - Build an XML Database OCI C++ Application </xsd:sequence> Chapter 24 - Building an XML Data-Retrieval Application </xsd:complexType> Part VI - Oracle XML for PL/SQL Developers <xsd:complexType name="ADDRESS_TYPType" xdb:SQLType="ADDRESS_TYP" Chapter 25 - Getting Started with Oracle XML and PL/SQL xdb:SQLSchema="POUSER" xdb:maintainDOM="false"> Chapter 26 - Building PL/SQL Web Services <xsd:sequence> Chapter 27 - Extending name="CUSTOMER_NAME" PL/SQL XML Functionality with Java <xsd:element xdb:SQLName="CUSTOMER_NAME" Chapter 28 - Putting It All Together xdb:SQLType="VARCHAR2"> Appendix - XML Standards Bodies and Open Specifications <xsd:simpleType> Glossary<xsd:restriction base="xsd:string"> Index <xsd:maxLength value="50"/> List of Figures </xsd:restriction> </xsd:simpleType> List of Tables </xsd:element> List of Sidebars <xsd:element name="STREET" xdb:SQLName="STREET" xdb:SQLType="VARCHAR2"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="100"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="CITY" xdb:SQLName="CITY" xdb:SQLType="VARCHAR2"> Chapter 6


<xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="200"/> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & </xsd:restriction> PL/SQL </xsd:simpleType> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang </xsd:element> McGraw-Hill/Osborne © 2004 (600 pages) <xsd:element name="STATE" xdb:SQLName="STATE" xdb:SQLType="VARCHAR2"> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <xsd:simpleType> emphasis on XML standards, their usage and best practices. <xsd:restriction base="xsd:string"> <xsd:maxLength value="20"/> Table of Contents </xsd:restriction> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL </xsd:simpleType> Introduction </xsd:element> Part I - Oracle and the XML Standards <xsd:element name="ZIP" xdb:SQLName="ZIP" xdb:SQLType="VARCHAR2"> Chapter 1 - Introducing XML <xsd:simpleType> Chapter <xsd:restriction 2 - Accessing XML withbase="xsd:string"> DOM, SAX, JAXB, and StAX Chapter 3<xsd:maxLength - Transforming XMLvalue="20"/> with XSLT and XPath Chapter </xsd:restriction> 4 - Validating XML with DTDs and XML Schemas Chapter 5 - XML Operations with XQuery </xsd:simpleType> Chapter </xsd:element> 6 - XML Messaging and RPC with SOAP <xsd:element name="COUNTRY" Chapter 7 - Putting It All Together with XMLxdb:SQLName="COUNTRY" Pipeline, JSPs, and XSQL xdb:SQLType="VARCHAR2"> Part II - Oracle XML Management for DBAs <xsd:simpleType> Chapter 8 - Getting Started with the Oracle XML Database <xsd:restriction Chapter 9 - Storing XML Data base="xsd:string"> <xsd:maxLength value="30"/> Chapter 10 - Generating and Retrieving XML </xsd:restriction> Chapter 11 - Searching XML Data </xsd:simpleType> Chapter 12 - Managing the Oracle XML Database </xsd:element> Part III - Oracle XML for Java Developers </xsd:sequence> Chapter 13 - Getting Started with Oracle XML and Java </xsd:complexType> Chapter 14 - Building an XML-Powered Web Site <xsd:complexType name="LINEITEM_TYPType" xdb:SQLType="LINEITEM_TYP" Chapter 15 - Creating a Portal Site with XML and Web Services xdb:SQLSchema="POUSER" xdb:maintainDOM="false"> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <xsd:sequence> Chapter 17 - Developingname="PRODUCT_ID" XML-Based Reusable Components <xsd:element xdb:SQLName="PRODUCT_ID" Part IV Oracle XML for C Developers xdb:SQLType="VARCHAR2"> Chapter 18 - Getting Started with Oracle XML and C <xsd:simpleType> Chapter <xsd:restriction 19 - Building an XML-Managed Application base="xsd:string"> Chapter 20 Build an XML Database OCI Application <xsd:maxLength value="10"/> Chapter </xsd:restriction> 21 - Create an XML-Configured High-Performance Transformation Engine Part V </xsd:simpleType> - Oracle XML for C++ Developers Chapter </xsd:element> 22 - Getting Started with Oracle XML and C++ <xsd:element name="PRODUCT_NAME" xdb:SQLName="PRODUCT_NAME" Chapter 23 - Build an XML Database OCI C++ Application xdb:SQLType="VARCHAR2"> Chapter 24 - Building an XML Data-Retrieval Application Part VI<xsd:simpleType> - Oracle XML for PL/SQL Developers base="xsd:string"> Chapter <xsd:restriction 25 - Getting Started with Oracle XML and PL/SQL <xsd:maxLength value="10"/> Chapter 26 - Building PL/SQL Web Services Chapter </xsd:restriction> 27 - Extending PL/SQL XML Functionality with Java </xsd:simpleType> Chapter 28 - Putting It All Together </xsd:element> Appendix - XML Standards Bodies and Open Specifications <xsd:element name="PRODUCT_QUANTITY" type="xsd:double" Glossary xdb:SQLName="PRODUCT_QUANTITY" xdb:SQLType="NUMBER"/> Index <xsd:element name="PRODUCT_PRICE" xdb:SQLName="PRODUCT_PRICE" List of Figures xdb:SQLType="VARCHAR2"> List of Tables <xsd:simpleType> List of Sidebars <xsd:restriction base="xsd:string"> <xsd:maxLength value="20"/> </xsd:restriction> </xsd:simpleType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:schema>


In the first part of your application, you will use this schema to validate incoming POs that are submitted as SOAP messages. Once a PO is validated, a confirmation e-mail can be sent to the customer via AQ’s e-mail functionality and the data will be added to your10g application’s schema. In Build the second part, XML you will extend the in design Oracle Database XML & SQL: Design, & Manage Applications Java,toC,accept C++ & POs that do not conform to your application’s schema but do map to it. PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Creating the XML Messaging Gateway PL/SQL

bypoint Markof V.this Scardina, Ben Chang and Jinyu Wang company’s business to the Internet, you ISBN:0072229527 Since the whole application is to extend the widget must set up © 2004This (600 can pages) Internet accessMcGraw-Hill/Osborne to its database schema. be done in a number of ways. The traditional approach is to use the middle tier This to container-manage the database applications suchXML-enabled as Oracle Toplink, comprehensive guide focuses onthrough utilizingobject-relational XML technologies within Oracle's products, with emphasis on XML standards, usage and best EJBs, etc. However, these applications cantheir be difficult to set uppractices. and maintain. Therefore, instead, you will use Oracle Database 10g’s built-in messaging infrastructure, Oracle Streams Advance Queuing (AQ), and its AQ servlet to send and receive SOAP messages. This robust system can be extended to perform application processing upon Table of Contents the messages theXML manner of workflow. To use AQ Streams, you needin toJava, set up servlet as well as create the Oracle Database in 10g & SQL—Design, Build & Manage XML Applications C,the C++ & PL/SQL messaging schema for storing accepted and rejected POs. Introduction Part I - Oracle and the XML Standards

- Introducing XML Creating the Messaging Schema

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Since this of your XML database will have exposure to the Internet, you need to create a separate user and Chapter 3 -portion Transforming with XSLT and XPath restrict access. This can be done by logging in as SYSDBA and creating POUSER, as follows: Chapter 4 - Validating XML with DTDs and XML Schemas CREATE IDENTIFIED Chapter 5 USER - XML pouser Operations with XQuery BY pouser DEFAULT USERS; Chapter 6 - XMLtablespace Messaging and RPC with SOAP GRANT 7CONNECT, pouser; Chapter - Putting ItRESOURCE All TogetherTO with XML Pipeline, JSPs, and XSQL -- II Grant AQXML privileges Part - Oracle Management for DBAs GRANT 8execute dbms_aq TOOracle pouser; Chapter - GettingON Started with the XML Database GRANT execute ON dbms_aqin TO pouser; - Storing XML Data ALTER USER pouser GRANT CONNECT through pouser; Chapter 10 - Generating and Retrieving XML / Chapter 9

Chapter 11 - Searching XML Data

Chapter Managing the Oracle Database As you12 did- for POADMIN earlier XML in the chapter, the preceding code grants to POUSER a number of AQ privileges as Part Oracle XML Java Developers wellIII as -the ability to for connect to the database.

Chapter 13 - Getting Started with Oracle XML and Java

You also to setanupXML-Powered the tables that willSite be needed by the AQ messaging queue to receive the POs and store Chapter 14need - Building Web copies 15 of accepted rejected Youand canWeb set up these tables with the following script: Chapter - Creatingand a Portal Site POs. with XML Services Chapter CREATE 16TABLE - Developing po_tbl( an XML Gateway Application with SOAP and AQ

msgid Chapter 17RAW(16), - Developing XML-Based Reusable Components consumer Part IV - OracleVARCHAR2(100), XML for C Developers sender Chapter 18 -VARCHAR2(200), Getting Started with Oracle XML and C podoc Chapter 19XMLTYPE - Building an XML-Managed Application ); Chapter 20 - Build an XML Database OCI Application CREATE Chapter 21TABLE - Createpo_rejected_tbl( an XML-Configured High-Performance Transformation Engine msgid RAW(16), Part V - Oracle XML for C++ Developers consumer VARCHAR2(100), sender VARCHAR2(200), Chapter 23 - Build an XML Database OCI C++ Application reason VARCHAR2(500), Chapter 24 - Building an XML Data-Retrieval Application podoc XMLTYPE Part VI - Oracle XML for PL/SQL Developers ); Chapter 25 - Getting Started with Oracle XML and PL/SQL CREATE TABLE po_backup_tbl( Chapter 26 - Building PL/SQL Web Services msgid RAW(16), Chapter 27 - Extending PL/SQL XML Functionality with Java consumer VARCHAR2(100), Chapter 28 -VARCHAR2(200), Putting It All Together sender Appendix - XML Standards Bodies and Open Specifications podoc XMLTYPE Glossary ); Index grant SELECT,DELETE on po_tbl to poadmin; List grant of Figures SELECT,DELETE on po_rejected_tbl to poadmin; grant SELECT,DELETE on po_backup_tbl to poadmin; List of Tables / List of Sidebars Chapter 22 - Getting Started with Oracle XML and C++

Note that you need to grant specific privileges on these tables to the administrator in order to review and maintain them. Finally, you need to set up specific user accounts in order to accept a PO. This permits you to set up a user ID and password for each company you wish to do business with. The following SQL script creates a PO Users table and seeds it with sample data: CREATE TABLE POUSER(


user_id VARCHAR(10) PRIMARY KEY, name VARCHAR2(50), street VARCHAR2(100), Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & city VARCHAR2(200), PL/SQL state VARCHAR2(20), ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang zip VARCHAR2(20), McGraw-Hill/Osborne © 2004 (600 pages) country VARCHAR2(30) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with ); emphasis on XML standards, their usage and best practices. INSERT INTO POUSER values('bob', 'Bob Smith','400 Oracle parkway', 'Redwood shores', 'CA', '94065','US'); Table of Contents INSERT INTO POUSER values('scott', 'Scott Tiger','400 Oracle parkway', Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL 'Redwood shores', 'CA', '94065','US'); Introduction / Part I - Oracle and the XML Standards

Chapter As you1can- Introducing see, there isXML no entry in the table for a password. This is because you will be using the JAZN support Chapter 2 by - Accessing with DOM, SAX, JAXB,you andare StAX provided the OC4JXML J2EE container in which going to deploy this application. JAZN is the Java Chapter Authentication 3 - Transforming and Authorization XML with Service XSLT and (JAAS) XPathprovider, which can be configured either with the Oracle Internet

Directory LDAP XML repository or with anXML XML repository file. For simplicity, you will use the latter configuration, Chapter 4 (OID) - Validating with DTDs and Schemas because adding jazn-data.xml file to the deployment. To set this up, you need to create an AQ Chapter 5 it-only XMLrequires Operations with aXQuery agent for and give the user theSOAP necessary execution privileges for database access, as in the following Chapter 6 each - XMLuser Messaging and RPC with SQL script: Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part BEGIN II - Oracle XML Management for DBAs

DBMS_AQADM.create_aq_agent(agent_name=>'"jazn.com/bob"', Chapter 8 - Getting Started with the Oracle XML Database enable_http =>true); - Storing XML Data END; Chapter 10 - Generating and Retrieving XML / Chapter 11 - Searching XML Data EXECUTE 'pouser'); Chapter 12 -dbms_aqadm.enable_db_access('JAZN.COM/BOB', Managing the Oracle XML Database Chapter 9

Part III - Oracle XML for Java Developers

Note that the agent name refers to “jazn.com/bob”. This is the JAZN realm set for your J2EE application as defined in the myjazn-data.xml file that gets deployed with your application. This XML file defines not only the set of users Chapter 14 - Building an XML-Powered Web Site and their passwords but also the policies and permissions for the realm. Chapter 13 - Getting Started with Oracle XML and Java

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Creating the AQ Agent and Queue

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

While AQ is built into the Oracle database, it still must be set up to supply messages to a predefined queue and then to your previously created tables. This is done with special functions that are part of the included DBMS_ADMIN Chapter 19 The - Building package. queuean is XML-Managed nothing more Application than special tables for the messages, and since these POs are XML Chapter 20 Build an XML OCI table, Application documents, you can use Database an XMLType as follows: Chapter 18 - Getting Started with Oracle XML and C

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

BEGIN dbms_aqadm.create_queue_table(queue_table=>'poxml_qt', Chapter 22 - Getting Started with Oracle XML and C++ queue_payload_type=>'SYS.XMLTYPE', Chapter 23 - Build an XML Database OCI C++ Application COMMENT=>'Purchase Order Queue Table', Chapter 24 - Building an multiple_consumers=>TRUE, XML Data-Retrieval Application Part VI - Oracle XML for primary_instance=>1, PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL secondary_instance=>2); Chapter 26 Building PL/SQL Web Services END; Chapter 27 Extending PL/SQL XML Functionality with Java / Chapter BEGIN 28 - Putting It All Together dbms_aqadm.create_queue(queue_name => 'poxml_q', Appendix - XML Standards Bodies and Open Specifications queue_table =>'poxml_qt'); Glossary END; Index / of Figures List BEGIN List of Tables dbms_aqadm.start_queue (queue_name => 'poxml_q'); List of Sidebars END; / Part V - Oracle XML for C++ Developers

POs as SOAP messages come into the database from the AQ servlet. Therefore, you need to extend the AQ servlet to handle these messages. This can be done by creating the following MyAQServletclass: package oracle.xml.sample.XMLIntegration; import java.io.PrintStream; import java.io.FileOutputStream;


import javax.servlet.ServletConfig; import javax.servlet.ServletException; import oracle.AQ.xml.AQxmlException; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & import oracle.AQ.xml.AQxmlDebug; PL/SQL import oracle.AQ.xml.AQxmlDataSource; ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang import oracle.AQ.xml.AQxmlCallback; McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

public class MyAQServlet extendstheir oracle.AQ.xml.AQxmlServlet { emphasis on XML standards, usage and best practices. public void init(ServletConfig p_config) throws ServletException { // Database Variables Table of Contents String username="pouser"; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL String password="pouser"; Introduction String sid="ORCL"; Part I - Oracle and the XML Standards String host="localhost"; Chapter 1 - Introducing XML String port="1521"; Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 - Transforming XMLdb_drv with XSLT XPath AQxmlDataSource = and null; Chapter 4 -{Validating XML with DTDs and XML Schemas try Chapter 5//- XML XQuery Set Operations the log with file Chapter 6PrintStream - XML Messaging debugFile and RPC with = SOAP new PrintStream (new Chapter 7

- PuttingFileOutputStream("aqdebug.log")); It All Together with XML Pipeline, JSPs, and XSQL

debugFile.println("Function Part II - Oracle XML Management for DBAs

Called");

Chapter 8debugFile.flush(); - Getting Started with the Oracle XML Database Chapter 9super.init(p_config); - Storing XML Data Chapter 10 - Generating and Retrieving XML

AQxmlDebug.setTraceLevel(5); Chapter 11 - Searching XML Data AQxmlDebug.setDebug(true); AQxmlDebug.setLogStream(new FileOutputStream("aqlogfile")); Part III - Oracle XML for Java Developers Chapter 12 - Managing the Oracle XML Database

Chapter 13 - Getting Started with Oracle XML and Java

// Get and Set DataSource db_drv = new AQxmlDataSource(username, password, sid, host, port); Chapter 15 - Creating a Portal Site with XML and Web Services this.setAQDataSource(db_drv); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ } Chapter 17 - Developing XML-Based Reusable catch (AQxmlException aq_ex) Components { Part IV - Oracle XML for C Developers aq_ex.printStackTrace(); Chapter 18 - Getting Started with Oracle XML and C aq_ex.getNextException().printStackTrace(); Chapter 19 } - Building an XML-Managed Application Chapter 20 - Build an XML Database catch (Exception ex) {OCI Application Chapter 21 Create an XML-Configured ex.printStackTrace(); High-Performance Transformation Engine Part V } - Oracle XML for C++ Developers Chapter } 22 - Getting Started with Oracle XML and C++ } Chapter 23 - Build an XML Database OCI C++ Application Chapter 14 - Building an XML-Powered Web Site

Chapter 24 - Building an XML Data-Retrieval Application

There several you should note about the preceding code: Part VI -are Oracle XMLthings for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

You need to use the javax.servletclasses that are part of the servlet.jar file included with OC4J to configure

Chapter - Building Web Services this26class as an PL/SQL extension.

Chapter 27 - Extending PL/SQL XML Functionality with Java

To28 aid- in debugging, the AQxmlDebugfunctionality is set up and initialized to create a log file. The database Chapter Putting It All Together communication is configured to pass in the necessary login and database Appendix - XML Standards Bodies by andusing OpenAqxmlDataSource Specifications parameters. Glossary Index

An option to include a stylesheet is provided. The reason is that once a submission is made, the AQ Servlet provides a response in XML, as in the following example, and you may want to format it for better presentation if List of Tables the response will be viewed by a person. The classes of the package ORACLE.AQ.XMLare delivered with the List ofdatabase Sidebars distribution, in a file called aqxml.jar. List of Figures

<?xml version="1.0" ?> <Envelope xmlns="http://ns.oracle.com/AQ/schemas/envelope"> <Body> <AQXmlPublishResponse xmlns="http://ns.oracle.com/AQ/schemas/access"> <status_response> <status_code>0</status_code> </status_response>


<publish_result> <destination>POADMIN.poxml_q</destination> <message_id>21238FFE4B5D41E89E670D8CC147CD75</message_id> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & </publish_result> PL/SQL </AQXmlPublishResponse> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang </Body>McGraw-Hill/Osborne © 2004 (600 pages) </Envelope> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Every AQ submission has an associated ID that is generated by the database and that uniquely identifies the message. Therefore, this number can be used by customers to trace the disposition of their POs, regardless of the Table of Contents PO numbers they might have assigned. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Creating the AQ PO Process Procedures

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML Now that your messaging queue is configured to be able to accept POs, you can finally create the procedures to

Chapter - Accessing and StAXa combination of PL/SQL and Java. The reason that you actually2process them.XML Youwith areDOM, goingSAX, to doJAXB, this by using Chapter 3 to - Transforming with XSLT and XPath are going use PL/SQL XML is that this processing is being done within the database itself. Had you chosen to Chapter 4 -this Validating DTDsSOAP and XML Schemas implement design XML with with a midtier service and a messaging protocol such as JMS, everything could have Chapter 5 - in XML Operations been done Java, with thewith dataXQuery inserted using JDBC. In this case, the data is already in the database and you will Chapter 6 within - XML a Messaging and RPC with use Java stored procedure only SOAP to validate and analyze the PO using the new XDK validator class. Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Once message submitted, itfor is considered to be in the queue and needs to be dequeued to be processed. Then, Part II -a Oracle XMLisManagement DBAs the PO8must be extracted envelope and validated against its schema. Finally, the PO must be Chapter - Getting Startedfrom with the the SOAP Oracle XML Database

inserted into the PO database schema to be fulfilled. This is done in a single PL/SQL procedure called - Storing XML Data dequeueXMLAnalysis(), which is listed in this section and then explained in its component parts because it is quite Chapter 10 - Generating and Retrieving XML long. Chapter 9

Chapter 11 - Searching XML Data

Chapter 12 must - Managing the Oracle XML Database First, you load some subprocedures. As mentioned earlier, you are going to use Java to perform the validation Part - Oracle XML for Java Developers andIII analysis; the following Java stored procedure will set this up:

Chapter 13 - Getting Started with Oracle XML and Java

CREATE OR REPLACE FUNCTION XMLSemanticProcessing(xml IN CLOB,

Chapter 14 - Building anxsd XML-Powered IN CLOB,Web Site Chapter 15 - Creating aresult Portal Site XML and Web Services INwith OUT CLOB) Chapter 16VARCHAR2 - Developing an XML Gateway Application with SOAP and AQ RETURN Chapter 17 - Developing XML-Based Reusable Components IS LANGUAGE JAVA NAME Part IV - Oracle XML for C Developers 'oracle.xml.sample.semantics.XMLAnalysis.analyze(oracle.sql.CLOB,

Chapter 18 - Getting Started with Oracle XML and C oracle.sql.CLOB,oracle.sql.CLOB[]) returns java.lang.String'; Chapter / 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

The PO21and the XSD schema are passed in as CLOBs.Transformation Even though these are XML documents, there is no need to Chapter - Create an XML-Configured High-Performance Engine useVan XMLType because the Java class will parse them; thus, they are simply character strings at input. Part - Oracle XMLhere for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++

The other subprocedure performs the actual XML data insert and uses the PL/SQL versions of the XML SQL Utility

Chapter 23 the - Build an XML Database Application over the older, unprefixed packages because they are written that have DBMS_ prefix. TheseOCI areC++ recommended Chapter - Building anJava XML Data-Retrieval Application over C 24 (versus calling in JServer), thus improving performance significantly. Part VI - Oracle XML for PL/SQL Developers

CREATE OR REPLACE PROCEDURE insProc(xmlDoc IN CLOB, tableName IN VARCHAR2) IS Chapter 26 - Building PL/SQL Web Services insCtx DBMS_XMLSave.ctxType; Chapter 27 -NUMBER; Extending PL/SQL XML Functionality with Java rows Chapter 28 - Putting It All Together BEGIN Appendix - XML:= Standards Bodies and Open Specifications insCtx DBMS_XMLSave.newContext(tableName); Glossary DBMS_XMLSave.setRowtag(insCtx,'purchaseorder'); Index rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc); List of Figures DBMS_OUTPUT.put_line(rows||' rows inserted'); DBMS_XMLSave.closeContext(insCtx); List of Tables END; List of Sidebars / Chapter 25 - Getting Started with Oracle XML and PL/SQL

Note that you are inserting into <purchaseorder> instead of the <PO> table of your original schema, because the POUSER schema spans multiple tables and you need to use the object view that you defined earlier. Upon insert, the INSTEAD OF INSERT trigger will fire, properly inserting the data and creating the appropriate keys to link the rows. Now you get to the main procedure. Because this has many parts and calls other procedures, you need to have a


set of variables declared as follows: CREATE OR REPLACE PROCEDURE dequeueXMLAnalysis(p_consumer IN VARCHAR2, p_queue IN &VARCHAR2) Oracle Database 10g XML SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL AS ISBN:0072229527 Ben Chang and Jinyu Wang v_msgidby Mark V. Scardina, RAW(16); © 2004 (600 pages) v_dopt McGraw-Hill/Osborne dbms_aq.dequeue_options_t; v_mpropThis comprehensive dbms_aq.message_properties_t; guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. v_payload XMLTYPE; no_messages EXCEPTION; PRAGMA EXCEPTION_INIT(no_messages, -25228); Table of Contents v_xml CLOB; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL v_xsd CLOB; Introduction v_result Part I - Oracle and CLOB; the XML Standards v_insert CLOB; Chapter 1 - Introducing XML v_out VARCHAR2(32767); Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX v_temp XMLType; Chapter 3 - Transforming XML with XSLT and XPath v_sendby VARCHAR2(32767); Chapter 4 - Validating XML with DTDs and XML Schemas v_id VARCHAR2(10); Chapter 5 - XML Operations with XQuery v_i NUMBER; Chapter 6 - XMLVARCHAR2(100); Messaging and RPC with SOAP v_name Chapter 7 Putting It All Together with XML Pipeline, JSPs, and XSQL v_doc XMLTYPE; Part II - Oracle XML Management for DBAs

Chapter Note that 8 v_dopt - Getting and Started v_mprop with are the simply Oracle aliases XML Database for longer function names. Now you begin the body by retrieving

the XML Chapter 9 document: - Storing XML Data Chapter BEGIN 10 - Generating and Retrieving XML Chapter - Searching XML Data -- 11 Setup Dequeue Options Chapter v_dopt.consumer_name 12 - Managing the Oracle XML := p_consumer; Database Part III v_dopt.dequeue_mode - Oracle XML for Java Developers := DBMS_AQ.REMOVE;

v_dopt.wait := DBMS_AQ.NO_WAIT; Chapter 13 - Getting Started with Oracle XML and Java v_dopt.navigation := DBMS_AQ.FIRST_MESSAGE; Chapter 14 - Building an XML-Powered Web Site LOOP Chapter 15 - Creating a Portal Site with XML and Web Services => p_queue, Chapter DBMS_AQ.dequeue(queue_name 16 - Developing an XML Gateway Application with SOAP and AQ dequeue_options => v_dopt, Chapter 17 - Developing XML-Based Reusable Components message_properties Part IV - Oracle XML for C Developers

=> v_mprop, payload => v_payload, Chapter 18 - Getting Started with Oracle XML and C msgid => v_msgid); Chapter 19 - Building an XML-Managed Application v_xml := v_payload.getClobVal(); Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Create an XML-Configured Transformation Engine In the preceding code you start a loopHigh-Performance to process each PO message. Once you have a PO, you need to get the Part V - Oracle XML for C++ Developers schema to validate:

Chapter 22 - Getting Started with Oracle XML and C++

SELECT xsd INTO v_xsd FROM xsd_tbl WHERE id=1;

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI perform - Oracle the XMLvalidation for PL/SQL Developers Then, and analysis:

Chapter 25 - Getting Started with Oracle XML and PL/SQL DBMS_LOB.createtemporary(v_result,TRUE,DBMS_LOB.SESSION); Chapter 26 - Building PL/SQL Web Services DBMS_LOB.createtemporary(v_insert,TRUE,DBMS_LOB.SESSION); Chapter v_out 27 - Extending PL/SQL XML Functionality with Java := XMLSemanticProcessing(v_xml,v_xsd,v_result); Chapter IF 28 -v_out Putting = It All Together 'OK' THEN Appendix INSERT - XML Standards Bodies and Open Specifications INTO po_tbl(msgid, consumer, podoc) Glossary VALUES(v_msgid,p_consumer, XMLTYPE(v_result)); Index

INSERT INTO po_backup_tbl(msgid, consumer, podoc)

VALUES(v_msgid,p_consumer, XMLTYPE(v_xml)); List of Figures List of Tables

Note that based upon a successful validation and analysis returning OK, you store the results in two tables—one for further processing and one for archiving. Finally, you insert the data into the tables with XSU and end the loop:

List of Sidebars

DBMS_LOB.OPEN(v_insert, DBMS_LOB.LOB_READWRITE); DBMS_LOB.writeappend(v_insert,length('<ROWSET>'),'<ROWSET>'); DBMS_LOB.append(v_insert,v_result); DBMS_LOB.writeappend(v_insert,length('</ROWSET>'),'</ROWSET>'); DBMS_LOB.CLOSE(v_insert); dbms_output.put_line(v_msgid); INSERT INTO poid values(v_msgid);


insProc(v_insert,'purchaseorder'); DBMS_LOB.freetemporary(v_insert); DBMS_LOB.freetemporary(v_result); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & -- Commit PL/SQL the transaction DELETE FROM ISBN:0072229527 by Mark V. poid; Scardina, Ben Chang and Jinyu Wang ELSE McGraw-Hill/Osborne © 2004 (600 pages) DBMS_OUTPUT.put_line(v_out); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with INSERT INTO onpo_rejected_tbl(msgid, consumer, podoc,reason) emphasis XML standards, their usage and best practices. VALUES(v_msgid,p_consumer, XMLTYPE(v_xml),v_out); END IF; Table of Contents COMMIT; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL v_dopt.navigation := DBMS_AQ.NEXT_MESSAGE; Introduction END LOOP Part I - Oracle and the XML Standards

Chapter 1 the - Introducing Note that XML was XML encapsulated in <ROWSET> elements. This is done to make the XML data acceptable by Chapter 2 - Accessing XML with DOM, JAXB, and not StAX XSU because the document listed at SAX, the end would have a single root. Also, rejected POs are stored in a Chapter separate 3 po_rejected_tbl. - Transforming XML Thewith procedure XSLT and then XPath ends by handling possible errors: Chapter 4 - Validating XML with DTDs and XML Schemas EXCEPTION Chapter 5 - XML Operations with XQuery WHEN no_messages THEN Chapter 6DBMS_OUTPUT.put_line( - XML Messaging and RPC with SOAP 'Error:'||'No more messages in queue.'); Chapter END; 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part / II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Now that you have walked through the process, you can see the transformation that took place between the original PO and the XML that was inserted by XSU. The following is the original PO:

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

<purchaseOrder Chapter 12 - ManagingorderDate="2003-10-20" the Oracle XML Database xmlns="http://ns.oracle.com/AQ/schemas/access"> Part III - Oracle XML for Java Developers <ShipTo country="US"> Chapter 13 - Getting Started with Oracle XML and Java <name>California Whirligig</name> <street>123 Maple Street</street> Chapter 15 - Creating a Portal Site with XML and Web Services <city>Mill Valley</city> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <state>CA</state> Chapter 17 - Developing XML-Based Reusable Components <zip>90952</zip> Part IV - Oracle XML for C Developers </ShipTo> Chapter 18 - Getting Started with Oracle XML and C <BillTo country="US"> Chapter 19 - Building an XML-Managed Application <name>U.S. Whirligig</name> Chapter 20 Build an XML Database OCI Application <street>8 Oak Avenue</street> Chapter 21 Create an XML-Configured High-Performance Transformation Engine <city>Old Town</city> Part V <state>PA</state> - Oracle XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++ <zip>95819</zip> Chapter 23 - Build an XML Database OCI C++ Application </BillTo> Chapter <LineItems> 24 - Building an XML Data-Retrieval Application Part VI<LineItem - Oracle XMLpartNum="872-AA"> for PL/SQL Developers <ProductName>Micro Widget</ProductName> Chapter 25 - Getting Started with Oracle XML and PL/SQL <Quantity>1</Quantity> Chapter 26 - Building PL/SQL Web Services <UnitofPrice>148.95</UnitofPrice> Chapter 27 - Extending PL/SQL XML Functionality with Java </LineItem> Chapter 28 - Putting It All Together <LineItem partNum="926-AA"> Appendix - XML Standards Bodies and Open Specifications <ProductName>Multi-Widget</ProductName> Glossary <Quantity>1</Quantity> Index <UnitofPrice>39.98</UnitofPrice> List of Figures </LineItem> List of Tables </LineItems> List of Sidebars <comment>Hurry, I can't stop this thing!</comment> </purchaseOrder> Chapter 14 - Building an XML-Powered Web Site

The original PO was transformed into the following: <ROWSET> <ROW num="1"> <PO_ID>7F2F2FED620F4400A2F598B23965492F</PO_ID> <SHIPPING_ADDR>


<CUSTOMER_NAME>California Whirligig</CUSTOMER_NAME> <STREET>123 Maple Street</STREET> <CITY>Mill Valley</CITY> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <STATE>CA</STATE> PL/SQL <ZIP>90952</ZIP> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <COUNTRY>US</COUNTRY> McGraw-Hill/Osborne © 2004 (600 pages) </SHIPPING_ADDR> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <BILLING_ADDR> emphasis on XML standards, their usage and best practices. <CUSTOMER_NAME>U.S. Whirligig</CUSTOMER_NAME> <STREET>8 Oak Avenue</STREET> Table of Contents <CITY>Old Town</CITY> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <STATE>PA</STATE> Introduction <ZIP>95819</ZIP> Part I - Oracle and the XML Standards <COUNTRY>US</COUNTRY> Chapter 1 - Introducing XML </BILLING_ADDR> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <LINEITEMS> Chapter 3 - Transforming XML with XSLT and XPath <LINEITEMS_ITEM> Chapter 4 - Validating XML with DTDs and XML Schemas <PRODUCT_ID>872-AA</PRODUCT_ID> Chapter 5 - XML Operations with XQuery <PRODUCT_NAME>Micro Widget</PRODUCT_NAME> Chapter <PRODUCT_QUANTITY>1</PRODUCT_QUANTITY> 6 - XML Messaging and RPC with SOAP <PRODUCT_PRICE>148.95</PRODUCT_PRICE> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL </LINEITEMS_ITEM> Part II - Oracle XML Management for DBAs <LINEITEMS_ITEM> Chapter 8 - Getting Started with the Oracle XML Database <PRODUCT_ID>926-AA</PRODUCT_ID> Chapter 9 - Storing XML Data <PRODUCT_NAME>Multi-Widget</PRODUCT_NAME> Chapter 10 - Generating and Retrieving XML <PRODUCT_QUANTITY>1</PRODUCT_QUANTITY> Chapter 11 - Searching XML Data <PRODUCT_PRICE>39.98</PRODUCT_PRICE> Chapter 12 - Managing the Oracle XML Database </LINEITEMS_ITEM> Part III - Oracle XML for Java Developers </LINEITEMS> Chapter 13 - Getting Started with Oracle XML and Java </ROW> Chapter 14 - Building an XML-Powered Web Site </ROWSET> Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 the - Developing an XML Gateway with andnames AQ Note that <comment> element wasApplication ignored and theSOAP element were transformed. This process occurred Chapter 17 -analysis Developing XML-Based during the phase in Java. Reusable The nextComponents section discusses this phase in detail. Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

Extending the Framework

Chapter 19 - Building an XML-Managed Application Chapter 20 your - Build an XMLis Database OCI Application Although company a successful one, it is not in position to dictate that all of your customers use your PO Chapter 21 - Create an XML-Configured High-Performance Transformation Engine XML schema. Therefore, when companies want to do business with your company, they will provide their own PO Part V - Oracle forstore C++ each Developers schemas. YouXML could of them and load them individually each time you get a PO, to validate it. This is

Chapter 22 - because Getting Started and C++ expensive, you notwith onlyOracle need XML to retrieve it but also need to parse it and build a compiled schema object Chapter that will23 be- thrown Build anaway XML each Database time.OCI Instead C++ of Application using these separately for each respective PO instance, you can

extract 24 the- types youanare interested in and Application add them to your base schema. The following is an example of a schema Chapter Building XML Data-Retrieval thatVI semantically meets your requirements Part - Oracle XML for PL/SQL Developers but uses different syntax: Chapter 25 - Getting Started with Oracle XML and PL/SQL <xsd:schema targetNamespace="http://ns.oracle.com/AQ/schemas/access" Chapter 26 - Building PL/SQL Web Services xmlns:xsd="http://www.w3.org/2001/XMLSchema" Chapter 27 - Extending xmlns:xdk="http://xmlns.oracle.com/xdk" PL/SQL XML Functionality with Java

xmlns="http://ns.oracle.com/AQ/schemas/access" Chapter 28 - Putting It All Together - XML elementFormDefault="qualified" Standards Bodies and Open Specifications xdk:TableName="ORDERS"> <!-Address Type --> Glossary <xsd:complexType name="AddressType"> Index <xsd:sequence> List of Figures <xsd:element name="name" type="xsd:string" List of Tables xdk:SQLName="CUSTOMER_NAME"/> List of Sidebars <xsd:element name="street" type="xsd:string" xdk:SQLName="STREET"/> <xsd:element name="city" type="xsd:string" xdk:SQLName="CITY"/> <xsd:element name="state" type="xsd:string" xdk:SQLName="STATE"/> <xsd:element name="zip" type="xsd:string" xdk:SQLName="ZIP"/> Appendix


</xsd:sequence> <xsd:attribute name="country" type="xsd:string" xdk:SQLName="COUNTRY"/> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <xsd:anyAttribute processContents="skip"/> PL/SQL </xsd:complexType> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <!--Sendby Address Element--> McGraw-Hill/Osborne © 2004 (600 pages) <xsd:element name="sendby" type="AddressType" This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with xdk:SQLName="SENDBY_ADDR"/> emphasis on XML standards, their usage and best practices. <!--Shipping Address Element--> <xsd:element name="DeliverTo" type="AddressType" Table of Contents xdk:SQLName="SHIPPING_ADDR"/> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <xsd:element name="ShipTo" type="AddressType" Introduction xdk:SQLName="SHIPPING_ADDR"/> Part I - Oracle and the XML Standards <!--Billing Address Element--> Chapter 1 - Introducing XML <xsd:element name="BillTo" type="AddressType" Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX xdk:SQLName="BILLING_ADDR"/> Chapter 3 - Transforming XML with XSLT andtype="AddressType" XPath <xsd:element name="InvoiceTo" Chapter 4 - Validating XML with DTDs and XML Schemas xdk:SQLName="BILLING_ADDR"/> Chapter 5 - XMLItem Operations with XQuery <!--Line Type--> Chapter <xsd:complexType 6 - XML Messagingname="LineItemType"> and RPC with SOAP <xsd:all> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL <xsd:element name="ProductName" type="xsd:string" Part II - Oracle XML Management for DBAs Chapter 8 - Getting Startedxdk:SQLName="PRODUCT_NAME"/> with the Oracle XML Database name="Quantity" type="xsd:string" Chapter 9<xsd:element - Storing XML Data Chapter 10 - Generating andxdk:SQLName="PRODUCT_QUANTITY"/> Retrieving XML <xsd:element type="xsd:string" Chapter 11 - Searching XMLname="UnitofPrice" Data xdk:SQLName="PRODUCT_PRICE"/> Chapter 12 - Managing the Oracle XML Database </xsd:all> Part III - Oracle XML for Java Developers <xsd:attribute name="partNum" type="xsd:string" Chapter 13 - Getting Started with Oracle XML and Java xdk:SQLName="PRODUCT_ID"/> Chapter 14 - Building an XML-Powered Web Site </xsd:complexType> Chapter 15 - Creating a Portal Site with XML and Web Services <xsd:complexType name="POItemType"> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <xsd:all> Chapter 17 - Developing XML-Based Reusable Components <xsd:element name="ProductID" type="xsd:string" Part IV - Oracle XML for C Developers xdk:SQLName="PRODUCT_ID"/> Chapter 18 - Getting Startedname="Quantity" with Oracle XML and type="xsd:string" C <xsd:element Chapter 19 - Building an XML-Managed Application xdk:SQLName="PRODUCT_QUANTITY"/> Chapter 20 - Build an XML Database OCI Application type="xsd:string" <xsd:element name="UnitofPrice" Chapter 21 - Create an XML-Configured High-Performance Transformation Engine xdk:SQLName="PRODUCT_PRICE"/> Part V </xsd:all> - Oracle XML for C++ Developers Chapter <xsd:attribute 22 - Getting Startedname="name" with Oracle XMLtype="xsd:string" and C++ Chapter 23 - Build an XML Database OCIxdk:SQLName="PRODUCT_NAME"/> C++ Application </xsd:complexType> Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

<!-Items Element -->XML and PL/SQL Chapter 25Line - Getting Started with Oracle <xsd:element name="LineItems" Chapter 26 - Building PL/SQL Web Services xdk:SQLName="LINEITEMS"> <xsd:complexType> Chapter 27 - Extending PL/SQL XML Functionality with Java <xsd:sequence> <xsd:element name="LineItem" type="LineItemType" Appendix - XML Standards Bodies and Open Specifications maxOccurs="unbounded" Glossary xdk:SQLName="LINEITEM"/> Index </xsd:sequence> List of Figures </xsd:complexType> List </xsd:element> of Tables List <xsd:element of Sidebars name="POLines" xdk:SQLName="LINEITEMS"> <xsd:complexType> <xsd:choice> <xsd:element name="POItem" type="POItemType" maxOccurs="unbounded" xdk:SQLName="LINEITEM"/> </xsd:choice> </xsd:complexType> </xsd:element> Chapter 28 - Putting It All Together


</xsd:schema> There are a few unexpected aspects to this schema that allow you to use it for more than simple validation. First, Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & each named element and attribute has an additional xdk:SQLName="" annotation that corresponds to the column PL/SQL name in your database schema. These annotations can be retrieved by your application by using the new ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang XSDValidator class in the xmlparserv2.jar file. These annotations conform to the extension mechanisms provided McGraw-Hill/Osborne © 2004 (600 pages) for in the XML Schema 1.0 specification and provide a similar function to the xdb:SQLType annotations used to This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with direct the XMLemphasis DB upon on schema registration. XML standards, their usage and best practices. Additionally, note that there are multiple elements that map to the same xdk:SQLName, such as “ShipTo” and Table of Contents “DeliverTo”. These reflect the addition of company schemas into your master schema, thus allowing you to only load Oracle one schema Database regardless 10g XML & of SQL—Design, the PO beingBuild received. & Manage In fact, XML your Applications application in can Java, keep C, C++ its compiled & PL/SQLschema object in

memory for all validations. Because you extracted these types from the original company PO schemas, any changes Introduction to them that do not change the specific types you need will not cause you to reject the PO. This is an important Part I - Oracle and the XML Standards feature1that promotes the reliability of your application. Chapter - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 6

- XML Messaging and RPC with SOAP

Now you are ready to analyze the Java code that will use this XML schema to deliver a validated and transformed Chapter 3 - Transforming XML with XSLT and XPath PO that can be successfully inserted into your PO database schema. This code is organized into two source files, Chapter 4 - Validating XML with DTDs and XML Schemas XMLAnalysis.java and XMLAnalysisHandler.java, the latter of which is called by the former to perform most of the Chapter 5 - XML Operations with XQuery work. The following are code fragments from XMLAnalysis.java: public class XMLAnalysis { - Putting It All Together with XML Pipeline, JSPs, and XSQL public XMLAnalysis() { Part II - Oracle XML Management for DBAs } Chapter 8 - Getting Started with the Oracle XML Database public static String analyze(CLOB xml_doc, CLOB xsd_doc, Chapter 9 - Storing XML Data CLOB[] res_doc) { Chapter 10 - Generating and Retrieving XML Reader rd; Chapter 11 - Searching XML Data Writer wt = null; Chapter 7

Chapter 12 - Managing the Oracle XML Database Part III - Oracle forResult Java Developers // CheckXML the CLOB

Chapter 13 - Getting Started Oracle if(res_doc[0] == with null) { XML and Java Chapter 14 - Building an XML-Powered return "CLOB to write Web canSite not be null."; Chapter } 15 - Creating a Portal Site with XML and Web Services

try Chapter 16 -{Developing an XML Gateway Application with SOAP and AQ wt- Developing =res_doc[0].getCharacterOutputStream(); Chapter 17 XML-Based Reusable Components //Build Schema Part IV - Oracle XMLup for XML C Developers

Object rd = xsd_doc.getCharacterStream(); Chapter 18 - Getting Started with Oracle XML and C XSDBuilder = new XSDBuilder(); Chapter 19 - Building an builder XML-Managed Application XMLSchema schemadoc = (XMLSchema)builder.build(rd,null); Chapter 20 - Build an XML Database OCI Application // Create Content Handlers Chapter 21 - Create an XML-Configured High-Performance Transformation Engine XMLAnalysisHandler POHandler = Part V - Oracle XML for C++ Developers new XMLAnalysisHandler(new PrintWriter(wt)); Chapter 22 - Getting Started with Oracle XML and C++ // Setup for SAX XML Schema Validation Chapter 23 - Build an XML Database OCI C++ Application SAXParser parser = new SAXParser(); Chapter 24 - Building an XML Data-Retrieval Application parser.setContentHandler(POHandler); Part VI - Oracle XML for PL/SQL Developers POHandler.setXMLProperty(XSDConstantValues.FIXED_SCHEMA,schemadoc); Chapter 25 - Getting Started with Oracle XML and PL/SQL POHandler.setXMLProperty(XSDConstantValues.VALIDATION_MODE, Chapter 26 - Building PL/SQL Web Services XSDConstantValues.LAX_VALIDATION); Chapter 27 PL/SQL Functionality with Java //- Extending Parse the XMLXML document Chapter 28 It All Together rd- Putting = xml_doc.getCharacterStream(); Appendix parser.parse(rd); - XML Standards Bodies and Open Specifications Glossary } catch(Exception e) { Index e.printStackTrace(); return e.getMessage(); List of Figures } List of Tables return "OK"; List of Sidebars } This is the method that gets the XML document and performs a SAX-based validation by using LAX mode and registering the XMLAnalysisHandler to receive the SAX events. The reason for using LAX mode is that the instance document may contain content that you are not interested in or that your application is not set up to consume, such as the <comment> element included earlier. In LAX mode the schema processor skips unknown content but performs STRICT mode validation on known content. All of the actual work is done in the XMLAnalysisHandler. The following listing includes the declarations and


constructor of this handler: public class XMLAnalysisHandler extends XSDValidator { private Oracle PrintWriter out; Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL isSelect; private boolean ISBN:0072229527 by Mark V. Scardina, private StringBuffer buf;Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) private int level; private Hashtable po_tbl; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on name_tbl; XML standards, their usage and best practices. private Hashtable private DMElement cur_elem; private XMLError err; Table of Contents private XSDElement elementNode; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

public XMLAnalysisHandler(PrintWriter Part I - Oracle and the XML Standards

out) throws XSDException,SAXException

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

{

po_tbl = new Hashtable(); Chapter 3 - Transforming XML with XSLT and XPath name_tbl = new Hashtable(); Chapter 4 - Validating XML with DTDs and XML Schemas buf = new StringBuffer(); Chapter 5 - XML Operations with XQuery err = new XMLError(); Chapter 6 - XML Messaging and RPC with SOAP setError(err); Chapter 7 - Putting false; It All Together with XML Pipeline, JSPs, and XSQL isSelect= Part IIlevel - Oracle=XML Management for DBAs 0; Chapter 8 Getting Started with the Oracle XML Database this.out= out; Chapter 9 - Storing XML Data write("<PURCHASEORDER>\n"); Chapter } 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

Note that the java.util.Hashtable class is used to store the elements of the PO and that an initial Part III - Oracle XML for Java Developers <purchaseOrder> is the root tag theJava transformed output. Chapter 13 - Getting element Started with Oracle XMLofand Chapter 14 - Building an XML-Powered Web Site

Since this is a SAX parse, you need to register event handlers for each type of SAX event you use. In this case, you

Chapter 15 - Creating aendElement(), Portal Site with XML and Web Services needstartElement(), and endDocument(). The following lists their respective code fragments: Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException Part IV - Oracle XML for C Developers { Chapter 18 - Getting Started with Oracle XML and C String schemaName = null; Chapter 17 - Developing XML-Based Reusable Components

Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application super.startElement(namespaceURI,localName,qName,atts); Chapter 21Create - Create an XML-Configured Transformation Engine // the DMElement High-Performance at the start of Strict validation Part V if(getCurrentMode()==_strict - Oracle XML for C++ Developers

&& level==0)

Chapter { 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application isSelect=true; Chapter 24 cur_elem= - Building annew XMLDMElement(); Data-Retrieval Application Part VI - Oracle //level=curState; XML for PL/SQL Developers

level=0; Chapter 25 - Getting Started with Oracle XML and PL/SQL } 26 - Building PL/SQL Web Services Chapter if == true) { Chapter 27(isSelect - Extending PL/SQL XML Functionality with Java level++; Chapter 28 - Putting It All Together mapped Bodies name based upon localName Appendix //Get - XML Standards and Open Specifications String elementName = getElementName(localName); if(elementName != null) Index { List of Figures //store in hashtable with localName as key List of Tables name_tbl.put(localName, elementName); List of Sidebars //write into buffer new mapped tag name and its attributes writeElement("<"+elementName+">"); printAttributes(atts); } } } Glossary

This handler is using the getCurrentMode method in the XSDValidator class to query the state of its schema


validation. If the mode returned is _strict, the content will be buffered for transformation in DMElement, as this is a known element, and subsequently written to the name_tbl hash table. On the other hand, any _lax results indicate an unrecognized element that will10g be ignored. NoteDesign, also theBuild use of& the level XML variable as a way toinhandle theC++ nesting Oracle Database XML & SQL: Manage Applications Java, C, & of XML elements. Once a strict validation starts, it is used as a stack to indicate the process is continuing. Finally, PL/SQL this handler calls an internal method to retrieve the mapped name based upon the ISBN:0072229527 by getElementName(), Mark V. Scardina, Benwhich Changisand Jinyu Wang local name. The following is the code: McGraw-Hill/Osborne © 2004 (600 pages) String getElementName(String { This comprehensive guidelocalName) focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML standards, their usage and best practices. String emphasis elementName=""; //Call new interface to get schema node associated with localname elementNode = getElementDeclaration(); Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

// Find the XDK Annotation from the attributes Introduction (elementNode != null) Part I -if Oracle and the XML Standards

{ XSDAnnotation ann = elementNode.getAnnotation(); Chapter 1 - Introducing XML if ( ann != null) { Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX Vector attrs = ann.getAttributes(); Chapter 3 - Transforming XML with XSLT and XPath int attrs_size = attrs.size(); Chapter 4 - Validating XML with DTDs and XML Schemas for (int i =0; i< attrs_size; i++) { Chapter 5 - XML Operations with XQuery XMLAttr xsd_attr = (XMLAttr)attrs.get(i); Chapter 6 - XML Messaging and with SOAP String name = RPC xsd_attr.getName(); Chapter 7 - Putting It All Together with XML Pipeline, JSPs,{and XSQL if (name.equals("xdk:SQLName")) Part II - Oracle XML Management for DBAs elementName= xsd_attr.getValue(); Chapter 8 - Getting Started with the Oracle XML Database break; Chapter 9 - Storing XML Data } Chapter 10 -}Generating and Retrieving XML Chapter 11 } - Searching XML Data no annotation let elementName=localName; Chapter 12//if - Managing the Oracle XML Database (elementName.equals("")) return null; Part III - if Oracle XML for Java Developers } 13 - Getting Started with Oracle XML and Java Chapter return elementName; Chapter 14 - Building an XML-Powered Web Site } Chapter 15 - Creating a Portal Site with XML and Web Services } Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

This method uses getElementDeclaration, which is another of the XSDValidator methods, and returns the node from the master XML schema in order to retrieve the xdk:SQLName annotation. This is done by populating a vector Chapter 18 - Getting Started with Oracle XML and C with all the annotations by calling the getAnnontation() method from the XSDAnnotationclass. Once populated, Chapter - Building an traversed XML-Managed Application theattrs19vector can be to find the matching name. If no SQLName annotation is found, then the element Chapter 20 Build an XML Database OCI Application name is returned unchanged. Part IV - Oracle XML for C Developers

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

While documents have the concept of attributes that may contain data, relational databases do not. Therefore, Part V -XML Oracle XML for C++ Developers any data-conveying attributes must be XML transformed, Chapter 22 - Getting Started with Oracle and C++ or canonicalized, into XML elements in order for them to be stored relationally. the purpose theApplication printAttributes() method in the startElement() handler. The following Chapter 23 - Build anThis XMLisDatabase OCI of C++ is the associated code: Chapter 24 - Building an XML Data-Retrieval Application Part void VI -printAttributes(Attributes Oracle XML for PL/SQL Developers atts)

{

String attr_name; Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

int = atts.getLength(); Chapter 27 -len Extending PL/SQL XML Functionality with Java if <1)It All return; Chapter 28(len - Putting Together for -(int i=0; i<Bodies len;and i++) { Specifications Appendix XML Standards Open attr_name = getAttributeName(atts.getLocalName(i)); if(attr_name != null) Index { List of Figures writeElement("<"+attr_name+">"); List of Tables writeElement(atts.getValue(i)); List of Sidebars writeElement("</"+attr_name+">"); } } } Glossary

Note that it needs to walk through the list of attributes for the XML element, and when a mapping is found by a string returned from getAttributeName(), write out its value as a mapped XML element. The code to check for this match is a derivation of the getElementName() method, as follows:


String getAttributeName(String localName) { String attrName=""; if(elementNode == null) return localName; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

elementNode by Mark= V.getElementDeclaration(); Scardina, Ben Chang and Jinyu Wang XSDAttribute[] attrNode© 2004 = elementNode.getAttributeDeclarations(); McGraw-Hill/Osborne (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

for (int j=0;j<attrNode.length; j++) and { best practices. emphasis on XML standards, their usage if (attrNode[j].getName().equals(localName)) { XSDAnnotation ann = attrNode[j].getAnnotation(); Table of Contents if ( ann != null) { Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Vector attrs = ann.getAttributes(); Introduction int attrs_size = attrs.size(); Part I - Oracle and the XML Standards for (int i =0; i< attrs_size; i++) { Chapter 1 - Introducing XML XMLAttr xsd_attr = (XMLAttr)attrs.get(i); Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX String name = xsd_attr.getName(); Chapter 3 - Transforming XML with XSLT and XPath if (name.equals("xdk:SQLName")) { Chapter 4 - Validating XML with DTDs and XML Schemas attrName= xsd_attr.getValue(); Chapter 5 - XML Operations break; with XQuery Chapter 6 - XML } Messaging and RPC with SOAP Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL } Part II - Oracle } XML Management for DBAs Chapter 8 }- Getting Started with the Oracle XML Database } 9 - Storing XML Data Chapter if return null; //attrName = localName; Chapter 10(attrName.equals("")) - Generating and Retrieving XML Chapter 11 - Searching XML Data

return attrName; Chapter 12 - Managing the Oracle XML Database Part}III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

Similar to getElementDeclaration(), there is a corresponding attribute version called getAttributeDeclarations() thatreturns all the attribute nodes associated with an element. However, since there can be many nodes, it returns Chapter 15 - Creating a Portal Site with XML and Web Services them in an array, and thus your code must walk through the attrNode array of attrs vectors. Chapter 14 - Building an XML-Powered Web Site

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter Turning17 now - Developing to the endElement() XML-Basedcode, Reusable you Components can see how the complete element is processed in the following code: Part IV - Oracle for C Developers public voidXML endElement(String

namespaceURI, String localName,String qName)

Chapter 18 - Getting Started with Oracle XML and C throws SAXException Chapter { 19 - Building an XML-Managed Application Chapter 20 - Build an XMLann; Database OCI Application XSDAnnotation Chapter String 21 - Create elementName; an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

super.endElement(namespaceURI, Chapter 22 - Getting Started with Oracle XML and localName,qName); C++ Chapter 23 - Build an XML Database OCI C++ Application

if { Chapter 24(isSelect - Building an == XMLtrue) Data-Retrieval Application level--; Part VI - Oracle XML for PL/SQL Developers flushChar(); Chapter 25 - Getting Started with Oracle XML and PL/SQL //- Building OutputPL/SQL the endTag of the Element Chapter 26 Web Services elementName = (String)name_tbl.get(localName); writeElement("</"+elementName+">"); Chapter 28 - Putting It All Together // If validation errors exists, exit the process Appendix - XML Standards Bodies and Open Specifications int i = err.getFirstError(); Glossary if (i!=-1) Index throw new List of Figures SAXException("(Line,Column)("+err.getLineNumber(i)+","+ List of Tables err.getColumnNumber(i)+"):"+err.getMessage(i)); List of Sidebars // Save the Validated Element cur_elem.level = level; cur_elem.isValid=true; po_tbl.put(elementName, cur_elem); if(level==0){ isSelect=false; } } else { flushChar(); Chapter 27 - Extending PL/SQL XML Functionality with Java


} } Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

First, note that PL/SQL although the validation is namespace aware, your database schema is not; therefore, you are only interested in the local name of the element for processing. Since this is the end tag and you have already done the ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang mapping for the start tag, it can be written by using a simple hash table lookup based upon the localName. If the McGraw-Hill/Osborne © 2004 (600 pages) element correctly validates, it is sent to the po_tblhash table, from which it will be evaluated. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices. Once all the elements are processed, the endDocument() event is received. This event triggers several actions, as illustrated in the following handler code: Table of Contents public void endDocument() throws SAXException Oracle { Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction String[] ship_elems = new String[]{"SHIPPING_ADDR"}; Part I -String[] Oracle and bill_elems the XML Standards = new

String[]{"BILLING_ADDR"};

Chapter 1 - Introducing XML String[] line_elems = new String[]{"LINEITEMS"}; Chapter 2 Accessing XML with=DOM, SAX, JAXB, and StAX DMElement ck_elem null; Chapter 3

- Transforming XML with XSLT and XPath

//Check Required Shipping Chapter 4 - Validating XML with DTDs andAddress XML Schemas = (DMElement) po_tbl.get(ship_elems[i]); Chapter 5ck_elem - XML Operations with XQuery (ck_elem !=and null) Chapter 6if- XML Messaging RPC with SOAP Chapter 7

write(ck_elem.content); - Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

if == null) Chapter 8 (ck_elem - Getting Started with the Oracle XML Database throw new SAXException("Missing required Shipping Address!"); - Storing XML Data else if (ck_elem.content == null) Chapter 10 - Generating and Retrieving XML throw new SAXException("Shipping Address doesn't have content!"); Chapter 9

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database

//Check Required Billing Address ck_elem = null; Chapter 13 - Getting Started with Oracle XML and Java ck_elem = (DMElement) po_tbl.get(bill_elems[i]); Chapter 14 an XML-Powered if- Building (ck_elem != null) Web Site Chapter 15 - Creating a Portal Site with XML and Web Services write(ck_elem.content); Part III - Oracle XML for Java Developers

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 if- Developing (ck_elemXML-Based == null)Reusable Components Part IV - Oracle C Developers throwXML newforSAXException("Missing

required Billing Address!");

Chapter 18 - Getting Started with Oracle XML and C else if (ck_elem.content == null) Chapter 19 throw - Building newanSAXException("Billing XML-Managed Application Address doesn't have content!"); Chapter 20 - Build an XML Database OCI Application

//Check Required LineItems Chapter 21 - Create an XML-Configured High-Performance Transformation Engine = for null; Part V ck_elem - Oracle XML C++ Developers ck_elem (DMElement) Chapter 22 - Getting=Started with Oraclepo_tbl.get(line_elems[i]); XML and C++ if- Build (ck_elem null)OCI C++ Application Chapter 23 an XML!= Database write(ck_elem.content); Chapter 24 - Building an XML Data-Retrieval Application if (ck_elem == null) Part VI - Oracle XML for PL/SQL Developers throw new SAXException("Missing required LineItems!"); else if (ck_elem.content == null) Chapter 26 - Building PL/SQL Web Services throw new SAXException("LineItems don't have content!"); Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

//Write new PO closing tag - XML Standards Bodies and Open Specifications write("</PURCHASEORDER>"); Glossary out.flush(); Index } Appendix

List of Figures

First, the essential types that you need to have a complete PO are initialized as strings. List of Tables List of Sidebars

Note Instead of being hard-coded, these strings could be read from an external configuration file or the DB itself, thus making the code more generic and extensible.

Then, you use these strings to look up the elements from the po_tbl hash table and check to see not only whether the element is there but also whether it contains content as is done in each ck_elem() function. If either of these conditions fails, then the appropriate error message is returned. If both conditions pass, then the closing element tag is printed and the validated and transformed document is returned for submission by XSU into the database.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML &Functionality SQL: Design, Build & Manage XML Applications in Java, C, C++ & ExtendingOracle the Database Application’s PL/SQL

ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyuwith Wang As you should by have seen, this use of a master schema Oracle Streams AQ and SOAP is quite powerful © 2004 (600 pages) functionality yetMcGraw-Hill/Osborne simple in its configuration. Adding new customers is simply a matter of adding new types to your master schema. Performance is not affected because additional elements and attributes areXML-enabled looked up efficiently This comprehensive guide focuses on utilizing XML technologies within Oracle's products,by with emphasis XML standards, their usage andmay bestbe practices. using hash tables. Note on however, that the client schema complex in situations where the types you need are not at the top level. This is not a problem, because the application won’t get the mode change signal from LAX to STRICT until the validator encounters the known type, no matter how buried it is. There are several features or Table of Contents conditions you may need& to accommodate. We will close theApplications chapter withinaJava, brief C, discussion of these. Oracle Database 10g XML SQL—Design, Build & Manage XML C++ & PL/SQL

Introduction

Submitting SOAP Messages

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Thus far, have covered onlyDOM, the processing SOAP-based POs, not the generation of them. Generation can be Chapter 2 we - Accessing XML with SAX, JAXB,of and StAX done in3several ways, butXML a very easy method is to do it as part of the PO generation process. For example, you Chapter - Transforming with XSLT and XPath could use XDK JAXB Generator to create a set of classes corresponding to your PO schema and use this Chapter 4 -the Validating XMLClass with DTDs and XML Schemas code in a JSPor XSQL-based web form to generate both the SOAP message and its PO content. An example of - XML Operations with XQuery such an XSQL page is included in the book’s downloadable source code.

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Handling of xsi:types in POs

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

XML Schema allows users to override built-in types by adding xsi:type annotations to attributes within the instance Chapter 9 - Storing XML Data document. These attributes must be retrieved differently in your getAttributeName() method because of their Chapter 10 - Generating and Retrieving XML reserved status. The following code will retrieve them: Chapter 11 - Searching XML Data

if (currNode.getNodeType() TYPE) Chapter 12 - Managing the Oracle XML == Database = currNode.getAttributeDeclarations(); PartXSDAttribute[] III - Oracle XML forattrNode Java Developers Chapter 13 - Getting Started with Oracle XML and Java

Conveying type overrides in an instance document is not a good design practice and thus should be avoided.

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services

Generating an E-Mail Confirmation

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Even though a user has received a transaction confirmation from AQ, it would be useful to provide to the user a notification of successful or failed PO processing. This functionality is built into AQ’s AQXmlRegister() and Chapter 18 - Getting Started with Oracle XML and C AQXmlCommit()methods, so you can set up a mail URL such as the following to notify users upon commit: Part IV - Oracle XML for C Developers

Chapter 19 - Building an XML-Managed Application

<?xml version="1.0"?> <Envelope xmlns= "http://ns.oracle.com/AQ/schemas/envelope"> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <Body> Part V - Oracle XML for C++ Developers <AQXmlRegister xmlns = "http://ns.oracle.com/AQ/schemas/access"> Chapter 22 - Getting Started with Oracle XML and C++ <register_options> Chapter 23 - Build an XML Database OCI C++ Application <destination>AQUSER.EMP_TOPIC</destination> Chapter 24 - Building an XML Data-Retrieval Application <consumer_name>WHIRLIGIG</consumer_name> Part VI - Oracle XML for PL/SQL Developers <notify_url>mailto:bob.smith@hotmail.com</notify_url> Chapter </register_options> 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services <AQXmlCommit/> Chapter 27 - Extending PL/SQL XML Functionality with Java </AQXmlRegister> Chapter </Body> 28 - Putting It All Together </Envelope> Appendix - XML Standards Bodies and Open Specifications Chapter 20 - Build an XML Database OCI Application

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 Mark V. Scardina, Chang andand Jinyu Wang In this chapter,by you learned how theBen Oracle XDK little-known yet powerful features such as AQ can create McGraw-Hill/Osborne 2004 (600 pages) applications that solve real business©problems. Even though XML started off as a document technology, its use for data exchangeThis has comprehensive rapidly becomeguide prevalent. The application presented is a very real one,products, as most with focuses on gateway utilizing XML technologies withinhere Oracle's XML-enabled emphasis on XML standards, usage best practices. business data is stored relationally and will their continue toand be stored in this manner in the future. It is not realistic in these economic times to have businesses totally rewrite their applications or database schemas in order to do business on the Internet. This approach satisfies both the preservation and expansion requirements and should be Table of Contents seriously considered when designing Internet Oracle Database 10g XML & SQL—Design, Build &applications. Manage XML Applications in Java, C, C++ & PL/SQL

Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 17:Database Developing XML-Based Reusable PL/SQL ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang Components McGraw-Hill/Osborne © 2004 (600 pages) comprehensive focusesXML on utilizing XML technologies Oracle's XML-enabled products, to with In this chapter This we begin to look at guide higher-order functionality. In previouswithin chapters you have been introduced emphasis on XML standards, their usage and best practices. the components that make up an XML infrastructure—XML parser, XSLT processor, XML Schema validator, etc. Now you will use this functionality in an XML-powered framework that supports building whole application processing Table of Contents blocks that can be easily configured by XML files instead of compiled code. This configuration not only covers the Oracle Database 10g XML & SQL—Design, Buildas & well. Manage Applications in Java, C, C++ & PL/SQL logic flow of your application but its schema ThisXML functionality allows for the creation of reusable software Introduction components that reduce development time and improve application reliability. In the past such a framework would Part have I -had Oracle performance and the XML disadvantages; Standards however, the design we will be discussing uses SAX streaming to mitigate these disadvantages and allow form-managed scalability. Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

- Transforming XML with XSLT and XPath Designing the Framework

Chapter 3 Chapter 4

- Validating XML with DTDs and XML Schemas

Consider book reseller, Big Barrel Books (BBB), who does business over the Internet with a wide variety Chapter 5 a- fictitious XML Operations with XQuery of suppliers. However, BBBand is not size of Amazon.com and thus cannot dictate to its suppliers the particular Chapter 6 - XML Messaging RPCthe with SOAP book listing XML format they use. Under these conditions, BBB needs to validate each entry against each Chapter 7 - Putting It All that Together with XML Pipeline, JSPs, and XSQL partner’s XML XML schema before accepting Part II - Oracle Management for DBAsthe entry. To improve the system performance, these schemas are stored locally. 8However, this openswith up a potential problem area because BBB may not be informed of a change or update Chapter - Getting Started the Oracle XML Database

to these schemas and thus could reject valid listings. Therefore, the system must include the capability to check for - Storing XML Data this condition without the overhead of always fetching the XSD file from the partner.

Chapter 9

Chapter 10 - Generating and Retrieving XML

Chapter 11 -diagram Searching XML Data The block in Figure 17-1 illustrates such a system organized as a streaming pipeline. The strategy is to Chapter 12 -validate Managing the Oracle Database parse and incoming XMLXML book listings using the SAX validation capabilities in Oracle XDK 10g against the Part III - Oracle XML for Java Developers local copies of partners’ schemas. If the listing validates, then it is passed through the pipeline to the output.

Chapter 13 -if Getting Started with Oracle XML and However, it fails validation, then the listing mayJava be invalid, its associated schema may need updating, or both. You Chapter - Building XML-Powered Web Site need to14 evaluate thisancondition and validate the listing against the new schema; then, you need to decide whether Chapter schema15changes - Creating have a Portal occurred Site with and whether XML and the Web listing Services is truly invalid. Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

Figure 17-1:an Book streaming pipeline Chapter 23 - Build XMLlisting Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

To perform this processing, you could custom design an application from scratch; however, you need a number of generic XML processing components, which means that you could design this in a modular form using a pipeline Chapter 25 - Getting Started with Oracle XML and PL/SQL strategy. This is exactly how we will proceed, using the new XML Pipeline Processor in Oracle XDK 10g. (See Chapter Building PL/SQL Web Services Chapter267 -for an introduction to the XML Pipeline Processor.) The following components constitute the required Chapter 27 Extending PL/SQL XML Functionality with Java functionality, as shown in Figure 17-1: Part VI - Oracle XML for PL/SQL Developers

Chapter 28 - Putting It All Together

SAXParserProcess and outputs SAX events Appendix - XML StandardsParses Bodies incoming and OpenXML Specifications Glossary Index

XSDValProcess Validates against the local schema, analyzes the results, and reports any errors if necessary

List ofXSDSchemaBuilder Figures Parses an XML schema and outputs a schema object for validation List of Tables

Receives the SAX stream as well as the isCheck from which it either passes on List ofXSDConditionalValProcess Sidebars the stream or compares and revalidates against the remote schema XMLDiffProcess Compares two XML schemas, checking for differences, and returns an XSL stylesheet to convert one to the other if one or more differences are found SAXPrintProcess Writes the SAX event output stream to a file These components and processes can be connected together through a combination of the Pipeline Processor and an XML pipeline control file. Before we build this application, let’s start with a couple simple pipeline processes.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Simple Pipeline Examples PL/SQL

ISBN:0072229527 by 10g MarkXML V. Scardina, Ben Chang provides and JinyuaWang The Oracle XDK Pipeline Processor command-line utility that makes it easy to prototype and McGraw-Hill/Osborne © 2004 (600 pages) test pipeline applications. Oracle.xml.pipeline.controller.orapipe is a utility that can be launched from Java and has the following parameters: This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

–help Prints the help message Table of Contents –version Prints the release version Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

–sequential Executes the pipeline in a sequential mode; the default is parallel Introduction Part I - Oracle and the XML Standards

–validate Validates the XML pipeline control file with the pipeline schema; by default, does not validate - Introducing XML

Chapter 1

Chapter 2 <logfile> - Accessing XML with DOM, SAX,to JAXB, and StAX –log Writes the errors/logs the output file; by default, writes to pipe.log Chapter 3

- Transforming XML with XSLT and XPath

–noinfo Doesn’t log info items; is on Chapter 4 - Validating XMLany with DTDs anddefault XML Schemas Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

–nowarning Doesn’t log any warnings; default is on

Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL no force is specified –force Executes pipeline even if target is up-to-date; by default, Part II - Oracle XML Management for DBAs

It also turns out thatStarted there iswith a very that was not documented in the initial release that lets you Chapter 8 - Getting the useful Oracle parameter XML Database pass in9parameters into Data the XML pipeline control file: Chapter - Storing XML Chapter 10 - Generating and Retrieving XML

–attr<name> <value> Sets the value of $name

Chapter 11 - Searching XML Data

Chapter - Managing XML Database We will12 use this utility the andOracle its parameters in the following simple examples. Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

SAX Parsing and Printing

Chapter 14 - Building an XML-Powered Web Site Chapter 15example - Creating a Portal Site how with to XML and Services This first demonstrates use theWeb XML Pipeline Processor to parse and print an input XML document. Chapter 16 - Developing an XML Gateway Application with SOAP and AQ An example of an instance document that should validate against this schema is as follows: Chapter 17 - Developing XML-Based Reusable Components

<?xml version="1.0"?> <book inStock="Yes"> Chapter 18 - Getting Started Principles, with Oracle XML Techniques, and C <title>Compilers: and Tools</title> Chapter 19 Building an XML-Managed Application <author>Alfred V.Aho, Ravi Sethi, Jeffrey D. Ullman</author> Chapter 20 - Build an XML Database OCI Application <ISBN>0-201-10088-6</ISBN> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <edition>Second</edition> Part<publisher>Addison V - Oracle XML for C++ Developers Wesley</publisher> Chapter 22 - Getting Started with Oracle XML and C++ </book> Part IV - Oracle XML for C Developers

Chapter 23 - Build an XML Database OCI C++ Application

You could write Java code to parse, validate, and write this document to a file. Instead, you could create Chapter 24 -obviously Building an XML Data-Retrieval Application an XML pipeline control file thatDevelopers calls generic classes to perform the same functions. The following file, Part VI - Oracle XML for PL/SQL pipeprocessing__1.xml, an example: Chapter 25 - Getting Startediswith Oracle XML and PL/SQL <pipeline xmlns="http://www.w3.org/2002/02/xml-pipeline"> Chapter 26 - Building PL/SQL Web Services <param name="target" select="result1.xml"/> Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

<processdef name="saxparser.p" Appendix - XML Standards Bodies and Open Specifications definition="oracle.xml.pipeline.processes.SAXParserProcess"/> <processdef name="saxprint.p" Index definition="oracle.xml.sample.pipeline.SAXPrintProcess"/> Glossary

List of Figures List of Tables

<process id="p1" type="saxparser.p" ignore-errors="true"> <input name="xmlsource" label="$source"/> <output name="sax" label="saxevents"/> </process>

List of Sidebars

<process id="p2" type="saxprint.p" ignore-errors="true"> <input name="pxmlsource" label="saxevents"/> <param name="isPrint" select="true"/> <output name="printxml" label="$result"/>


</process> </pipeline> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

Note that two named processes are called, saxparser.p and saxprint.p, and that these are associated with actual PL/SQL Java classes. This allows them to be used in the process sections identified by id attributes p1 and p2. ISBN:0072229527 These by Mark V. Scardina, Ben Chang and Jinyu Wang processes supply the parameters required by the XML Pipeline Processor and the called classes. In this case you McGraw-Hill/Osborne © 2004 (600 pages) see$sourceas the parameter for specifying the input filename and $result for the output filename. The following is This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with the command line for executing this process after you have added the xml.jar in ORACLE_HOME/lib and the emphasis on XML standards, their usage and best practices. compiledoracle.xml.sample.pipeline.SAXPrintProcess class to your Java CLASSPATH: java oracle.xml.pipeline.controller.orapipe -sequential –force -attr source xml/book1.xml –attr result result1.xml Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL pipeline/pipeProcessing_1.xml

Table of Contents Introduction

Part I - Oracle and the XML Standards

Chapter 1 -there Introducing As noted, are twoXML classes that need to be created that implement the pipeline interfaces. The Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX oracle.xml.pipeline.processes.SAXParserProcess method is a built-in class, and the following is a listing for the Chapter 3 - Transforming XML with XSLT and XPath other,oracle.xml.sample.pipeline.SAXPrintProcess: Chapter 4 -oracle.xml.sample.pipeline; Validating XML with DTDs and XML Schemas package Chapter 5

- XML Operations with XQuery

Chapter 6 java.io.IOException; - XML Messaging and RPC with SOAP import Chapter 7 java.io.OutputStream; - Putting It All Together with XML Pipeline, JSPs, and XSQL import Part II - Oracle XML Management for DBAs import java.io.PrintWriter;

Chapter import 8 java.io.StringWriter; - Getting Started with the Oracle XML Database

import Chapter 9 oracle.xml.parser.v2.XMLSAXSerializer; - Storing XML Data import Chapter 10oracle.xml.pipeline.controller.Process; - Generating and Retrieving XML import Chapter 11oracle.xml.pipeline.controller.Input; - Searching XML Data import Chapter 12oracle.xml.pipeline.controller.Output; - Managing the Oracle XML Database import oracle.xml.pipeline.controller.PipelineException; Part III - Oracle XML for Java Developers import Chapter 13org.xml.sax.ContentHandler; - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

public class SAXPrintProcess extends Process { StringWriter sw=new StringWriter(); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ PrintWriter out= new PrintWriter(sw); Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

public SAXPrintProcess() { } Chapter 19 - Building an XML-Managed{Application public void initialize() Chapter 20 Build an XML Databasexml OCI Application /* Set the supported infoset types for the inputs and outputs */ Chapter 21 Create an XML-Configured High-Performance Transformation Engine Input i = getInput("pxmlsource"); Part V i.supportType(SAXSOURCE); - Oracle XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++ i.supportType(DOCUMENT); Chapter 23 - Build Database OCI C++ Application Output o an = XML getOutput("printxml"); Chapter o.supportType(STREAMRESULT); 24 - Building an XML Data-Retrieval Application Part VIo.supportType(DOCUMENT); - Oracle XML for PL/SQL Developers } 25 - Getting Started with Oracle XML and PL/SQL Chapter public ContentHandler throws PipelineException Chapter 26 - Building PL/SQL Web SAXContentHandler() Services { 27 - Extending PL/SQL XML Functionality with Java Chapter printHandler new XMLSAXSerializer(out); Chapter 28 - Putting It All= Together return printHandler; Appendix - XML Standards Bodies and Open Specifications } Glossary public void execute() throws PipelineException { Index Object isPrint= getInParamValue("isPrint"); List of Figures if(isPrint == null) isPrint="false"; List of Tables if(isPrint.equals("true")) { List of Sidebars try { OutputStream outstream = getOutputStream("printxml"); outstream.write(sw.toString().getBytes()); out.flush(); } catch(IOException ex) { ex.printStackTrace(); } } Chapter 18 - Getting Started with Oracle XML and C


} XMLSAXSerializer printHandler; }

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

The steps needed to implement a customized XML pipeline processor are to extend the McGraw-Hill/Osborne © 2004 (600 pages) oracle.xml.pipeline.controller.Processclass and implement the initialize() and execute() function. In order to This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with create SAX-based pipeline processors, you also need to implement the SAXContentHandler()to process SAX emphasis on XML standards, their usage and best practices. events. Table of Contents

Parsing and Checking for Differences

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Another simple example and a task we will incorporate into the application is the comparison of two XML files by using the XMLDiff class from the Oracle XDK 10g. In this case, you will compare two XML schemas. The following Chapter 1 - Introducing XML book_local.xsd schema specifies the format for the book listing files: Part I - Oracle and the XML Standards

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> Chapter 3 - Transforming XML with XSLT and XPath <xsd:element name="book" type="bookType"/> Chapter 4 - Validating XML with DTDs and XML Schemas <xsd:complexType name="bookType"> Chapter 5 - XML Operations with XQuery <xsd:sequence> Chapter 6<xsd:element - XML Messagingref="title"/> and RPC with SOAP Chapter 7<xsd:choice> - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs <xsd:element ref="author"/> Chapter 8 -<xsd:element Getting Started with the Oracle XML Database ref="editor"/> Chapter 9</xsd:choice> - Storing XML Data Chapter 10 - Generating andref="ISBN"/> Retrieving XML <xsd:element Chapter 11 <xsd:element - Searching XMLref="edition" Data minOccurs="1"/> <xsd:element ref="publisher"/> Chapter 12 - Managing the Oracle XML Database </xsd:sequence> Part III - Oracle XML for Java Developers <xsd:attribute use="required"> Chapter 13 - Getting Startedname="inStock" with Oracle XML and Java <xsd:simpleType> Chapter 14 - Building an XML-Powered Web Site base="xsd:string"> Chapter 15 -<xsd:restriction Creating a Portal Site with XML and Web Services <xsd:enumeration value="Yes"/> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <xsd:enumeration value="No"/> Chapter 17 - Developing XML-Based Reusable Components </xsd:restriction> Part IV - Oracle XML for C Developers </xsd:simpleType> Chapter 18 - Getting Started with Oracle XML and C </xsd:attribute> Chapter 19 - Building an XML-Managed Application </xsd:complexType> Chapter 20 - Build an XML Database OCI Application <xsd:element name="title" type="xsd:string"/> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <xsd:element name="author" type="nameType"/> Part V - Oracle XML for C++ Developers <xsd:element name="ISBN" type="xsd:string"/> Chapter 22 - Getting Started with Oracle XML and C++ <xsd:element name="edition" default="First"> Chapter 23 Build an XML Database OCI C++ Application <xsd:simpleType> Chapter 24 - Building an XML Data-Retrieval Application <xsd:restriction base="xsd:string"> Part VI - Oracle XML for PL/SQL Developers <xsd:enumeration value="First"/> Chapter 25 -<xsd:enumeration Getting Started with Oracle XML and PL/SQL value="Second"/> Chapter 26 -<xsd:enumeration Building PL/SQL Web Services value="Third"/> Chapter 27 -<xsd:enumeration Extending PL/SQL XML value="Fourth"/> Functionality with Java <xsd:enumeration value="Fifth"/> Chapter 28 - Putting It All Together Appendix </xsd:restriction> - XML Standards Bodies and Open Specifications </xsd:simpleType> Glossary </xsd:element> Index name="publisher" type="xsd:string"/> List <xsd:element of Figures <xsd:element name="editor" type="nameType"/> List of Tables <xsd:simpleType name="nameType"> List of Sidebars <xsd:restriction base="xsd:string"> <xsd:minLength value="4"/> </xsd:restriction> </xsd:simpleType> </xsd:schema>

A second schema, book_remote.xsd, differs only in the <edition/> element, changing from a mandatory occurrence to an optional one, as follows:


<xsd:element ref="edition" minOccurs="0"/> The two schemas canDatabase be compared a very pipeline file, XML pipeProcessing_2.xml: Oracle 10gusing XML & SQL:simple Design, Build control & Manage Applications in Java, C, C++ & PL/SQL <pipeline xmlns="http://www.w3.org/2002/02/xml-pipeline"> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) <param name="target" select="result2.xsl"/> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. <processdef name="xmldiff.p"

definition="oracle.xml.sample.pipeline.XMLDiffProcess"/> Table of Contents

<process id="p1" type="xmldiff.p" Oracle Database 10g XML & SQL—Design, Build & ignore-errors="true"> Manage XML Applications in Java, C, C++ & PL/SQL <input name="xmlsource1" label="$source1"/> Introduction Part<input I - Oraclename="xmlsource2" and the XML Standards label="$source2"/>

<outparam name="isDiff" label="isDiffStatus"/> Chapter 1 - Introducing XML <output name="xsl" label="result2.xsl"/> - Accessing XML with DOM, SAX, JAXB, and StAX </process> Chapter 3 - Transforming XML with XSLT and XPath </pipeline> Chapter 2 Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter - XML Operations with XQuery This file5 specifies a single xmldiff.p process to be called and process two input files, source1 and source2, and Chapter 6 output - XML to Messaging andifRPC with print the result2.xsl there is aSOAP difference. This file is executed with the following command line: Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL java oracle.xml.pipeline.controller.orapipe -sequential -force -attr source1 xsd/book_local.xsd -attr source2 xsd/book_remote.xsd Chapter 8 - Getting Started with the Oracle XML Database pipeline/pipeProcessing_2.xml Part II - Oracle XML Management for DBAs

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

In this case a difference is Data found, so you get a result2.xslstylesheet detailing the expected change in the Chapter 11 - Searching XML <edition> Chapter 12 -element: Managing the Oracle XML Database Part III - Oracle XML for Java Developers xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:stylesheet version="1.0"

Chapter 13 - Getting Started with Oracle XML and Java <xsl:output xmlns:ora="http://www.oracle.com/XSL/Transform/java" Chapter 14 ora:omit-xml-encoding="yes"/> - Building an XML-Powered Web Site

<!--Select all nodes--> Chapter 15 - Creating a Portal Site with XML and Web Services <xsl:template Chapter 16 - Developing match="node()|@*"> an XML Gateway Application with SOAP and AQ <xsl:copy> Chapter 17 - Developing XML-Based Reusable Components <xsl:apply-templates Part IV - Oracle XML for C Developers

select="node()|@*"/> </xsl:copy> Chapter 18 - Getting Started with Oracle XML and C </xsl:template> Chapter 19 - Building an XML-Managed Application <xsl:template match="/xsd:schema[1]/xsd:complexType[1]/xsd:sequence[1] Chapter 20 - Build an XML Database OCI Application /xsd:element[3]/@minOccurs"> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <xsl:attribute name="minOccurs">0</xsl:attribute> Part V - Oracle XML for C++ Developers </xsl:template> Chapter 22 - Getting Started with Oracle XML and C++ </xsl:stylesheet> Chapter 23 - Build an XML Database OCI C++ Application

Chapter XML Data-Retrieval As with24 the- Building previousan example, you need toApplication implement oracle.xml.sample.pipeline.XMLDiffProcess with the Part VI -pipeline Oracle XML for PL/SQL proper interfaces. The Developers following is an example of such an implementation:

Chapter 25 - Getting Started with Oracle XML and PL/SQL

package oracle.xml.sample.pipeline;

Chapter 26 - Building PL/SQL Web Services Chapter 27java.io.FileInputStream; - Extending PL/SQL XML Functionality with Java import Chapter 28java.io.InputStream; - Putting It All Together import Appendix - XML Standards Bodies and Open Specifications import java.io.OutputStream; Glossary import java.io.Reader; Index import java.net.URL;

import javax.xml.transform.Source; List of Figures import javax.xml.transform.dom.DOMResult; List of Tables import javax.xml.transform.stream.StreamSource; List of Sidebars import oracle.xml.differ.XMLDiff; import oracle.xml.parser.v2.DOMParser; import oracle.xml.parser.v2.XMLDocument; import oracle.xml.parser.v2.XMLParser; import oracle.xml.pipeline.controller.Input; import oracle.xml.pipeline.controller.Output; import oracle.xml.pipeline.controller.PipelineException; import oracle.xml.pipeline.controller.Process;


import org.xml.sax.InputSource; public class XMLDiffProcess extends Process { Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & public XMLDiffProcess() { PL/SQL } ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

public void initialize() { This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with // Initialized inputs emphasis on XML standards, their usage and best practices. Input input1 = getInput("xmlsource1"); input1.supportType(DOMSOURCE); Table of Contents input1.supportType(DOCUMENT); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Input input2 = getInput("xmlsource2"); Introduction input2.supportType(DOMSOURCE); Part I - Oracle and the XML Standards input2.supportType(DOCUMENT); Chapter 1 Initialized - Introducing XML // Output Chapter 2 - Accessing XML DOM, SAX, JAXB, and StAX Output output = with getOutput("xsl"); Chapter 3 - Transforming XML with XSLT and XPath output.supportType(STREAMRESULT); Chapter 4 - Validating XML with DTDs and XML Schemas output.supportType(DOCUMENT); Chapter } 5 - XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP

public void execute() Chapter 7 - Putting It All Togetherthrows with XMLPipelineException Pipeline, JSPs, and XSQL{ doc1=null, doc2=null; Part IIXMLDocument - Oracle XML Management for DBAs boolean res=false; Chapter 8 - Getting Started with the Oracle XML Database DOMParser Chapter 9 - Storing parser XML Data= new DOMParser(); Chapter 10 - Generating and Retrieving XML

/* input XML stream Chapter 11get - Searching Data source */ Source xmlSource1 = getInputSource("xmlsource1"); Source xmlSource2 = getInputSource("xmlsource2"); Part III - Oracle XML for Java Developers XMLDiff xmlDiff = new XMLDiff(); Chapter 13 - Getting Started with Oracle XML and Java if(xmlSource1 instanceof StreamSource) { Chapter 14 - Building an XML-Powered Web Site StreamSource xmlstream = (StreamSource)xmlSource1; Chapter 15 - Creating a Portal Site with XML and Web Services Object instream; Chapter 16 - Developing an XML Gateway Application with SOAP and AQ try { Chapter 17 -if((instream Developing XML-Based Reusable Components = xmlstream.getInputStream()) != null) { Part IV - Oracleparser.parse((InputStream)instream); XML for C Developers Chapter 18 -}Getting with Oracle XML and C else Started { Chapter 19 - Building an XML-Managed Application new String[]{"xmlsource"}); error(30005, FATAL_ERROR, Chapter 20 -}Build an XML Database OCI Application Chapter 21 -doc1= Create an XML-Configured High-Performance Transformation Engine parser.getDocument(); Part V - Oracle XML for C++ Developers } catch(Exception e) { Chapter 22 -e.printStackTrace(); Getting Started with Oracle XML and C++ } - Build an XML Database OCI C++ Application Chapter 23 } 24 else { Chapter - Building an XML Data-Retrieval Application error(30002, FATAL_ERROR, Part VI - Oracle XML for PL/SQL Developers new String[]{"StreamSource"}); } 25 - Getting Started with Oracle XML and PL/SQL Chapter if(xmlSource2 instanceof StreamSource) { Chapter 26 - Building PL/SQL Web Services StreamSource xmlstream = (StreamSource)xmlSource2; Chapter 27 - Extending PL/SQL XML Functionality with Java Object instream; Chapter 28 - Putting It All Together try { Appendix - XML Standards Bodies and Open Specifications if((instream = xmlstream.getInputStream()) != null) { Glossary parser.parse((InputStream)instream); Index } else { List of Figures error(30005, FATAL_ERROR, new String[]{"xmlsource"}); List of Tables} List of Sidebars doc2= parser.getDocument(); } catch(Exception e) { e.printStackTrace(); } } else { error(30002, FATAL_ERROR, new String[]{"StreamSource"}); } if(doc1!=null && doc2 !=null) { xmlDiff.setInput1(doc1); Chapter 12 - Managing the Oracle XML Database


xmlDiff.setInput2(doc2); res = xmlDiff.diff(); if(res == true) setOutParam("isDiff","true"); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & else PL/SQL setOutParam("isDiff","false"); } else by setOutParam("isDiff","N/A"); ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang if(res==true){ McGraw-Hill/Osborne © 2004 (600 pages) try {This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with XMLDocument = xmlDiff.generateXSLDoc(); emphasis on doc XML standards, their usage and best practices. OutputStream outstream = getOutputStream("xsl"); doc.print(outstream); Table of Contents } catch(Exception e) { Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL e.printStackTrace(); Introduction } Part I - Oracle and the XML Standards } Chapter 1 - Introducing XML return; Chapter } 2 - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 - Transforming XML with XSLT and XPath public void endExecute() throws PipelineException Chapter { 4 - Validating XML with DTDs and XML Schemas Chapter 5 - XML Operations with XQuery System.out.println("End of XMLDiffProcess!!"); Chapter } 6 - XML Messaging and RPC with SOAP } Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Building the Pipeline Application PL/SQL

ISBN:0072229527 by simply Mark V.wanted Scardina, Ben Chang and Jinyu Wang you would not need to use a pipeline framework. Obviously, if you to invoke one or two processes, © 2004 (600 pages) That, however,McGraw-Hill/Osborne is not the case for our application. Building upon the previous examples, our application needs to invoke additional processes, and thus your pipeline control file morewithin sophisticated, as shown here in This comprehensive guide focuses on utilizing XMLbecomes technologies Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. pipeProcessing_3.xml:

<pipeline xmlns="http://www.w3.org/2002/02/xml-pipeline"> Table of Contents <param name="target" select="result3.xml"/> Oracle <processdef Database 10g name="saxparser.p" XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction definition="oracle.xml.pipeline.processes.SAXParserProcess"/>

name="XSDVal.p" Part<processdef I - Oracle and the XML Standards Chapter 1

-definition="oracle.xml.sample.pipeline.XSDValProcess"/> Introducing XML

<processdef name="xsdschemabuilder.p" Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX -definition="oracle.xml.pipeline.processes.XSDSchemaBuilder"/> Transforming XML with XSLT and XPath <processdef name="conditionvalidation.p" Chapter 4 - Validating XML with DTDs and XML Schemas definition="oracle.xml.sample.pipeline.XSDConditionalValProcess"/> Chapter 5 - XML Operations with XQuery <processdef name="xmldiff.p" Chapter 6 - XML Messaging and RPC with SOAP definition="oracle.xml.sample.pipeline.XMLDiffProcess"/> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL <processdef name="saxprint.p" Part II - Oracle XML Management for DBAs definition="oracle.xml.sample.pipeline.SAXPrintProcess"/> Chapter 3

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data <!-- Parse and build the local schema -->

Chapter 10 - Generating Retrieving XML <process id="p1"and type="xsdschemabuilder.p" ignore-errors="true"> Chapter 11 - Searching XML Datalabel="$Lschema"/> <input name="schema" Chapter 12 - Managing the Oracle XML Database <param name="baseURL" select="url"></param> Part<outparam III - Oracle XML for Java Developerslabel="xmlschemaobj"/> name="xmlschema"

Chapter 13 - Getting Started with Oracle XML and Java </process> Chapter 14 - Building an XML-Powered Web Site Chapter <!--Parse 15 - Creating the source a Portal XML Site with -->XML and Web Services

<process id="p2" ignore-errors="true"> Chapter 16 - Developing an type="saxparser.p" XML Gateway Application with SOAP and AQ name="xmlsource" label="$source"/> Chapter <input 17 - Developing XML-Based Reusable Components name="sax" label="saxevents"/> Part IV -<output Oracle XML for C Developers name="preserveWhitespace" Chapter <param 18 - Getting Started with Oracle XML and C select="false"></param> </process> Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

<!--Check for validation errors and switch the output accordingly --> <process id="p3" type="XSDVal.p" ignore-errors="true"> Part V - Oracle XML for C++ Developers <input name="xml" label="saxevents"/> Chapter 22 - Getting Started with Oracle XML and C++ <param name="sschemaObj" label="xmlschemaobj"></param> Chapter 23 - Build an XML Database OCI C++ Application <outparam name="isCheckXSDDiff" label="isCheckStatus"></outparam> Chapter 24 - Building an XML Data-Retrieval Application <output name="validatedxml" label="xsdsaxevents"/> Part VI - Oracle XML for PL/SQL Developers </process> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 26 - Building PL/SQLthe Web remote Services schema --> <!--Parse and build Chapter 27 Extending PL/SQL XML Functionality with Java <process id="p4" type="xsdschemabuilder.p" ignore-errors="true"> Chapter 28 - Putting It All Together <input name="schema" label="$Rschema"/> Appendix Standards Bodiesselect="url"></param> and Open Specifications <param- XML name="baseURL" Glossary <outparam name="xmlschema" label="txmlschemaobj"/> Index </process> List of Figures

<!--Compare local and remote schemas and report result --> List of Tables <process id="p5" type="xmldiff.p" ignore-errors="true"> List of Sidebars <input name="xmlsource1" label="$Lschema"/> <input name="xmlsource2" label="Rschema"/> <outparam name="isDiff" label="isDiffStatus"/> <output name="xsl" label="result.xsl"/> </process> <!--Optionally validates input if remote schema is different --> <process id="p6" type="conditionvalidation.p" ignore-errors="true">


<input name="csax" label="xsdsaxevents"/> <param name="txmlschema" label="txmlschemaobj"/> <param name="isCheck" label="isCheckStatus"/> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <param name="isXSDDiff" label="isDiffStatus"/> PL/SQL <outparam name="isValid" label="isConditionalValid"/> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <output McGraw-Hill/Osborne name="xmlout" label="valsaxevents"/> © 2004 (600 pages) </process>This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

<!-- Print validated document if successful --> <process id="p7" type="saxprint.p" ignore-errors="true"> Table of Contents <input name="pxmlsource" label="valsaxevents"/> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <param name="isPrint" label="isConditionalValid"/> Introduction <output name="printxml" label="result3.xml"/> Part I - Oracle and the XML Standards </process> Chapter 1 - Introducing XML </pipeline> Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter In this application, 3 - Transforming no fewer XML than withseven XSLT processes and XPath are pipelined, each process passing its results to the next. We

have already reviewedXML fourwith of these Let’s review the remaining three. Chapter 4 - Validating DTDs processes. and XML Schemas Chapter 5

- XML Operations with XQuery

- XML Messaging and RPC with SOAP The XSDSchemaBuilder Process

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part TheIIXSDSchemaBuilder - Oracle XML Management processfor is built DBAs into the XML Pipeline Processor and builds schema objects that are used

for validating XML documents. this case,XML it isDatabase used for both the local and remote schemas and returns the XML Chapter 8 - Getting Started withIn the Oracle schema9 objects xmlschemaobj and txmlschemaobjrespectively,which can then be passed into other processes Chapter - Storing XML Data for validation. Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

The XSDValProcess Process

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

TheXSDValProcess class performs a validation of the source file input via SAX events and reports the result of a Chapter 13 - Getting Started with Oracle XML and Java validation analysis. The following is its code listing: Chapter 14 error - Building an XML-Powered Web Site Chapter package 15 -oracle.xml.sample.pipeline; Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

import Chapter 17java.io.IOException; - Developing XML-Based Reusable Components import java.io.ObjectOutputStream; Part IV - Oracle XML for C Developers import Chapter 18java.io.OutputStream; - Getting Started with Oracle XML and C import Chapter 19java.io.PrintWriter; - Building an XML-Managed Application import Chapter 20java.io.StringWriter; - Build an XML Database OCI Application import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; Part V - Oracle XML for C++ Developers import oracle.xml.comp.CXMLContext; Chapter 22 - Getting Started with Oracle XML and C++ import oracle.xml.comp.CXMLStream; Chapter 23 - Build an XML Database OCI C++ Application import oracle.xml.parser.schema.XSDConstantValues; Chapter 24 - Building an XML Data-Retrieval Application import oracle.xml.parser.v2.XMLDocument; Part VI - Oracle XML for PL/SQL Developers import oracle.xml.pipeline.controller.Input; Chapter 25 - Getting Started with Oracle XML and PL/SQL import oracle.xml.pipeline.controller.Output; Chapter 26oracle.xml.pipeline.controller.Process; - Building PL/SQL Web Services import Chapter 27 - Extending PL/SQL XML Functionality with Java import oracle.xml.pipeline.controller.PipelineException; Chapter 28org.xml.sax.ContentHandler; - Putting It All Together import Appendix - XML Standards Bodies and Open Specifications import org.xml.sax.ErrorHandler;

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Glossary Index public class XSDValProcess extends Process {

sw=new StringWriter(); List StringWriter of Figures out= new PrintWriter(sw); List PrintWriter of Tables List boolean of SidebarsisCheckXSDDiff=false;

boolean isValid=true; public XSDValProcess() { } public void initialize() { /* Set the supported xml infoset types for the inputs and outputs */ Input i = getInput("xml");


}

i.supportType(SAXSOURCE); i.supportType(DOCUMENT); Output Oracle o = getOutput("validatedxml"); Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & //o.supportType(DOMRESULT); PL/SQL o.supportType(SAXRESULT); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang o.supportType(STREAMRESULT); McGraw-Hill/Osborne © 2004 (600 pages) o.supportType(DOCUMENT); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

public ContentHandler SAXContentHandler() throws PipelineException { try { Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Output output = getOutput("validatedxml"); Introduction // if dependents are not available then return null Part I - Oracle and the XML Standards ContentHandler hdlr = getSAXContentHandler(output); Chapter 1if- Introducing (hdlr == XML null) Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX return null; Chapter 3Object - Transforming XML with XSLT and XPath schemaObj = getInParamValue("sschemaObj"); Chapter 4if- Validating XML with DTDs and XML Schemas (schemaObj == null) Chapter 5 - XML Operations return null;with XQuery Chapter 6exXsdHandler - XML Messaging= and new RPC ExXSDHandler(new with SOAP PrintWriter(out), this); Chapter 7exXsdHandler.addContentHandler(hdlr); - Putting It All Together with XML Pipeline, JSPs, and XSQL exXsdHandler.setXMLProperty(XSDConstantValues.VALIDATION_MODE, Part II - Oracle XML Management for DBAs XSDConstantValues.STRICT_VALIDATION); Chapter 8 - Getting Started with the Oracle XML Database Object obj = ExXSDHandler.setXMLProperty(XSDConstantValues.FIXED_SCHEMA, Chapter 9 - Storing XML Data schemaObj); Chapter 10 - Generating and Retrieving XML if(obj== null) Chapter 11 - Searching XML Data throw new PipelineException("The XML Schema Object is not correct."); Chapter 12 - Managing the Oracle XML Database

Table of Contents

Part III - Oracle XML for Java Developers

} catch(Exception ex) { ex.printStackTrace(); Chapter 14 - Building an XML-Powered Web Site }

Chapter 13 - Getting Started with Oracle XML and Java Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

return exXSDHandler;

Chapter } 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XMLPipelineException and C public void execute() throws { Chapter 19 Building an XML-Managed Application super.execute(); Chapter 20 - Build an XML Database OCI Application if(isValid==true) { Chapter 21 - Create an XML-Configured High-Performance Transformation Engine setOutParam("isCheckXSDDiff","ignore"); Part V } - Oracle else XML { for C++ Developers

Chapter 22 //Set - Getting theStarted output withparameter Oracle XML and C++

if(isCheckXSDDiff ==OCI true) setOutParam("isCheckXSDDiff","true"); Chapter 23 - Build an XML Database C++ Application else { Chapter 24 - Building an XML Data-Retrieval Application setOutParam("isCheckXSDDiff","false"); Part VI - Oracle XML for PL/SQL Developers } Started with Oracle XML and PL/SQL Chapter 25 - Getting } - Building PL/SQL Web Services Chapter 26 } 27 - Extending PL/SQL XML Functionality with Java Chapter Chapter 28 - Putting It All Together

ExXSDHandler exXsdHandler;

Appendix

}

- XML Standards Bodies and Open Specifications

Glossary Index After initializing the objects, the XSDValProcess takes the input schema object, schemaObj, and sets the type of List of Figures validation and confirms its validity in SAXContentHandler(),returningexXsdHandler. This handler, along with the List of stream, Tables is passed to execute() to perform the validation. The SAX stream by way of exXsdHandler is output SAX List of Sidebars along with the validation result in the isCheckASDiff output parameter. The exXsdHandler performs an error

analysis to determine whether the error is one that should trigger a check of the remote schema. Here is its code listing: package oracle.xml.sample.pipeline; import java.io.PrintWriter; import java.util.Hashtable; import oracle.xml.parser.schema.XSDException; import oracle.xml.parser.schema.XSDValidator;


import oracle.xml.parser.v2.DefaultXMLDocumentHandler; import oracle.xml.parser.v2.XMLError; import org.xml.sax.Attributes; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & import org.xml.sax.ContentHandler; PL/SQL import org.xml.sax.SAXException; ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

public class ExXSDHandler extends XSDValidator { This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with private MyXMLError err; emphasis on XML standards, their usage and best practices. Hashtable ht; PrintWriter out; Table of Contents XSDValProcess parentProcess; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL int errorIndex=0; Introduction

Part I - Oracle and the XML Standards

public ExXSDHandler(PrintWriter out, XSDValProcess parentProcess) throws

Chapter 1 - Introducing XML XSDException,SAXException { Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX this.out= out; Chapter 3 - Transforming XML with XSLT and XPath this.parentProcess=parentProcess; Chapter 4 - Validating XML with DTDs and XML Schemas parentProcess.isValid=true; Chapter 5 -=XML Operations with XQuery err new MyXMLError(); Chapter setError(err); 6 - XML Messaging and RPC with SOAP

//Initialize numbers Chapter 7 - Putting hashtable It All Togetherfor witherror XML Pipeline, JSPs,to andtrack XSQL =newXML Hashtable(); Part IIht - Oracle Management for DBAs // XML-24536 Missing ''{0}'' Attribute Chapter 8 - Getting Started with the Oracle XML Database ht.put(new Integer(24536),"24536"); Chapter 9 - Storing XML Data // XML-24534 "Element ''{0}'' not expected. Chapter 10 - Generating and Retrieving XML ht.put(new Integer(24534),"24534"); Chapter 11 - Searching XML Data } public void startDocument() throws SAXException { Part III - Oracle XML for Java Developers super.startDocument(); Chapter 13 - Getting Started with Oracle XML and Java } Chapter 14 - Building an XML-Powered Web Site public void startElement(String namespaceURI, String localName, Chapter 15 - Creating a Portal Site with XML and Web Services String qName, Attributes atts) throws SAXException { Chapter 16 - Developing an XML Gateway Application with SOAP and AQ super.startElement(namespaceURI,localName,qName,atts); Chapter } 17 - Developing XML-Based Reusable Components Partpublic IV - Oracle XMLendElement(String for C Developers void namespaceURI, String localName,String qName) Chapter 18 Getting Started with{Oracle XML and C throws SAXException Chapter 19 - Building an XML-Managed ApplicationlocalName,qName); super.endElement(namespaceURI, Chapter 20If - Build an XML Database OCIexist, Application // validation errors exit the process Chapter 21 Create an XML-Configured High-Performance Transformation Engine int i = err.getNumMessages(); Part V if(i>errorIndex) - Oracle XML for C++ Developers { Chapter 22 errorIndex=i; - Getting Started with Oracle XML and C++ parentProcess.isValid=false; Chapter 23 - Build an XML Database OCI C++ Application int j= err.getErrorCode(i-1); Chapter 24 - Building an XML Data-Retrieval Application if(ht.get(new Integer(j)) != null) { Part VI - Oracle XML for PL/SQL Developers Chapter 25 -parentProcess.isCheckXSDDiff=true; Getting Started with Oracle XML and PL/SQL } - Building PL/SQL Web Services Chapter 26 } Chapter 27 - Extending PL/SQL XML Functionality with Java } Chapter 28 - Putting It All Together public void endDocument() throws SAXException { Appendix - XML Standards Bodies and Open Specifications super.endDocument(); Glossary } Index } Chapter 12 - Managing the Oracle XML Database

List of Figures List of Tables

List of Sidebars Note that this class creates a hash table of error numbers to be compared to the validation errors. The reason for

this analysis is to minimize the round trips to compare the remote schema with the local one. The schema validator returns error messages and associated numbers from 24000 to 24999. These numbers are available in errid, which can be retrieved by extending the XMLError class as follows: package oracle.xml.sample.pipeline; import oracle.xml.parser.v2.XMLError; import oracle.xml.parser.v2.XMLParseException;


public class MyXMLError extends XMLError { public MyXMLError() { } Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

}

public int index) ISBN:0072229527 by getErrorCode(int Mark V. Scardina, Ben Chang and{Jinyu Wang return McGraw-Hill/Osborne errid[index]; © 2004 (600 pages) } This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Note The error codes and their messages were not included in the Oracle Database 10g release. However,

Table of Contents their documentation is available on OTN in the Oracle XDK Development section of the XML Technology Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Center. Introduction Part I - Oracle and the XML Standards

The XSDConditionalValProcess Process - Introducing XML

Chapter 1

Chapter 2 Pipeline - Accessing XML with DOM, JAXB, and StAX The XML Processor does notSAX, include the capability for conditional logic branching. The specification Chapter 3 - Transforming XML with and XPath simple. However, sometimes you may need branching, as in this intentionally omits this capability soXSLT that it remains Chapter 4 application. - Validating XML with process, DTDs andXSDConditionalValProcess, XML Schemas chapter’s The final adds conditional logic to the pipeline. The Chapter - XMLanOperations XQueryparsed into SAX events, the schemaObject, txmlschema, the conditional, process5 takes input XMLwith document Chapter 6 and - XML RPC with SOAPIf isCheck is true, it validates the XML document against an XSD file. isCheck, anMessaging isXSDDiffand input parameter. Chapter Otherwise, 7 - no Putting action It is Alltaken. Together Thewith following XML Pipeline, is its code JSPs, listing: and XSQL Part II - Oracle XML Management for DBAs package oracle.xml.sample.pipeline;

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 java.io.IOException; - Storing XML Data import Chapter 10java.io.ObjectOutputStream; - Generating and Retrieving XML import Chapter import 11java.io.OutputStream; - Searching XML Data

import Chapter 12java.io.PrintWriter; - Managing the Oracle XML Database import java.io.StringWriter; Part III - Oracle XML for Java Developers import Chapter 13javax.xml.transform.Source; - Getting Started with Oracle XML and Java import Chapter 14javax.xml.transform.dom.DOMSource; - Building an XML-Powered Web Site import Chapter 15oracle.xml.comp.CXMLContext; - Creating a Portal Site with XML and Web Services import Chapter 16oracle.xml.comp.CXMLStream; - Developing an XML Gateway Application with SOAP and AQ import oracle.xml.parser.schema.XSDConstantValues; import oracle.xml.parser.v2.XMLDocument; Part IV - Oracle XML for C Developers import oracle.xml.pipeline.controller.Input; Chapter 18 - Getting Started with Oracle XML and C import oracle.xml.pipeline.controller.Output; Chapter 19 - Building an XML-Managed Application import oracle.xml.pipeline.controller.Process; Chapter 20 - Build an XML Database OCI Application import oracle.xml.pipeline.controller.PipelineException; Chapter 21 - Create an XML-Configured High-Performance Transformation Engine import org.xml.sax.ContentHandler; Chapter 17 - Developing XML-Based Reusable Components

Part V - Oracle XML for C++ Developers

Chapter 22class - Getting Started with Oracle XML and C++extends Process { public XSDConditionalValProcess Chapter 23 Build an Database OCI C++ Application StringWriter XML sw=new StringWriter(); Chapter 24 - Buildingout= an XML Data-Retrieval Application PrintWriter new PrintWriter(sw); Partboolean VI - OracleisValid=true; XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services public XSDConditionalValProcess() { Chapter } 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

public- XML void initialize() Appendix Standards Bodies and{ Open Specifications /* Set the supported xml infoset types for the inputs and outputs */ Glossary Index Input i = getInput("csax");

i.supportType(SAXSOURCE); List of Figures i.supportType(DOCUMENT); Output o = getOutput("xmlout"); List of Sidebars o.supportType(SAXRESULT); o.supportType(STREAMRESULT); o.supportType(DOCUMENT); } List of Tables

public ContentHandler SAXContentHandler() throws PipelineException { try {


Object schemaObj = getInParamValue("txmlschema"); if (schemaObj == null) return null; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Output output = getOutput("xmlout"); PL/SQL xsdHandler XSDValidationHandler(new ISBN:0072229527 by Mark = V. new Scardina, Ben Chang and Jinyu Wang PrintWriter(out), this); xsdHandler.setXMLProperty(XSDConstantValues.VALIDATION_MODE, McGraw-Hill/Osborne © 2004 (600 pages) XSDConstantValues.STRICT_VALIDATION); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Object obj = xsdHandler.setXMLProperty(XSDConstantValues.FIXED_SCHEMA, emphasis on XML standards, their usage and best practices. schemaObj); if(obj== null) Table of Contents throw new PipelineException("The XML Schema Object is not correct."); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL ContentHandler hdlr = getSAXContentHandler(output); Introduction xsdHandler.addContentHandler(hdlr); Part I - Oracle and the XML Standards } catch(Exception ex) { Chapter 1ex.printStackTrace(); - Introducing XML Chapter 2 } - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 - Transforming XML with XSLT and XPath return xsdHandler; Chapter } 4 - Validating XML with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

Chapter public 6 - XML void Messaging execute() and RPC throws with SOAP PipelineException

{ 7 Chapter

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part IIsuper.execute(); - Oracle XML Management for DBAs

Object isCheck getInParamValue("isCheck"); Chapter 8 - Getting Started= with the Oracle XML Database if(isCheck.equals("true")) { Chapter 9 - Storing XML Data Object isDiff getInParamValue("isXSDDiff"); Chapter 10 - Generating and = Retrieving XML if(isDiff.equals("true")) { Chapter 11 - Searching XML Data System.out.println("XSD documents are not consistent."); System.out.println("Please upload the new XSD file."); Part III - Oracle XML for Java Developers if(isValid==true) { Chapter 13 - Getting Started with Oracle XML and Java System.out.println("XML document accepted."); Chapter 14 - Building an XML-Powered Web Site setOutParam("isValid","true"); Chapter 15 - Creating a Portal Site with XML and Web Services } else { Chapter 16 - Developing an XML Gateway Application with SOAP and AQ System.out.println("XML document rejected."); Chapter 17 - Developing XML-Based Reusable Components setOutParam("isValid","false"); Part IV - Oracle XML for C Developers } Chapter 18 Getting Started with Oracle XML and C } else { Chapter 19 -System.out.println("XSD Building an XML-Managed Application documents are consistent."); Chapter 20 -System.out.println("XML Build an XML Database OCI Application document rejected."); Chapter 21 -setOutParam("isValid","false"); Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers } Chapter } 22 else - Getting if(isCheck.equals("ignore")) Started with Oracle XML and C++ { setOutParam("isValid","true"); Chapter 23 - Build an XML Database OCI C++ Application System.out.println("XML document Chapter 24 - Building an XML Data-Retrieval Applicationaccepted."); else if(isCheck.equals("false")) { Part VI}- Oracle XML for PL/SQL Developers setOutParam("isValid","false"); Chapter 25 - Getting Started with Oracle XML and PL/SQL System.out.println("XML Chapter 26 - Building PL/SQL Web Servicesdocument rejected."); } Chapter 27 - Extending PL/SQL XML Functionality with Java } Chapter 28 - Putting It All Together XSDValidationHandler xsdHandler; Appendix - XML Standards Bodies and Open Specifications } Chapter 12 - Managing the Oracle XML Database

Glossary

Index If the validation process is performed and the XML document is valid, isXSDDiff is checked. If it is true, then the List of Figures message indicates that the XML document is valid according to the local XSD but that the local XSD and the remote List of are Tables XSD not consistent. If isXSDDiff is false, the message indicates that the XML document is valid according to the List of XSD Sidebars local and that the local and remote XSDs are consistent (this is not shown in the example because isCheck is

false in this case). When the validation process is performed and the XML document is invalid, isXSDDiff is checked. If it is true, then the message indicates that the XML document is invalid according to the local XSD but that the XSDs are not consistent. If isXSDDiff is false, the message shows that the XML document is invalid according to the local XSD and that the XSDs are consistent.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Running the Pipeline Application PL/SQL

ISBN:0072229527 by Mark Benexamples, Chang andyou Jinyu As you have done with V. theScardina, two simple canWang use the orapipe utility to run the pipeline application. Referring to its

McGraw-Hill/Osborne © 2004 (600 pages)

source The input XML book listing This comprehensive guide file focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Lschema The local schema

Table of Contents Rschema The remote schema Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Even though you pass the remote schema filename or URL, it is not actually retrieved unless the condition calls for it. The follo Introduction java oracle.xml.pipeline.controller.orapipe Part I - Oracle and the XML Standards

–sequential -force

-attr 1source xml/book1.xml -attr Lschema xsd/book_local.xsd Chapter - Introducing XML -attr 2Rschema xsd/book_remote.xsd pipeline/pipeProcessing_3.xml Chapter - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Because this is a valid book listing, you will see the message “XML document accepted” and an identical result3.xml file writte

Processing an Invalid - XML Messaging and RPCDocument with SOAP

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

In the previous sections, we discussed the details of each process in the XML pipeline application. Now, we will show you how

Part II - Oracle XML Management for DBAs

<?xml 8version="1.0"?> Chapter - Getting Started with the Oracle XML Database <book 9inStock="true"> Chapter - Storing XML Data <title>Compilers: Principles, Techniques, and Tools</title> <author>Alfred V.Aho, Ravi Sethi, Jeffrey D. Ullman</author> Chapter 11 - Searching XML Data <ISBN>0-201-10088-6</ISBN> Chapter 12 - Managing the Oracle XML Database <edition>Second</edition> Part III - Oracle XML for Java Developers <publisher>Addison Wesley</publisher> Chapter 13 - Getting Started with Oracle XML and Java </book> Chapter 10 - Generating and Retrieving XML

Chapter 14 - Building an XML-Powered Web Site

Chapter Creating a Portal Sitehaving with XML and Web Services Instead15 of -the instock attribute a value of “Yes” or “No” as per the schema, it is “true.” Recall that this error is not one t Chapter result: 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components java oracle.xml.pipeline.controller.orapipe –sequential –force Part IV - Oracle XMLxml/book2.xml for C Developers -attr source

-attr Lschema xsd/book_local.xsd

Chapter - Gettingxsd/book_remote.xsd Started with Oracle XML and C -attr 18 Rschema pipeline/pipeProcessing_3.xml Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application XML document rejected. Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

Processing a Document That Is Valid Against the Remote Schema

Chapter 23 - Build an XML Database OCI C++ Application

Chapter 24 - Building an XML Data-Retrieval Application This section considers the situation in which a partner has altered its schema but without your knowledge. In this case, the par Part VIreceived - Oracle book3.xml XML for PL/SQL Developers have with the following listing:

Chapter - Getting Started with Oracle XML and PL/SQL <?xml 25 version="1.0"?> Chapter - Building PL/SQL Web Services <book 26 inStock="Yes"> Chapter 27 - Extending PL/SQL XML Functionality with Java <title>Compilers: Principles, Techniques, and Tools</title> Chapter 28 - Putting It AllV.Aho, TogetherRavi Sethi, Jeffrey D. Ullman</author> <author>Alfred Appendix - XML Standards Bodies and Open Specifications <ISBN>0-201-10088-6</ISBN> Glossary <publisher>Addison Wesley</publisher>

</book> Index List of Figures

The initial validation against the local XML schema should fail with an errid of 24534, indicating that there is an XSD error. Thi the remote XSD, changes found in the remote XML schema will be noted and the XML document will be finally accepted, as s

List of Tables

List of Sidebars

java oracle.xml.pipeline.controller.orapipe –sequential –force -attr source xml/book3.xml -attr Lschema xsd/book_local.xsd -attr Rschema xsd/book_remote.xsd pipeline/pipeProcessing_3.xml XSD documents are not consistent. Please upload the new XSD file. XML document accepted.


Processing an Invalid XML Document with Consistent Local and Remote XSDs

If the invalidating errorDatabase happens to return of the watched numbers, thereXML is a chance that the Oracle 10g XMLone & SQL: Design, Build & Manage Applications in remote Java, C,schema C++ & has not cha PL/SQL well as a second validation, but ultimately the XML document or, in this case, book4.xml will be rejected, as shown in the follo

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang java oracle.xml.pipeline.controller.orapipe –sequential -force -attr source xml/book4.xml -att

McGraw-Hill/Osborne © 2004 (600 pages) This are comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with XSD documents consistent. emphasis on XML standards, their usage and best practices. XML document rejected. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Processing an Invalid Document Against Both Schemas with Change

Introduction

Part I - Oracle and the the invalidating XML Standards In this final case, error again returns one of the watched numbers, and a check of the schemas detected a diff

Chapter 1

- Introducing XML java oracle.xml.pipeline.controller.orapipe –sequential -force -attr source

Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX xml/book4.xml -attr Lschema xsd/book_local.xsd -attr Rschema xsd/book_remote_ Chapter 3 - Transforming XML with XSLT and XPath same.xsd pipeline/pipeProcessing_3.xml Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 - XML Operations XQuery XSD documents are notwith consistent. Chapter 6 upload - XML Messaging and RPCfile. with SOAP Please the new XSD Chapter XML document 7 - Puttingrejected. It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 Ben Chang and Jinyu Wang In this chapter by youMark hadV. theScardina, chance to build an application that was truly XML-powered, using the new Oracle XML McGraw-Hill/Osborne © 2004 (600was pages) Pipeline Processor. The example application multimodal in that its logic was implemented with a combination of compiled and declarative code. While this can initially appear foreign to developers, it is not XML-enabled much different than with This comprehensive guide focuses on utilizing XML technologies within Oracle's products, emphasis XML standards, usage and best practices. JSPs, XSQL pages, ASPonpages, etc. With their development and support costs going up, the ability to create stable, bugfree components that can be assembled in a declarative way can yield significant efficiencies, thereby reducing time to deployment and increasing the bottom line. A particularly apt comparison is to the electronics industry at the time Table of Contents when the switch was made from discreteBuild components integrated circuits, which only lowered costs but Oracle Database 10g XML & SQL—Design, & Manageto XML Applications in Java, C,not C++ & PL/SQL improved reliability. Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Part IV:Oracle Oracle XML for C Developers PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Chapter List

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Chapter 18: Getting Started with Oracle XML and C

Table of Contents

OracleChapter Database XML &an SQL—Design, BuildApplication & Manage XML Applications in Java, C, C++ & PL/SQL 19:10g Building XML-Managed Introduction

an XML Database OCI Application Part IChapter - Oracle 20: andBuild the XML Standards Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 21: Create an XML-Configured High-Performance Transformation Engine

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 18:Database Getting Started with Oracle XML and C PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Oracle Database 10g includes in its default installation the Oracle XDK 10g C libraries and utilities. They provide McGraw-Hill/Osborne © 2004 (600 pages) portable XML functionalities that allow you to easily develop stand-alone or Oracle Call Interface (OCI) XML-enabled guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with applications. InThis thiscomprehensive chapter, we describe the various libraries and utilities, set up both the compile-time and run-time emphasis on XML standards, their usage and best practices. environments, and cover the basics of the configuration that is necessary to get connected to the Oracle database. Table of Contents

The Oracle XDK C Libraries

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction The Oracle XDK C components contain functionalities for reading, manipulating, transforming, and validating XML Part I - OracleAll and XML Standards documents. thethe Oracle XDK C components reside in the ORACLE_HOME/lib directory, and are split into the

Chapter - Introducing libraries1 described in theXML following sections. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath libxml10.a, libxml10.so, and oraxml10.dll - Validating XML with DTDs and XML Schemas

Chapter 4

Chapter 5 - releases XML Operations with XQuery In previous the C XML components have been in multiple libraries. In Oracle XDK 10g, these components Chapter 6 - consolidated XML Messaging and RPC with SOAP library on UNIX and an oraxml10.dll library on Windows. have been into a single libxml10.a Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Within the following Part II -libxml10.a Oracle XMLare Management forXML DBAscomponents: Chapter 8

- Getting Started with the Oracle XML Database

XML parser Checks whether an XML document is well-formed and, optionally, validates it against a DTD or Chapter 9 - Storing XML Data XML schema. The parser can construct an object tree that can be accessed via a DOM interface or operate Chapter 10 - Generating and Retrieving XML serially via a SAX interface. Chapter 11 - Searching XML Data

Chapter 12 -processor Managing the Oracle the XMLcapability Databaseto transform an XML document according to an XSLT stylesheet and is XSLT Provides Part III - Oracle XML Java Developers bundled with thefor parser.

Chapter 13 - Getting Started with Oracle XML and Java

XSLT Compiles XSL stylesheets Chapter 14 -Compiler Building an XML-Powered Web Site into byte code, to be used later by the XSLT Virtual Machine (VM). Chapter 15 - Creating a Portal Site with XML and Web Services

XSLT VM High-performance XSLT transformation engine that accepts compiled XSL stylesheets for faster

Chapter 16 - Developing an XML Gateway SOAP and AQ processing, using less memory thanApplication the regularwith XSLT engine. Chapter 17 - Developing XML-Based Reusable Components

Part IV XML - Oracle Schema XML processor for C Developers Supports parsing and validating XML files against an XML Schema Definition (XSD)

file.18 - Getting Started with Oracle XML and C Chapter Chapter 19 - Building an XML-Managed Application

While all of the XML functionality resides in these XML libraries, they do depend on two additional libraries and an optional third one as described in the following section.

Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

libcore10.a, libcoresh10.so, and libcore10.dll

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application

The C common run-time functions that permit Oracle code to be portable across platforms are contained in libcore10.a on UNIX and libcore10.dllon Windows. An additional library that is new in Oracle Database 10g, Part VI - Oracle XML for PL/SQL Developers libcoresh10.so, supports dynamic linking on the UNIX platforms. It is also used to build libxmlsh10.so,which is Chapter 25 - Getting Started with Oracle XML and PL/SQL why it is considerably smaller than libxml10.a. Chapter 24 - Building an XML Data-Retrieval Application

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending PL/SQL XML Functionality with Java

libnls10.a and oranls10.dll

Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

One of the advantages of the Oracle C XML implementation over others resides in its extensive internationalization support. Support for the UTF-8, UTF-16, and ISO-8859-1 character sets is provided in libnls10.aon UNIX and Index oranls10.dll on Windows. These libraries also depend on the environment to find their encoding and message files. List Figures Theofsetup of the environment will be covered in a later section. Glossary

List of Tables List of Sidebars

libunls10.a and oraunls10.dll When you need support for other character sets, you also need to use libunls10.aon UNIX and oraunls10.dll on Windows. Generally, these character sets can be classified as Asian, European, or Middle Eastern language character sets. Because over 300 character sets are supported, we are not listing them here, but you can find them in Appendix A of the Oracle Data Globalization Support Guide 10g. As with the previous libraries, these also depend on the environment to find their encoding and message files.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g Development XML & SQL: Design, Environment Build & Manage XML Applications in Java, C, C++ & Setting Up Your C XML PL/SQL

ISBN:0072229527 Mark V. Scardina, Ben Chang Jinyu Wang Database 10g installation, there are several While much of by your environment is already set and up by an Oracle steps McGraw-Hill/Osborne © 2004 pages)to both compile and run your Oracle C XML-enabled applications. that are platform-specific that you need to (600 perform

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Note that in later sections XDK directory is referred to as $XDK_HOME or %XDK_HOME% and the Oracle emphasis onthe XML standards, their usage and best practices. Home is referred to as $ORACLE_HOME or %ORACLE_HOME%. Table of Contents

UNIX Setup of XDK C Components

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

In order to successfully runStandards your UNIX C application, several environment variables need to be set for the various Part I - Oracle and the XML components so they can find their support files. - Introducing XML

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX ORA_NLS10

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4 - Validating XML ORA_NLS10 with DTDs andisXML Schemas The environment variable set to point to the location of the NLS character-encoding definition files. If Chapter 5 installed - XML Operations with XQuery you have Oracle Database 10g, then you can set it as follows: Chapter 6 ORA_NLS10 - XML Messaging and RPC with SOAP setenv ${ORACLE_HOME}/nls/data Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II -don’t Oracle XML for DBAs If you have anManagement Oracle database installed, you can use the NLS character-encoding definition files that come

Chapter with the8 OTN - Getting Oracle Started XDK release, with the as Oracle follows: XML Database Chapter 9 ORA_NLS10 - Storing XML${XDK_HOME}/nls/data Data setenv Chapter 10 - Generating and Retrieving XML

Note XDK-included encoding files contain a subset of the character sets that are in the Oracle database Chapter 11 The - Searching XML Data While contains 34 character-encoding files, they are the most common ones. Chapter 12 release. - Managing the itOracle XMLonly Database Part III - Oracle XML for Java Developers

ORA_XML_MESG Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

The environment variable ORA_XML_MESG is set to point to the location of the XML error message files. These files are provided in the xdk/mesg/ directory. Files ending in .msb are machine-readable and needed at runtime; Chapter 16 - Developing XML Gateway Application with SOAP andaction AQ descriptions for each error. For Oracle files ending in .msg arean human-readable and include cause and Chapter 17 Developing XML-Based Reusable Components database installations, these message files exist in the $ORACLE_HOME/xdk/mesg directory and no environment Part IV - Oracle XML forIfC no Developers variable is necessary. Oracle database is installed, you should set the environment variable ORA_XML_MESG Chapter 18 Getting Started Oracle XML anddirectory: C to point to the absolute pathwith of the xdk/mesg/ Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 19 - Building an XML-Managed Application

setenv ORA_XML_MESG ${XDK_HOME}/xdk/mesg

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Checking Your C Run-Time Environment

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

Several ready-to-run XML utilities are included in Oracle XDK 10g. These make it easy for you to confirm that your run-time environment is properly configured. They all reside in $ORACLE_HOME/bin for Oracle database Chapter 24 - Building an XML Data-Retrieval Application installations and $XDK_HOME/bin for OTN XDK installations. The following sections describe these XML utilities Part VI - Oracle XML for PL/SQL Developers along with their command-line options. Chapter 23 - Build an XML Database OCI C++ Application

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter xml 26 - Building PL/SQL Web Services

Chapter 27 - Extending PL/SQL XML Functionality with Java

The C XML parser may called as an executable by invoking xml from your $ORACLE_HOME/bin or Chapter 28 - Putting It All be Together $XDK_HOME/bin as follows: Appendix - XML Standards Bodies and Open Specifications Glossary xmloptions URI Index List of Figures

Theoffollowing List Tables is the list of options: List of Sidebars

-c Perform conformance check only, no validation -eencoding Specify default input file encoding (“incoding”) -Eencoding Specify DOM/SAX encoding (“outcoding”) -f file Interpret as filespec, not as URI -llanguage Specify language for error reporting


-nnumber Perform DOM traversal and report number of elements -p Print document after parsing it

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

-v Display PL/SQL parser version then exit

by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne -w Preserve all white spaces © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

-W Stop parsing after warning emphasis onaXML standards, their usage and best practices. -xExercise SAX interface and print document

Table of Contents

Oracle xsl Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

TheI C- Oracle XSLT processor may be called as an executable by invoking bin/xsl as follows: Part and the XML Standards Chapter 1 - Introducing XML xsloptions URI Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

The following is the listXML of options: Chapter 4 - Validating with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

-f file Interpret as filespec, not as URI

Chapter - Putting All Together with -h 7Show usageIthelp and full list of XML flagsPipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

-in8Specify number of times to iterate processing Chapter - Getting Started with the Oracle the XMLXSLT Database Chapter 9

- Storing XML Data

-llanguage Specify language for error reporting

Chapter 10 - Generating and Retrieving XML

Chapter 11 - outfile Searching XML output Data file of XSLT processor -oXSL Specify Chapter 12 - Managing the Oracle XML Database

-r Do not ignore <xsl:output> instruction in XSLT processing Part III - Oracle XML for Java Developers Chapter 13 - Getting Started with Oracle XML and Java

-sstylesheet Specify the XSL stylesheet

Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating Portal Siteversion with XML and Web Services -v Display XSLTaprocessor then exit Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

-Vvar Test top-level variables in CComponents XSLT Chapter 17 -value Developing XML-Based Reusable Part IV - Oracle XML for C Developers

schema

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

The Schema Validator may be called as an executable by invoking bin/schema, which takes two arguments: the

Chapter 20 - Build an XML Database OCI Application XML instance document and, optionally, a default schema to apply:

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

schemaoptions document schema

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an list XMLofDatabase The following is the options: OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

-0 -Always code 0 (success) Part VI Oracle exit XMLwith for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

-eencoding Specify default input file encoding (“incoding”)

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending PL/SQL XML Functionality with Java -Eencoding Specify output/data/presentation encoding (“outcoding”) Chapter 28 - Putting It All Together

-i Ignore provided schema fileand Open Specifications Appendix - XML Standards Bodies Glossary Index

-onum Specify validation options

List of-p Figures Print instance document to standard output on success List of Tables

Force the Unicode code path List of-u Sidebars -v Display version and then exit

Setting Up Your C Compile-Time Environment To compile your code, you need to have the run-time environment set up and you need to have the header files for the components that you are using. These header files reside in the xdk/include directory in either installation. The following is a listing of each and its corresponding description:


oratypes.h Includes all the private Oracle C data types independent of XML. oraxml.h Includes all the Oracle9i XML ORA data types and all the public ORA APIs in libxml. This is for Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & backward compatibility only. PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

oraxmlcg.h Includes the C APIs for the C++ Class Generator.

ISBN:0072229527

This comprehensive guide on data utilizing XML technologies Oracle's XML-enabled products, oraxsd.h Includes the Oracle9i XSDfocuses validator types and APIs. Thiswithin is for backward compatibility only. with emphasis on XML standards, their usage and best practices.

xml.h Is the header to handle the Unified DOM APIs transparently, whether using OCI or standalone. Table of Contents

xmlerr.h Includes the XML errors and their numbers.

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction xmlotn.h Includes all the other headers based upon whether you are compiling standalone or using OCI and Part Ithe - Oracle and the XML Standards Unified DOM.

Chapter 1

- Introducing XML

xmlproc.h Includes the DOM, Oracle 10gJAXB, XML and dataStAX types and XML public parser APIs in libxml10. Chapter 2 - Accessing XMLallwith SAX, Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

xmlsch.h Includes all the Oracle 10g XSD validator public APIs.

Chapter 5 - XML Operations with XQuerydata types and APIs. These are not currently documented or supported. xmlptr.h Includes all the XPointer Chapter 6

- XML Messaging and RPC with SOAP

xmlxsl.h Includes the XSLT processor data types and XSQL public APIs. Chapter 7 - Putting It Allall Together with XML Pipeline, JSPs, and Part II - Oracle XML Management for DBAs

xmlxvm.h Includes all the XSLT compiler and VM data types and public APIs.

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 - Storing XMLCData Confirming Your Compile-Time Environment Chapter 10 - Generating and Retrieving XML

You can your XML setupData by compiling the demo programs, by using makefile in the $XDK_HOME/xdk/demo Chapter 11confirm - Searching directory the OTN release. The demos are not shipped with the Oracle Database 10g CD but are on the Chapter 12of - Managing the Oracle XML Database Companion CDXML and for willJava be inDevelopers the $ORACLE_HOME/xdk/demodirectory once installed. Part III - Oracle Chapter 13 - Getting Started with Oracle XML and Java

Windows Setup of XDK C Components

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services

In order16to-successfully runXML your Windows C application, several variables need to be set for the Chapter Developing an Gateway Application with SOAP andenvironment AQ various17 components soXML-Based they can find their support files. Chapter - Developing Reusable Components Part IV - Oracle XML for C Developers

ORA_NLS10 Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

The environment variable ORA_NLS10 is set to point to the location of the NLS character-encoding definition files. If you have installed Oracle Database 10g (and assuming that the variable ORACLE_HOME has been set), then you Chapter - Create an XML-Configured High-Performance Transformation Engine can set21 it as follows: Chapter 20 - Build an XML Database OCI Application Part V - Oracle XML for C++ Developers

set ORA_NLS10 %ORACLE_HOME%\nls\data

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building XML database Data-Retrieval Application If you don’t have an an Oracle installed, after setting a variable called XDK_HOME, you can use the NLS Part VI - Oracle XML for PL/SQL Developers character-encoding definition files that come with the OTN Oracle XDK release as follows:

Chapter 25 - Getting Started with Oracle XML and PL/SQL

set ORA_NLS10 %XDK_HOME%\nls\data

Chapter 26 - Building PL/SQL Web Services Chapter 27 The - Extending PL/SQLencoding XML Functionality withaJava Note XDK-included files contain subset of the character sets that are in the Oracle database Chapter 28 release. - Putting While It All Together it contains only 34 character-encoding files, they are the most common ones. Appendix

- XML Standards Bodies and Open Specifications

ORA_XML_MESG Glossary Index

The environment variable ORA_XML_MESG is set to point to the location of the XML error message files. These files are provided in the xdk\mesg\ directory. Files ending in .msb are machine-readable and needed at runtime; List of Tables files ending in .msg are human-readable and include cause and action descriptions for each error. For Oracle List of Sidebars database installations, these message files exist in the $ORACLE_HOME\xdk\mesg directory and no environment variable is necessary. If no Oracle database is installed, you should set the environment variable, ORA_XML_MESG, to point to the absolute path of the xdk\mesg\ directory: List of Figures

set ORA_XML_MESG %XDK_HOME%\xdk\mesg

Checking Your C Run-Time Environment Several ready-to-run XML utilities are included in Oracle XDK 10g. They help you to make sure that your run-time


environment is properly configured. They all reside in %ORACLE_HOME%\bin for Oracle database installations and %XDK_HOME%\bin for OTN XDK installations. The following sections describe these XML utilities. Their commandline options areOracle the same as in the previous Database 10g XML & UNIX SQL: section. Design, Build & Manage XML Applications in Java, C, C++ &

xml.exe

PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

The C XML parser may be called as an executable by invoking xml.exe in the bin directory as follows:

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

xml.exeoptions URI on XML standards, their usage and best practices. emphasis Table of Contents

xsl.exe

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction The C XSLT processor may be called as an executable by invoking xsl.exe in the bindirectoryas follows: Part I - Oracle and the XML Standards

xsl.exeoptions URI

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath schema.exe

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 - XML Operations XQuery The Schema Validator may with be called as an executable by invoking schema.exe in the bin directory, which takes Chapter 6 - XML the Messaging and RPCdocument with SOAPand, optionally, a default schema to apply: two arguments: XML instance Chapter 7options - Putting document It All Together with XML Pipeline, JSPs, and XSQL schema schema Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Setting Up Your C Compile-Time Environment

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

To compile your code, you need to have the run-time environment set up and you need to have the header files for

Chapter 12 - Managing the Oracle XMLThese Database the components that you are using. header files reside in the xdk\include directory in either installation. Part III - Oracle XML for Java Developers

These are the same files as described in the previous UNIX section.

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Confirming Your C Compile-Time Environment

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16confirm - Developing an XML SOAP and AQ make.batin the %XDK_HOME%\xdk\demo You can your setup by Gateway compilingApplication the demo with programs, by using Chapter 17of - Developing XML-Based Components directory the OTN release only. Reusable The demos are not shipped with the Oracle Database 10g release. The make file Part IV - Oracle XML for Ccl.exe Developers assumes you are using and that you have it in your PATH. You also have to edit make.bat to provide the

Chapter - Getting Oracle XML and C paths to18the header Started files as with well as the corresponding .libfiles located in %ORACLE_HOME%\libor Chapter 19 - Building an XML-Managed Application %XDK_HOME%\lib. Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Setting Up Microsoft Visual C/C++

Part V - Oracle XML for C++ Developers

Chapter 22 much - Getting Started with C Oracle XML and C++ Because of the Windows development is done using Microsoft Visual C/C++, we will show you how to set Chapter 23 - Build an settings XML Database C++ Application up a project and its for theOCI applications covered in the later chapters. These instructions can also be used Chapter - Building an included XML Data-Retrieval Application for the 24 demos that are in Oracle XDK 10g. These instructions assume Microsoft Visual C/C++ version 6.0a Part VI - Oracle XML for PL/SQL Developers is compatible.

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Creating a NewPL/SQL Project Chapter 26 - Building Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

Projects need to be attached to workspaces; therefore, if you don’t already have one that you would like to use, you will need to create a blank one. You do so by clicking File | New | Workspaces and entering a name, after which you Appendix - XML Standards Bodies and Open Specifications can click the now activated OK button to give you a new workspace. Chapter 28 - Putting It All Together Glossary

Index To add a project to this new workspace or to an existing one, you need to click File | New| Projects at which point List Figures youofwill see the screen shown in Figure 18-1. For the applications in this book as well as the Oracle XDK 10g List demos, of Tables you need to select Win32 Console Application and enter the name of your project. In Figure 18-1, this is

CXMLApp. List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2 - Accessing with DOM, SAX, JAXB, and StAX Figure 18-1: NewXML Projects window Chapter 3

- Transforming XML with XSLT and XPath

Chapter Note 4 This - Validating name will XML bewith used DTDs as the andone XMLfor Schemas your executable unless you specify an alternate debug executable

the Project with Settings | Link | General category. Chapter 5 under - XML Operations XQuery Chapter 6

- XML Messaging and RPC with SOAP

Once you click OK, you will be asked the kind of console application you wish to create. You can select an empty - Putting It All Together with XML Pipeline, JSPs, and XSQL project and click Finish. This will add your new project to your workspace in the FileView pane.

Chapter 7

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database Configuring Your Project

Chapter 9

- Storing XML Data

Chapter 10 -have Generating Retrieving Once you createdand a project, youXML can then configure its settings. This is done by right-clicking the project name, Chapter 11 Settings, - Searching Data selecting andXML then clicking C/C++ in the Project Settings window that appears. You’ll find numerous Chapter settings12here, - Managing but, as the youOracle can see XML in Database Figure 18-2, you can keep them in their default configuration with or without Part Debug III -optimizations. Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Figure 18-2: Project Settings: C/C++ Chapter 25 - Getting Started with Oracle XMLwindow and PL/SQL Chapter 26 - Building PL/SQL Web Services

At this point you can set up your link configuration by selecting the Link tab in the Project Settings window. You will then see the window shown in Figure 18-3.

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1 - Introducing Figure 8-3: ProjectXML Settings: Link window Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter Addoraxml10.lib 3 - Transforming as the first XMLentry with XSLT in theand Object/Library XPath Modules text box and it will be added to your link line

automatically as shown in Figure 18-3. AtXML runtime you will need the oraxml10.dll,oracore10.dll, and oranls10.dll Chapter 4 - Validating XML with DTDs and Schemas to be in5your PATH for the objects to be found. You can now click OK and begin populating the Source Files and Chapter - XML Operations with XQuery Header6Files folders. Chapter - XML Messaging and RPC with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 Scardina, Changthe and Jinyuof Wang In this chapter,by weMark haveV.walked youBen through basics configuring and setting up your XDK C development © 2004and (600 then pages)confirming proper setup. You will use this environment in the environment forMcGraw-Hill/Osborne either UNIX or Windows following chapters, in which we willguide showfocuses you how build real XML-enabled applications covering a range of This comprehensive onto utilizing XMLCtechnologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. solution scenarios.

Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 19:Database Building an XML-Managed Application PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Many software applications, from servers to simple client applications, use configuration files to set up their McGraw-Hill/Osborne © 2004 (600 pages) environment, run-time options, look and feel, and other persisted conditions and options. In the past these files have This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with usually been simply a collection of name-value pairs with specified delimiters. It turns out that this format suffers emphasis on XML standards, their usage and best practices. significant limitations. For example, it is a very fragile format, because misplacement of a single character may invalidate every subsequent entry. Also, there is no random access to this type of format, so if you want a single bit Table of Contents of information, it has to be processed linearly until the data appears. Finally, a flat list of pairs may not be sufficient to Oracle Database 10g XML & SQL—Design, Build & Manage Applications in Java, C++replaced & PL/SQL support the required semantics. For these reasons and XML more, these flat files are C, being by XML files, which Introduction eliminate or mitigate these issues. Part I - Oracle and the XML Standards

In this chapter, you will XML build a C XML application that is configured by an XML file. The scenario is a simple one that Chapter 1 - Introducing is easily2 extensible and involves publishing XML and content Chapter - Accessing XML with DOM, SAX, JAXB, StAXto a variety of devices by using XSLT and the XML configuration file to specify thewith stylesheets profiles that control the transformations. Chapter 3 - Transforming XML XSLT andand XPath Chapter 4

- Validating XML with DTDs and XML Schemas

Designing the Framework - XML Operations with XQuery

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

For this example, you are going to build a media catalog application, called publishcat, for a fictitious company that - Putting It All Together with XML Pipeline, JSPs, and XSQL brokers the sale of books, CDs, and DVDs. It receives its catalogs in XML and must publish them in a way that Part II - Oracle XML Management for DBAs optimizes their presentation on a variety of devices, such as PCs, PDAs, and cell phones. You could implement this Chapter 8 - Getting Started with the Oracle XML Database by using a custom-built stylesheet for each device; however, you can use a single stylesheet and have the device Chapter 9 - Storing XML Data profile passed in as parameters read from an XML configuration file. This is the approach we will examine and Chapter 10 - Generating and Retrieving XML implement. Chapter 7

Chapter 11 - Searching XML Data

Chapter - Managing the you Oracle To build12this application, willXML needDatabase the XML-formatted catalog entries for books, CDs, and DVDs. Since each of Part IIImedia - Oracle XMLhas for differing Java Developers these types semantics for its description, and thus different DTDs, you will have a different

Chapter stylesheet 13 -for Getting each.Started The configuration with Oracle file XMLwill and also Java have a schema that contains not only the XSL stylesheets to be

applied14 to -each typean butXML-Powered also the three profiles Chapter Building Web Site and their elements. To optimize the display characteristics, you will need to15 specify the following parameters applying the stylesheet: Chapter - Creating a Portal Site with XMLwhen and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Character Set The proper character encoding for the device

Chapter 17 - Developing XML-Based Reusable Components

Part IV - Oracle XML forThe C Developers OutputFileType markup language to use for the display

Chapter 18 - Getting Started with Oracle XML and C

LinesPerPage number of lines to display per screen page Chapter 19 - Building The an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

Graphics An option to display graphics

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part VColor - Oracle XML The for C++ Developers Depth number of colors supported to display the best graphics

Chapter 22 - Getting Started with Oracle XML and C++

Because are numerous and a mixture of data types, instead of passing each one in on the Chapter 23 these - Buildparameters an XML Database OCI C++ Application command you will groupData-Retrieval them as named profiles that the application can read from the configuration file. Chapter 24 -line, Building an XML Application Part VI - Oracle XML for PL/SQL Developers

Thepublishcat application will be a command-line application that functionally performs the following steps to produce the appropriate output from a set of XML input files:

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

1. Parses the command Chapter 27 - Extending PL/SQL line. XML Functionality with Java Chapter 28 - Putting It All Together

2. Validates and creates a DOM from the input XML media documents.

Appendix

- XML Standards Bodies and Open Specifications

Glossary 3. Retrieves the schema URL for each DOM. Index

4. Parses XSLConfig.xml using SAX.

List of Figures

List of 5. Tables Retrieves XSLT Stylesheet and profile parameters. List of Sidebars

6. Performs XSLT transformation on the DOMs passing the profile parameters to the stylesheet. 7. Serializes the result to the specified output file. If no output file is specified, it prints to the screen. Cleans up and terminates. Each of these steps will be discussed and implemented in the following sections.


Database The XML Oracle Media Files 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 byuse Mark V. Scardina, Ben Chang Jinyu Wang To illustrate this case, it is sufficient to useand simple XML data files for the catalogs of the different media types. McGraw-Hill/Osborne © 2004 (600 pages) These files could be based upon either DTDs or XML schemas. In this

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

case we choseemphasis to use DTDs as standards, most of thistheir typeusage of content is based on DTDs and there are no datatypes used on XML and best practices. beyond strings that would benefit from an XML Schema data model. Table Contents Evenofthough each book, CD, and DVD listing has common components, since you will be using the DOCTYPE Oracle 10g XML SQL—Design, Buildwe & Manage XML Applications in Java, C, C++ & PL/SQL value Database to differentiate the&type of processing, have chosen to create three DTDs: Introduction

bookcatalog.dtd Part I - Oracle and the XML Standards Chapter - Introducing XMLencoding="UTF-8"?> <?xml 1version="1.0" Chapter 2 - Accessing XML(#PCDATA)> with DOM, SAX, JAXB, and StAX <!ELEMENT color64K Chapter <!ATTLIST 3 - Transforming color64K XML URL with ENTITY XSLT and #REQUIRED> XPath

<!ELEMENT color256 Chapter 4 - Validating XML(#PCDATA)> with DTDs and XML Schemas <!ATTLIST color256 URL Chapter 5 - XML Operations withENTITY XQuery #REQUIRED> <!ELEMENT color16 (#PCDATA)> Chapter 6 - XML Messaging and RPC with SOAP <!ATTLIST color16 ENTITY #REQUIRED> Chapter 7 - Putting It All URL Together with XML Pipeline, JSPs, and XSQL <!ELEMENT (color256 | color16 Part II - Oraclegraphics XML Management for DBAs

| color64K)>

<!ELEMENT priceStarted (#PCDATA)> Chapter 8 - Getting with the Oracle XML Database <!ELEMENT publisher (#PCDATA)> - Storing XML Data <!ELEMENT year (#PCDATA)> Chapter 10 - Generating and Retrieving XML <!ELEMENT ISBN (#PCDATA)> Chapter 11 - Searching XML Data <!ELEMENT title (#PCDATA)> Chapter 12 - Managing the Oracle XML Database <!ELEMENT author_lastname (#PCDATA)> Part III - Oracle XML for Java Developers <!ELEMENT publisher (#PCDATA)> Chapter 13 - Getting Started with Oracle XML and Java <!ELEMENT book (ISBN, title, author_lastname, publisher, Chapter 14year, - Building an XML-Powered graphics, priceWeb )>Site Chapter 15 - Creating a Portal Site with XML and Web Services <!ELEMENT Bookcatalog (book+)> Chapter 9

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

cdcatalog.dtd Part IV - Oracle XML for C Developers Chapter - Getting Started encoding="UTF-8"?> with Oracle XML and C <?xml 18 version="1.0" Chapter 19 - Building an XML-Managed Application <!ELEMENT color64K (#PCDATA)> Chapter <!ATTLIST 20 - Build color64K an XML Database URL ENTITY OCI Application #REQUIRED>

<!ELEMENT color256 (#PCDATA)> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <!ATTLIST ENTITY Part V - Oracle color256 XML for C++URL Developers

#REQUIRED> <!ELEMENT color16 (#PCDATA)> Chapter 22 - Getting Started with Oracle XML and C++ <!ATTLIST color16 ENTITY #REQUIRED> Chapter 23 - Build an XMLURL Database OCI C++ Application <!ELEMENT graphics (color256 | color16 Chapter 24 - Building an XML Data-Retrieval Application| color64K)> <!ELEMENT (#PCDATA)> Part VI - OracleISBN XML for PL/SQL Developers <!ELEMENT title (#PCDATA)> Chapter 25 - Getting Started with Oracle XML and PL/SQL <!ELEMENT artist_lastname (#PCDATA)> Chapter 26 - Building PL/SQL Web Services <!ELEMENT producer (#PCDATA)> Chapter 27 - Extending PL/SQL XML Functionality with Java <!ELEMENT price (#PCDATA)> Chapter 28 - Putting It All Together <!ELEMENT cd (ISBN, title, artist_lastname, producer, Appendix - XML Standards Bodies and Open Specifications year, graphics, price )> Glossary <!ELEMENT CDcatalog (cd+)> Index List of Figures dvdcatalog.dtd List of Tables <?xml version="1.0" encoding="UTF-8"?> List of Sidebarscolor64K (#PCDATA)> <!ELEMENT

<!ATTLIST color64K URL ENTITY #REQUIRED> <!ELEMENT color256 (#PCDATA)> <!ATTLIST color256 URL ENTITY #REQUIRED> <!ELEMENT color16 (#PCDATA)> <!ATTLIST color16 URL ENTITY #REQUIRED> <!ELEMENT graphics (color256 | color16 | color64K)> <!ELEMENT ISBN (#PCDATA)> <!ELEMENT title (#PCDATA)>


<!ELEMENT director_lastname (#PCDATA)> <!ELEMENT studio (#PCDATA)> <!ELEMENT price (#PCDATA)> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <!ELEMENT dvd (ISBN, title, director_lastname, studio, year, PL/SQL graphics, )> Ben Chang and Jinyu Wang ISBN:0072229527 by Mark price V. Scardina, <!ELEMENT DVDcatalog (dvd+)> McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Note that eachemphasis book, CD, and DVD catalog element has a plus appended to indicate that there needs to be one or on XML standards, their usage and best practices. more records for the input files to be valid. Also, we are using the element content for each graphic for its name and an attribute of type ENTITY to point to its location.

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL:File Design, Build & Manage XML Applications in Java, C, C++ & Creating an XML Configuration PL/SQL

by Mark V. Scardina, file Benformat Changthat and can Jinyu Wang all the parameterized information that will ISBN:0072229527 You need to create a configuration contain be needed McGraw-Hill/Osborne © 2004 (600 pages) at runtime to produce the proper result. Since this file is an integral part of the application and is designed to be updated, it needs be validated and thus should a DTD XML schema. ForOracle's this application, we will use anwith Thistocomprehensive guide focuses onhave utilizing XMLortechnologies within XML-enabled products, emphasis on XML standards, their usage and best practices. XML schema. The following is the XML schema derived from the requirements, which is divided into two parts for ease of discussion. Table of Contents

Defining the XSLT Stylesheets

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

TheI configuration XMLXML schema file is called XSLConfig.xsd and initially defines the stylesheets used in your Part - Oracle and the Standards application: Chapter 1 - Introducing XML Chapter - Accessing XML with DOM, SAX, JAXB, and StAX <?xml 2version="1.0"?> Chapter <xsd:schema 3 - Transforming xmlns:xsd="http://www.w3.org/2001/XMLSchema" XML with XSLT and XPath

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> Chapter 4 - Validating XML with DTDs and XML Schemas <xsd:element name="Styles"> Chapter 5 - XML Operations with XQuery <xsd:complexType> Chapter 6 - XML Messaging and RPC with SOAP <xsd:sequence> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL name="Stylesheets" Part II<xsd:element - Oracle XML Management for DBAs

type="Stylesheets"/>

<xsd:element name="Profiles" type="Profiles" maxOccurs="unbounded"/> Chapter 8 - Getting Started with the Oracle XML Database </xsd:sequence> - Storing XML Data </xsd:complexType> Chapter 10 - Generating and Retrieving XML </xsd:element> Chapter 11 - Searching XML Data <!–– Define Stylesheets Type made up of Books, CDs, and DVDs ––> Chapter 12 - Managing the Oracle XML Database <xsd:complexType name="Stylesheets"> Part III - Oracle XML for Java Developers <xsd:sequence maxOccurs="unbounded"> Chapter 13 - Getting Started with Oracle XML and Java <xsd:element name="Books"> Chapter 14 - Building an XML-Powered Web Site <xsd:complexType> Chapter <xsd:sequence> 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an name="bookxsl" XML Gateway Application with SOAP and AQ <xsd:element maxOccurs="unbounded"> Chapter 17<xsd:complexType> - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers <xsd:simpleContent> Chapter 18 - Getting Started with Oracle XML and C <xsd:extension base="xsd:string"> Chapter 19 - Building <xsd:attribute an XML-Managed name="dtd" Application type="xsd:string"/> </xsd:extension> Chapter 20 - Build an XML Database OCI Application Chapter 21 -</xsd:simpleContent> Create an XML-Configured High-Performance Transformation Engine </xsd:complexType> Part V - Oracle XML for C++ Developers </xsd:element> Chapter 22 - Getting Started with Oracle XML and C++ Chapter </xsd:sequence> 23 - Build an XML Database OCI C++ Application </xsd:complexType> Chapter 24 - Building an XML Data-Retrieval Application </xsd:element> Part VI - Oracle XML for PL/SQL Developers <xsd:element name="CDs"> Chapter 25 - Getting Started with Oracle XML and PL/SQL <xsd:complexType> Chapter 26 - Building PL/SQL Web Services <xsd:sequence> Chapter 27 - Extending PL/SQL XML Functionality with Java <xsd:element name="cdxsl" maxOccurs="unbounded"> Chapter 28 - Putting It All Together <xsd:complexType> Appendix - XML Standards Bodies and Open Specifications <xsd:simpleContent> Glossary <xsd:extension base="xsd:string"> Index <xsd:attribute name="dtd" type="xsd:string"/> List of Figures</xsd:extension> List of Tables</xsd:simpleContent> List of Sidebars </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="DVDs"> <xsd:complexType> <xsd:sequence> <xsd:element name="dvdxsl" maxOccurs="unbounded"> Chapter 9


<xsd:complexType> <xsd:simpleContent> <xsd:extension base="xsd:string"> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <xsd:attribute name="dtd" type="xsd:string"/> PL/SQL </xsd:extension> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang </xsd:simpleContent> McGraw-Hill/Osborne © 2004 (600 pages) </xsd:complexType> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with </xsd:element> emphasis on XML standards, their usage and best practices. </xsd:sequence> </xsd:complexType> Table of Contents </xsd:element> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL </xsd:sequence> Introduction </xsd:complexType> Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter - Accessing XML with DOM, SAX,to JAXB, and StAXand its child elements to be <Stylesheets> and This first2 section defines the root element be <Styles> Chapter <Profiles> 3 - Transforming elements of the XML corresponding with XSLT andtypes. XPathIt then defines the Stylesheets type to contain <Books>,<CDs>,

and <DVDs> elements, which theirXML respective Chapter 4 - Validating XML withcontain DTDs and Schemas<bookxsl>, <cdxsl>, and <dvdxsl> elements. These *xsl elements the stylesheets to apply when the corresponding DTDs are retrieved from the DOCTYPE of the Chapter 5 specify - XML Operations with XQuery input XML Note and thatRPC more than one *xsl element can be specified for each media type and that more Chapter 6 -document. XML Messaging with SOAP media types can beItadded because of XML the presence of theand maxOccurs="unbounded" attribute on the Chapter 7 - Putting All Together with Pipeline, JSPs, XSQL <xsd:sequence> The for following Part II - Oracle XMLelements. Management DBAs is a conformant and valid Stylesheetsinstance XML fragment: <Stylesheets> Chapter 8 - Getting Started with the Oracle XML Database <Books> Chapter 9 - Storing XML Data <bookxsl dtd="bookcatalog.dtd">booklist.xsl</bookxsl> Chapter 10 - Generating and Retrieving XML </Books> Chapter 11 - Searching XML Data <CDs> Chapter 12 - Managing the Oracle XML Database dtd="cdcatalog.dtd">cdlist.xsl</cdxsl> Part<cdxsl III - Oracle XML for Java Developers </CDs> <DVDs> Chapter 14 - Building an XML-Powered Web Site <dvdxsl dtd="dvdcatalog.dtd">dvdlist.xsl</dvdxsl> Chapter 15 - Creating a Portal Site with XML and Web Services </DVDs> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ </Stylesheets> Chapter 13 - Getting Started with Oracle XML and Java

Chapter 17 - Developing XML-Based Reusable Components

Part - Oracle XML C Developers TheIV application will for retrieve the DOCTYPE DTD declaration and execute the matching XSL stylesheet.

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Defining the Profiles

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create High-Performance Transformation Engineparameter set as of type Profileset. In The second sectionanofXML-Configured XSLConfig.xsd defines the profiles for each device’s Part - Oracle XMLdefining for C++one Developers thisVcase, we are for PC,PDA, and PHONE.

Chapter 22 - Getting Started with Oracle XML and C++

<xsd:element name="Profileset" type="Profileset"/>

Chapter 23 - Build an XMLname="Profiles"> Database OCI C++ Application <xsd:complexType Chapter 24 - BuildingmaxOccurs="unbounded"> an XML Data-Retrieval Application <xsd:choice Part VI - Oracle XML forname="PC" PL/SQL Developers <xsd:element type="Profileset"/>

Chapter 25 - Getting Started with Oracle XML and PL/SQL <xsd:element name="PDA" type="Profileset"/> Chapter 26 - Building PL/SQL Web Services <xsd:element name="PHONE" type="Profileset"/> Chapter 27 - Extending PL/SQL XML Functionality with Java </xsd:choice> Chapter </xsd:complexType> 28 - Putting It All Together

<xsd:complexType name="Profileset"> Appendix - XML Standards Bodies and Open Specifications <xsd:sequence> Glossary Index<xsd:element name="CharacterSet" type="CharacterSetType"/>

name="OutputFileType" type="OutputFileTypeType"/> List of<xsd:element Figures name="Graphics" type="OnOffType"/> List of<xsd:element Tables <xsd:element name="ColorDepth" type="ColorDepthType"/> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="ColorDepthType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="16"/> <xsd:enumeration value="256"/> <xsd:enumeration value="64K"/> </xsd:restriction>

List of Sidebars


</xsd:simpleType> <xsd:simpleType name="OnOffType"> <xsd:restriction base="xsd:string"> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <xsd:enumeration value="ON"/> PL/SQL <xsd:enumeration value="OFF"/> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang </xsd:restriction> McGraw-Hill/Osborne © 2004 (600 pages) </xsd:simpleType> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <xsd:simpleType emphasisname="CharacterSetType"> on XML standards, their usage and best practices. <xsd:restriction base="xsd:string"> <xsd:enumeration value="UTF-8"/> Table of Contents <xsd:enumeration value="8859-1"/> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <xsd:enumeration value="US-ASCII"/> Introduction </xsd:restriction> Part I - Oracle and the XML Standards </xsd:simpleType> Chapter 1 - Introducingname="OutputFileTypeType"> XML <xsd:simpleType Chapter 2 Accessing XML with DOM, SAX, JAXB, and StAX <xsd:restriction base="xsd:string"> Chapter 3 - Transforming XML with XSLT and XPath <xsd:enumeration value="WML"/> Chapter 4 - Validating XML with DTDs and XML Schemas <xsd:enumeration value="HTML"/> Chapter 5 - XML Operations with XQuery </xsd:restriction> Chapter </xsd:simpleType> 6 - XML Messaging and RPC with SOAP </xsd:schema> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Note that ofStarted using <xsd:sequence> to specify the named profiles, as we did with the different media types, Chapter 8 instead - Getting with the Oracle XML Database

we used <xsd:choice>. The distinction is that a valid configuration file must be able to transform all of the specified - Storing XML Data types; however, it needs to optimize the output only for one or more devices. Obviously, this is an option that you Chapter 10 - Generating and Retrieving XML can eliminate by using <xsd:sequence> instead. Chapter 9

Chapter 11 - Searching XML Data

Chapter 12 that - Managing the Oracle XML Database Also note the Profileset type is made up of element types that use enumerations to further restrict their content. Part - Oracle Javavalues Developers ThisIII means thatXML onlyfor those specified are legal.

Chapter 13 - Getting Started with Oracle XML and Java

Finally,14 there are twoanother options ofWeb noteSite in the second section of XSLConfig.xsd. The first is the definition of Chapter - Building XML-Powered OnOffType as a restriction xsd:string. As we are using “ON” and “OFF” as the values for better semantic Chapter 15 - Creating a Portalof Site with XML and Web Services understanding, we chose restrict to aApplication string enumeration. Chapter 16 - Developing an to XML Gateway with SOAPYou andcould AQ also select a Boolean, should you wish to

instead have TRUE/FALSE or 1/0 as the values. A similar option holds true for LinesPerPagetype; however, in this case we are enumerating over actual numerical values. In the case of XSLT 1.0, these will be implicitly cast anyway. Part IV - Oracle XML for C Developers Chapter 17 - Developing XML-Based Reusable Components

Chapter 18 - Getting Started with Oracle and CXML instance section from an XSLConfig.xml file: The following is a conformant and validXML Profiles Chapter 19 - Building an XML-Managed Application

<Profiles> <PC> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <CharacterSet>UTF-8</CharacterSet> Part V - Oracle XML for C++ Developers <OutputFileType>HTML</OutputFileType> Chapter 22 - Getting Started with Oracle XML and C++ <Graphics>ON</Graphics> Chapter 23 - Build an XML Database OCI C++ Application <ColorDepth>64K</ColorDepth> Chapter 24 - Building an XML Data-Retrieval Application </PC> Part<PDA> VI - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL <CharacterSet>US-ASCII</CharacterSet> Chapter 26 - Building PL/SQL Web Services <OutputFileType>HTML</OutputFileType> Chapter <Graphics>ON</Graphics> 27 - Extending PL/SQL XML Functionality with Java <ColorDepth>256</ColorDepth> Chapter 28 - Putting It All Together </PDA>- XML Standards Bodies and Open Specifications Appendix <PHONE> Glossary Index<CharacterSet>8859-1</CharacterSet> List of<OutputFileType>WML</OutputFileType> Figures <Graphics>OFF</Graphics> List of Tables <ColorDepth>16</ColorDepth> List of Sidebars </PHONE> </Profiles> Chapter 20 - Build an XML Database OCI Application

The application will retrieve these parameters along with the stylesheets using the SAX parser because there is no need to build a DOM of the configuration document, as you are not altering it. The following is an example dvdlist.xmlinstance document: <?xml version="1.0" encoding="UTF-8" standalone="no"?>


<!DOCTYPE DVDcatalog SYSTEM "dvdcatalog.dtd"> <DVDcatalog> <dvd> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <ISBN>2222</ISBN> PL/SQL <title>Titanic</title> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <director_lastname>Cameron</director_lastname> McGraw-Hill/Osborne © 2004 (600 pages) <studio>MGM</studio> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <year>2003</year> emphasis on XML standards, their usage and best practices. <graphics> <color64K URL="http:/pictures.foo.com/64K/2222.jpg"> Table of Contents Don Quixote Cover</color64K> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <color256 URL="http:/pictures.foo.com/256/2222.jpg"> Introduction Don Quixote Cover</color256> Part I - Oracle and the XML Standards <color16 URL="http:/pictures.foo.com/16/2222.jpg"> Chapter 1Don - Introducing Quixote XML Cover</color16> Chapter 2 Accessing XML with DOM, SAX, JAXB, and StAX </graphics> Chapter 3 - Transforming XML with XSLT and XPath <price>9.99</price> Chapter 4 - Validating XML with DTDs and XML Schemas </dvd> Chapter 5 - XML Operations with XQuery </DVDcatalog> Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Creating the XSL Stylesheets PL/SQL

Mark Benthat Chang andused JinyutoWang It is now time tobyturn to V. theScardina, stylesheet will be produce HTML or WML pages based upon theISBN:0072229527 specific © 2004 pages) device. We willMcGraw-Hill/Osborne examine the stylesheet for(600 DVDs; however, the book and CD stylesheets are the same except for the names of aThis fewcomprehensive elements. Because is a on complex stylesheet, we will discuss each template. guide this focuses utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

The following section is where the parameter values are passed into the stylesheet. In this case, we use the optional select="value"attribute to set a default value if a parameter is missing. This is also an effective way to debug a Table of Contents stylesheet that uses a variety of parameter values. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

<?xml version="1.0" encoding="UTF-8"?> Introduction <xsl:stylesheet version="1.0" Part I - Oracle and the XML Standards

xmlns:xsl= "http://www.w3.org/1999/XSL/Transform"> Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 5

- XML Operations with XQuery

<xsl:param name="Graphics" select="'ON'"/> Chapter 3 - Transforming XML with XSLT and XPath <xsl:param name="ColorDepth" select="'16'"/> Chapter 4 - Validating XML with DTDs and XML Schemas <xsl:param name="Profile" select="'PC'"/> Chapter 6 - XML Messagingsection and RPC with SOAP The following xsl:choose handles the setting of the character set and the output file type since this cannot Chapter 7 within - Putting It All Together Pipeline,between JSPs, and XSQL the HTML and WML DOCTYPE declarations be done a template in XSLTwith 1.0.XML It chooses inserting Part II - Oracle Management for DBAs as well as the XML specific output encoding, which in this case is UTF-8, based upon the active Profile.

Chapter 8 - Getting Started with the Oracle XML Database <xsl:choose> Chapter 9 - Storing XML Data <xsl:when select="$Profile='PC'"> Chapter 10 - Generatingencoding="UTF-8" and Retrieving XML method="HTML"/> <xsl:output Chapter 11 - Searching XML Data </xsl:when> Chapter <xsl:otherwise> 12 - Managing the Oracle XML Database Part III <xsl:choose> - Oracle XML for Java Developers

<xsl:when Chapter 13 - Gettingtest="$Profile='PHONE'"> Started with Oracle XML and Java Chapter <xsl:output 14 - Building an encoding="UTF-8" XML-Powered Web Site method="XML"

doctype-public="-//WAPFORUM//DTD WML 1.1//EN" Chapter 15 - Creating a Portal Site with XML and Web Services doctype-system="http://www.wapforum.org/DTD/wml_1.1.xml"/> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ </xsl:when> Chapter 17 - Developing XML-Based Reusable Components Part IV<xsl:otherwise> - Oracle XML for C Developers

<xsl:output encoding="UTF-8" method="HTML"/> </xsl:otherwise> Chapter 19 - Building an XML-Managed Application </xsl:choose> Chapter 20 - Build an XML Database OCI Application </xsl:otherwise> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine </xsl:choose> Chapter 18 - Getting Started with Oracle XML and C

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting with Oracle XML and C++ The following modeStarted template allows you to control execution based upon the Profile passed in and sets the basis Chapter 23 - Build an XML Database OCI C++ Application forexecuting the following mode-specific templates: Chapter 24 - Buildingmatch="/"> an XML Data-Retrieval Application <xsl:template Part VI - Oracle XML for PL/SQL Developers <xsl:if test="$Profile='PC'">

Chapter 25 - Getting Started with Oracle XML and PL/SQL <xsl:apply-templates mode="PC" select="/" /> Chapter 26 - Building PL/SQL Web Services </xsl:if> Chapter 27 - Extending PL/SQL XML Functionality with Java <xsl:if test="$Profile='PDA'"> Chapter 28 - Putting It All Togethermode="PC" select="/" /> <xsl:apply-templates Appendix </xsl:if> - XML Standards Bodies and Open Specifications

<xsl:if test="$Profile='PHONE'"> Glossary Index<xsl:apply-templates mode="PHONE" select="/" /> List</xsl:if> of Figures

</xsl:template> List of Tables List of Sidebars

The following is the template that is executed if the mode is PC or PDAand uses the corresponding mode parameters to configure the display for Graphics and ColorDepth. Note that the images are differentiated by different paths in the HREF attribute, which is created from the URL attribute in the input XML document. <xsl:template match="DVDcatalog" mode="PC | PDA"> <html> <body> <table>


<tr> <th>ISBN</th> <td>Title</td> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <td>Director</td> PL/SQL <td>Studio</td> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <td>Year</td> McGraw-Hill/Osborne © 2004 (600 pages) <xsl:if test="$Graphics='ON'"> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <td>Picture</td> emphasis on XML standards, their usage and best practices. </xsl:if> <td>Price</td> Table of Contents </tr> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <xsl:for-each select="dvd"> Introduction <tr> Part I - Oracle and the XML Standards <td><xsl:value-of select="ISBN"/></td> Chapter 1<td><xsl:value-of - Introducing XML select="title"/></td> Chapter 2<td><xsl:value-of - Accessing XML with DOM, SAX, JAXB, and StAX select="director_lastname"/></td> Chapter 3<td><xsl:value-of - Transforming XML with XSLT and XPath select="studio"/></td> Chapter 4<td><xsl:value-of - Validating XML with DTDs and XML Schemas select="year"/></td> Chapter 5<xsl:if - XML Operations with XQuery test="$Graphics='ON'"> Chapter 6<td> - XML Messaging and RPC with SOAP test="$ColorDepth = 16"> Chapter 7 -<xsl:if Putting It All Together with XML Pipeline, JSPs, and XSQL href="{graphics/color16/@URL}"/> Part II - Oracle<img XML Management for DBAs Chapter 8 -</xsl:if> Getting Started with the Oracle XML Database <xsl:if test="$ColorDepth = 64"> Chapter 9 - Storing XML Data <img href="{graphics/color64K/@URL}"/> Chapter 10 - Generating and Retrieving XML Chapter 11 -</xsl:if> Searching XML Data </td> Chapter 12 - Managing the Oracle XML Database </xsl:if> Part III - Oracle XML for Java Developers <td><xsl:value-of select="price"/></td> Chapter 13 - Getting Started with Oracle XML and Java </tr> Chapter 14 - Building an XML-Powered Web Site </xsl:for-each> Chapter 15 - Creating a Portal Site with XML and Web Services </table> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ </body> Chapter 17 - Developing XML-Based Reusable Components </html> Part IV Oracle XML for C Developers </xsl:template> Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

This final the WML for the PHONE mode. Since for our example this mode does not Chapter 20 template - Build anproduces XML Database OCI output Application support21 graphics, don’t have to handle them within the template. Figure 19-1 shows an example of the output on Chapter - Create you an XML-Configured High-Performance Transformation Engine a phone. Part V - Oracle XML for C++ Developers Chapter 22 - Gettingmatch="DVDcatalog" Started with Oracle XML and C++ <xsl:template mode="PHONE"> Chapter <wml> 23 - Build an XML Database OCI C++ Application

<card> Chapter 24 - Building an XML Data-Retrieval Application Part<xsl:for-each VI - Oracle XML forselect="dvd"> PL/SQL Developers

<p> Chapter 25 - Getting Started with Oracle XML and PL/SQL ISBN: select="ISBN"/><br/> Chapter 26 -<xsl:value-of Building PL/SQL Web Services Title: <xsl:value-of select="title"/><br/> Chapter 27 - Extending PL/SQL XML Functionality with Java Director: <xsl:value-of Chapter 28 - Putting It All Together select="director_lastname"/><br/> Studio: <xsl:value-of select="studio"/><br/> - XML Standards Bodies and Open Specifications Year: <xsl:value-of select="year"/><br/> Glossary Price: <xsl:value-of select="price"/><br/> Index </p> List of Figures </xsl:for-each> List of Tables </card> List of</wml> Sidebars </xsl:template> </xsl:stylesheet> Appendix


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

Figure 19-1: DVDXML listing on WML phone Chapter 11 - Searching Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Creating the publishcat Application PL/SQL

ISBN:0072229527 by Mark V. Scardina, Bensupporting Chang andfiles, Jinyu Wang Now that we have explained all of the we can discuss the publishcat application itself. It uses the C © 2004 SAX parser to McGraw-Hill/Osborne read the XSLConfig.xml file(600 andpages) the DOM parser to prepare the input document for stylesheet transformation This that comprehensive is done with theguide XSLT processor. focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

This section declares the header files and sets up a global structure to hold the profile parameters that will be retrieved from the configuration file:

Table of Contents

#include <stdio.h> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL #include <string.h> Introduction #include Part I - Oracle<stdlib.h> and the XML Standards Chapter 1

- Introducing XML

#ifndef XML_ORACLE - Accessing XML with DOM, SAX, JAXB, and StAX # include <xml.h> Chapter 3 - Transforming XML with XSLT and XPath #endif Chapter 2 Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

XML Operations with XQuery typedef -struct {

Chapter 6 - XML *xctx; Messaging and RPC with SOAP xmlctx Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL oratext *sskeyword; Part IIsize_t - Oracle XML Management for DBAs sskeylen;

Chapter 8 - Getting Started with the Oracle XML Database oratext *elem; Chapter 9 - Storing XML Data oratext characterset[80]; Chapter 10 - Generating and Retrieving XML oratext outputfile[80]; Chapter oratext 11 - Searching graphics[80]; XML Data

oratext colordepth[80]; Chapter 12 - Managing the Oracle XML Database oratext stylesheets[80]; Part III - Oracle XML for Java Developers oratext profiles[80]; Chapter 13 - Getting Started with Oracle XML and Java } saxctx; Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

Thefindsub() support function is used to handle the SAX character events that we are not interested in:

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

/*–––––––––––––––––––––––––––––––––––––––––––––––––– Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

support functions ––––––––––––––––––––––––––––––––––––––––––––––––––*/ Chapter 19 - Building an XML-Managed Application static oratext *findsub(oratext *buf, size_t bufsiz, Chapter 20 - Build an XML Database OCI Application oratext *sub, size_t subsiz) Chapter 21 - Create an XML-Configured High-Performance Transformation Engine { Part V - Oracle XML for C++ Developers uword i; Chapter 18 - Getting Started with Oracle XML and C

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23(!buf - Build an Database C++ Application if ||XML !bufsiz ||OCI (subsiz > bufsiz)) Chapter 24 -return Building an XML Data-Retrieval Application NULL; Part VIif - Oracle XML PL/SQL Developers (!sub ||for!subsiz)

Chapter 25 -return Getting Started buf; with Oracle XML and PL/SQL Chapter 26 -(i Building Web Services for = 0;PL/SQL i < bufsiz - subsiz; i++, buf++) Chapter 27 Extending PL/SQL XML Functionality with Java { Chapter 28 -if Putting (!memcmp(buf, It All Together sub, subsiz)) Appendix

- XML return Standardsbuf; Bodies and Open Specifications

} Glossary Index return NULL;

} of Figures List List of Tables List of Sidebars

The following is the SAX callback section in which you declare the content handlers for the SAX event stream. Note that you need to handle expected content types, which in this case are startDocument, endDocument, startElement, endElement, and characters. /* –––––––––––––––––––––––––––––––––––––––––– SAX callbacks –––––––––––––––––––––––––––––––––-–––––––––*/ static XMLSAX_START_DOC_F(startDocument, ctx)


{ return 0; }

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

static XMLSAX_END_DOC_F(endDocument, ISBN:0072229527 by Mark V. Scardina, Ben Chang andctx) Jinyu Wang { McGraw-Hill/Osborne © 2004 (600 pages) return This 0; comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with } emphasis on XML standards, their usage and best practices. static XMLSAX_START_ELEM_F(startElement, ctx, name, attrs) { Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL ((saxctx *) ctx)->elem = name; Introduction return 0; Part I - Oracle and the XML Standards }

Table of Contents

Chapter 1

- Introducing XML

Chapter 2 XMLSAX_END_ELEM_F(endElement, - Accessing XML with DOM, SAX, JAXB, and StAXname) static ctx, Chapter 3 {

- Transforming XML with XSLT and XPath

Chapter 4 - Validating XML with DTDs=and XML Schemas ((saxctx *) ctx)->elem (oratext *) ""; Chapter 5 - XML0; Operations with XQuery return Chapter } 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

static XMLSAX_CHARACTERS_F(characters, Part II - Oracle XML Management for DBAs { Chapter 8

ctx, ch, len)

- Getting Started with the Oracle XML Database

saxctx *sc XML = (saxctx *) ctx; Chapter 9 - Storing Data Chapter 10 - Generating and Retrieving XML

if *) sc->elem, "Stylesheets")) Chapter 11(!strcmp((char - Searching XML Data {

Chapter 12 - Managing the Oracle XML Database

memcpy(sc->stylesheets, ch, len); sc->stylesheets[len] = 0;

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

/* set current ss */

} else if (!strcmp((char *)sc->elem, "Profiles")) Chapter 15 - Creating a Portal Site with XML and Web Services { Chapter 16 - Developing an XML Gateway Application with SOAP and AQ memcpy(sc->profiles, ch, len); /* set current profiles */ Chapter 17 -sc->profiles[len] Developing XML-Based Reusable = 0; Components Part IV}- Oracle XML for C Developers Chapter 18 - Getting Started with Oracle XML and C else if (!strcmp((char *)sc->elem, "CharacterSet")) Chapter 19 Building an XML-Managed Application { Chapter 20 -memcpy(sc->characterset, Build an XML Database OCI Application ch, len); Chapter 21 -sc->characterset[len] Create an XML-Configured High-Performance Transformation Engine = 0; Part V } - Oracle XML for C++ Developers Chapter else 22 - Getting if (!strcmp((char Started with Oracle *)sc->elem, XML and C++ "OutputFileType")) { 23 - Build an XML Database OCI C++ Application Chapter len); Chapter 24 -memcpy(sc->outputfile, Building an XML Data-Retrievalch, Application sc->outputfile[len] = 0; Part VI - Oracle XML for PL/SQL Developers } 25 - Getting Started with Oracle XML and PL/SQL Chapter else if (!strcmp((char *)sc->elem, "Graphics")) Chapter 26 - Building PL/SQL Web Services { Chapter 27 - Extending PL/SQL XML Functionality with Java memcpy(sc->graphics, ch, len); Chapter 28 - Putting It All Together sc->graphics[len] = 0; Appendix - XML Standards Bodies and Open Specifications } Glossary else if (!strcmp((char *)sc->elem, "ColorDepth")) Index { List of Figures memcpy(sc->colordepth, ch, len); List of Tablessc->colordepth[len] = 0; List of Sidebars } else if (!strcmp((char *)sc->elem, "LinesPerPage")) { memcpy(sc->linesperpage, ch, len); sc->linesperpage[len] = 0; } else if (findsub((oratext *) ch, len, sc->sskeyword, sc->sskeylen)) return 0; } Chapter 14 - Building an XML-Powered Web Site


static xmlsaxcb saxcb = { startDocument, Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & endDocument, PL/SQL startElement, ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang endElement, McGraw-Hill/Osborne © 2004 (600 pages) characters This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with }; emphasis on XML standards, their usage and best practices. The following is the main function of publishcat that initially processes the command-line parameters by assigning Table themoftoContents variables. The code is commented to describe its flow. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

/*–––––––––––––-Main function ––––––––––––––-*/ int main(int argc, char *argv[]) Part I - Oracle and the XML Standards { Chapter 1 - Introducing XML = NULL; xmlctx *xctx Chapter 2 Accessing XML with=DOM, SAX, JAXB, and StAX xslctx *xslx NULL; Chapter 3 - Transforming saxctx sc;XML with XSLT and XPath Chapter 4 - Validating err; XML with DTDs and XML Schemas xmlerr Chapter 5 - XML Operations with XQuery oratext *xmlfile, *outfile, *xslconfigFile, *xslfile, *schemaURL; Chapter xmldocnode 6 - XML Messaging *docand = NULL, RPC with*ss_doc SOAP = NULL; Introduction

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

(argc < Management 4) { Part IIif - Oracle XML for DBAs error: publishcat -h -i<inputXML> -o<outputFile> Chapter printf("\nUsage 8 - Getting Started with the Oracle XML Database --p<XSLConfig.xml>\n\ Storing XML Data \n h show commandline and parameters \n\ Chapter 10 --Generating and Retrieving XML \n i input XML \n\ Chapter 11 - Searching XML Data \n - o output file (extension optional as it will use default Chapter 12 - Managing the Oracle XML Database for format)\n\ Part III - Oracle XML for Java Developers \n - p profile (defined in XSLConfig.xml)\n\n"); Chapter 13 - Getting Started with Oracle XML and Java return 0; Chapter 14 - Building an XML-Powered Web Site } Chapter 9

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

xmlfile = (oratext *)argv[2];

Chapter 17 - Developing XML-Based Reusable Components xmlfile = xmlfile+2; Part IVoutfile - Oracle XML for C Developers = (oratext *)argv[3];

Chapter 18 - Getting Started with Oracle XML and C outfile = outfile+2; Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML=Database OCI Application xslconfigFile (oratext *)argv[4]; Chapter 21 - Create an XML-Configured High-Performance Transformation Engine xslconfigFile = xslconfigFile + 2; Part V - Oracle XML for C++ Developers

Chapter /* 22Creates - Getting Started the context with Oracle */XML and C++

if = XmlCreate(&err, (oratext *)"xslsample_xctx", NULL))) Chapter 23(!(xctx - Build an XML Database OCI C++ Application { 24 - Building an XML Data-Retrieval Application Chapter printf("Failed create Part VI - Oracle XML for PL/SQL to Developers

XML context, error %u\n", (unsigned)err);

terminate; Chapter 25 -goto Getting Started with Oracle XML and PL/SQL } 26 - Building PL/SQL Web Services Chapter Chapter 27 - Extending PL/SQL XML Functionality with Java

/* Creates the DOM and parses */ if (!(doc=XmlLoadDom(xctx, &err, "file", xmlfile, Appendix - XML Standards Bodies and Open Specifications "validate", TRUE, "discard_whitespace", TRUE, NULL))) Glossary { Index printf("Parse failed, code %d\n", (int)err); List of Figures goto terminate; List of Tables } Chapter 28 - Putting It All Together

List of Sidebars

/* Retrieves Schema URL from DOM */ schemaURL = XmlDomGetSchema(xctx, doc); /* Init SAX context */ memset(&sc, sizeof(sc), 0); sc.sskeyword = (oratext *)"xsl"; sc.sskeylen = strlen(sc.sskeyword); sc.elem = (oratext *) "";


/* Parse XSLConfig.xml using SAX */ if (!(err=XmlLoadSax(xctx, &saxcb, &sc, "file", xslconfigFile, Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & "validate", TRUE, "discard_whitespace", TRUE, NULL))) PL/SQL { ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang printf("Parse failed, code %d\n", (int)err); McGraw-Hill/Osborne © 2004 (600 pages) goto terminate; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with } emphasis on XML standards, their usage and best practices. /* Retrieves XSL stylesheet using SAX and profile parameters */ xslfile = sc.stylesheets;

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction /* Parsing stylesheet */ Part I -if Oracle and the XML Standards (!(ss_doc = XmlLoadDom(xctx,

Chapter 1 Chapter {2 Chapter 3

&err, "file", xslfile,

- Introducing XML TRUE, "discard_whitespace", TRUE, NULL))) "validate", - Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 4

-printf("Parse Transforming XML failed, with XSLT and XPath error %u\n", (unsigned)err); -goto Validating XML with DTDs and XML Schemas terminate;

Chapter }5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

/* result context */JSPs, and XSQL Chapter 7 Initialize - Putting It All the Together with XML Pipeline, = XML XmlXslCreate(xctx, Part IIxslx - Oracle Management for DBAsss_doc, Chapter 8

xslfile, &err);

- Getting Started with the Oracle XML Database

/* Profile Parameters */ Chapter 9 Set - Storing XML Data if (oratext *)"CharacterSet", Chapter 10(err=XmlXslSetTextParam(xslx, - Generating and Retrieving XML sc.characterset))

Chapter 11 - Searching XML Data

{

Chapter 12 - Managing the Oracle XML Database

printf("Setting failed, error %u\n", (unsigned)err);

Part III - Oracle XML for Java Developers

}

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

if (err=XmlXslSetTextParam(xslx, (oratext *)"OutputFileType", sc.outputfile)) Chapter { 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17printf("Setting - Developing XML-Based Reusable Components failed, error %u\n", (unsigned)err); Part IV}- Oracle XML for C Developers Chapter 18(err=XmlXslSetTextParam(xslx, - Getting Started with Oracle XML and C (oratext *)"Graphics", sc.graphics)) if Chapter 19 { - Building an XML-Managed Application Chapter 20printf("Setting - Build an XML Database OCI Application failed, error %u\n", (unsigned)err); Chapter } 21 - Create an XML-Configured High-Performance Transformation Engine Part V if - Oracle (err=XmlXslSetTextParam(xslx, XML for C++ Developers (oratext *)"ColorDepth", sc.colordepth)) Chapter 22 - Getting Started with Oracle XML and C++ { 23 - Build an XML Database OCI C++ Application Chapter failed, error %u\n", (unsigned)err); Chapter 24printf("Setting - Building an XML Data-Retrieval Application } Part VI - Oracle XML for PL/SQL Developers if (oratext *)"LinesPerPage", Chapter 25(err=XmlXslSetTextParam(xslx, - Getting Started with Oracle XML and PL/SQL sc.linesperpage)) Chapter 26 - Building PL/SQL Web Services { Chapter 27 - Extending PL/SQL XML Functionality with Java printf("Setting failed, error %u\n", (unsigned)err); Chapter 28 - Putting It All Together } Chapter 15 - Creating a Portal Site with XML and Web Services

Appendix

- XML Standards Bodies and Open Specifications

Glossary

/* XSL processing */ if (err = XmlXslProcess(xslx, doc, FALSE)) List of Figures { List of Tablesprintf("Processing failed, error %u\n", (unsigned)err); List of Sidebars goto terminate; } Index

/* Serialize result to specified output file */ XmlSaveDom(xctx, &err, doc, "outFile", NULL); /* Clean up and terminate contexts */ terminate: if (doc)


XmlFreeDocument(xctx, doc); if (ss_doc) XmlFreeDocument(xctx, ss_doc); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & if PL/SQL (xctx) XmlDestroy(xctx); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang if McGraw-Hill/Osborne (xslx) © 2004 (600 pages) XmlXslDestroy(xslx); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with return 1; on XML standards, their usage and best practices. emphasis } Table Contents The of following is an example command line for execution: Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

publishcat -i dvdlist.xml -o dvdlist.html -p XSLConfig.xml

Introduction

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Scardina, an Ben Chang andthat Jinyu Wang In this chapter by weMark haveV.discussed application uses XML to convey not only data and content butISBN:0072229527 McGraw-Hill/Osborne 2004this (600ispages) configuration information as well. In ©fact, exactly how many of the Oracle products interface with Oracle Enterprise Manager to handle configuration and on maintenance. creating publishcat, you have used many of the C This comprehensive guide focuses utilizing XMLIntechnologies within Oracle's XML-enabled products, with on XML their usage and bestparsers practices. components inemphasis Oracle XDK 10g,standards, including the DOM and SAX and the XSLT processor. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 20:Database Build10gan XML Database OCI Application PL/SQL

Overview

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Many applications emphasis require onaccess XML standards, to database theirdata, usage because and bestthey practices. typically are designed to return large result sets or to update and retrieve data frequently. While Oracle offers PL/SQL as an in the database programming language, manyofapplications Table Contents need the flexibility and functionality of C or need to offload program logic from the database. This is where building your application using the Oracle Class Interface (OCI) libraries can be a real value. Previous Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Oracle Database releases included no OCI support for the XMLType. Applications had to serialize the output from a Introduction query and reparse using DOM or SAX APIs on the client to process XML. This processing model has distinct Part I - Oracle and the XML Standards disadvantages when the datasets become large, especially when using the DOM APIs, because you need to Chapter 1 - Introducing XML materialize the entire dataset on the client in order to access and modify or update it. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter - Transforming XSLT and XDK XPath10g, now provides XMLType support to OCI applications through a Oracle 3Database 10g, byXML way with of the Oracle Chapter 4 -APIs Validating XML with DTDs XML. and XML set of new that have the prefix TheSchemas reason that these do not have the prefix OCI is that they are the Chapter same APIs 5 - that XML can Operations be used with for XQuery stand-alone XDK applications. Chapter 6

- XML Messaging and RPC with SOAP

In this chapter we show you how to create an OCI program by using these new APIs and connecting to the - Putting It All Together with XML Pipeline, JSPs, and XSQL database. There is a fair amount of boilerplate OCI code that is necessary for all OCI applications. We are not going Part II - Oracle XML Management for DBAs to spend time explaining this code since it can simply be copied and pasted into your application without alteration. Chapter 7 Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & DesigningOracle the Database Framework PL/SQL

ISBN:0072229527 byall Mark Scardina, Ben Chang Jinyu The premise for OCIV.applications is that theyand need to Wang connect to Oracle databases and retrieve, insert, or update McGraw-Hill/Osborne © 2004 pages) data. In the case of XML, this data may be(600 stored in XML format or generated from relational tables. For this example application, you will use OCI to focuses generate XMLType a SQL/ XML overXML-enabled relational tables from with This comprehensive guide onan utilizing XML from technologies withinquery Oracle's products, XML standards, their usage and besta practices. the SH sampleemphasis schema. on However, instead of simply returning serialized stream of the data that would need to be reparsed, you will return an XMLType DOM called an XOB (XML object) that can be accessed directly through the new of XML* APIs. You will then update the XOB and serialize it for consumption or display. You can also save it back Table Contents to the database. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Introduction

The steps to create such an application are as follows:

Part I - Oracle and the XML Standards

1. Initialize the OCIXML application context, handles, environment, etc., with the boilerplate code. Chapter 1 - Introducing Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX 2. Initialize the OCIXMLDB and XDK contexts to operate on an XOB.

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 3. Log 4 - on Validating to the database XML with and DTDs submit and XML the Schemas SQL/XML query. Chapter 5

- XML Operations with XQuery

4. Cast the result to an XDK xmldocnode to prepare it for DOM operations. - XML Messaging and RPC with SOAP

Chapter 6

Chapter 7 - Putting It All Togetherwith withthe XML Pipeline, 5. Perform DOM operations XML* APIs.JSPs, and XSQL Part II - Oracle XML Management for DBAs

Chapter 6. Save 8 - Getting the XOB. Started with the Oracle XML Database Chapter 9

- Storing XML Data

Serialize the XOB or save it back to the database with OCI.

Chapter 10 - Generating and Retrieving XML

Chapter 11 - Searching Data These steps are usedXML in the following command-line xmlupdateapplication that can accept as parameters the Chapter 12 -query, Managing the Oracle XML Database SQL/XML the XPath expression to the location to be updated, and the update data. Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle 10g XML & SQL:Environment Design, Build & Manage XML Applications in Java, C, C++ & Setting Up theDatabase OCI Application PL/SQL

ISBN:0072229527 by Mark V. Scardina, Chang Wang To build OCI XML applications, youBen need to setand up Jinyu the necessary headers and libraries and make files. Fortunately, you alread McGraw-Hill/Osborne © 2004 pages) companion CD-ROM and specified as the (600 destination directory $ORACLE_HOME on Unix or %ORACLE_HOME% on Window

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

The OCI XML Application Headers

Table Contents The of headers in Oracle Database 10g are installed into your Oracle Home by performing a companion CD installation. Once yo Oracle directories Database that 10g include XMLthe & SQL—Design, necessary header Build & files: Manage $ORACLE_HOME/rdbms/public XML Applications in Java, C, C++ and& $ORACLE_HOME/xdk/include PL/SQL on

%ORACLE_HOME%/oci/include and %ORACLE_HOME%/xdk/include on Windows.The following is xmlupdate.h,the appl Introduction Oracle headers with Standards the application functions: Part I - Oracle andalong the XML Chapter 1 -STDIO Introducing XML #ifndef Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX #include <stdio.h> Chapter #endif 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

#ifndef Chapter 5 -STDLIB XML Operations with XQuery #include <stdlib.h> Chapter 6 - XML Messaging and RPC with SOAP #endif Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

#ifndef Chapter 8 -STRING Getting Started with the Oracle XML Database #include- Storing <string.h> XML Data #endif

Chapter 9

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

#ifndef OCIAP_ORACLE #include <ociap.h> Part III - Oracle XML for Java Developers #endif

Chapter 12 - Managing the Oracle XML Database Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 -XML_ORACLE Building an XML-Powered Web Site #ifndef Chapter 15 - Creating #include <xml.h>a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ #endif Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers /*----------------End of including

files -----------------*/

Chapter 18 - Getting Started Public with Oracle XML and C and Variables ---------*/ /*----------------Constants Chapter /* constants 19 - Building */an XML-Managed Application

#define 2000OCI Application Chapter 20 -MAXBUFLEN Build an XML Database #define "SYS" High-Performance Transformation Engine Chapter 21 -SCHEMA Create an XML-Configured #define TYPE "XMLTYPE" Part V - Oracle XML for C++ Developers /*----------------of Constants and Variables -----------------*/ Chapter 22 - Getting Started End with Oracle XML and C++ /*--------------------Functions Declaration --------------------*/ Chapter 23 - Build an XML Database OCI C++ Application int main(/*_ argc, char *argv[] _*/); Chapter 24 - Buildingint an XML Data-Retrieval Application static voidXML checkerr(/*_ OCIError Part VI - Oracle for PL/SQL Developers

*errhp, sword status _*/); static void cleanup(/*_ OCIEnv *envhp _*/); Chapter 25 - Getting Started with Oracle XML and PL/SQL static sb4 connect_server(/*_ OCIServer *srvhp, OCIError *errhp, Chapter 26 - Building PL/SQL Web Services OCISvcCtx *svchp, OCISession *authp, text *user, text *password _*/); Chapter 27 - Extending PL/SQL XML Functionality with Java static void disconnect_server(/*_ OCIEnv *envhp, OCISvcCtx *svchp, Chapter 28 - Putting It All Together OCIError errhp, OCISession *authp, OCIServer *srvhp, OCIStmt *stmthp, Appendix - XML Standards Bodies and Open Specifications boolean tab_exists _*/); Glossary static sb4 init_env_handle(/*_ OCIEnv **envhp, OCISvcCtx **svchp, Index OCIError *errhp, OCIServer **svrhp, OCISession **authp, List of Figures OCIStmt **stmthp _*/); Liststatic of Tablessb4 select_xml(/*_ OCIEnv *envhp, OCISvcCtx *svchp, List of Sidebars OCIError *errhp, OCIStmt *stmthp, ub4 row, text *sel, text*xpath, text *value_*/); static sb4 do_xml(/*_ OCIEnv *envhp, OCISvcCtx *svchp, OCIError *errhp, OCIXMLType *xml, text *xsl_file, text *xpathexpr, text *value _*/); int update_xml(/* struct xmlctx *xctx, xmldocnode *doc, text *xpathexpr, text *value;_*/); /*----------------- End of Functions Declaration ----------------*/


Note that while there are only two explicit Oracle header files, ociap.hand xml.h, they include others from their respective direc get to the code throughout the chapter. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL The OCI XML Application Libraries

by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 pages) OCI applications are dynamically linked on(600 both Unix and Windows using libclntsh.so, located in $ORACLE_HOME/lib32 on %ORACLE_HOME%\oci\lib\Msvc on Windows. the pastXML thetechnologies Solaris library has been in the lib directory, but since This comprehensive guide focuses onInutilizing within Oracle's XML-enabled products, withOracle D emphasis on XML their usage and best practices. the 32-bit libraries are located instandards, their own directory. On Windows you also need to link with the user32.lib,kernel32.lib,msvc winmm.lib Windows libraries. Table of Contents

The OCI libraries do not contain the XML APIs; therefore, you also need to link with libxml10.a on Unix and oraxml10.libon W one like the OCI library and thus the objects you need will be pulled into your executable.

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Part I - Oracle and the XML Standards

The OCI XML Application Make Files - Introducing XML

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

As previously mentioned, the make files necessary to compile and link your application are provided with the database. On Un Chapter 3 - Transforming XML with XSLT and XPath resides in your $ORACLE_HOME/rdbms/demo directory. This is a complicated make file because it works for various builds a Chapter 4 - Validating XML with DTDs and XML Schemas for our example: make -f demo_rdbms32.mk build EXE=xmlupdate OBJS="xmlupdate.o"

Part II this - Oracle XML for DBAs Now, make file Management includes $ORACLE_HOME/rdbms/lib/env_rdbms.mk, which includes the actual compile and link lines. T

Chapter Getting with the to Oracle XMLofDatabase linked, 8you- need to Started add libxml10.a the end the OCISHAREDLIBS variable as follows: Chapter 9

- Storing XML Data

OCISHAREDLIBS=$(LLIBCLNTSH) $(LDLIBS) $(LLIBTHREAD) -lxml10

Chapter 10 - Generating and Retrieving XML

Chapter 11 - Searching On Windows the makeXML file Data is make.batand is located in the %ORACLE_HOME%\oci\samplesdirectory. Only one section is u Chapter - Managing the Oracle Database follows,12 with oraxml10.lib addedXML to the link portion: Part III - Oracle XML for Java Developers

cl -I%ORACLE_HOME%\oci\include -I. -D_DLL -D_MT %1.c /link /LIBPATH:%ORACLE_HOME%\oci\lib\msvc

Chapter 13 - Getting Started with Oracle XML and Java %ORACLE_HOME\Lib\Oraxml10.lib /nod:libc Chapter 14 - Building an XML-Powered Web Site

This section is calledawith theSite following command line for our example: Chapter 15 - Creating Portal with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ make xmlupdate Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & The Update Application PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang Now that you understand the mechanics of creating an OCI XML application, we can examine the Update McGraw-Hill/Osborne © 2004 (600 pages) application’s Main function:

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with #include "xmlupdate.h" emphasis on XML standards, their usage and best practices.

/*---------------------------Main function -----------------------------*/ Table Contents int ofmain(argc, argv) Oracle int argc; Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

char *argv[]; Introduction { I - Oracle and the XML Standards Part /* OCI Handles and Chapter 1 - Introducing XML Variables */ OCIEnv (OCIEnv *) 0; Chapter 2 - Accessing*envhp XML with=DOM, SAX, JAXB, and StAX OCIServer *srvhp (OCIServer *) 0; Chapter 3 - Transforming XML = with XSLT and XPath OCISvcCtx *svchp = DTDs (OCISvcCtx *) 0; Chapter 4 - Validating XML with and XML Schemas OCIError *errhp = (OCIError *) 0; - XML Operations with XQuery OCISession *authp = (OCISession *) 0; Chapter 6 - XML Messaging and RPC with SOAP OCIStmt *stmthp = (OCIStmt *) 0; Chapter 5 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

/* database login information */ - Getting Started with the Oracle XML Database text *user=(text *)"SH"; Chapter 9 - Storing XML Data text *password=(text *)"SH"; Chapter 10 - Generating and DB Retrieving XML if remote DB */ /*Service Name for instance Chapter 11 Searching XML Data text *conn=(text *)""; Chapter 8

Chapter 12 - Managing the Oracle XML Database Part/* III Miscellaneous - Oracle XML for Java */ Developers

Chapter 13 - Getting Started with Oracle and Java boolean tab_exists = XML TRUE; Chapter XML-Powered Web Site ub4 14 - Building anrow = 1; Chapter 15 - Creating a Portal Site with XML and Web Services

if (argc < 3) { an XML Gateway Application with SOAP and AQ Chapter 16 - Developing printf("\nUsage error: Reusable xmlupdate \"<SQL/XML Query>\" \"<XPath>\" Chapter 17 - Developing XML-Based Components Part IV -\"<value>\"\n\n"); Oracle XML for C Developers

return OCI_ERROR; Chapter 18 - Getting Started with Oracle XML and C } Chapter 19 - Building an XML-Managed Application /* Initialize the Database environment and allocate handles */ Chapter 20 - Build an XML OCI Application if (init_env_handle(&envhp, &svchp, &errhp, &srvhp, &authp, &stmthp)) { Part V - Oracle XML for C++ Developers printf("FAILED: init_env_handle()!\n"); Chapter 22 - Getting Started with Oracle XML and C++ return OCI_ERROR; Chapter 23 - Build an XML Database OCI C++ Application } Chapter 24 - Building an XML Data-Retrieval Application /* Log on to the server and begin a session */ Part VI - Oracle XML for PL/SQL Developers if (connect_server(srvhp, errhp, svchp, authp, user, password)) Chapter 25 - Getting Started with Oracle XML and PL/SQL { Chapter 26 - Building PL/SQL Web Services printf("FAILED: connect_server()!\n"); Chapter 27 Extending PL/SQL XML Functionality with Java cleanup(envhp); Chapter 28 - Putting It All Together return OCI_ERROR; Appendix - XML Standards Bodies and Open Specifications } Glossary /* Select an xmltype column by defining it to an xmltype instance, Index apply some OCIXMLType and unified DOM APIs */ = 1; Listrow of Figures (select_test_xml(envhp, svchp, errhp, stmthp, row, (text *)argv[1], Listif of Tables (text *)argv[2], (text *)argv[3])) List of Sidebars { printf("FAILED: select_test_xml()!\n"); disconnect_server(envhp, svchp, errhp, authp, srvhp, stmthp, tab_exists); return OCI_ERROR; } /* Detach from a server and clean up the environment */ disconnect_server(envhp, svchp, errhp, authp, srvhp, stmthp, tab_exists); Chapter 21 - Create an XML-Configured High-Performance Transformation Engine


return OCI_SUCCESS; } Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

Note that the application has the software steps of initialization; connecting to the database; submitting the query; PL/SQL performing the application logic on the results; and cleaning up before exiting. In the following sections, you will see ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang the details of each of these steps as the application is built out. McGraw-Hill/Osborne © 2004 (600 pages)

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & InitializingOracle theDatabase OCI Application PL/SQL

ISBN:0072229527 by Mark V. Scardina, Chang and Jinyu Wangall of the necessary OCI initializations and allocations. The first step when creating an OCIBen application is to perform McGraw-Hill/Osborne 2004 (600 pages) These steps are required for all OCI©applications, as the following code illustrates:

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with /*--------------------------------------------------------*/ emphasis on XML standards, their usage and best practices. /* Initialize the environment and allocate handles */ /*--------------------------------------------------------*/ Table Contents sb4 ofinit_env_handle(envhp, svchp, errhp, srvhp, authp, stmthp) Oracle OCIEnv Database **envhp; 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL OCISvcCtx **svchp; Introduction OCIError Part I - Oracle**errhp; and the XML Standards OCIServer **srvhp;XML Chapter 1 - Introducing OCISession **authp; Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX OCIStmt **stmthp; Chapter 3 - Transforming XML with XSLT and XPath { Chapter 4 - Validating XML with DTDs and XML Schemas sword status = 0; Chapter 5 - XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP

/* Environment initialization and creation */ - Putting It All Together with XML Pipeline, JSPs, and XSQL if (OCIEnvCreate((OCIEnv **) envhp, (ub4) OCI_OBJECT, (dvoid *) 0, Part II - Oracle XML Management for DBAs (dvoid * (*)(dvoid *,size_t)) 0, Chapter 8 - Getting Started with the Oracle XML Database (dvoid * (*)(dvoid *, dvoid *, size_t)) 0, Chapter 9 - Storing XML Data (void (*)(dvoid *, dvoid *)) 0, (size_t) 0, (dvoid **) 0)) Chapter 10 - Generating and Retrieving XML { Chapter 11 - Searching XMLOCIEnvCreate()\n"); Data printf("FAILED: Chapter 12 Managing the Oracle XML Database return OCI_ERROR; Part III Oracle XML for Java Developers } Chapter 13 - Gettingerror Started handle with Oracle /* allocate */XML and Java Chapter 14 Building an XML-Powered Web*envhp, Site if (OCIHandleAlloc((dvoid *) (dvoid **) errhp, Chapter 15 - Creating (ub4) a Portal OCI_HTYPE_ERROR, Site with XML and Web (size_t) Services0, (dvoid **) 0)) { Chapter 16 - Developing an XML Gateway Application with SOAP and AQ printf("FAILED: OCIHandleAlloc() on errhp\n"); Chapter 17 - Developing XML-Based Reusable Components return OCI_ERROR; Part IV - Oracle XML for C Developers } Chapter 18 - Getting Started with Oracle XML and C Chapter 7

Chapter 19 - Building an XML-Managed Application

/* allocate server handleOCI */Application Chapter 20 - Build an XML Database if (status = OCIHandleAlloc((dvoid *) *envhp, (dvoid **) srvhp, (ub4) OCI_HTYPE_SERVER, (size_t) 0, (dvoid **) 0)) Part V - Oracle XML for C++ Developers { Chapter 22 - Getting Started with Oracle XML and C++ printf("FAILED: OCIHandleAlloc() on srvhp\n"); Chapter 23 - Build an XML Database OCI C++ Application checkerr(*errhp, status); Chapter 24 - Building an XML Data-Retrieval Application return OCI_ERROR; Part VI - Oracle XML for PL/SQL Developers } Chapter 25 - Getting Started with Oracle XML and PL/SQL /* allocate service context handle */ Chapter 26 - Building PL/SQL Web Services if (status = OCIHandleAlloc((dvoid *) *envhp, (dvoid **) svchp, Chapter 27 - Extending PL/SQL XML Functionality with Java (ub4) OCI_HTYPE_SVCCTX, (size_t) 0, (dvoid **) 0)) Chapter 28 - Putting It All Together { Appendix - XML StandardsOCIHandleAlloc() Bodies and Open Specifications printf("FAILED: on svchp\n"); Glossary checkerr(*errhp, status); Indexreturn OCI_ERROR; List} of Figures allocate session handle */ List/* of Tables if (status = OCIHandleAlloc((dvoid *) *envhp, (dvoid **) authp, List of Sidebars (ub4) OCI_HTYPE_SESSION, (size_t) 0, (dvoid **) 0)) { printf("FAILED: OCIHandleAlloc() on authp\n"); checkerr(*errhp, status); return OCI_ERROR; } /* Allocate statement handle */ if (status = OCIHandleAlloc((dvoid *) *envhp, (dvoid **) stmthp, Chapter 21 - Create an XML-Configured High-Performance Transformation Engine


(ub4) OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0)) { printf("FAILED: OCIHandleAlloc() on stmthp\n"); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & checkerr(*errhp, status); PL/SQL return OCI_ERROR; ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang }

McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

return OCI_SUCCESS; emphasis on XML standards, their usage and best practices.

} /*----------------------Subfunctions ---------------------*/ Table of Contents /* Return corresponding messages in different cases-------*/ Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL /*--------------------------------------------------------*/ Introduction void checkerr(errhp, status) Part I - Oracle and the XML Standards OCIError *errhp; Chapter sword 1 - Introducing status; XML Chapter 2 Accessing XML with DOM, SAX, JAXB, and StAX { Chapter 3 -msgbuf[512]; Transforming XML with XSLT and XPath text Chapter Validating = XML sb4 4 -errcode 0;with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

Chapter memset((void 6 - XML Messaging *) msgbuf, and RPC(int)'\0', with SOAP (size_t)512); Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

(status) Partswitch II - Oracle XML Management for DBAs { 8 Chapter

- Getting Started with the Oracle XML Database

case break; Chapter 9 OCI_SUCCESS: - Storing XML Data case OCI_SUCCESS_WITH_INFO: Chapter 10 - Generating and Retrieving XML printf("status OCI_SUCCESS_WITH_INFO\n"); Chapter 11 - Searching XML=Data OCIErrorGet((dvoid *) errhp, (ub4) 1, (text *) NULL, &errcode, Chapter 12 - Managing the Oracle XML Database msgbuf, (ub4) sizeof(msgbuf), (ub4) OCI_HTYPE_ERROR); Part III - Oracle XML for Java Developers printf("ERROR CODE = %d\n", errcode); Chapter 13 - Getting Started with Oracle XML and Java printf("%.*s\n", 512, msgbuf); Chapter 14 - Building an XML-Powered Web Site if (errcode == 436 || errcode == 437 || errcode == 438 || Chapter 15 - Creating a Portal Site with XML and Web Services errcode == 439) exit(1); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ break; Chapter 17OCI_NEED_DATA: - Developing XML-Based Reusable Components case Part IVprintf("status - Oracle XML for C Developers = OCI_NEED_DATA\n"); Chapter 18 - Getting Started with Oracle XML and C break; Chapter 19OCI_NO_DATA: - Building an XML-Managed Application case Chapter printf("status 20 - Build an XML Database OCI Application = OCI_NO_DATA\n"); Chapter 21 Create an XML-Configured High-Performance Transformation Engine break; Partcase V - Oracle XML for C++ Developers OCI_ERROR: Chapter printf("status 22 - Getting Started = with OCI_ERROR\n"); Oracle XML and C++ *)OCI errhp, (ub4) 1, (text *) NULL, &errcode, Chapter OCIErrorGet((dvoid 23 - Build an XML Database C++ Application (ub4) sizeof(msgbuf), (ub4) OCI_HTYPE_ERROR); Chapter 24 - Buildingmsgbuf, an XML Data-Retrieval Application CODE Developers = %d\n", errcode); Part VI -printf("ERROR Oracle XML for PL/SQL 512, msgbuf); Chapter printf("%.*s\n", 25 - Getting Started with Oracle XML and PL/SQL if == 436 || errcode == 437 || errcode == 438 Chapter 26(errcode - Building PL/SQL Web Services errcodePL/SQL == 439) Chapter 27|| - Extending XML Functionality with Java exit(1); Chapter 28 - Putting It All Together break; Appendix - XML Standards Bodies and Open Specifications case OCI_INVALID_HANDLE: Glossary printf("status = OCI_INVALID_HANDLE\n"); Index break; List of Figures case OCI_STILL_EXECUTING: List of Tables printf("status = OCI_STILL_EXECUTE\n"); List of Sidebars break; case OCI_CONTINUE: printf("status = OCI_CONTINUE\n"); break; default: break; } return;


} /*--------------------------------------------------------*/ /* Free theOracle envhpDatabase whenever there is an error--------------*/ 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & /*--------------------------------------------------------*/ PL/SQL void cleanup(envhp) ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang OCIEnv *envhp; McGraw-Hill/Osborne © 2004 (600 pages) { This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with if (envhp)emphasis { on XML standards, their usage and best practices. OCIHandleFree((dvoid *)envhp, OCI_HTYPE_ENV); }

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

return;

Introduction

}

Part I - Oracle and the XML Standards

Chapter Introducing XML No part1of -this code is specific to an application, thus it can be pasted into your OCI applications without Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX modification. Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & RetrievingOracle a DOM of the Record List via OCI PL/SQL

ISBN:0072229527 by Markqueries V. Scardina, Ben Chang and Jinyu Wang Since the application a set of relational tables and then encapsulates the data returned in XML as dictated McGraw-Hill/Osborne © 2004 (600 pages) by the SQL/XML query, we don’t want to return the XML directly but rather return it as an XOB-based DOM so that it can be directly This accessed. However, first focuses you need connect to technologies the databasewithin as follows: comprehensive guide on to utilizing XML Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices. /*--------------------------------------------------------*/ /* Attach to server, set attributes, and begin session----*/ Table of Contents /*--------------------------------------------------------*/ Oracle sb4 connect_server(srvhp, Database 10g XML & SQL—Design, errhp, Buildsvchp, & Manage authp, XML Applications user, password) in Java, C, C++ & PL/SQL OCIServer *srvhp; Introduction OCIError Part I - Oracle*errhp; and the XML Standards OCISvcCtx *svchp; XML Chapter 1 - Introducing OCISession *authp; Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX text *user; Chapter 3 - Transforming XML with XSLT and XPath text *password; Chapter 4 - Validating XML with DTDs and XML Schemas { Chapter 5 - XML Operations with XQuery sword status = 0; Chapter 6 - XML Messaging and RPC with SOAP /* attach to server */ Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL if (status = OCIServerAttach((OCIServer *) srvhp, (OCIError *) errhp, Part II - Oracle XML Management for DBAs (text *) conn, (sb4) strlen(conn), (ub4) OCI_DEFAULT)) Chapter 8 - Getting Started with the Oracle XML Database { Chapter 9 - Storing XML Data printf("FAILED: OCIServerAttach() on srvhp\n"); Chapter 10 - Generating andstatus); Retrieving XML checkerr(errhp, Chapter 11 Searching XML Data return OCI_ERROR; Chapter 12 - Managing the Oracle XML Database } Part III - Oracle XML for Java Developers /* set server attribute to service context */ Chapter 13 Getting Started with Oracle XML *) and svchp, Java if (status = OCIAttrSet((dvoid (ub4) OCI_HTYPE_SVCCTX, Chapter 14 - Building an XML-Powered Web Site (dvoid *) srvhp, (ub4) 0, (ub4) OCI_ATTR_SERVER, Chapter 15 - Creating (OCIError a Portal Site *) with errhp)) XML and Web Services { Chapter 16 - Developing an XML Gateway Application with SOAP and AQ printf("FAILED: OCIAttrSet() svchp\n"); Chapter 17 - Developing XML-Based Reusableon Components checkerr(errhp, status); Part IV - Oracle XML for C Developers return OCI_ERROR; Chapter 18 - Getting Started with Oracle XML and C } Chapter 19 - Building an XML-Managed Application /* set attribute to OCI session */ Chapter 20 -user Build an XML Database Application if (status = OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION, Chapter 21 - Create an XML-Configured High-Performance Transformation Engine (dvoid *) user, (ub4) strlen((char *)user), Part V - Oracle XML for C++ Developers (ub4) OCI_ATTR_USERNAME, (OCIError *) errhp)) Chapter 22 - Getting Started with Oracle XML and C++ { Chapter 23 - Build an XML Database OCI C++ Application printf("FAILED: OCIAttrSet() on authp for user\n"); Chapter 24 - Building an XML Data-Retrieval Application checkerr(errhp, status); Part VI - Oracle XML for PL/SQL Developers return OCI_ERROR; Chapter 25 - Getting Started with Oracle XML and PL/SQL } Chapter 26 -password Building PL/SQL Web Services /* set attribute to session */ Chapter 27 Extending PL/SQL XML Functionality Java (ub4) OCI_HTYPE_SESSION, if (status = OCIAttrSet((dvoid *) with authp, Chapter 28 - Putting (dvoid It All Together *) password, (ub4) strlen((char *)password), Appendix - XML Standards and Open Specifications (ub4) Bodies OCI_ATTR_PASSWORD, (OCIError *) errhp)) Glossary { Indexprintf("FAILED: OCIAttrSet() on authp for password\n"); status); List ofcheckerr(errhp, Figures List ofreturn Tables OCI_ERROR; List} of Sidebars /* Begin a session */ if (status = OCISessionBegin((OCISvcCtx *) svchp, (OCIError *) errhp, (OCISession *) authp, (ub4) OCI_CRED_RDBMS, (ub4) OCI_DEFAULT)) { printf("FAILED: OCISessionBegin()\n"); checkerr(errhp, status); return OCI_ERROR;


} /* set session attribute to service context */ if (statusOracle = OCIAttrSet((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX, Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & (dvoid *) authp, (ub4) 0, (ub4) OCI_ATTR_SESSION, PL/SQL (OCIError *) Ben errhp)) ISBN:0072229527 by Mark V. Scardina, Chang and Jinyu Wang { McGraw-Hill/Osborne © 2004 (600 pages) printf("FAILED: OCIAttrSet() on svchp\n"); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with checkerr(errhp, status); emphasis on XML standards, their usage and best practices. return OCI_ERROR; } Table of Contents return OCI_SUCCESS; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL } Introduction

Part I - Oracle and the XML Standards

Chapter 1 - Introducing XML to the database and opening a session, you can submit the query that was passed in After successfully connecting Chapter 2 - Accessing XMLfollows: with DOM, SAX, JAXB, and StAX on the command line as Chapter 3 - Transforming XML with XSLT and XPath /*--------------------------------------------------------------*/ Chapter 4 - Validating with DTDs XMLtable Schemas /* select an xml XML column fromand the into an xmltype instance */ Chapter 5 - XML Operations with XQuery /*--------------------------------------------------------------*/ Chapter 6 - XML Messaging and RPC witherrhp, SOAP stmthp, row, selstmt, sb4 select_xml(envhp, svchp, Chapter xpathexpr, 7 - Putting It All value) Together with XML Pipeline, JSPs, and XSQL Part OCIEnv II - Oracle *envhp; XML Management for DBAs

OCISvcCtx *svchp; Chapter 8 - Getting Started with the Oracle XML Database OCIError *errhp; Chapter 9 - Storing XML Data OCIStmt Chapter 10 -*stmthp; Generating and Retrieving XML ub4 row; Chapter 11 - Searching XML Data text *selstmt; Chapter 12 - Managing the Oracle XML Database text Part III *xpathexpr; - Oracle XML for Java Developers text *value; { Chapter 14 - Building an XML-Powered Web Site ub4 colc = row; Chapter 15 - Creating a Portal Site with XML and Web Services ub4 xmlsize = 0; Chapter 16 - Developing an XML Gateway Application with SOAP and AQ sword status = 0; Chapter 17 - Developing XML-Based Reusable Components OCIDefine *defnp = (OCIDefine *) 0; Part IV - Oracle XML for C Developers OCIBind *bndhp = (OCIBind *) 0; Chapter 18 - Getting Started with Oracle XML*) and OCIXMLType *xml = (OCIXMLType 0;C Chapter 19 Building an XML-Managed Application OCIType *xmltdo = (OCIType *) 0; Chapter 20 -ind Build=anOCI_IND_NULL; XML Database OCI Application OCIInd Chapter 21 Create an High-Performance Transformation Engine OCIInd *xml_indXML-Configured = &ind; Chapter 13 - Getting Started with Oracle XML and Java

Part V - Oracle XML for C++ Developers

Chapter 22 - GettingSelecting Started with Oracle XMLby and C++ printf("\n=> row %d defining to an XMLType Chapter 23 - Build instance...\n", an XML Database OCI row); C++ Application Chapter 24 - Building an XML Data-Retrieval Application

the tdo the xmltype Part/* VI -get Oracle XML for for PL/SQL Developers

*/

if(status = OCITypeByName(envhp, errhp, Chapter 25 - Getting Started with Oracle XML and PL/SQL svchp, (const text *) SCHEMA, (ub4)PL/SQL strlen((char *)SCHEMA), (const text *) TYPE, Chapter 26 - Building Web Services (ub4) strlen((char *)TYPE), text *) 0, Chapter 27 - Extending PL/SQL XML Functionality with(CONST Java (ub4)It All 0, Together OCI_DURATION_SESSION, OCI_TYPEGET_HEADER, Chapter 28 - Putting (OCIType **) &xmltdo)) { - XML Standards Bodies and Open Specifications printf("FAILED: OCITypeByName()\n"); Glossary checkerr(errhp, status); Index return OCI_ERROR; List of Figures } List of Tables if(!xmltdo) List{ of Sidebars printf("NULL tdo returned\n"); return OCI_ERROR; } /* create a new xmltype instance */ if(status = OCIObjectNew((OCIEnv *)envhp, (OCIError *)errhp, (CONST OCISvcCtx *)svchp, (OCITypeCode) OCI_TYPECODE_OPAQUE, (OCIType *) xmltdo, (dvoid *) 0, (OCIDuration) OCI_DURATION_SESSION, FALSE, Appendix


(dvoid **) &xml)) { printf("FAILED: OCIObjectNew()\n"); checkerr(errhp, status); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & return OCI_ERROR; PL/SQL } ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang if(status McGraw-Hill/Osborne = OCIStmtPrepare(stmthp, errhp, (OraText *)selstmt, © 2004 (600 pages) (ub4)strlen((char *)selstmt), This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT)) { emphasis on XML standards, their usage and best practices. printf("FAILED: OCIStmtPrepare()\n"); checkerr(errhp, status); Table of Contents return OCI_ERROR; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL } Introduction /* define it to an xmltype instance */ Part I - Oracle and the XML Standards if(status = OCIDefineByPos(stmthp, &defnp, errhp, (ub4) 1, (dvoid *) 0, Chapter 1 -(sb4) Introducing XML 0, SQLT_NTY, (dvoid *) 0, (ub2 *)0, Chapter 2 -(ub2 Accessing XML with DOM, SAX, JAXB, and{ StAX *)0, (ub4) OCI_DEFAULT)) Chapter 3 - Transforming XML with XSLT and XPath printf("FAILED: OCIDefineByPos()\n"); Chapter 4 - Validating XMLstatus); with DTDs and XML Schemas checkerr(errhp, Chapter 5 - XML Operations with XQuery return OCI_ERROR; Chapter } 6 - XML Messaging and RPC with SOAP if(status = OCIDefineObject(defnp, errhp, (OCIType *) xmltdo, Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL (dvoid **) &xml,for &xmlsize, (dvoid **) &xml_ind, (ub4 *) 0)) { Part II - Oracle XML Management DBAs printf("FAILED: Chapter 8 - Getting StartedOCIDefineObject()\n"); with the Oracle XML Database checkerr(errhp, status); Chapter 9 - Storing XML Data return OCI_ERROR; Chapter 10 - Generating and Retrieving XML } Chapter 11 - Searching XML Data if(status = OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0, Chapter 12 - Managing the Oracle XML Database (CONST OCISnapshot*) 0, (OCISnapshot*) 0, (ub4) OCI_DEFAULT)) { Part III - Oracle XML for Java Developers printf("FAILED: OCIStmtExecute()\n"); Chapter 13 - Getting Started with Oracle XML and Java checkerr(errhp, status); Chapter 14 - Building an XML-Powered Web Site return OCI_ERROR; Chapter 15 - Creating a Portal Site with XML and Web Services } Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 17 - Developing XML-Based Reusable Components member called xml, populated with an XMLType XOB At this point you have an OCI context, the OCIXMLType Part IV - Oracle XML C Developers corresponding to thefor result set in XML format. However, it is not quite ready to be accessed, because you need to

Chapter - Getting Started and withperform Oracle XML andas C follows: initialize18one more context a cast Chapter 19 - Building an XML-Managed Application /*--------------------------------------------------------*/ Chapter 20 - Build anXML XMLcontext Database OCI /* Initialize andApplication call DOM APIs---------------*/ Chapter 21 Create an XML-Configured High-Performance Transformation Engine /*--------------------------------------------------------*/ Part - Oracle XML for C++ Developers sb4V do_xml(envhp, svchp, errhp,

xml, xpathexpr, value)

Chapter 22*envhp; - Getting Started with Oracle XML and C++ OCIEnv Chapter OCISvcCtx 23 - Build *svchp; an XML Database OCI C++ Application

OCIError *errhp; Chapter 24 - Building an XML Data-Retrieval Application OCIXMLType Part VI - Oracle *xml; XML for PL/SQL Developers text *xpathexpr; Chapter 25 - Getting Started with Oracle XML and PL/SQL text *value; Chapter 26 - Building PL/SQL Web Services { Chapter 27 - Extending PL/SQL XML Functionality with Java boolean resultIt All = 0; Chapter 28 - Putting Together OCIXMLType *newxml = (OCIXMLType *) 0; - XML Standards Bodies and Open Specifications OCIXMLType *xmltran = (OCIXMLType *) 0; Glossary sword status = 0; Index /* For XML DOM APIs */ List of Figures OCIStmt *stmthp = (OCIStmt *)0; List of Tables OCIDuration dur = OCI_DURATION_SESSION; Liststruct of Sidebars xmlctx *xctx = (xmlctx *)0; xmldocnode *doc = (xmldocnode *)0; ocixmldbparam params[1]; Appendix

/* Get an XML context */ params[0].name_ocixmldbparam = XCTXINIT_OCIDUR; params[0].value_ocixmldbparam = &dur; xctx = OCIXmlDbInitXmlCtx(envhp, svchp, errhp, params, 1);


/* cast the xmltype value to an xmldomctx */ doc = (xmldocnode *) xml; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

/* test PL/SQL xml unified C APIs */ if(update_xml((xmlctx *)xctx, doc, ISBN:0072229527 by Mark V. Scardina, Ben Chang andxpathexpr, Jinyu Wang value)) { printf("FAILED: update_xml()\n"); McGraw-Hill/Osborne © 2004 (600 pages) return This OCI_ERROR; comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with } emphasis on XML standards, their usage and best practices. /* free the statement handle */ if (stmthp) { Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL OCIHandleFree((dvoid *)stmthp, OCI_HTYPE_STMT); Introduction }

Table of Contents

Part I - Oracle and the XML Standards

Chapter 1 - Introducing XML */ /* free the xmlctx Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX OCIXmlDbFreeXmlCtx(xctx); Chapter 3

- Transforming XML with XSLT and XPath

Chapter - Validating XML with DTDs and XML Schemas /* 4free xml instances using OCIObjectFree */ Chapter 5 - XML&& Operations with XQuery if(newxml Chapter (status 6 - XML = Messaging OCIObjectFree(envhp, and RPC with SOAP errhp, (dvoid *) newxml, (ub2)

OCI_OBJECTFREE_FORCE))) Chapter 7 - Putting It All Together with{XML Pipeline, JSPs, and XSQL printf("FAILED: OCIObjectFree()\n"); Part II - Oracle XML Management for DBAs checkerr(errhp, Chapter 8 - Getting Startedstatus); with the Oracle XML Database return OCI_ERROR; Chapter 9 - Storing XML Data } Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

return OCI_SUCCESS; } Part III - Oracle XML for Java Developers

Chapter 12 - Managing the Oracle XML Database Chapter 13 - Getting Started with Oracle XML and Java

Note the pair of functions called OCIXmlDbInitXmlCtx() and OCIXmlDbFreeXmlCtx().These set up and free the

Chapter 14 - Building XML context that willanbeXML-Powered used by the Web DOMSite APIs. These are also only used when you are working with an XOB, as Chapter - Creating PortalAdditionally, Site with XML and is Web distinct15 from an XDKaDOM. there an Services important cast of xmlcontext to an xmldocnode, doc. This is Chapter 16 -to Developing Gateway Application SOAP and AQ for DOM access. equivalent providing an theXML XMLDocument from thewith parse operation Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Performing Unified DOM Operations PL/SQL

MarkDOM V. Scardina, Ben Chang andon Jinyu At this point thebyXML functions can operate theWang document node in exactly the same way as if it ISBN:0072229527 were parsed © 2004 pages) from a file. TheMcGraw-Hill/Osborne Xml* APIs are identical and(600 thus your code can be portable for the actual application logic you need to perform. In the update guide example, youon use both XmlDom* and XmlXPath* functions to find the products, node and with Thisfollowing comprehensive focuses utilizing XML technologies within Oracle's XML-enabled emphasis on XMLinstandards, their usage update it with the data passed on the command line:and best practices.

/*--------------------------------------------------------*/ Table of Contents /* Test XML unified C XML APIs----------------------------*/ Oracle /*--------------------------------------------------------*/ Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

sword update_xml(xctx, doc, xpathexpr, value) Introduction xmlctx *xctx; Part I - Oracle and the XML Standards xmldocnode *doc; XML Chapter 1 - Introducing OraText Chapter 2 -*xpathexpr; Accessing XML with DOM, SAX, JAXB, and StAX OraText Chapter 3 -*value; Transforming XML with XSLT and XPath { Chapter 4

- Validating XML with DTDs and XML Schemas

xpctx *xpathctx = (xpctx *) 0; - XML Operations with XQuery OraText *baseuri = (OraText *) 0; Chapter 6 - XML Messaging and RPC with SOAP ub2 ctxpos = 1; Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL ub2 ctxsize = 1; Part II - Oracle XML Management for DBAs xpexpr *exprtree = (xpexpr *) 0; Chapter 8 - Getting Started with the Oracle XML Database xpobj *xpathobj = (xpobj *) 0; Chapter 9 - Storing XML Data xmlerr xerr = (xmlerr)0; Chapter 10 - Generating and Retrieving boolean nodes_exists = 0; XML Chapter 11 Searching XML Data xmlnode *foo, *foobar; Chapter 5

Chapter 12 - Managing the Oracle XML Database Part/* III print - Oracle out XML for theJava xmlDevelopers doc before

updating it */

Chapter 13 - Getting Started with Oraclebefore XML and updating Java printf("\nThe xml instance with the unified APIs:\n"); Chapter 14 Building an XML-Powered Web Site XmlSaveDom(xctx, &xerr, (xmlnode *)doc, "stdio", stdout, NULL); Chapter 15 - Creating a Portal Site with XML and Web Services

/* create an XPath context Chapter 16 - Developing an XML Gateway*/ Application with SOAP and AQ xpathctx = XmlXPathCreateCtx(xctx, baseuri, (xmlnode *)doc, Chapter 17 - Developing XML-Based Reusable Components ctxsize); Part IV -ctxpos, Oracle XML for C Developers Chapter 18 - Getting Started with Oracle XML and C

/* parse XPath */ Chapter 19 - Building an expression XML-Managed Application exprtree = XmlXPathParse((xpctx *)xpathctx, (OraText *)xpathexpr, Chapter 20 - Build an XML Database OCI Application (xmlerr)&xerr);

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

/* evaluate XPath expression */ xpathobj = XmlXPathEval((xpctx *)xpathctx, (xpexpr *)exprtree, Chapter 23 - Build an XML Database OCI C++ Application (xmlerr *)&xerr); Chapter 22 - Getting Started with Oracle XML and C++

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

foobar = XmlXPathGetObjectNSetNode(xpathobj, 0); foo = XmlDomGetFirstChild(xctx, foobar); Chapter 26 - Building PL/SQL Web Services XmlDomSetNodeValue(xctx, foo, (oratext *)value); Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting Itxml All Together printf("\nThe instance after updating with the unified APIs:\n"); Appendix - XML Standards Bodies (xmlnode and Open Specifications XmlSaveDom(xctx, &xerr, *)doc, "stdio", stdout, NULL); Glossary Index return OCI_SUCCESS;

} of Figures List XML_ERRMSG_F(tkpgerr, ectx, msg, err) List of Tables { of Sidebars List if (err) { printf("Error: %d\n", (int)err); printf("%s\n", msg); } }


To demonstrate that the XML is actually updated, the function initially prints the XML document as it was received from the database query. It then must find the node that needs updating. This could be found by walking the DOM tree, but that can be tedious because it requires many linesBuild of code. Instead,XML you Applications can make useinofJava, XmlXpath Oracle Database 10g XML & SQL: Design, & Manage C, C++ & functions to have the search done for you. XmlXpathParse() converts the XPath string into an expression form, PL/SQL which can thenby beMark passed to XmlPathEval() actually the node. Now you can call ISBN:0072229527 V. Scardina, Ben Changtoand Jinyu find Wang XmlXPathGetObjectNSetNode() to©return thepages) node, traverse to the first child, which is the text node, and perform McGraw-Hill/Osborne 2004 (600 the update withThis XmlDomGetFirstChild() and XmlDomSetNodeValue(). comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

At this point you have an updated XOB and need to send it on its way. In update_xml(), the XmlSaveDom() function is called to send it to standard I/O. It just as easily could have been saved as a file or saved back to the Table of Contents database with another OCI SQL statement. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Running the xmlupdate Application PL/SQL

by Mark V.from Scardina, Ben Chang andpassing Jinyu Wang You can run xmlupdate the command line, in the specified parameters. You need to haveISBN:0072229527 Oracle © 2004 (600 pages) to a remote database, then you will need to set the service name Database 10g McGraw-Hill/Osborne up and running locally. If connecting of your DB instance to the connvariable. The following command line querieswithin the SH schema in the database for all This comprehensive guide focuses on utilizing XML technologies Oracle's XML-enabled products, with onprices XML standards, their usage practices. of the productsemphasis whose list are greater than 1000and andbest returns the result as an XML document. It also queries that XML document for the item whose ProductID is 17 and updates its price to 999.99. Table of Contents xmlupdate "select XMLELEMENT("ProductList", XMLAGG(XMLELEMENT( Oracle Database "Product", 10g XMLXMLATTRIBUTES(PROD_ID & SQL—Design, Build & Manage AS XML "ProductID"), Applications in Java, C, C++ & PL/SQL

XMLELEMENT("Name", PROD_NAME), XMLELEMENT("Price", Introduction PROD_LIST_PRICE)))) Part I - Oracle and the XML Standards AS

result from products

PROD_LIST_PRICE>1000" Chapter 1 where - Introducing XML Chapter 2 "//Product[@ProductID=17]/Price/text()" - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 "999.99" - Transforming XML with XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

The preceding SQL/XML query constructs a single XML document containing multiple products by first specifying - XML Operations with XQuery the root XML element <ProductList> and then using the XMLAGG() function to aggregate the set of products Chapter 6 - XML Messaging and RPC with SOAP meeting the query constraint. The following is the resulting XML document retrieved as a XOB before it is updated. Chapter 7 price - Putting It All Together withitem. XML Pipeline, JSPs, and XSQL Note the of 1099.99 for the first Chapter 5

Part II - Oracle XML Management for DBAs

<ProductList> - Getting Started with the Oracle XML Database <Product ProductID="17"> Chapter 9 - Storing XML Data <Name>Mini DV Camcorder with 3.5" Swivel LCD</Name> Chapter 10 - Generating and Retrieving XML <Price>1099.99</Price> Chapter 11 - Searching XML Data </Product> Chapter 12 - Managing the Oracle XML Database <Product ProductID=18> Part III Oracle XML for Java Developers <Name>Envoy Ambassador</Name> Chapter 13 Getting Started with Oracle XML and Java <Price>1299.99</Price> Chapter 14 Building an XML-Powered Web Site </Product> Chapter 15 - Creating a Portal Site with XML and Web Services </ProductList> Chapter 8

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

ThisIVnext XML XML document is the same as the preceding one except the first item’s price has been updated to be Part - Oracle for C Developers 999.99.18 - Getting Started with Oracle XML and C Chapter <ProductList> Chapter 19 - Building an XML-Managed Application <Product ProductID="17"> Chapter 20 - Build an XML Database OCI Application <Name>Mini Camcorder High-Performance with 3.5"Transformation Swivel LCD</Name> Chapter 21 - Create anDV XML-Configured Engine Part V <Price>999.99</Price> - Oracle XML for C++ Developers

</Product> Chapter 22 - Getting Started with Oracle XML and C++ <Product ProductID=18> <Name>Envoy Ambassador</Name> Chapter 24 - Building an XML Data-Retrieval Application <Price>1299.99</Price> Part VI - Oracle XML for PL/SQL Developers </Product> Chapter 25 - Getting Started with Oracle XML and PL/SQL </ProductList> Chapter 23 - Build an XML Database OCI C++ Application

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending XMLresults Functionality with Java This application simplyPL/SQL prints the to the screen. The XMLSaveDOM() function performing this can also be Chapter - Putting It All Together used to28 write the results to a file or stream. Alternatively, the XOB can be saved back to the database using Appendix - XML Standards Bodies and Open Specifications standard OCI statement binding. Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 Scardina, Ben Chang and Jinyu In this chapter by youMark haveV.built an OCI XML application byWang using the new unified XML APIs that are available in Oracle 2004 This (600 pages) Database 10g McGraw-Hill/Osborne by way of the Oracle ©XDK. functionality has not been available in the past and answers a real need when operating close to largeguide datasets where serializing data only to reparse it before working products, on it This comprehensive focuses on utilizing XMLthis technologies within Oracle's XML-enabled with emphasis on standards, their usage and bestinterfaces practices.also enable an OCI application developer to produces an application thatXML doesn’t scale or perform. These work natively with XMLTypes, thereby utilizing the full flexibility and power of the Oracle XML DB and XMLTypes.

Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 21:Database Create an XML-Configured High-Performance PL/SQL ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang Transformation Engine McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide utilizingto XML technologies Oracle'stoXML-enabled products, with Transforming XML documents from one focuses markupon language another or fromwithin one schema another is the emphasis on XML standards, their usage and best practices. responsibility of an XSLT processor. This process can be expensive in terms of time and memory even with the high-performance C and Java processors that are included in Oracle XDK 10g. This expense is largely due to the Table of Contents complexity and reiterative nature of the XSLT process. Therefore, to improve performance further, Oracle took an Oracle Database 10g XML SQL—Design, Build XDK & Manage XML Applications in XSLT Java, C, C++machine & PL/SQL(XSLTVM). In this alternative approach and& created the Oracle 10g XSLT Compiler and virtual Introduction chapter we show you how you can put these to use for an application that requires dynamic selection of an XSLT Part stylesheet I - Oracle and and thethe fastest, XML Standards most efficient transformation. This will be done by creating a high-performance transformation engine that Chapter 1 - Introducing XMLis XML-configured to apply precompiled stylesheets. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

- Transforming XML with XSLT and XPath Designing the Framework

Chapter 3 Chapter 4

- Validating XML with DTDs and XML Schemas

To create XSLT transformation, we must first examine the individual steps that go into the XSLT Chapter 5 -high-performance XML Operations with XQuery process6 and thenMessaging see which steps optimized, combined, or even eliminated. For example, if you have a Chapter - XML and RPCcan withbe SOAP records.xml input XML to be transformed by a publish.xsl XSLT stylesheet into a report.htmloutput file, you Chapter 7 - Putting It All file Together with XML Pipeline, JSPs, and XSQL need perform theManagement following functional steps: Part II to - Oracle XML for DBAs Chapter 1. Parse 8 - Getting records.xml Startedinto withathe DOM. Oracle XML Database Chapter 9

- Storing XML Data

2. Parsepublish.xslinto an XSLT stylesheet object.

Chapter 10 - Generating and Retrieving XML

Chapter 11 - Searching Data from the stylesheet object to the input DOM to create an XSLT result object. 3. Apply the XSLTXML templates Chapter 12 - Managing the Oracle XML Database Part Serialize III - Oracle the result XMLobject for Java to report.html. Developers

Chapter 13 - Getting Started with Oracle XML and Java

One way to optimize run-time performance is to introduce precompilation wherever possible. Although the input XML documents are not known ahead of time, the XSLT stylesheets usually are; however, standard XSLT processors do Chapter 15 - Creating a Portal Site with XML and Web Services not serialize out nor read in their object formats. There is an XSLT compiler in Oracle XDK 10g that effectively does Chapter 16 - Developing an XML Gateway Application with SOAP and AQ exactly this. Only instead of creating a serializable object, it creates XSLT byte code that can be understood by a Chapter 17 - Developing XML-Based Reusable Components purpose-built XSLT virtual machine. The advantage of this approach is that it can optimize Step 3 because it Part IV - Oracle XML for C Developers translates XSLT templates and functions into ready-to-execute byte-code instructions. Finally, Step 4 is usually not a Chapter 18 - Getting Started with Oracle XML and C bottleneck and, in fact, is very fast in the case of the VM, which is written in C. Chapter 14 - Building an XML-Powered Web Site

Chapter 19 - Building an XML-Managed Application

Chapter A question 20 - remains Build an as XML toDatabase how these OCI compiled Application stylesheets become associated with the input XML files if there is

more than to choose from. XML files that require XSLT transformation usually include a stylesheet processing Chapter 21 -one Create an XML-Configured High-Performance Transformation Engine instruction (PI)XML in their prolog: Part V - Oracle for C++ Developers Chapter - Getting Started with Oracle XML and C++ <?xml 22 version="1.0"?> Chapter 23 - Build an XML Database OCI C++ Application <?xml-stylesheet type="text/xsl" href="publish.xsl"?> Chapter 24 - Building an XML Data-Retrieval Application

Since is a reference to the Developers stylesheet file and not the compiled version, you must create a mapping of one to the Part VI this - Oracle XML for PL/SQL other. For engine, you do this with XML an XSLT mapping file of the following form: Chapter 25 -this Getting Started with Oracle and PL/SQL <?xml 26 version "1.0"?> Chapter - Building=PL/SQL Web Services <xslmap> Chapter 27 - Extending PL/SQL XML Functionality with Java <xsl Chapter 28xsb="booklist.xsb">booklist.xsl</xsl> - Putting It All Together <xsl xsb="cdlist.xsb">cdlist.xsl</xsl> Appendix - XML Standards Bodies and Open Specifications <xsl xsb="dvdlist.xsb">dvdlist.xsl</xsl> Glossary </xslmap>

Index

List of Figures List Tablesthis xslmap.xml file on startup, the engine can create a mapping table so that when it gets the By of parsing List of Sidebars stylesheet PI from the input document, it knows what compiled stylesheet to load into the VM.

To implement this engine, you will create two command-line applications. The first, xslcompile, creates the compiled XSLT stylesheets and adds a corresponding entry in the map file. The second, xsbtransform,applies the stylesheets to the input XML file to create the output file.


Database 10gwith XML &xslcompile SQL: Design, Build & Manage XML Applications in Java, C, C++ & CompilingOracle Stylesheets PL/SQL

ISBN:0072229527 by Mark V. Scardina, Chang Jinyu Wang Because the Oracle XSLT CompilerBen resides in and oraxml10.lib on Windows NT and libxml10.a, it can be used either McGraw-Hill/Osborne 2004 (600 pages)application. Using the compiler from within an application as a stand-alone application or from©within another requires these This steps: comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

1. Create an instance of the XDK context using XmlCreate().

an instance of the XSLT compiler using XmlXvmCreateComp(). Table2.of Create Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Compile the XSLT file using XmlXvmCompileFile().

Introduction

Part I - Oracle and can the XML Standards At this point, you either pass the compiled stylesheet to the VM or, as you will do in this application, write it to a

Chapter - Introducing file. The1 following is the XML code for xslcompile: Chapter 2

XML with DOM, SAX, JAXB, and StAX #include- Accessing <stdio.h> Chapter 3 - Transforming #include <stdarg.h>XML with XSLT and XPath Chapter 4 Validating XML with DTDs and XML Schemas #include <string.h> Chapter 5

- XML Operations with XQuery

Chapter 6 -XML_ORACLE XML Messaging and RPC with SOAP #ifndef Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL # include <xml.h> Part II - Oracle XML Management for DBAs #endif

Chapter 8

- Getting Started with the Oracle XML Database

/* Deposit xsb XML andData insert into the map file function */ Chapter 9 - Storing void depositxsb(char *fileargv, Chapter 10 - Generating and Retrieving XML ub2 *code, ub4 len, char *filemap) { Chapter 11 - Searching XML Data char filename[200], *name; Chapter 12 - Managing the Oracle XML Database char *input, *inputxsl; Part III - Oracle XML for Java Developers FILE *xsb; Started with Oracle XML and Java Chapter 13 - Getting xmlctx *ctx; Chapter 14 - Building an XML-Powered Web Site xmlerr *ecode; Chapter 15 - Creating a Portal Site with XML and Web Services xmltextnode *textnode; Chapter 16 - Developing an XML Gateway Application with SOAP and AQ xmlattrnode *attr1; Chapter 17 - Developing XML-Based Reusable Components xmldocnode *doc; Part IV - Oracle XML for C Developers xmlelemnode *node, *elem; Chapter 18 - Getting Started with Oracle XML and C

Chapter 19 - Building an *)strtok(fileargv, XML-Managed Application "."); name = (char Chapter 20 - Build an XML Database OCI Application strcpy(filename, name); Chapter 21 - Create an XML-Configured High-Performance Transformation Engine strcat(filename, ".xsb"); Part V xsb - Oracle XML for C++ Developers = fopen(filename, "w");

Chapter 22 - Getting Started with Oracle C++ fwrite((void *)code, len,XML 1, and xsb); Chapter 23 - Build an XML Database OCI C++ Application fclose(xsb); Chapter 24 - Building an XML Data-Retrieval Application Part/* VI -Assuming Oracle XMLthe for PL/SQL XML declaration Developers

and root node already exist

* in mapStarted file. with xml map file Chapter 25 -the Getting withInit Oracleand XML deal and PL/SQL */ 26 - Building PL/SQL Web Services Chapter if = XmlCreate(ecode, (oratext Chapter 27(!(ctx - Extending PL/SQL XML Functionality with Java *)"xml_context", NULL))) { 28 - Putting It All Together Chapter Appendix

toand initialize XML parser, error \n"); -printf("Failed XML Standards Bodies Open Specifications

} Glossary Index

if (!(doc=XmlLoadDom(ctx, ecode, filemap, NULL))) { List of Tables printf("Parse failed, code %d\n", (int) ecode); List of Sidebars } List of Figures

/* Get root element */ node = XmlDomGetDocElem(ctx, doc); /* Create the element, add data, create the attribute */ if (!(elem = XmlDomCreateElem(ctx, doc, (oratext *)"xsl"))) {


printf("Element creation failed\n"); } if (!(textnode = XmlDomCreateText(ctx, doc, (oratext *)inputxsl)) || Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & !XmlDomAppendChild(ctx, elem, textnode)) PL/SQL { ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang printf("Text node creation failed\n"); McGraw-Hill/Osborne © 2004 (600 pages) } This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with if (!(attr1 = XmlDomCreateAttr(ctx, doc, emphasis on XML standards, their usage and (oratext*)"xsb", best practices. (oratext*)input))) { Table of Contents printf("Attribute creation failed\n"); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL } Introduction if (!XmlDomSetAttrNode(ctx, elem, attr1)) Part I - Oracle and the XML Standards { Chapter printf("Attribute 1 - Introducing XML setting failed\n"); Chapter } 2 - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4 - Validating XML with DTDs /* insert the element */ and XML Schemas Chapter 5 - XML Operations with XQuery (xmlnode *)node, (xmlnode *)elem)) if (!XmlDomAppendChild(ctx, Chapter { 6 - XML Messaging and RPC with SOAP

towith root failed \n"); Chapter printf("Appending 7 - Putting It All Together XMLelement Pipeline, JSPs, and XSQL Part}II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

XmlFreeDocument(ctx, Chapter 9 - Storing XML Data doc); Chapter 10 - Generating and Retrieving XML

} Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

Thedepositxsb()function performs three supporting tasks. First, it creates the file to which the compiled stylesheet will be saved. Second, it updates the xslmap.xmlfile with an entry for the compiled stylesheet and associates it with Chapter 13 - Getting Started with Oracle XML and Java the actual stylesheet that will be in the input XML document PI. Finally, it cleans up after itself before returning to the Chapter 14 - Building XML-Powered Web Site main function, whichan follows: Part III - Oracle XML for Java Developers

Chapter 15 - Creating a Portal Site with XML and Web Services

/* ==================================================================== main Chapter 17 - Developing XML-Based Reusable Components –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/ Part IV - Oracle XML for C Developers int main (sword argc, char *argv[]) Chapter 18 - Getting Started with Oracle XML and C { Chapter 19 - Building an*xctx XML-Managed Application xmlctx = NULL; Chapter 20 Build an XML Database OCI xmlxvmcomp *comp = NULL;Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine xmlerr err; Part V ub2 - Oracle XML for *code; C++ Developers Chapter 22 - Getting Started with Oracle XML and C++ ub4 len; Chapter oratext 23 - Build an XML *xslFile; Database OCI C++ Application Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 24 - Building an XML Data-Retrieval Application

(argc < for 2)PL/SQL { Part VIif - Oracle XML Developers is: xslcompile <input xsl>\n"); Chapter 25 -printf("Usage Getting Started with Oracle XML and PL/SQL -1; Chapter 26 -return Building PL/SQL Web Services } 27 - Extending PL/SQL XML Functionality with Java Chapter xslFile = (oratext*)argv[1]; Chapter 28 - Putting It All Together xctx- XML = XmlCreate(&err, (oratext *) "sample", Standards Bodies and Open Specifications "data_encoding", "US-ASCII", NULL); Glossary if (!xctx) { Index printf("Failed to create xctx: %d\n",err); List of Figures goto terminate; List of Tables } List of Sidebars comp = XmlXvmCreateComp (xctx); if (!comp) { printf("Failed to create Compiler."); goto terminate; } Appendix

code = XmlXvmCompileFile (comp, xslFile, NULL, 0, &err); if (err != XMLERR_OK) { printf("Failed to Compile:%u\n", err);


goto terminate; } len = XmlXvmGetBytecodeLength(code, &err); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

/* Deposit inV.xsb */ Ben Chang and Jinyu Wang by Mark Scardina, depositxsb(argv[1], code, len, argv[2]); McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

terminate: emphasis on XML standards, their usage and best practices. /* clean the memory */ if (comp) Table of Contents XmlXvmDestroyComp(comp); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL if (xctx) Introduction XmlDestroy(xctx); Part I - Oracle and the XML Standards return 0; Chapter 1 - Introducing XML } Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

The preceding is the main routine in the It first initializes the XML context, xctx, which is the necessary first Chapter 4 - Validating XML with DTDs andprogram. XML Schemas step for5all- CXML XDK applications. compile stylesheets, you must first initialize the XSLT compiler, which is done Chapter Operations with To XQuery usingXmlXvmCreateComp() in your XML context. Now you can compile by calling Chapter 6 - XML Messaging andand RPCpassing with SOAP XmlXvmCompileFile() passing the stylesheet file. and NoteXSQL that this function supports passing in a file path Chapter 7 - Putting It All and Together withinXML Pipeline, JSPs, and/or URI in Management order to locate stylesheet. For this example, since the file is local, the base URI in not used. Part II - base Oracle XML forthe DBAs Chapter 8

- Getting Started with the Oracle XML Database

Once you have the compiled stylesheet, all that is left is to get its length, since it is a binary file, and pass it to Chapter 9 - Storing XML Data depositxsb() along with the map filename to have it saved and to have the map file updated. Chapter 10 - Generating and Retrieving XML

Chapter Oncexslcompile 11 - Searching is compiled XML Data and linked, you can execute it with the following command line and any supported

XSLT file: Chapter 12 - Managing the Oracle XML Database Part III - Oracle bookcatalog.xsl XML for Java Developers xslcompile xslmap.xml

Chapter 13 - Getting Started with Oracle XML and Java

Note that Oraclean XSLT Compiler supports Chapter 14 the - Building XML-Powered Web Site only XSLT 1.0 and XPath 1.0 in the Oracle XDK 10g release and thus the stylesheets mustabe limited thisXML version. Chapter 15 - Creating Portal Sitetowith and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Running the XSLT Virtual Machine with xsbtransform PL/SQL

by Mark Ben Chang and Jinyu Wang Now that you have oneV.orScardina, more stylesheets and their associated compiled XSB files, you can use them ISBN:0072229527 in your © 2004 (600 pages) how xsbtransform works. applications, asMcGraw-Hill/Osborne shown in this section as we discuss This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

To use this resource from application, must perform the practices. following steps: emphasis onan XML standards,you their usage and best 1. Create an instance of the XDK context using XmlCreate(). Table of Contents

2. Create a parser to read the map file using XMLLoadSax().

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction 3. Parse the map file for its entries using SAX callbacks. Part I - Oracle and the XML Standards

4. Create a parser to read the input XML file using XmlLoadDom(). Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

5. Retrieve the stylesheet PI to get the filename using XmlDomGet*().

Chapter 4 - Validating with to DTDs and XML Schemas 6. Match the XSLXML filename its XSB filename. Chapter 5

- XML Operations with XQuery

7. Create the XSLT virtual machine Chapter 6 - XML Messaging and RPC with using SOAP XmlXvmCreate(). Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

8. Perform the transformation by passing in the input XML and XSB file using XmlXvmSetBytecodeFile() and XmlXvmTransformFile().

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter - Storing XML Data Get the9DOM and output the result of the transformation using XmlXvmGetOutputDom() and XmlSaveDom(). Chapter 10 - Generating and Retrieving XML

The following code forXML xsbtransform implements these steps: Chapter 11 - Searching Data Chapter #include 12 - Managing <stdio.h> the Oracle XML Database Part #include III - Oracle <stdlib.h> XML for Java Developers

#include <stdlib.h> Chapter 13 - Getting Started with Oracle XML and Java #include <string.h> Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

#ifndef Chapter 16 -XML_ORACLE Developing an XML Gateway Application with SOAP and AQ #include <xml.h> XML-Based Reusable Components Chapter 17 - Developing #endif Part IV - Oracle XML for C Developers Chapter 18 - Getting Started with Oracle XML and C

/* Obtains XSL compiled code filename */ oratext *getXSBFileName (xmlctx *xctx, xmldocnode *doc, Chapter 20 - Build an XML Database OCI Application oratext *xslmapfile) Chapter 21 - Create an XML-Configured High-Performance Transformation Engine { Part V - Oracle XML for C++ Developers oratext *p, *filename; Chapter 22 - Getting Started with Oracle XML and C++ static oratext input[100]; Chapter 19 - Building an XML-Managed Application

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an *stpinode, XML Data-Retrieval Application xmlpinode *pinode; Part VI - Oracle XML for *stnode; PL/SQL Developers xmlnode

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services filename = (oratext *)malloc(200); Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter /* 28 Get - Putting firstIt All PI Together */

pinode = (xmlpinode *)XmlDomGetFirstChild(xctx, (xmlnode *)doc); Appendix - XML Standards Bodies and Open Specifications /* Get stylesheet PI */ Glossary Indexstpinode = (xmlpinode *)XmlDomGetNextSibling(xctx,

(xmlnode *)pinode); List of Figures Get href node as last child */ List of/* Tables stnode = XmlDomGetLastChild(xctx, (xmlnode *)stpinode); /* Get attribute value, which is the filename */ filename = XmlDomGetAttrValue(xctx, (xmlattrnode *)stnode);

List of Sidebars

p = (oratext*)strtok((char*)filename, "."); strcpy((char*)input, (char*)p); strcat((char*)input, ".xsb"); return input;


} The support function getXSBFileName() receives the input XML file DOM and walks the DOM tree using Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XMLDomGetFirstChild(), XMLDomGetNextSibling(), and XmlDomGetLastChild() to retrieve the stylesheet PI PL/SQL and then calls XmlDomGetAttrValue() to retrieve the stylesheet attribute. Finally, it tokenizes the string ISBN:0072229527 to retrieve by Mark V. Scardina, Ben Chang and Jinyu Wang the filename, less its extension, and returns the compiled stylesheet by appending its extension as follows: McGraw-Hill/Osborne © 2004 (600 pages)

/* ================================================================ This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with maintheir usage and best practices. emphasis on XML standards, –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/ int main (sword argc, char *argv[]) Table of Contents { Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL xmlctx *xctx = NULL; Introduction xmlxvm *vm = NULL; Part I - Oracle and the XML Standards xmlerr err; Chapter 1 - Introducing XML oratext *xmlFile, *outFile, *xslmapFile, *codeFile; Chapter 2 - Accessing XML with *odoc; DOM, SAX, JAXB, and StAX xmldocnode *doc, Chapter 3 - Transforming XML with XSLT and XPath xmlfragnode *root; Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 (argc - XML Operations if < 3) { with XQuery Chapter 6 Chapter 7

-printf("Usage XML Messaging and RPCxsbtransform with SOAP is: <xmlfile> <outputfile> - Putting <xslmap It All file>\n"); Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle return XML Management 0; for DBAs

}8 Chapter

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

xmlFile = (oratext *)argv[1]; Chapter 10 - Generating and Retrieving XML outFile = (oratext Chapter 11 - Searching XML Data*)argv[2]; xslmapFile (oratext *)argv[3]; Chapter 12 - Managing=the Oracle XML Database Part III - Oracle XML for Java Developers

/* Get the xsl compiled code */

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

/* Creates the context */ xctx = XmlCreate(&err, (oratext *) "sample", Chapter 16 - Developing an XML Gateway Application with SOAP and AQ "data_encoding", "US-ASCII", NULL); Chapter 17 - Developing XML-Based Reusable Components if (!xctx) { Part IV - Oracle XML for C Developers printf("Failed to create xctx: %d\n", err); Chapter 18 -goto Getting Started with Oracle XML and C terminate; Chapter 19 Building an XML-Managed Application } Chapter 20 Build an XML Database OCI Application if (!(doc=XmlLoadDom(xctx, &err, xmlFile, NULL))) Chapter 21 Create an XML-Configured High-Performance Transformation Engine { Part V - Oracle XML for C++ Developers printf("Parse failed, code %d\n", (int) err); Chapter } 22 - Getting Started with Oracle XML and C++ Chapter codeFile 23 - Build an = getXSBFileName(xctx, XML Database OCI C++ Application doc, xslmapFile); Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 24 - Building an XML Data-Retrieval Application

Creates the VM */ Part VI/* - Oracle XML for PL/SQL Developers vm XmlXvmCreate (xctx, NULL); Chapter 25=- Getting Started with Oracle XML and PL/SQL if { PL/SQL Web Services Chapter 26(!vm) - Building to Functionality create VM"); Chapter 27 -printf("Failed Extending PL/SQL XML with Java Chapter 28 -goto Puttingterminate; It All Together

}

Appendix

- XML Standards Bodies and Open Specifications

Glossary

/* Create the output document node */ odoc = XmlCreateDocument(xctx, NULL, NULL, NULL, &err); List of Figures err = XmlXvmSetOutputDom(vm, odoc); Index

List of Tables

List of Sidebars err = XmlXvmSetBytecodeFile(vm, codeFile);

if (err != XMLERR_OK) { printf("Failed to set the bytecode: %u\n", err); goto terminate; } err = XmlXvmTransformDom (vm, doc); if (err != XMLERR_OK) { printf("Failed to transform: %u\n", err);


goto terminate; } Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

/* Get PL/SQL DOM of transformed XML file and write into output file */ root = by XmlXvmGetOutputDom(vm); Mark V. Scardina, Ben Chang and Jinyu Wang XmlSaveDom(xctx, &err, ©root, "outFile", NULL); McGraw-Hill/Osborne 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

terminate: emphasis on XML standards, their usage and best practices. /* clean the memory */ if (vm) Table of Contents XmlXvmDestroy(vm); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL if (xctx) Introduction XmlDestroy(xctx); Part I - Oracle and the XML Standards

Chapter 1 - Introducing XML return 0; Chapter 2 }

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Once again, the main XML function where the application work is performed. After the XML context is initialized Chapter 4 - Validating with is DTDs andmost XML of Schemas byXmlCreate(), input XML fileXQuery is parsed into a DOM with XmlLoadDom(). At this point you need to retrieve the Chapter 5 - XMLthe Operations with stylesheet therefore youand callRPC the with custom getXSBFileName()function, which returns the compiled stylesheet Chapter 6 -PI, XML Messaging SOAP name to Chapter 7 use. - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

The next step initializes the XSLT virtual machine with XmlXvmCreate()and sets it up by setting the output root with - Getting Started with the Oracle XML Database XmlCreateDocument() and the output DOM with XmlXvmSetOutputDom(). Finally, the initialization is completed Chapter 9 - Storing XML Data by setting the compiled stylesheet with XmlXvmSetBytecodeFile(). Chapter 8

Chapter 10 - Generating and Retrieving XML

Chapter At this point 11 - Searching the XSL transformation XML Data can take place by calling XmlXvmTransformDom()and passing in the DOM of

the input doc. Youthe now can XML get the output document’s DOM by calling XmlXvmGetOutputDom() and print it to Chapter 12file, - Managing Oracle Database a file with XmlSaveDom(). output method is quite flexible because it can also print to a URI, buffer, stream, or Part III - Oracle XML for JavaThis Developers STDIO.13 You can also specify “pretty printing,” setting the number of spaces to indent, specifying the output Chapter - Getting Started with Oracle XML andbyJava encoding use, andanchoosing whether toSite print the XML declaration. Chapter 14 to - Building XML-Powered Web Chapter 15 - Creating a Portal Site with XML and Web Services

It is now time to run the program. Make sure that the XML, XSB, and map files are local if specified without paths and then run this example command line:

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

xsbtransform booklist.xml bookcatalog.html xslmap.xml

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Scardina, in Ben Chang Jinyu Wang In this chapter by weMark haveV.discussed detail the and Oracle XDK 10g XSLT Compiler and XSLTVM. We have ISBN:0072229527 also showed © 2004 (600 pages) you how to useMcGraw-Hill/Osborne them to create one of the fastest software XSLT engines available when the stylesheets can be compiled in advance. You also realized of the memory footprintswithin during XSLT transformation. In this with This comprehensive guide one focuses on smallest utilizing XML technologies Oracle's XML-enabled products, emphasis onthese XML standards, their usage reside and best particular implementation, compiled stylesheets onpractices. your file system, but you could just as readily create an implementation in which they are retrieved from a database or URL. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Part V: Oracle Oracle XML for C++ Developers PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Chapter List

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Chapter 22: Getting Started with Oracle XML and C++

Table of Contents

OracleChapter Database XML SQL—Design, Manage XML Applications in Java, C, C++ & PL/SQL 23:10g Build an&XML DatabaseBuild OCI &C++ Application Introduction

XML Data-Retrieval Application Part IChapter - Oracle 24: andBuilding the XMLan Standards Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 22:Database Getting Started with Oracle XML and C++ PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Oracle Database 10g includes in its default installation the Oracle XDK 10g C++ libraries and utilities. These provide McGraw-Hill/Osborne © 2004 (600 pages) portable XML functionality that permits you to easily develop stand-alone or database XML-enabled applications. In comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with this chapter weThis describe the various libraries and utilities, set up both the compile-time and run-time environments, emphasis on XML standards, their usage and best practices. and cover the basics of the configuration that is necessary to connect to the Oracle database. Table of Contents

The Oracle XDK C++ Libraries

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction The Oracle XDK C++ components are built upon the C components and contain the same functionality for reading, Part I - Oracle and the XML Standards manipulating, transforming, and validating XML documents. In addition, a class generator is available for

Chapter 1 - Introducing XML constructing XML documents. The Oracle XDK C++ components reside in the same libraries as the C components. Chapter 2 - Accessing XMLinwith DOM, SAX, JAXB, and These libraries all reside ORACLE_HOME\lib andStAX in XDK_HOME/libif installed from the OTN distribution. Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas libxml10.a, libxml10.so, and libxml10.dl - XML Operations with XQuery

Chapter 5

Chapter 6 - releases XML Messaging and RPC In previous the C and C++with XMLSOAP components have been in multiple libraries. In Oracle XDK 10g, these Chapter 7 - Putting It All consolidated Together withinto XMLaPipeline, JSPs, and XSQL components have been single libxml10.a library on UNIX and an oraxml10.dll library on Part II - Oracle XML Management for DBAs Windows.

Chapter 8

- Getting Started with the Oracle XML Database

Withinlibxml10.a theData following XML components: Chapter 9 - Storingare XML Chapter 10 - Generating and Retrieving XML

XML parser Checks whether an XML document is well-formed and, optionally, validates it against a DTD or XML schema. The parser constructs an object tree that can be accessed via a DOM interface or operate serially Chapter - Managing the Oracle XML Database via12 a SAX interface. Chapter 11 - Searching XML Data

Part III - Oracle XML for Java Developers

Chapter XSLT 13 -processor Getting Started Provides with the Oracle functionality XML and Java to transform an XML document according to an XSLT stylesheet

and14is-bundled the parser. Web Site Chapter Building with an XML-Powered Chapter 15 - Creating a Portal Site with XML and Web Services

XSLT Compiler Compiles XSLT stylesheets into byte code for use by the XSLT Virtual Machine.

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 17 - Developing XML-BasedXSLT Reusable Components XSLTVM High-performance transformation engine that accepts compiled XSLT stylesheets for faster Part IV - Oracle XML forless C Developers processing using memory.

Chapter 18 - Getting Started with Oracle XML and C

XML Supports parsing and validating XML files against an XML Schema Definition (XSD) Chapter 19 Schema - Buildingprocessor an XML-Managed Application file.20 - Build an XML Database OCI Application Chapter Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

XML Class Generator Creates a set of C++ source files based on an input DTD or XML Schema. These classes can then be used to construct XML documents conforming to the DTD or XML schema.

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23of - the Build an XML Databaseresides OCI C++ Application While all XML functionality in this library, it does depend on an additional library to provide run-time Chapter - Building an XML Application support24 and an optional thirdData-Retrieval library to provide globalization support as described in the following section. Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

libcore10.a, libcoresh10.so, and libcore10.dll

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending PL/SQL XML Functionality with Java The C common run-time functions that permit Oracle code to be portable across platforms are contained in Chapter 28 - Putting It All libcore10.a on UNIX andTogether libcore10.dllon Windows. An additional library that is new in Oracle Database 10g, Appendix libcoresh10.so, - XML Standards supports dynamic Bodies and linking Openon Specifications the UNIX platforms. Even though these are C libraries, they are used

for C++ applications and need to be linked in. Glossary Index

libnls10.a and oranls10.dll

List of Figures List of Tables

One the advantages of the Oracle C++ XML implementation over others resides in its extensive List of of Sidebars internationalization support. Support for the UTF-8, UTF-16, and ISO-8859-1 character sets is provided in libnls10.a on UNIX and oranls10.dll on Windows. These libraries also depend on the environment to find their encoding and message files. The environment setup will be covered in a later section.

libunls10.a and oraunls10.dll When you need support for other character sets, you also need to use libunls10.aon UNIX and oraunls10.dll on Windows. Generally, these character sets can be classified as Asian, European, or Middle Eastern language


character sets. Because over 300 character sets are supported, we are not listing them here, but you can find them in Appendix A of the Oracle Data Globalizatio n Support Guide 10g. As with the previous libraries, these also depend on the environment to Database find their encoding message files. Oracle 10g XMLand & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Setting Up Your C++ 10g XML Development Environment PL/SQL

ISBN:0072229527 Mark V. Scardina, Ben Chang Jinyu Wang Database 10g installation, there are several While much of by your environment is already set and up by an Oracle steps McGraw-Hill/Osborne © 2004 pages) to both compile and run your Oracle C++ XML-enabled that are platform-specific that you need to (600 performed applications. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

Note that in later sections the XDK directory is referred to as $XDK_HOME on UNIX or %XDK_HOME% on Windows and that the Oracle Home is referred to as $ORACLE_HOME on UNIX or %ORACLE_HOME% on Table of Contents Windows. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

UNIX Setup of XDK C++ Components

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

In order to successfully run your UNIX C++ XML application, you need to set several environment variables for the - Accessing XML with DOM, SAX, JAXB, and StAX various components so that the components can find their support files, and you need to establish the run-time Chapter 3 - Transforming XML with XSLT and XPath configuration. Chapter 2 Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 - XML Operations with XQuery ORA_NLS10 Chapter 6

- XML Messaging and RPC with SOAP

Chapter The environment 7 - Puttingvariable It All Together ORA_NLS10 with XML is set Pipeline, to point JSPs, to the andlocation XSQL of the NLS character-encoding definition files. If Part youII have - Oracle installed XML Oracle Management Database for DBAs 10g, then you can set it as follows:

Chapter 8 ORA_NLS10 - Getting Started with the Oracle XML Database setenv $ORACLE_HOME/nls/data Chapter 9

- Storing XML Data

If you don’t have an Oracle database XML installed, you can use the NLS character encoding definition files which come Chapter 10 - Generating and Retrieving with the11OTN Oracle XDK as follows: Chapter - Searching XML release Data Chapter setenv 12 -ORA_NLS10 Managing the$XDK_HOME/nls/data Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

Note XDK-included encodingWeb filesSite contain a subset of the character sets that are in the Oracle database Chapter 14 The - Building an XML-Powered release. While it contains only 34 character-encoding files, they are the most common ones.

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

ORA_XML_MESG

Chapter 17 - Developing XML-Based Reusable Components Part - Oracle XML for C Developers TheIV environment variable ORA_XML_MESG is set to point to the location of the XML error message files. These

Chapter - Getting with Oracle XML and C ending in .msb are machine-readable and needed at runtime; files are18provided inStarted the xdk/mesg/ directory. Files Chapter 19 - Building Application files ending in .msg an areXML-Managed human-readable and include cause and action descriptions for each error. For Oracle Chapter 20 installations, - Build an XML Database OCI Application database these message files exist in the $ORACLE_HOME/xdk/mesg directory and no environment Chapter variable21is -necessary. Create an XML-Configured If an Oracle database High-Performance is not installed, Transformation you shouldEngine set the environment variable, Part ORA_XML_MESG, V - Oracle XML for toC++ pointDevelopers to the absolute path of the xdk/mesg/directory:

Chapter 22ORA_XML_MESG - Getting Started $XDK_HOME/xdk/mesg with Oracle XML and C++ setenv Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

Checking Your C++ Run-Time Environment

Part VI - Oracle XML for PL/SQL Developers

Chapter - Getting Started with Oracle XML andinPL/SQL Several25ready-to-run XML utilities are included Oracle XDK 10g. These make it easy for you to confirm that your Chapter 26environment - Building PL/SQL Web Services run-time is properly configured. They all reside in $ORACLE_HOME/bin for Oracle database Chapter 27 - Extending PL/SQL XML Functionality with Java installations and $XDK_HOME/bin for OTN XDK installations. The following sections describe these XML utilities Chapter 28 -their Putting It All Together along with command-line options. Appendix

- XML Standards Bodies and Open Specifications

xml Glossary Index

There is no command-line C++ XML parser utility; however, the C XML parser may be called as an executable by invokingxml from your $ORACLE_HOME/bin or $XDK_HOME/bin as follows:

List of Figures List of Tables

xml List ofoptions Sidebars URI The following is the list of options: –c Perform conformance check only, no validation –eencoding Specify default input file encoding (“incoding”) –Eencoding Specify DOM/SAX encoding (“outcoding”)


–f Interpret as filespec, not as URI –llanguage Specify language forXML error&reporting Oracle Database 10g SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

–n Perform DOM traversal and report number of elements by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne –p Print document after parsing©it2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML standards, their usage and best practices. –v Displayemphasis parser version then exit

–w Preserve all whitespace

Table of Contents

Oracle–W Database 10g XML & SQL—Design, Stop parsing after a warning Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Exercise interface and print document Part I–x - Oracle andSAX the XML Standards Chapter 1

xsl 2 Chapter Chapter 3

- Introducing XML - Accessing XML with DOM, SAX, JAXB, and StAX - Transforming XML with XSLT and XPath

There is no command-line C++ XSLT processor; however, the C XSLT processor may be called as an executable by - Validating XML with DTDs and XML Schemas invokingxsl from your $ORACLE_HOME/bin or $XDK_HOME/bin as follows:

Chapter 4 Chapter 5

- XML Operations with XQuery

xsloptions URI - XML Messaging and RPC with SOAP

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

The following is the list of options:

Chapter 8

- Getting Started with the Oracle XML Database

Chapter -f Interpret 9 - Storing as filespec, XML Datanot URI Chapter 10 - Generating and Retrieving XML

-h Show usage help and full list of flags

Chapter 11 - Searching XML Data

Chapter - Managing theofOracle Database -in12 Specify number times XML to iterate the XSLT processing Part III - Oracle XML for Java Developers

Chapter -llanguage 13 - Getting Specify Started language with Oracle for error XML reporting and Java Chapter 14 - Building an XML-Powered Web Site

-oXSLoutfile Specify output file of XSLT processor

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 not - Developing an XML Gateway Application with SOAP and AQ -r Do ignore <xsl:output> instruction in XSLT processing Chapter 17 - Developing XML-Based Reusable Components Part IV -sstylesheet - Oracle XML Specify for C Developers the XSL stylesheet

Chapter 18 - Getting Started with Oracle XML and C

-v Display XSLT processor version then exit

Chapter 19 - Building an XML-Managed Application

Chapter 20 value - BuildTest an XML Database OCI Application -Vvar top-level variables in C XSLT Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part schema V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

There is no command-line C++ schema validator; however, the C XML Schema Validator may be called as an executable by invoking bin/schema, which takes two arguments: the XML instance document and a default schema Chapter 24 - Building an XML Data-Retrieval Application to apply: Chapter 23 - Build an XML Database OCI C++ Application Part VI - Oracle XML for PL/SQL Developers

schema options Chapter 25 - Gettingdocument Started withschema Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

The following is the list of options:

Chapter 28 - Putting It All Together

Appendix - XML Standards Bodies and Open Specifications -0 Always exit with code 0 (success) Glossary Index -eencoding Specify default input file encoding (“incoding”) List of Figures

-Eencoding Specify output/data/presentation encoding (“outcoding”)

List of Tables

List of-iSidebars Ignore provided schema file

-onum Specify validation options -p Print instance document to stdout on success -u Force the Unicode code path -v Display version then exit


xmlcg The stand-alone C++ XML Class Generator may be called as an executable by invoking xmlcg from your Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & $ORACLE_HOME/bin or $XDK_HOME/bin. The following is the command line with its syntax and options: PL/SQL xmlcg <inputBen file> by [flags] Mark V. Scardina, Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

The following are the option flags and their their descriptions: emphasis on XML standards, usage and best practices.

-dname Generate name.cpp and name.h when there is an external DTD Table of Contents

directory10g Display directoryBuild for generated is current directory) Oracle-oDatabase XML &output SQL—Design, & Manage files XML (default Applications in Java, C, C++ & PL/SQL Introduction

-eencoding Specifydefault input file encoding

Part I - Oracle and the XML Standards

Chapter - Introducing -h 1Show this usageXML help Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

-sname Generate name.cpp when input is an XML schema; Chapter 3 - Transforming XML with and XSLTname.h and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

-v Show the Class Generator version

Chapter 6 -Up XMLYour Messaging RPC with SOAP Environment Setting C++and Compile-Time Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management DBAsthe run-time environment set up and you need to have the header files for To compile your code, you need for to have

Chapter the components 8 - Getting that Started you are with using. the Oracle TheseXML header Database files reside in the xdk/include directory in either installation.

Refer to9 Chapter 18XML for aData description of the C header files. The following is a listing of the C++ files and their Chapter - Storing corresponding description: Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

oraxml.hpp Includes all the Oracle9i XML ORA data types and all the public ORA APIs in libxml. This is for backward compatibility only.

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Startedthe with XML Java oraxmlcg.h Includes C Oracle APIs for theand C++ class generator. Chapter 14 - Building an XML-Powered Web Site

oraxsd.hpp Includes theSite Oracle9i XSD validator data types and APIs. This is for backward compatibility only. Chapter 15 - Creating a Portal with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

xml.hpp Is the header to handle the Unified DOM APIs transparently, whether using OCI or standalone.

Chapter 17 - Developing XML-Based Reusable Components

Part IV - Oracle XML for C Developers xmlotn.hpp Includes all the common APIs, whether you are compiling standalone or using OCI and the Unified

Chapter 18 - Getting Started with Oracle XML and C DOM. Chapter 19 - Building an XML-Managed Application

xmlctx.hpp all the initialization and exception-handling public APIs. Chapter 20 - Build Includes an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Confirming Your C++ Compile-Time Environment

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

You can confirm your setup by compiling the demo programs, by using makefilein the

Chapter 23 - Build an XML Database OCI C++ Application $XDK_HOME/xdk/demo/cpp directory of the OTN release or in the $ORACLE_HOME/xdk/demo/cpp directory if Chapter 24 installed - Buildingthe anOracle XML Data-Retrieval Application you have Database 10g Companion CD in $ORACLE_HOME. Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Windows Setup of XDK C++ Components

Chapter 26 - Building PL/SQL Web Services

Chapter Extending PL/SQL XMLWindows Functionality In order27to-successfully run your C++ with XMLJava application, you need to set several environment variables for Chapter 28 - Putting It All Together the various components so that the components can find their support files, and you need to establish the run-time Appendix - XML Standards Bodies and Open Specifications configuration. Glossary Index ORA_NLS10 List of Figures

Theofenvironment variable ORA_NLS10 is set to point to the location of the NLS character-encoding definition files. If List Tables you have installed Oracle Database 10g, then you can set it as follows:

List of Sidebars

set ORA_NLS10 %ORACLE_HOME%\nls\data

If you don’t have an Oracle database installed, you can use the NLS character-encoding definition files that come with the OTN Oracle XDK release as follows: set ORA_NLS10 %XDK_HOME%\nls\data


Note The XDK-included encoding files contain a subset of the character sets that are in the Oracle database release. While it contains only 34 character-encoding files, they are the most common ones.

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ORA_XML_MESG by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600is pages) The environment variable ORA_XML_MESG set to point to the location of the XML error message files. These Thisincomprehensive focuses on ending utilizingin XML technologies within Oracle's XML-enabled products, with files are provided the xdk\mesg\guide directory. Files .msb are machine-readable and needed at runtime; emphasis on XML standards, their usage and best practices. files ending in .msg are human-readable and include cause and action descriptions for each error. For Oracle database installations, these message files exist in the $ORACLE_HOME\xdk\mesg directory and no environment Table of Contents variable is necessary. If an Oracle database is not installed, you should set the environment variable, Oracle ORA_XML_MESG, Database 10g XML to point & SQL—Design, to the absolute Buildpath & Manage of the xdk\mesg\ XML Applications directory: in Java, C, C++ & PL/SQL Introduction set ORA_XML_MESG %XDK_HOME%\xdk\mesg Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Checking Your C++ Run-Time Environment - Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 2

Chapter - Transforming withare XSLT and XPath Several3 ready-to-run XMLXML utilities included in Oracle XDK 10g. They make it easy for you to confirm that your Chapter 4 environment - Validating XML with DTDs and XMLThey Schemas run-time is properly configured. all reside in %ORACLE_HOME%\bin for Oracle database Chapter 5 - XML with XQueryfor OTN XDK installations. The following sections describe these XML utilities. installations and Operations %XDK_HOME%\bin Chapter 6 - XML Messaging SOAP Their command-line optionsand areRPC the with same as in the previous UNIX section. Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

xml.exe

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

There is9 no command-line C++ XML parser utility; however, the C XML parser may be called as an executable by Chapter - Storing XML Data invoking xml.exe from your %ORACLE_HOME%/bin or %XDK_HOME%/bin as follows: Chapter 10 - Generating and Retrieving XML xml.exe URI Chapter 11options - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

xsl.exe Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

There is no command-line C++ XSLT processor; however, the C XSLT processor may be called as an executable by invokingxsl.exe from your %ORACLE_HOME%/bin or %XDK_HOME%/bin as follows:

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

xsl.exeoptions URI

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

schema.exe

Chapter 19 - Building an XML-Managed Application Chapter - Build an XML Database OCIhowever, Application There is20no command-line C++ XML; the Schema Validator may be called as an executable by invoking Chapter 21 - Create an XML-Configured High-Performance Transformation Engine schema.exe from your %ORACLE_HOME%/bin or %XDK_HOME%/bin, which takes two arguments: the XML Part V - Oracle XML for C++ Developers instance document and, optionally, a default schema to apply:

Chapter 22 - Getting Started with Oracle XML and C++

schema.exeoptions document schema

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL xmlcg.exe Chapter 26 - Building PL/SQL Web Services

The stand-alone C++ PL/SQL XML class maywith be called Chapter 27 - Extending XMLgenerator Functionality Java as an executable by invoking xmlcg.exe from your %ORACLE_HOME%/bin or %XDK_HOME%/bin. The following is the command line with its syntax and options: Chapter 28 - Putting It All Together Appendix xmlcg.exe - XML Standards Bodies <input and Openfile> Specifications [flags] Glossary Index

Setting Up Your C++ Compile-Time Environment

List of Figures

List Tables your code, you need to have the run-time environment set up and you need to have the header files for To of compile List Sidebars theofcomponents that you are using. These header files reside in the xdk\include directory in either installation.

These are the same files as described in the previous UNIX section.

Confirming Your C++ Compile-Time Environment You can confirm your setup by compiling the demo programs, by using makefile.batin the %XDK_HOME%\xdk\demo\newdirectory of the OTN release only or in the %ORACLE_HOME%\xdk\demo\cpp\new directory if you have installed the Oracle Database 10g Companion CD in$ORACLE_HOME.


The make file assumes you are using cl.exe for compiling and link.exe for linking andthat you have both in your PATH. You also have to edit the make.bat file to provide the paths to theheader files as well as the corresponding .libfiles locatedOracle in %ORACLE_HOME%\lib %XDK_HOME%\lib. Database 10g XML &orSQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang Setting Up Microsoft Visual C/C++ McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

comprehensive guide focusesisondone utilizing XML technologies Oracle's XML-enabled products, Since much of This the Windows C++ development using Microsoft Visualwithin C/C++, we will show you how to set with up emphasis their usagein and best practices. a project and its settingson forXML the standards, applications covered later chapters. These instructions can also be used for the demos that are included in Oracle XDK 10g. These instructions assume Microsoft Visual C/C++ version 6.0a or Table compatible. of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Creating a New Project Introduction Part I - Oracle and the XML Standards

Projects need to be attached to workspaces; therefore, if you don’t already have one that you would like to use, you - Introducing XML will need to create a blank workspace. You do so by choosing File | New | Workspaces and entering a name, after Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX which the OK button is activated, and clicking it gives you a new workspace. Chapter 1 Chapter 3

- Transforming XML with XSLT and XPath

Chapter - Validating XML with DTDs andorXML Schemas To add4a project to this new workspace to an existing one, you need to select File | New | Projects, at which point Chapter - XML Operations with XQuery you will5see the screen in Figure 22-1. For the applications in this book as well as the Oracle XDK 10g demos, you Chapter need to6click - XML Win32 Messaging Console and Application RPC with SOAP and enter the name of your project. In Figure 22-1 the name of the project

is “CPPXMLApp”. Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Note This name will be used for your executable unless you specify an alternate debug executable under the - Getting Started with the Oracle XML Database Project Settings | Link | General category.

Chapter 8 Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

Figure 22-1: New projects window

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

Once click XML OK, for youPL/SQL will be asked what kind of console application you wish to create. You can simply select an Part VI you - Oracle Developers empty project and click Finish. willXML add and yourPL/SQL new project to your workspace in the FileView pane. Chapter 25 - Getting Started withThis Oracle Chapter 26 - Building PL/SQL Web Services

Configuring Your Project

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 -have Putting It All Together Once you a project you can then configure its settings. This is done by right-clicking the project name, Appendix - XML Standards and Open in Specifications selecting Settings and thenBodies clicking C/C++ the Project Settings window that appears. There are numerous Glossary settings here but, as you can see in Figure 22-2, you can keep them in their default configuration with or without Index Debug optimizations. List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1 - Introducing XML Figure 22-2: Project Settings: C/C++ window Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter At this point 3 - Transforming you can set up XML your with link XSLT configuration and XPath using another tab in the Project Settings window. Click the Link

tab and4you will see the window shown inXML Figure 22-3. Enter “oraxml10.lib” in the Object/Libraries Modules text box Chapter - Validating XML with DTDs and Schemas to add it line automatically, Chapter 5 to- your XML link Operations with XQueryas shown here. Note, at runtime you will need the oraxml10.dll, oracore10.dll, oranls10.dll to with be inSOAP your PATH for the objects to be found. You can now click OK and begin Chapter 6 - XMLand Messaging and RPC populating source files and header files Pipeline, folders. JSPs, and XSQL Chapter 7 -the Putting It All Together with XML Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Figure 22-3: Project Settings: Link window

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 Scardina, Changthe and Jinyuof Wang In this chapter,by weMark haveV.walked youBen through basics configuring and setting up your XDK C++ development © 2004and (600 then pages)confirming proper setup. You will use this environment in the environment forMcGraw-Hill/Osborne either UNIX or Windows following chapters, in which we willguide showfocuses you how build real XML-enabled covering aproducts, range of with This comprehensive onto utilizing XMLC++ technologies withinapplications Oracle's XML-enabled emphasis on XML standards, their usage and best practices. solution scenarios.

Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 23:Database Build10gan XML Database OCI C++ Application PL/SQL

Overview

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Many C++ applications emphasisrequire on XMLdirect standards, access their to database usage anddata, best practices. typically because they are designed to work with large data sets or to retrieve and update data frequently. While Oracle offers PL/SQL as an in the database programming language, many applications need the flexibility and functionality of C++ or need to offload program Table of Contents logic from the database. This is where building your C++ application using the Oracle C++ Call Interface (OCCI) Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL libraries can be a real value. However, unlike the Oracle Call Interface (OCI) for C, OCCI has not had XMLType Introduction support added. Generally, this means that C++ programs must use C code and thus OCI. However, as you will Part I - Oracle and the XML Standards discover in this chapter, you can use the Oracle XDK C++ components with some C++ wrappers of OCI code to Chapter 1 - Introducing XML enable C++ XMLType support. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 - Transforming XMLhave withhad XSLTtoand XPaththe output from a query and reparse using DOM or SAX APIs on C++ applications that would serialize Chapter 4 in - Validating XML with DTDs XMLneed Schemas the client order to process XML no and longer to do so because they can take advantage of a DOM within the Chapter database 5 as - XML an XMLType. Operations Thus, with XQuery when the data sets become large, especially when using the DOM APIs, you’ll be

able to 6preserve memory resources because Chapter - XML Messaging and RPC with SOAPyou no longer need to materialize the entire data set on the client in order to7 access andItmodify or update Chapter - Putting All Together with it. XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Oracle Database 10g with the inclusion of Oracle XDK 10g now offers XMLType support to C++ applications through - Getting Started with the Oracle XML Database a set of new APIs located in the xml*.hppheader files. The reason these APIs are not included in the OCCI header Chapter 9 - Storing XML Data files is that they are the same APIs that can be used for stand-alone XDK applications. Chapter 8

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & DesigningOracle the Database Framework PL/SQL

ISBN:0072229527 byall Mark Scardina,applications Ben Chang and Jinyu Wang The premise for C++V.database is that they need to connect to Oracle databases and retrieve, insert, 2004 (600may pages) or update data.McGraw-Hill/Osborne In the case of XML,©this data be stored in XML format or generated from relational tables. While Oracle Database 10g provides an guide OCCI focuses library to types of applications, OCCIXML-enabled cannot be used for anwith This comprehensive onsupport utilizingthese XML technologies within Oracle's products, emphasis XML standards, their usage and best practices.in Chapter 20) is not available. For this XML application becauseoncurrently the unified DOM support (discussed example application, you will use special C++ classes that call OCI functions to generate an XMLType from a SQL/XML query over relational tables from the SALES sample schema. However, instead of simply returning a Table of Contents serialized stream ofXML the data that would Build need &toManage be reparsed, you will return an XMLType called an XOB (XML Oracle Database 10g & SQL—Design, XML Applications in Java, C, C++ &DOM PL/SQL object) that can be accessed directly through the new C++ XML APIs. You will then query the XOB with an XPath Introduction and serialize it for consumption or display. You can also save it back to the database. Part I - Oracle and the XML Standards

Chapter 1

XML The steps -toIntroducing create such an application are as follows:

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

1. Initialize the OCI environment from C++ and create a connection.

Chapter 4 - Validating XML with DTDs and XML Schemas 2. Initialize the OCIXMLDB and XDK contexts to operate on an XOB. Chapter 5

- XML Operations with XQuery

3. Log toMessaging the database the SQL/XML query. Chapter 6 - on XML and and RPC submit with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

4. Cast the result to an xmldocnode to prepare it for DOM operations.

Part II - Oracle XML Management for DBAs

Chapter 8 - Getting Started with the Oracle XML Database 5. Perform DOM operations with the XML* APIs. Chapter 9

- Storing XML Data

6. Serialize the DOM save back to the database with a C++ class calling OCI. Chapter 10 - Generating andorRetrieving XML Chapter 11 - Searching XML Data

These steps are used in the following specific example, which creates a command-line selectxpq application that can accept as parameters the SQL/XML query and the XPath to evaluate and print the result. The Part III - Oracle XML for Java Developers following is an example selectxpq command line: Chapter 12 - Managing the Oracle XML Database

Chapter 13 - Getting Started with Oracle XML and Java

selectxpq 'select xmlelement("Exec", xmlattributes(s.ENAME "Name"), xmlforest(s.JOB as "Job", s.SAL as "Salary")) from EMP s where Chapter 15 - Creating a Portal Site with XML and Web Services s.SAL>3000;" /Exec/Job" Chapter 14 - Building an XML-Powered Web Site

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 17 - Developing XML-Based Reusable Components The SQL/XML query returns this XML document using the sample schema: Part IV - Oracle XML for C Developers

<Exec Name=”KING”> <Job>PRESIDENT</Job> Chapter 19 - Building an XML-Managed Application <Salary>5000</Salary> Chapter 20 - Build an XML Database OCI Application </Exec> Chapter 18 - Getting Started with Oracle XML and C

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part - Oracle XML C++ evaluation Developersresult: TheVfollowing is thefor XPath

Chapter 22 - Getting Started with Oracle XML and C++ <Job>PRESIDENT</Job> Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle 10g XML XML & SQL: Design, BuildEnvironment & Manage XML Applications in Java, C, C++ & Setting Up theDatabase C++ OCI Application PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang To build C++ XML database applications, you need to set up the necessary headers and libraries and make files. McGraw-Hill/Osborne 2004 (600 pages) Fortunately, you already have these©items if you have installed the companion CD and specified as your destination directory $ORACLE_HOME on Unix or %ORACLE_HOME% ontechnologies Windows. You willOracle's be usingXML-enabled both the OCI and XDK This comprehensive guide focuses on utilizing XML within products, with on XML You standards, usagethe andOCCI best practices. header files foremphasis this application. will nottheir be using header files.

The OCI XML Application Headers

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

The headers in Oracle Database 10g are installed into your Oracle Home when you perform the initial companion Introduction CD Iinstallation. Once you have done this, you will have two directories that include the necessary header files: Part - Oracle and the XML Standards $ORACLE_HOME/rdbms/demo and $ORACLE_HOME/xdk/ include on Unix, and Chapter 1 - Introducing XML %ORACLE_HOME%/rdbms/demo %ORACLE_HOME%/xdk/include on Windows. The following is the Chapter 2 - Accessing XML with DOM,and SAX, JAXB, and StAX application file that listswith theXSLT required Chapter 3 - header Transforming XML and Oracle XPath headers along with the application functions: #ifndef STDIO XML with DTDs and XML Schemas Chapter 4 - Validating #include <stdio.h> Chapter 5 - XML Operations with XQuery #endif Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

#ifndef STDLIB Part II - Oracle XML Management for DBAs #include <stdlib.h> Chapter 8 - Getting Started with the Oracle XML Database #endif - Storing XML Data

Chapter 9

Chapter 10 - Generating and Retrieving XML

#ifndef STRING #include <string.h> Chapter 12 - Managing the Oracle XML Database #endif Chapter 11 - Searching XML Data

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

extern "C" {

Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers #ifndef OCIAP_ORACLE

Chapter 18 - Getting Started with Oracle XML and C #include <ociap.h> Chapter #endif 19 - Building an XML-Managed Application

} Chapter 20 - Build an XML Database OCI Application extern { an XML-Configured High-Performance Transformation Engine Chapter 21 -"C" Create #ifndef XML_ORACLE Part V - Oracle XML for C++ Developers #include <xml.h> Chapter 22 - Getting Started with Oracle XML and C++ #endif Chapter 23 - Build an XML Database OCI C++ Application } Chapter 24 - Building an XML Data-Retrieval Application #ifndef XMLCTX_CPP_ORACLE Part VI - Oracle XML for PL/SQL Developers #include <xmlctx.hpp> #endif

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

/* constants */ #define MAXBUFLEN 2000 Appendix - XML Standards Bodies and Open Specifications #define SCHEMA "SYS" Glossary #define TYPE "XMLTYPE" Chapter 28 - Putting It All Together

Index List/* of Figures classes */ List of Tables Listclass of Sidebars ociapi {

public: /* constructors and destructors */ ociapi(); ~ociapi(); /* member functions */ sb4 init_env_handle();


sb4 connect_server( text* user, text* password); void disconnect_server( boolean tab_exists); void cleanup(); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

sb4 select_and_query(text* select_stmt, by Mark V. Scardina, Ben Chang and Jinyutext* Wang xpathexp); sb4 select_from_doc( OCIXMLType* xml, text *xpathexpr); McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

/* get member functions for private variables */ emphasis on XML standards, their usage and best practices. OCIEnv* getEnv() const; Table of Contents

private: /* OCI Handles and Variables */ Introduction OCIEnv *envhp; Part I - Oracle and the XML Standards OCIServer *srvhp; Chapter 1 - Introducing OCISvcCtx *svchp; XML Chapter 2 Accessing XML with DOM, SAX, JAXB, and StAX OCIError *errhp; Chapter 3 - Transforming OCISession *authp; XML with XSLT and XPath Chapter 4 -*stmthp; Validating XML with DTDs and XML Schemas OCIStmt Chapter 5 - XML Operations with XQuery };

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter 6

- XML Messaging and RPC with SOAP

/* functions Chapter 7 - Putting */ It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

void 8checkerr( OCIError* sword status); Chapter - Getting Started with theerrhp, Oracle XML Database Chapter 9

- Storing XML Data

/* generic functions */ Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

template< typename TCtx, typename Tnode> sb4 doXPath( TCtx* ctxp, DocumentRef< Tnode>& doc_ref, Part III - Oracle XML for Java Developers char* xpath_exp); Chapter 13 - Getting Started with Oracle XML and Java /*----------------- End of Functions Declaration -----------------*/ Chapter 12 - Managing the Oracle XML Database

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an note XML Gateway with SOAP and AQ In examining this file, first that thereApplication are two Oracle C header files, xml.hand ociap.h. These contain the C Chapter 17 -and Developing XML-Based Reusable XML APIs OCI APIs, respectively. The Components xmlctx.hppfile is the header file for the constructor class for OCI XML Part IV - Oracle XML for C Developers initialization. We discuss the functions when we get to the code throughout the chapter.

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

The OCI and C++ XML Application Libraries

Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Createare andynamically XML-Configured High-Performance Engine OCI applications linked on both Unix andTransformation Windows using libclntsh.so,located in Part V - Oracle XML for C++ $ORACLE_HOME/lib32 onDevelopers Unix, and oci.libplus ociw32.lib,located in %ORACLE_HOME%\ oci\lib\Msvc on

Chapter 22 -InGetting Started with Oracle C++ Windows. the past the Solaris libraryXML hasand been in the libdirectory, but since Oracle Database 10g is now only a Chapter 64-bit release, 23 - Build thean32-bit XML Database libraries are OCIlocated C++ Application in their own directory. On Windows you also need to link with the

user32.lib, kernel32.lib, msvcrt.lib, advapi32.lib, oldnames.lib, and winmm.libWindows libraries. Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

The OCI libraries do not contain the XML APIs; therefore, you also need to link with libxml10.aon Unix and oraxml10.libon Windows, which include both the C and C++ XML APIs. The Unix library is not a shared one like Chapter 26 - Building PL/SQL Web Services the OCI library and thus the objects you need will be pulled into your executable. Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Creating the C++ OCI10g Helper Class PL/SQL

byAPIs Markfrom V. Scardina, Ben Chang andaJinyu Wang context. In the case of a midtier or client ISBN:0072229527 To use the XML C++, you must create compatible application, 2004 (600 you do this withMcGraw-Hill/Osborne the built-in xmlinit()©method inpages) the XMLParserclass. However, in the case of working with the database, you This needcomprehensive to call a method to initialize theutilizing OCI context along with the XMLOracle's context.XML-enabled At the sameproducts, time, youwith guide focuses on XML technologies within emphasis on XML standards,and their usageyour and query best practices. need to establish a database connection submit in order to return the DOM of the XMLType you are interested in. You do all of this with the ociapiclass specified in the previous header file, which has the following member functions: Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

init_env_handle()Creates and initializes and the OCI environment

Introduction

Part Iconnect_server() - Oracle and the XML Standards Creates a database connection and passes in the user ID and password

Chapter 1

- Introducing XML

disconnect_server() from the server, ending the session Chapter 2 - Accessing XML Disconnects with DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

cleanup()Cleans up the OCI environment

Chapter 5 - XML Operations with XQuery select_and_query() Submits the SQL/XML statement and returns the DOM of the Chapter 6

- XML Messaging and RPC with SOAP

XMLType while calling out to theXML DOM APIs toJSPs, do the Chapter 7 -result Putting It All Together with Pipeline, andXPath XSQL query Part II - Oracle XML Management for DBAs

query_xmlApi() Performs C++ XPath operations on XMLType and prints the result

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 - Storing XMLexamine Data The following sections the actual source code for the ociapiclass implementation, broken down by its Chapter 10functions. - Generating and Retrieving XML member Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & InitializingOracle theDatabase C++ Database XML Application PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Changapplication and Jinyu Wang The first step when creating a C++ database is to perform all of the necessary OCI initializations and McGraw-Hill/Osborne © 2004 (600 pages) allocations. These steps are required for all OCI applications, as the following code illustrates. This init_env_handle() createsguide and initializes OCI environment that requires an allocation of several handles This function comprehensive focuses onthe utilizing XML technologies within Oracle's XML-enabled products, with emphasis standards, their usage and best practices. that will be populated by on theXML subsequent member functions. This function is not application-specific and thus can be used as-is in your applications. /*--------------------------------------------------------*/ Table of Contents

Oracle /* Initialize Database 10g XML the& environment SQL—Design, Build and& allocate Manage XMLhandles Applications */in Java, C, C++ & PL/SQL

/*--------------------------------------------------------*/ Introduction sb4 ociapi::init_env_handle() Part I - Oracle and the XML Standards { sword = 0; Chapter 1 -status Introducing XML /* Environment Chapter 2 - Accessing initialization XML with DOM, SAX, and JAXB,creation and StAX */ if (OCIEnvCreate((OCIEnv Chapter 3 - Transforming XML with**) XSLT&envhp, and XPath(ub4) OCI_OBJECT, (dvoid *) 0, (dvoid (*)(dvoid Chapter 4 *- Validating XML*,size_t)) with DTDs and0, XML Schemas (dvoid *- XML (*)(dvoid *, dvoid *, size_t)) 0, Operations with XQuery (void (*)(dvoid *, dvoid *)) 0, (size_t) 0, (dvoid **) 0)) Chapter 6 - XML Messaging and RPC with SOAP { printf("FAILED: OCIEnvCreate()\n"); Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL return OCI_ERROR; Part II - Oracle XML Management for DBAs } Chapter 8 - Getting Started with the Oracle XML Database /* allocate error handle */ Chapter 9 - Storing XML Data if (OCIHandleAlloc( (dvoid *)envhp, (dvoid **) errhp, Chapter 10OCI_HTYPE_ERROR, - Generating and Retrieving XML 0, (dvoid **) 0)) (ub4) (size_t) Chapter 11 Searching XML Data { printf("FAILED: OCIHandleAlloc() on errhp\n"); Chapter 12OCI_ERROR; - Managing the Oracle XML Database return Part III Oracle XML for Java Developers } Chapter 13 Getting Started handle with Oracle /* allocate server */XML and Java Chapter 14 Building an XML-Powered Site if (status = OCIHandleAlloc(Web (dvoid*)envhp, (dvoid **) &srvhp, Chapter (ub4) 15OCI_HTYPE_SERVER, - Creating a Portal Site with (size_t) XML and0, Web (dvoid Services**) 0)) { printf("FAILED: OCIHandleAlloc() on with srvhp\n"); Chapter 16 - Developing an XML Gateway Application SOAP and AQ checkerr( errhp, status); Chapter 17 - Developing XML-Based Reusable Components return OCI_ERROR; Part IV - Oracle XML for C Developers } Chapter 18 - Getting Started with Oracle XML and C /* allocate service contextApplication handle */ Chapter 19 - Building an XML-Managed if (status = OCIHandleAlloc(( dvoid*)envhp, (dvoid **) &svchp, Chapter 20 - Build an XML Database OCI Application (ub4) OCI_HTYPE_SVCCTX, (size_t) 0, (dvoid **) 0)) Chapter 21 - Create an XML-Configured High-Performance Transformation Engine { printf("FAILED: OCIHandleAlloc() on svchp\n"); Part V - Oracle XML for C++ Developers checkerr( errhp, status); Chapter 22 - Getting Started with Oracle XML and C++ return OCI_ERROR; Chapter 23 - Build an XML Database OCI C++ Application } Chapter 24 - Building an XML Data-Retrieval Application /* allocate session handle */ Part VI - Oracle XML for PL/SQL Developers if (status = OCIHandleAlloc( (dvoid*)envhp, (dvoid **) &authp, Chapter 25 - Getting Started with Oracle XML and PL/SQL (ub4) OCI_HTYPE_SESSION, (size_t) 0, (dvoid **) 0)) Chapter 26 - Building PL/SQL Web Services { printf("FAILED: OCIHandleAlloc() on authp\n"); Chapter 27 Extending PL/SQL XML Functionality with Java checkerr( errhp, status); Chapter 28OCI_ERROR; - Putting It All Together return Appendix - XML Standards Bodies and Open Specifications } Chapter 5

Glossary Index /* Allocate statement handle */

ifof(status List Figures = OCIHandleAlloc( (dvoid*)envhp, (dvoid **) stmthp, OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0)) List(ub4) of Tables { printf("FAILED: OCIHandleAlloc() on stmthp\n"); List of Sidebars checkerr( errhp, status); return OCI_ERROR; } return OCI_SUCCESS; }


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Handling Oracle OCI Errors PL/SQL

ISBN:0072229527 V. error Scardina, Ben Chang Wang This can be done with the following checker() It is necessary by to Mark include checking within and this Jinyu application. McGraw-Hill/Osborne © 2004 (600 function. This generic code can be copied andpages) pasted into your applications without customization.

This comprehensive focuses on utilizing XML{technologies within Oracle's XML-enabled products, with void checkerr( OCIError* guide errhp, sword status) emphasis on XML standards, their usage and best practices. text msgbuf[512]; sb4 errcode = 0; Table of Contents Oracle memset((void Database 10g*) XMLmsgbuf, & SQL—Design, (int)'\0', Build & Manage (size_t)512); XML Applications in Java, C, C++ & PL/SQL Introduction

switch (status) Part I - Oracle and the XML Standards { Chapter 1

- Introducing XML

case OCI_SUCCESS: break; Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX case OCI_SUCCESS_WITH_INFO: Chapter 3 - Transforming XML with XSLT and XPath printf("status = XML OCI_SUCCESS_WITH_INFO\n"); Chapter 4 - Validating with DTDs and XML Schemas OCIErrorGet((dvoid *) errhp, (ub4) 1, (text *) NULL, &errcode, - XML Operations with XQuery msgbuf, (ub4) sizeof(msgbuf), (ub4) OCI_HTYPE_ERROR); Chapter 6 - XML Messaging and RPC with SOAP printf("ERROR CODE = %d\n", errcode); Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL printf("%.*s\n", 512, msgbuf); Part II - Oracle XML Management for DBAs if (errcode == 436 || errcode == 437 || errcode == 438 Chapter 8 - Getting Started with the Oracle XML Database || errcode == 439) Chapter 9 - Storing XML Data exit(1); Chapter 10 - Generating and Retrieving XML break; Chapter 11 - Searching XML Data case OCI_NEED_DATA: Chapter 12 - Managing=the Oracle XML Database printf("status OCI_NEED_DATA\n"); Part III Oracle XML for Java Developers break; Chapter 13 Getting Started with Oracle XML and Java case OCI_NO_DATA: Chapter 14 Building an XML-Powered Web Site printf("status = OCI_NO_DATA\n"); Chapter break; 15 - Creating a Portal Site with XML and Web Services case OCI_ERROR: Chapter 16 - Developing an XML Gateway Application with SOAP and AQ printf("status = OCI_ERROR\n"); Chapter 17 - Developing XML-Based Reusable Components OCIErrorGet((dvoid *) errhp, (ub4) 1, (text *) NULL, &errcode, Part IV - Oracle XML for C Developers msgbuf, (ub4) sizeof(msgbuf), (ub4) Chapter 18 - Getting Started with Oracle XML and COCI_HTYPE_ERROR); printf("ERROR CODE = %d\n", errcode); Chapter 19 - Building an XML-Managed Application printf("%.*s\n", 512, msgbuf); Chapter 20 - Build an XML Database OCI Application if (errcode == 436 || errcode == 437 || errcode == 438 Chapter 21 - Create an XML-Configured High-Performance Transformation Engine || errcode == 439) Part V - Oracle XML for C++ Developers exit(1); Chapter 22 - Getting Started with Oracle XML and C++ break; Chapter 5

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

case OCI_INVALID_HANDLE: printf("status = OCI_INVALID_HANDLE\n"); Chapter 25 - Getting Started with Oracle XML and PL/SQL break; Chapter 26 - Building PL/SQL Web Services case OCI_STILL_EXECUTING: Chapter 27 - Extending XML Functionality with Java printf("status = PL/SQL OCI_STILL_EXECUTE\n"); Chapter 28 - Putting It All Together break; Appendix - XML Standards Bodies and Open Specifications case OCI_CONTINUE: Glossary printf("status = OCI_CONTINUE\n"); Index break; default: List of Figures break; List of Tables } List of Sidebars return; } Part VI - Oracle XML for PL/SQL Developers

This is a standard case-statement-error-routine checking for the OCI error condition constants defined in oci.h.Now that the generic code is complete, we can begin discussing the application specific code.


Oracle 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Connecting toDatabase the Database PL/SQL

by Mark V.application, Scardina, Ben andconnect Jinyu Wang Since this is a database youChang need to to it using the Oracle Net services provided byISBN:0072229527 OCI. The McGraw-Hill/Osborne 2004user (600 pages) connect_server() function passes in© the ID and password to initialize a database session. It does this by populating dataThis fields within the session handle and then sets the session handle the service context. While with comprehensive guide focuses on utilizing XML technologies withininto Oracle's XML-enabled products, emphasis on XML standards, their usage best practices. your user ID and password is passed in, the code itselfand is generic and independent of your application.

Since the example is querying a set of relational tables to return the result in XML as dictated by the SQL/XML query, we don’t want to return the XML directly but rather return it as an XOBbased DOM so that it can be directly Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL accessed. However, first you need to connect to the database as follows:

Table of Contents Introduction

*---------------------------------------------------------------------*/ Part I - Oracle and the XML Standards /* connect_server member function to connect to the DB */ - Introducing XML *---------------------------------------------------------------------*/ Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX sb4 ociapi::connect_server( text* user, text* password) Chapter 3 - Transforming XML with XSLT and XPath { sword status = 0; Chapter 4 - Validating XML with DTDs and XML Schemas /* attach to server */ Chapter 5 - XML Operations with XQuery if (status = OCIServerAttach((OCIServer *) srvhp, (OCIError *) errhp, Chapter 6 *) - XML Messaging and RPC with SOAP (text "", (sb4) strlen(""), (ub4) OCI_DEFAULT)) Chapter 7 Putting It All Together with XML Pipeline, and XSQL { printf("FAILED: OCIServerAttach() on JSPs, srvhp\n"); Part II Oracle XML Management for DBAs checkerr(errhp, status); Chapter 8 OCI_ERROR; - Getting Started with the Oracle XML Database return Chapter 9 - Storing XML Data } Chapter 10 -server Generating and Retrieving /* set attribute to XML service context */ Chapter if (status 11 - Searching = OCIAttrSet((dvoid XML Data *) svchp, (ub4) OCI_HTYPE_SVCCTX, (dvoid srvhp, 0, (ub4) OCI_ATTR_SERVER, Chapter 12 -*) Managing the(ub4) Oracle XML Database (OCIError *)XML errhp)) Part III - Oracle for Java Developers { printf("FAILED: Chapter 13 - Getting StartedOCIAttrSet() with Oracle XML on and svchp\n"); Java checkerr(errhp, Chapter 14 - Building anstatus); XML-Powered Web Site Chapter 1

Chapter 15 - Creating a Portal Site with XML and Web Services

return Chapter 16 -OCI_ERROR; Developing an XML Gateway Application with SOAP and AQ }

Chapter 17 - Developing XML-Based Reusable Components

/* set user attribute to session */ if (status = OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION, Chapter 18 - Getting Started with Oracle XML and C (dvoid *) user, (ub4) strlen((char *)user), Chapter 19 - Building an XML-Managed Application (ub4) OCI_ATTR_USERNAME, (OCIError *) errhp)) Chapter 20 - Build an XML Database OCI Application { printf("FAILED: OCIAttrSet() on authp for user\n"); Chapter 21 - Create an XML-Configured High-Performance Transformation Engine checkerr(errhp, status); Part V - Oracle XML for C++ Developers return OCI_ERROR; Chapter 22 - Getting Started with Oracle XML and C++ } Chapter 23 -password Build an XML Database OCI Application /* set attribute toC++ session */ Chapter 24 - Building an XML Data-Retrieval*) Application if (status = OCIAttrSet((dvoid authp, (ub4) OCI_HTYPE_SESSION, Part VI - Oracle XML for PL/SQL Developers (dvoid *) password, (ub4) strlen((char *)password), Chapter - Getting Started with Oracle XML and *) PL/SQL (ub4) 25 OCI_ATTR_PASSWORD, (OCIError errhp)) Chapter 26 - Building PL/SQL Web Services on authp for password\n"); { printf("FAILED: OCIAttrSet() Chapter checkerr( 27 - Extending errhp, PL/SQL status); XML Functionality with Java return OCI_ERROR; Chapter 28 - Putting It All Together } Appendix - XML Standards Bodies and Open Specifications /* Begin a session */ Glossary if (status = OCISessionBegin((OCISvcCtx *) svchp, (OCIError *) errhp, Index *) authp, (ub4) OCI_CRED_RDBMS, List(OCISession of Figures (ub4) OCI_DEFAULT)) List of Tables { printf("FAILED: OCISessionBegin()\n"); List of Sidebars checkerr( errhp, status); return OCI_ERROR; } /* set session attribute to service context */ if (status = OCIAttrSet((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX, (dvoid *) authp, (ub4) 0, (ub4) OCI_ATTR_SESSION, (OCIError *) errhp)) { printf("FAILED: OCIAttrSet() on svchp\n"); Part IV - Oracle XML for C Developers


checkerr( errhp, status); return OCI_ERROR; } Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & return OCI_SUCCESS; PL/SQL } ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, & Manage XML Applications in Java, C, C++ & Disconnecting from the Database andBuild Cleaning Up PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang Jinyu Wang from the database and clean up the context Once your database session is completed, youand need to detach by McGraw-Hill/Osborne © 2004 freeing all of the allocated handles. You do(600 thispages) by calling detach_server() in the following generic code, which is not application-dependent. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices. /*--------------------------------------------------------*/ /* End the session, detach server, and free handles. */ Table of Contents /*--------------------------------------------------------*/ Oracle void Database ociapi::disconnect_server( 10g XML & SQL—Design, Buildboolean & Manage tab_exists) XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

{ sword status = XML 0; Chapter 1 - Introducing Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

printf("\n\nLogged off and detached Chapter 3 - Transforming XML with XSLT and XPathfrom server.\n"); Chapter 4

- Validating XML with DTDs and XML Schemas

/* End -aXML session */ Operations with XQuery if (status = OCISessionEnd((OCISvcCtx *)svchp, (OCIError *)errhp, Chapter 6 - XML Messaging and RPC with SOAP (OCISession *)authp, (ub4) OCI_DEFAULT)) { Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL checkerr( errhp, status); Part II - Oracle XML Management for DBAs cleanup(); Chapter 8 - Getting Started with the Oracle XML Database return; Chapter 9 - Storing XML Data } Chapter 10 - Generating and server Retrieving*/ XML /* Detach from the Chapter 11 Searching XML Data if (status = OCIServerDetach((OCIServer *)srvhp, (OCIError *)errhp, Chapter 12 - Managing the Oracle XML Database (ub4)OCI_DEFAULT)) { Part III Oracle XML for Java Developers checkerr( errhp, status); Chapter 13 - Getting Started with Oracle XML and Java cleanup(); Chapter 14 - Building an XML-Powered Web Site return; Chapter } 15 - Creating a Portal Site with XML and Web Services /* Free the handles */Gateway Application with SOAP and AQ Chapter 16 - Developing an XML if (stmthp) { Chapter 17 - Developing XML-Based Reusable Components OCIHandleFree((dvoid *)stmthp, (ub4) OCI_HTYPE_STMT); Part IV - Oracle XML for C Developers } Chapter 18 - Getting Started with Oracle XML and C if (authp) { an XML-Managed Application Chapter 19 - Building OCIHandleFree((dvoid *)authp, (ub4) OCI_HTYPE_SESSION); Chapter 20 - Build an XML Database OCI Application } Chapter 21 - Create an XML-Configured High-Performance Transformation Engine if (svchp) { Part V - Oracle XML for C++ Developers OCIHandleFree((dvoid *)svchp, (ub4) OCI_HTYPE_SVCCTX); Chapter 22 - Getting Started with Oracle XML and C++ } Chapter 23 - Build an XML Database OCI C++ Application if (srvhp) { Chapter 24 - Building an XML Data-Retrieval Application OCIHandleFree((dvoid *)srvhp, (ub4) OCI_HTYPE_SERVER); Part VI - Oracle XML for PL/SQL Developers } Chapter 25 - Getting Started with Oracle XML and PL/SQL if (errhp) { Chapter 26 - Building PL/SQL Web Services (ub4) OCI_HTYPE_ERROR); OCIHandleFree((dvoid *)errhp, Chapter 27 Extending PL/SQL XML Functionality with Java } Chapter 28 - Putting if (envhp) { It All Together Appendix - XML Standards Bodies and Open Specifications OCIHandleFree((dvoid *)envhp, (ub4) OCI_HTYPE_ENV); Glossary } Index } Chapter 5

List of Figures

To of perform List Tables the final bit of housekeeping, you call the cleanup()function to free the OCI environment as a whole: List/*--------------------------------------------------------*/ of Sidebars

/* Clean up OCI handles. */ /*--------------------------------------------------------*/ void ociapi::cleanup() { if (envhp) { OCIHandleFree((dvoid *)envhp, OCI_HTYPE_ENV); } }


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Creating the C++ Query Application PL/SQL

by Mark V. Scardina, Ben Chang and Jinyu Wang Now that you understand the mechanics of creating an OCI XML application, we can examine the QueryISBN:0072229527 McGraw-Hill/Osborne © 2004 (600 pages) application’s Main function: This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with #include "sample.hpp" emphasis on XML standards, their usage and best practices. /*-------------------------Main function --------------------------*/ Table Contents intof main( int argc, char* argv[]) Oracle { Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

/* database login information */ Introduction text *user=(text *)"HR"; Part I - Oracle and the XML Standards text *password=(text Chapter 1 - Introducing XML *)"HR"; Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

/* OCI variables */ XPath Chapter 3 -environment Transforming XML with XSLT and ociapi* ociobjp; Chapter 4 - Validating XML with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

/* Miscellaneous */ - XML Messaging and RPC with SOAP boolean tab_exists = TRUE; Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL ub4 row = 1; Chapter 6

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

if (argc < 2) { Chapter 9 - Storing XML Data printf( "\nUsage error: \"<SQL-XML Query>\" \"<XPath>\" \n\n"); Chapter 10OCI_ERROR; - Generating and Retrieving XML return Chapter 11 - Searching XML Data } Chapter 12 the Oracle XML Database ociobjp- Managing = new ociapi(); Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XMLand and allocate Java /* Initialize the environment handles */ Chapter 14 - Building an XML-Powered Web Site if (ociobjp->init_env_handle()) Chapter { 15 - Creating a Portal Site with XML and Web Services

printf("FAILED: Chapter 16 - Developing init_env_handle()!\n"); an XML Gateway Application with SOAP and AQ delete Chapter 17ociobjp; - Developing XML-Based Reusable Components return OCI_ERROR; Part IV - Oracle XML for C Developers } Chapter 18 - Getting Started with Oracle XML and C /* Log to the server andApplication begin a session */ Chapter 19 -on Building an XML-Managed if (ociobjp->connect_server( user, password)) Chapter 20 - Build an XML Database OCI Application { printf("FAILED: connect_server()!\n"); Part V - Oracle XML for C++ Developers delete ociobjp; Chapter 22 - Getting Started with Oracle XML and C++ return OCI_ERROR; Chapter 23 - Build an XML Database OCI C++ Application } Chapter 24 - Building an XML Data-Retrieval Application /* Select an xmltype column by defining it to an xmltype instance, Part VI - Oracle XML for PL/SQL Developers and query the XOB using the Xpath expression with Chapter 25 - Getting Started with Oracle XML and PL/SQL the unified DOM APIs */ Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java if (ociobjp->select_and_query((text *)argv[1], (text *)argv[2]) Chapter 28 - Putting It All Together Appendix {

- XML Standards Bodies and Open Specifications

Glossary printf("FAILED: select_and_query!\n"); Index ociobjp->disconnect_server( tab_exists);

delete ociobjp; List of Figures return OCI_ERROR; List of Tables List}of Sidebars

/* Detach from a server and clean up the environment */ ociobjp->disconnect_server( tab_exists); delete ociobjp; return OCI_SUCCESS; }


The application has the software steps of initialization; connecting to the database; submitting the query; performing the application logic on the results; and cleaning up before exiting. In the following sections, you will see the details of each of these stepsDatabase as the application out. Note that there is a series of Applications if statements in to Java, call the Oracle 10g XMLis&built SQL: Design, Build & Manage XML C,code C++we & have discussedPL/SQL that set up the environment, connect to and disconnect from the database, and clean up. What is ISBN:0072229527 by Mark V. Scardina, Benthat Chang and Wang left is the select_and_query() function does allJinyu the work. McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Selecting Oracle into Database an XMLType PL/SQL

by Mark V. Scardina, Chang and opening Jinyu Wang After successfully connecting to theBen database a session, you can submit the query that wasISBN:0072229527 passed in McGraw-Hill/Osborne © 2004 (600 pages) on the command line. This is the select section of the select_and_query()function: This comprehensive guide focuses utilizing XML technologies within Oracle's XML-enabled products, with sb4 ociapi::select_and_query( text*onselect_stmt, text *xpathexpr) emphasis on XML standards, their usage and best practices. { ub4 xmlsize = 0; Table of Contents sword status = 0; Oracle OCIDefine Database *defnp 10g XML & = SQL—Design, (OCIDefineBuild *) &0; Manage XML Applications in Java, C, C++ & PL/SQL OCIBind *bndhp = (OCIBind *) 0; Introduction OCIXMLType *xml = (OCIXMLType *) 0; Part I - Oracle and the XML Standards OCIType = XML (OCIType *) 0; Chapter 1 -*xmltdo Introducing OCIInd = OCI_IND_NULL; Chapter 2 ind - Accessing XML with DOM, SAX, JAXB, and StAX OCIInd *xml_ind = XML &ind; Chapter 3 - Transforming with XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

printf("\n=> \"%select_stmt\" as an XMLType instance......\n", row); - XML Operations with XQuery

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

/* get the tdo for the xmltype */ - Putting It All Together with XML Pipeline, JSPs, and XSQL if (status = OCITypeByName(envhp, errhp, svchp, (const text *) SCHEMA, Part II - Oracle XML Management for DBAs (ub4) strlen((char *)SCHEMA), (const text *) TYPE, Chapter 8 - Getting Started with the Oracle XML Database (ub4) strlen((char *)TYPE), (CONST text *) 0, Chapter 9 - Storing XML Data (ub4) 0, OCI_DURATION_SESSION, OCI_TYPEGET_HEADER, Chapter 10 - Generating and Retrieving XML (OCIType **) &xmltdo)) Chapter 11 Searching XML Data { Chapter 12 Managing the Oracle XML Database printf("FAILED: OCITypeByName()\n"); Part III Oracle XML for Java Developers checkerr( errhp, status); Chapter 13OCI_ERROR; - Getting Started with Oracle XML and Java return Chapter 14 - Building an XML-Powered Web Site } Chapter 7

Chapter 15 - Creating a Portal Site with XML and Web Services

if (!xmltdo) Chapter 16 - Developing an XML Gateway Application with SOAP and AQ { Chapter 17 - Developing XML-Based Reusable Components printf("NULL tdo Part IV - Oracle XML for returned\n"); C Developers return Chapter 18OCI_ERROR; - Getting Started with Oracle XML and C } Chapter 19 - Building an XML-Managed Application /* create a an new xmltype */ Chapter 20 - Build XML Databaseinstance OCI Application if (status = OCIObjectNew( (OCIEnv*)envhp, (OCIError*)errhp, (CONST OCISvcCtx *)svchp, Part V - Oracle XML for C++ Developers (OCITypeCode) OCI_TYPECODE_OPAQUE, Chapter 22 - Getting Started with Oracle XML and C++ (OCIType *) xmltdo, (dvoid *) 0, Chapter 23 - Build an XML Database OCI C++ Application (OCIDuration) OCI_DURATION_SESSION, FALSE, Chapter 24 - Building an XML Data-Retrieval Application (dvoid **) &xml)) Part VI - Oracle XML for PL/SQL Developers { Chapter 25 - Getting Started with Oracle XML and PL/SQL printf("FAILED: OCIObjectNew()\n"); Chapter 26 - Building PL/SQL Web Services checkerr( errhp, status); Chapter 27 Extending PL/SQL XML Functionality with Java return OCI_ERROR; Chapter 28 - Putting It All Together } Appendix - XML= Standards Bodies and Open Specifications if(status OCIStmtPrepare( stmthp, errhp, (OraText *)select_stmt, Glossary (ub4)strlen((char*)select_stmt), Index (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT)) { of Figures List printf("FAILED: OCIStmtPrepare()\n"); List of Tables checkerr( errhp, status); List of Sidebars return OCI_ERROR; } /* define it to an xmltype instance */ if(status = OCIDefineByPos( stmthp, &defnp, errhp, (ub4) 1, (dvoid *) 0, (sb4) 0, SQLT_NTY, (dvoid *) 0, (ub2 *)0, (ub2 *)0, (ub4) OCI_DEFAULT)) { printf("FAILED: OCIDefineByPos()\n"); Chapter 21 - Create an XML-Configured High-Performance Transformation Engine


checkerr( errhp, status); return OCI_ERROR; } Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & if(status PL/SQL = OCIDefineObject( defnp, errhp, (OCIType *) xmltdo, (dvoid **)by&xml, ISBN:0072229527 Mark V.&xmlsize, Scardina, Ben Chang and Jinyu Wang (dvoid **) McGraw-Hill/Osborne &xml_ind, (ub4 *) 0)) © 2004 (600 pages) { This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with printf("FAILED: OCIDefineObject()\n"); emphasis on XML standards, their usage and best practices. checkerr(errhp, status); return OCI_ERROR; Table of Contents } Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL if(status = OCIStmtExecute( svchp, stmthp, errhp, (ub4) 1, (ub4) 0, Introduction (CONST OCISnapshot*) 0, (OCISnapshot*) 0, Part I - Oracle and the XML Standards (ub4) OCI_DEFAULT)) Chapter 1

- Introducing XML

Chapter 2 {

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 - Transforming XML with XSLT and XPath printf("FAILED: OCIStmtExecute()\n"); Chapter 4 - Validating status); XML with DTDs and XML Schemas checkerr(errhp, Chapter 5 OCI_ERROR; - XML Operations with XQuery return Chapter } 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

At this point, assuming the with statement execution was successful, you have an OCI context, xml, populated with an Chapter 8 - Getting Started the Oracle XML Database

XMLType -XOB corresponding to the result set in XML format. You now need to initialize the XDK context and bind it Storing XML Data to the XOB so you can use the C++ unified XDK APIs on the XOB.

Chapter 9

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10gXMLType XML & SQL: Design, & Manage XML Applications in Java, C, C++ & InitializingOracle theDatabase XDK for XOB Build Access PL/SQL

ISBN:0072229527 Mark V. need Scardina, Ben context Chang and Jinyu Wang The XDK C++ by XML APIs an XML from which to operate. When using the C APIs this is done by calling McGraw-Hill/Osborne © 2004its (600 pages)context to xmlnode. This can’t be done directly in C++; OCIXmlDbInitXmlCtx() and then casting return therefore, the following function wraps C oneontoutilizing produceXML a C++ context you canOracle's use withXML-enabled the C++ XDK APIs. with This comprehensive guidethe focuses technologies within products,

emphasis on XML standards, their usage and best practices. sb4 ociapi::select_from_doc(OCIXMLType* xml, text *xpathexpr){ boolean result = 0; Table of Contents*newxml = (OCIXMLType *) 0; OCIXMLType Oracle OCIXMLType Database *xmltran 10g XML & SQL—Design, = (OCIXMLType Build &*) Manage 0; XML Applications in Java, C, C++ & PL/SQL sword status = 0; Introduction Part I - Oracle and the XML Standards

/* For C++ APIs Chapter 1 -XML Introducing XML */ OCIDuration dur = OCI_DURATION_SESSION; Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX struct *xctxXML = (xmlctx *)0; Chapter 3 xmlctx - Transforming with XSLT and XPath xmldocnode *doc =XML (xmldocnode Chapter 4 - Validating with DTDs and*)0; XML Schemas ocixmldbparam params[1]; - XML Operations with XQuery

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

/* Get an XML C and C++ context */ params[0].name_ocixmldbparam = XCTXINIT_OCIDUR; Chapter 8 - Getting Started with the Oracle XML Database params[0].value_ocixmldbparam = &dur; Chapter 9 - Storing XML Data xctx = OCIXmlDbInitXmlCtx( envhp, svchp, errhp, params, 1); Chapter 10 - Generating Retrieving XML xctx); CXmlCtx* cxctxp =and new CXmlCtx( Part II - Oracle XML Management for DBAs

Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database /* convert the xmltype value to C++ DocumentRef */ Part Oracle XML for Java Developers docIII= - (xmldocnode *) xml;

Chapter 13 - Getting Started with Oracle XML and Java DOMImplRef< CXmlCtx, xmlnode> Chapter 14 - Building an XML-Powered Web Site impl_ref( cxctxp, new DOMImplementation< xmlnode>( FALSE)); Chapter DocumentRef< 15 - Creating xmlnode>* a Portal Site doc_refp with XML and = impl_ref.formDocument( Web Services (xmlnode*)doc); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

/* test xml unified C APIs */ Components Chapter 17 - Developing XML-Based Reusable if IV (doXPath< CXmlCtx, xmlnode>( Part - Oracle XML for C Developers

cxctxp, *doc_refp, (char*)xpathexpr)) { printf("FAILED: doXPath()\n"); Chapter 18 - Getting Started with Oracle XML and C return Chapter 19OCI_ERROR; - Building an XML-Managed Application } Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

/* free the statement handle */ if (stmthp) { Chapter 22 - Getting Started with Oracle XML and C++ OCIHandleFree((dvoid *)stmthp, OCI_HTYPE_STMT); Chapter 23 - Build an XML Database OCI C++ Application } Chapter 24 - Building an XML Data-Retrieval Application /* free the xmlctx */ Part VI - Oracle XML for PL/SQL Developers OCIXmlDbFreeXmlCtx(xctx); Part V - Oracle XML for C++ Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 26 - Building PL/SQL Web Services /* free xml instances using OCIObjectFree */ Chapter 27 Extending PL/SQL XML Functionality with Java if (newxml && Chapter 28 - Putting It All Together (status = OCIObjectFree(envhp, errhp, (dvoid *) newxml, Appendix - XML Standards Bodies and Open (ub2)OCI_OBJECTFREE_FORCE))) { Specifications Glossary printf("FAILED: OCIObjectFree()\n"); Index checkerr(errhp, status);

return OCI_ERROR; List of Figures List}of Tables

OCI_SUCCESS; Listreturn of Sidebars } TheOCIXmlDbInit()function returns the C context, xctx, which is then passed to the CXmlCtx() constructor to return the C++ context, cxctxp. This context can then be used to create the C++ DocumentRef, doc_refp,that points to the XOB DOM and can be used with the C++ XDK APIs.


Database 10g XML & SQL:C++ Design, BuildAPIs & Manage XML Applications in Java, C, C++ & Querying Oracle an XMLType with the XDK PL/SQL

by C++ MarkXML V. Scardina, andon Jinyu At this point, the functionsBen canChang operate the Wang document node in exactly the same way as if it ISBN:0072229527 were parsed McGraw-Hill/Osborne 2004thus (600 your pages)code can be portable for the actual application logic you need to from a file. These APIs are identical©and perform. The following generic template, doXPath(), evaluates XPath expression, doXPath, and prints out thewith This comprehensive guide focuses on utilizing XML the technologies within Oracle's XML-enabled products, emphasis on XML standards, their usage and best practices. result to the screen:

/* generic template to handle XPath processing */ Table of Contents template< typename TCtx, typename Tnode> Oracle sb4 doXPath( Database 10g TCtx* XML & ctxp, SQL—Design, DocumentRef< Build & Manage Tnode>& XML Applications doc_ref,inchar* Java, C,xpath_exp) C++ & PL/SQL{

printf("Initializing Tools Factory\n"); Introduction Factory< Tnode>* fp = Part I - Oracle TCtx, and the XML Standards try { 1 Chapter

NULL;

- Introducing XML

fp = new Factory< TCtx, Tnode>( ctxp); Chapter 2 - Accessing XML with DOM, SAX, JAXB, and } StAX catch 3(FactoryException& Chapter - Transforming XML withfe) XSLT{and XPath unsigned ecode = XML fe.getCode(); Chapter 4 - Validating with DTDs and XML Schemas printf( -"Failed to create factory, error %u\n", ecode); XML Operations with XQuery return ecode;} Chapter 6 - XML Messaging and RPC with SOAP printf("Creating XPath processor\n"); Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL XPath::Processor< TCtx, Tnode>* prp = NULL; Part II - Oracle XML Management for DBAs try { Chapter 8 - Getting Started with the Oracle XML Database prp = fp->createXPathProcessor( XPathPrCXml, NULL);} Chapter 9 - Storing XML Data catch (FactoryException& fe1) { Chapter 10 - Generating and Retrieving XML unsigned ecode = fe1.getCode(); Chapter 11 Searching XML Data printf( "Failed to create XPath processor, error %u\n", ecode); Chapter 5

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 -ecode; Getting Started with Oracle XML and Java return } Chapter 14 -"Create Building anDOM XML-Powered Web Site printf( source for the DOM tree\n"); Chapter InputSource* 15 - Creating isrcp a Portal = new Site with DOMSource< XML and Web Tnode>( Servicesdoc_ref);

printf("Processing tree with '%s' with ...\n", xpath_exp); Chapter 16 - Developing an DOM XML Gateway Application SOAP and AQ XPathObject< Tnode>* objp Reusable = NULL;Components Chapter 17 - Developing XML-Based tryIV{- Oracle XML for C Developers Part objp = } Chapter 18prp->process - Getting Started (isrcp, with Oracle(oratext*)xpath_exp); XML and C catch 19 (XPathException& xpe) Application { Chapter - Building an XML-Managed unsigned ecode = xpe.getCode(); Chapter 20 - Build an XML Database OCI Application printf( "Failed to process the document, error %u\n", ecode); return ecode; } Part V - Oracle XML for C++ Developers NodeSet< Tnode>* np = NULL; Chapter 22 - Getting Started with Oracle XML and C++ boolean varb = FALSE; Chapter 23 - Build an XML Database OCI C++ Application double num = 0.0; Chapter 24 - Building an XML Data-Retrieval Application oratext* str = NULL; Part VI - Oracle XML for PL/SQL Developers unsigned i = 0; Chapter 25 - Getting Started with Oracle XML and PL/SQL switch (objp->getObjType()) { Chapter 26 - Building PL/SQL Web Services case XPOBJ_TYPE_NDSET: Chapter 27 - Extending PL/SQL XML Functionality with Java np = objp->getNodeSet(); Chapter 28 - Putting It All Together printf("NodeSet:\n"); Appendix Standards Bodies and Open Specifications for (i =- XML 0; i < np->getSize(); i++ ) { Glossary NodeRef< Tnode>* nrefp = np->getNode( i); Index switch( nrefp->getNodeType()) { case ELEMENT_NODE: List of Figures case ATTRIBUTE_NODE: List of Tables printf("Node Name : %s\n", List of Sidebars nrefp->getNodeName()); break; default: printf("Other Node: %s\n" nrefp->getNodeValue() ); break; } } break; case XPOBJ_TYPE_BOOL: Chapter 21 - Create an XML-Configured High-Performance Transformation Engine


varb = objp->getObjBoolean(); printf("Boolean Value : %d\n", varb); break; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & case XPOBJ_TYPE_NUM: PL/SQL num = objp->getObjNumber(); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang printf("Numeric Value : %10.2f\n", num); McGraw-Hill/Osborne © 2004 (600 pages) break; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with case XPOBJ_TYPE_STR: emphasis on XML standards, their usage and best practices. str = objp->getObjString(); printf("String Value : %s\n", str); Table of Contents break; Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL default: Introduction printf( "Failed to create valid object\n"); Part I - Oracle and the XML Standards } Chapter 1 -0; Introducing XML return Chapter 2 Accessing XML with DOM, SAX, JAXB, and StAX } Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

This code sections. First, you must create an XPath processor, which can accept as parameters your Chapter 6 -has XMLseveral Messaging and RPC with SOAP XPath expression tree Pipeline, and thenJSPs, returnand theXSQL result. Since the result may be a collection of nodes, Chapter 7 - Puttingand It Alldatabase TogetherDOM with XML a string, a number, or a Boolean,for you need to set up a case statement because the code to print these items is not Part II - Oracle XML Management DBAs the same. Chapter 8 - Getting Started with the Oracle XML Database Chapter 9

Storing XML Data For a node- set, you need to iterate over each item and properly detect whether they are a set of attributes or

Chapter 10 -You Generating and Retrieving elements. must convert Boolean XML and number values to strings before you can print them. Even though they Chapter Searching XML Data started11 out- as lexical representations, the XPath processor implicitly cast them per the 1.0 specification. Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Running the Application PL/SQL

Mark V. Scardina, Ben Chang Jinyu Wang Once you havebythe source code compiled and and linked, it can be run connecting to the database specifiedISBN:0072229527 by your McGraw-Hill/Osborne © 2004 (600 pages) ORACE_SID environment setting and using the HR/HR userID/Password. The following is an example command line with its result. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with XML standards, their usage and best practices. selectxpq emphasis “select onXMLELEMENT("EmployeeList", XMLAGG(XMLELEMENT("Employee", XMLATTRIBUTES( employee_id AS "EmpID"), XMLELEMENT("Name", first_name Table Contents || 'of '|| last_name), XMLELEMENT("Salary", salary))))AS result FROM Oracle hr.employees Database 10g where XML & Salary SQL—Design, > 13000” Build & “//Employee/Name[../Salary="17000"]” Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

This query the following XML document from the employeestable: Chapter 1 - returns Introducing XML <EmployeeList> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <Employee EmpID="100"> Chapter 3 - Transforming XML with XSLT and XPath <Name>Steven King</Name> Chapter 4 - Validating XML with DTDs and XML Schemas <Salary>24000</Salary> Chapter 5 - XML Operations with XQuery </Employee> - XML Messaging and RPC with SOAP <Employee EmpID="101"> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL <Name>Neena Kochhar</Name> Part II - Oracle XML Management for DBAs <Salary>17000</Salary> Chapter 8 - Getting Started with the Oracle XML Database </Employee> Chapter 9 - Storing XML Data <Employee EmpID="102"> Chapter 10 - Generating and Retrieving XML <Name>Lex De Haan</Name> Chapter 11 - Searching XML Data <Salary>17000</Salary> Chapter 12 - Managing the Oracle XML Database </Employee> Part III - Oracle EmpID="145"> XML for Java Developers <Employee Chapter 13 Getting Started with Oracle XML and Java <Name>John Russell</Name> Chapter 14 Building an XML-Powered Web Site <Salary>14000</Salary> Chapter 15 - Creating a Portal Site with XML and Web Services </Employee> Chapter <Employee 16 - Developing EmpID="146"> an XML Gateway Application with SOAP and AQ <Name>Karen Partners</Name> Chapter 17 - Developing XML-Based Reusable Components <Salary>13500</Salary> Part IV - Oracle XML for C Developers </Employee> Chapter 18 - Getting Started with Oracle XML and C </EmployeeList> Chapter 19 - Building an XML-Managed Application Chapter 6

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

The XPath expression //Employee/Name[../Salary="17000"]asks for all the names of employees whose salary is equal to 17000 and returns the following XML fragment:

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

<Name>Neena Kochhar</Name> <Name>Lex De Haan</Name>

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 Scardina, Ben Chang and Jinyu In this chapter by youMark haveV.built an OCI XML application byWang using the new unified XML APIs that are available in Oracle 2004 This (600 pages) Database 10g McGraw-Hill/Osborne by way of the Oracle ©XDK. functionality has not been available in the past and answers a real need to allow operating close to large datasets. Theutilizing alternative serializing within this data only to reparse it before This comprehensive guide focuses on XML of technologies Oracle's XML-enabled products, with emphasisan onapplication XML standards, their usage and practices. working on it produces that doesn’t scale or best perform. These interfaces also enable an OCI application developer to work natively with XMLTypes and thereby utilize the full flexibility and power of the XML database and XMLTypes. Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 24:Database Building an XML Data-Retrieval Application PL/SQL

Overview

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

As XML becomes emphasis the industry on XMLstandard standards, fortheir exchanging usage and business best practices. data, the capability to retrieve selective data from large XML documents becomes increasingly more important. Because XPath is the XML navigational language, it lies at foundation of standards-based data-retrieval solutions. XPath-supported solutions such as XSLT require Table of the Contents creation and traversal of the input XML’s Document Object Model (DOM). In practice, DOMs require up to ten times Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL the memory of the original document because DOMs include traversal APIs that are difficult to optimize. Other XML Introduction processing methods, such as SAX and StAX, are event-based and require less memory; however, they lack the Part I - Oracle and the XML Standards desired XPath support for retrieving XML data. Chapter 1

- Introducing XML

Chapter 2 - Accessing XML with DOM, SAX, JAXB, XPath allows you to retrieve XML data based notand onlyStAX on its content but also on the XML document structure. In Chapter - Transforming XML with XSLT XPath Oracle 3XDK 10g, you have access to anand XPath processor in C and C++ that can evaluate an XPath and return a set Chapter 4 or - Validating with DTDs and XML Schemas of nodes values as XML appropriate. Chapter 5

- XML Operations with XQuery

In this chapter, first examine typical for data retrieval from XML documents, and then discuss the Chapter 6 - XMLwe Messaging and RPC withrequirements SOAP

design of an application that provides XPath-based XML data retrieval. Then you will build a lightweight data- Putting It All Together with XML Pipeline, JSPs, and XSQL extraction engine that can efficiently match XPaths and retrieve the results. Finally, we describe how this engine can Part II - Oracle XML Management for DBAs be easily integrated into a content-management application in an actual use case. Chapter 7 Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & DesigningOracle the Database Framework PL/SQL

by Mark Scardina, Ben Chang andaJinyu Wangdatabase, XPath expressions can be usedISBN:0072229527 In much the same way V. that SQL is used to query relational to query an McGraw-Hill/Osborne © 2004 (600 pages) XML document. While the W3C XPath standard is not meant to stand alone, any implementation of XSLT or XQuery requires an internal XPath processor. Since Oracle has exposed its XPath processor, you can use it for aproducts, variety ofwith This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled emphasis on framework XML standards, their usage best practices. applications. The example presented in thisand chapter supports two specific applications that are quite common. Table of Contents

To work with XML documents that are stored in your database, you need to be able to query them for information. One approach is to simply index them within your database; however, that is expensive. Another approach is to Introduction extract from the document, prior to or upon its insertion, key data that can be stored relationally and linked to the Part I - Oracle and the XML Standards document itself through an ID. This results in far faster and more efficient queries. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter 1

- Introducing XML

Chapter 2 - Accessing XML with DOM, SAX, JAXB, large and StAX The second application enables you to process XML documents that consist of repeating subtrees, which are Chapter quite common 3 - Transforming in database XML data. with Instead XSLT and of processing XPath the document as a whole, this application enables you to split

it based4 on- Validating an XPath and a setand of smaller documents that are easier to process. Chapter XML return with DTDs XML Schemas Chapter 5

- XML Operations with XQuery

Both of these applications have in common the use of an XPath processor. The first application returns a set of - XML Messaging and RPC with SOAP values, the second a set of nodes. Therefore, your design must be able to handle both conditions. To do this, you Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL will build a framework around the C++ XPath processor. For ease of testing, this framework will be packaged as a Part II - Oracle XML Management for DBAs command-line utility, but it can easily be plugged into a larger application. Chapter 6

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Building the cppextract Application PL/SQL

ISBN:0072229527 by XDK Mark 10g V. Scardina, Ben Chang and Jinyu Wang to use C++ templates, you will use this design Since the Oracle C++ libraries have been converted McGraw-Hill/Osborne © 2004 (600 pages) approach for the application called cppextract. It will be made up of the following three object files and their associated source This files: comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

cppextractGen.cpp The generic functions used within the application Table of Contents cppextractForce.cpp The specific instantiation of the generic functions in the application Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

cppextract.cpp The user interface to the application Introduction Part I - Oracle and the XML Standards

The following sections discuss these files and their usage within the application. - Introducing XML

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Creating the Generic Chapter 3 - Transforming XML withFunctions XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

ThecppextractGen.cpp file contains the code of the templates that are used in the application. Its only - XML Operations with XQuery dependencies are on the standard C I/O library, stdio.h, and the XDK C/C++ library, oraxml10, which is referenced Chapter 6 - XML Messaging and RPC with SOAP by including xml.hpp: Chapter 5 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

#ifndef XML_CPP_ORACLE Part II - Oracle XML Management for DBAs #include <xml.hpp> Chapter 8 - Getting Started with the Oracle XML Database #endif - Storing XML Data

Chapter 9

Chapter 10 - Generating and Retrieving XML

The processXPath() Template

Chapter 11 - Searching XML Data

Chapter 12 - Managingtemplate the Oracle XML Database TheprocessXPath() performs the actual XPath evaluation by wrapping the process() function with the Part III - Oracle for Java necessary codeXML to parse theDevelopers input XML document and to handle the resulting output. Let’s examine the template in

Chapter detail. 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

This first15section handles the Site initialization theWeb XDKServices context and is a call that all C++ XDK applications need to Chapter - Creating a Portal with XMLofand make. It to be made onlyGateway one timeApplication because itwith canSOAP be reused throughout the application. Chapter 16needs - Developing an XML and AQ template< typename TCtx, typename Tnode> unsigned processXPath( Chapter 17 - Developing XML-Based Reusable Components char* dname, Part IV - Oracle XML for C Developers

char* xpath_exp);

Chapter 18 - Getting Started with Oracle XML and C

extern { Chapter 19"C" - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

#include <stdio.h> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine } V - Oracle XML for C++ Developers Part #include "cppextract.hpp"

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

template< typename Tnode> void printSubtree( NodeRef< Tnode>& nrefp);

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

template< typename TCtx, typename Tnode> unsigned processXPath( char* dname, char* xpath_exp) {

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Chapter 27 -ctxp Extending PL/SQL XML Functionality with Java TCtx* = NULL; Chapter 28 - Putting It All Together Appendix - XML Standards Bodies Extract\n"; and Open Specifications cout << "XML C++ XPath Glossary Index try List { of Figures

ctxp = new TCtx(); List of Tables List } of Sidebars

catch (XmlException& e) { unsigned ecode = e.getCode(); cout << "Failed to initialize XML context, error " <<ecode<< "\n"; return ecode; }


Thenext section creates an instance of the XPath processor by first creating a new Tools Factory instance, fp, and then using it to create the processor, prp, with createXPathProcessor(): & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Factory< Oracle TCtx, Database Tnode>* 10g fp XML = NULL; PL/SQL

by Mark V. Scardina, Ben Chang and Jinyu Wang try McGraw-Hill/Osborne © 2004 (600 pages) { This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with fp = new Factory< TCtx, Tnode>( ctxp); emphasis on XML standards, their usage and best practices. } catch (FactoryException& fe) Table { of Contents Oracle unsigned Database 10g XML & =SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL ecode fe.getCode();

ISBN:0072229527

Introduction Part I -cout Oracle<< and"Failed the XML Standards to create

factory, error " <<ecode <<"\n";

return ecode; XML Chapter 1 - Introducing } 2 Chapter

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

printf("Creating processor\n"); Chapter 4 - Validating XMLXPath with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

XPath::Processor< TCtx, Tnode>* prp = NULL; - XML Messaging and RPC with SOAP

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

try { Chapter 8 - Getting Started with the Oracle XML Database prp = fp->createXPathProcessor( XPathPrCXml, NULL); Chapter 9 - Storing XML Data } Chapter 10 - Generating and Retrieving XML catch (FactoryException& fe1) Chapter { 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database unsigned ecode = fe1.getCode(); Part II - Oracle XML Management for DBAs

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started to withcreate Oracle XML and Java cout << "Failed XPath processor, error " <<ecode <<"\n"; Chapter 14 Building an XML-Powered Web Site return ecode; Chapter } 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Next, the XML document is passed in Components by calling Filesource(): Chapter 17 input - Developing XML-Based Reusable PartInputSource* IV - Oracle XML for isrcp C Developers = new FileSource(

(oratext*)dname);

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

The following section invokes the XPath processor through its process() function by passing in the document object, isrcp, and the XPath expression, xpath_exp. The result is returned as objp(which is analyzed in the next section).

Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

"Processing "<<dname; Partcout<< V - Oracle XML for C++ Developers cout<<"using"<<"\""<<xpath_exp<<"\""<<"\n"; Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

XPathObject< Tnode>* objp = NULL;

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

try { Chapter 26 - Building PL/SQL Web Services objp = prp->process (isrcp, (oratext*)xpath_exp); Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

}

Appendix XML Standards Bodies xpe) and Open Specifications catch -(XPathException& Glossary { Index unsigned ecode = xpe.getCode(); List of Figures List of Tables cout << "Failed to process the document, error " <<ecode <<"\n"; List of Sidebars return ecode;

} Thenext section queries the result object, objp, and the case statement branches the resulting processing: NodeSet< Tnode>* np = NULL; boolean varb = FALSE; double num = 0.0; oratext* str = NULL; unsigned i = 0;


switch (objp->getObjType()) { Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & case XPOBJ_TYPE_NDSET: PL/SQL np = objp->getNodeSet(); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang cout << "NodeSet:\n"; McGraw-Hill/Osborne © 2004 (600 pages) for (i = 0; i < np->getSize(); i++ ) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with { emphasis on XML standards, their usage and best practices. NodeRef< Tnode>* nrefp = np->getNode( i); switch( nrefp->getNodeType()) Table of Contents { Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL case ELEMENT_NODE: Introduction NodeRef< Tnode> elref( (*np), nrefp); Part I - Oracle XML Standards coutand << the "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; Chapter 1printSubTree< - Introducing XMLTnode>( *nrefp); Chapter 2 break; - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

ATTRIBUTE_NODE: Chapter 4case - Validating XML with DTDs and XML Schemas << "Attribute Name :" <<nrefp->getNodeName()<<"\n"; -cout XML Operations with XQuery break; Chapter 6 - XML Messaging and RPC with SOAP default: Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL cout<<("Node Value : "<<nrefp->getNodeValue()<<"\n"; Part II - Oracle XML Management for DBAs break; Chapter 8 - Getting Started with the Oracle XML Database } Chapter 9 - Storing XML Data } Chapter 10 - Generating and Retrieving XML break; Chapter 5

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database

case XPOBJ_TYPE_BOOL: varb = objp->getObjBoolean(); Chapter 13 - Getting Started Value with Oracle XML and Java cout<<("Boolean : "<<varb<<"\n"; Chapter 14 Building an XML-Powered Web Site break; Chapter 15XPOBJ_TYPE_NUM: - Creating a Portal Site with XML and Web Services case Chapter 16 -=Developing an XML Gateway Application with SOAP and AQ num objp->getObjNumber(); Chapter 17 - Developing XML-Based Components cout<<("Numeric Value Reusable : "<<num<<"\n"; Part IVbreak; - Oracle XML for C Developers Part III - Oracle XML for Java Developers

Chapter 18 - Getting Started with Oracle XML and C

case Chapter 19XPOBJ_TYPE_STR: - Building an XML-Managed Application str objp->getObjString(); Chapter 20 -=Build an XML Database OCI Application cout << "String Value : High-Performance " << str << "\n"; Chapter 21 - Create an XML-Configured Transformation Engine = XML prp->process (isrcp, Part V objp - Oracle for C++ Developers

(oratext*)xpath_exp);

Chapter 22 - Getting Started with Oracle XML and C++

default: Chapter 23 - Build an XML Database OCI C++ Application cout<<( "Failed to create valid object\n"); } Part VI - Oracle XML for PL/SQL Developers return 0; Chapter 25 - Getting Started with Oracle XML and PL/SQL } Chapter 24 - Building an XML Data-Retrieval Application

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - may Extending PL/SQL XML with Java etc., you need to loop through them as is done in the FOR Since objp represent a set of Functionality nodes, values, strings, Chapter Putting All Together loop. If 28 the- result is ItXPOBJ_TYPE_NDSET, then the return type is a node set. An additional case statement further Appendix Standardsthe Bodies Open Specifications processes-itXML to determine typeand of nodes. If the nodes are elements, it treats this as a request for splitting the Glossary document into subtrees and thus first prints out the XML processing instruction and then calls the printSubTree() Index function. If the result is one or more attribute nodes, it prints their names. If the node type is neither an element nor

attribute node, it prints its value. For example, consider the following document: List of Figures List of Tables <?xml version="1.0" encoding="UTF-8"?> List of Sidebars <Bookcatalog>

<book ISBN = "7564"> <title>The Adventures of Don Quixote</title> <author_lastname>Cervantes</author_lastname> <publisher>Oracle Press</publisher> <year>2000</year> <price>50.00</price> </book> <book ISBN= "5354">


<title>The Iliad</title> <author_lastname>Homer</author_lastname> <publisher>Oracle Press</publisher> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <year>1000</year> PL/SQL <price>5.00</price> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang </book> McGraw-Hill/Osborne © 2004 (600 pages) </Bookcatalog> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

The XPath /bookcatalog/book will print each book record. The XPath //book/@* will print the name of each

Table of Contents attribute, which in this case is ISBN. The XPath string(//book/@*) will return the ISBN values of 7564 and 5354 Oracle 10g XML & will SQL—Design, Build &XPOBJ_TYPE_STR. Manage XML Applications Java,isC, C++ &an PL/SQL since Database the case statement break out under If theinnode neither element nor an attribute, Introduction such as a text node, the NodeSet case statement executes its default section and returns the associated string Part I - Oracle and the XML Standards values as in //book/title/text() which returns “The Adventures of Don Quixote” and “The Iliad”.

Chapter 1

- Introducing XML

This file2 also includes XML the cppextract.hpp header fileStAX that declares the main template, processXPath(), as follows: Chapter - Accessing with DOM, SAX, JAXB, and Chapter #ifndef 3 -XML_CPP_ORACLE Transforming XML with XSLT and XPath

#include <xml.hpp> Chapter 4 - Validating XML with DTDs and XML Schemas #endif Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

template< typename TCtx, typename Tnode> unsigned Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL processXPath( Part II - Oracle XML Management for DBAs char*

Chapter 8

dname, char* xpath_exp);

- Getting Started with the Oracle XML Database

The printSubTree() Template - Storing XML Data

Chapter 9

Chapter 10 - Generating and Retrieving XML

TheprintSubTree() template is used to print the subtrees rooted at the specified element to separate documents:

Chapter 11 - Searching XML Data

template< typename Tnode> void printSubTree( NodeRef< Tnode>& nref) { Part III - Oracle XML for Java Developers oratext* tag = nref.getNodeName(); Chapter 13 - Getting Started with Oracle XML and Java if (tag == NULL) Chapter 14 - Building an XML-Powered Web Site { Chapter 15 - Creating a Portal Site and-Web Services cout << " Element haswith noXML name error\n"; Chapter 16 - Developing an XML Gateway Application with SOAP and AQ return; Chapter } 17 - Developing XML-Based Reusable Components Part// IV -print Oracle opening XML for C Developers tag Chapter 18 -<< Getting with Oracle XML and C cout "<" Started << tag; Chapter 12 - Managing the Oracle XML Database

Chapter 19 - Building an XML-Managed Application Chapter //Get 20 -attributes Build an XML Database on element OCI Application

NamedNodeMap< attrs = nref.getAttributes(); Chapter 21 - Create an Tnode>* XML-Configured High-Performance Transformation Engine attref( PartNamedNodeMapRef< V - Oracle XML for C++Tnode> Developers

nref, attrs); ub4 n_attrs = attref.getLength(); Chapter 22 - Getting Started with Oracle XML and C++ NodeRef< Tnode>* attrefpOCI = C++ NULL; Chapter 23 - Build an XML Database Application for (unsigned a = 0; a < n_attrs; a++) Chapter 24 - Building an XML Data-Retrieval Application { Part VI - Oracle XML for PL/SQL Developers Tnode* ap =Started attref.item( a); and PL/SQL Chapter 25 - Getting with Oracle XML if (a == 0) Chapter 26 - Building PL/SQL Web Services attrefp = new NodeRef< Tnode>( nref, ap); Chapter 27 - Extending PL/SQL XML Functionality with Java else Chapter 28 - Putting It All Together attrefp->resetNode( ap); Appendix - XML Standards Bodies and Open Specifications // print attribute Glossary cout << " " << attrefp->getNodeName() << " = " << attrefp->getNodeValue(); Index } List cout of Figures << ">"; List NodeRef< of Tables Tnode>* nrefp = NULL; List if of Sidebars (nref.hasChildNodes()) { NodeList< Tnode>* lp = nref.getChildNodes(); NodeListRef< Tnode> lref( nref, lp); ub4 len = lref.getLength(); for (unsigned i = 0; i < len; i++) { Tnode* np = lref.item( i);


if (i == 0) nrefp = new NodeRef< Tnode>( nref, np); else Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & nrefp->resetNode( np); PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

if (nrefp->getNodeType() == pages) ELEMENT_NODE) McGraw-Hill/Osborne © 2004 (600 { This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with //Continue emphasis iterration on XML standards, their usage and best practices. printSubTree< Tnode>( *nrefp); } Table of Contents else if (nrefp->getNodeType() == TEXT_NODE) Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL //Print Text value Introduction cout << nrefp->getNodeValue(); Part I - Oracle and the XML Standards } Chapter } 1 - Introducing XML Chapter 2 -closing Accessing tag XML with DOM, SAX, JAXB, and StAX //Print Chapter 3 << - Transforming XML << with">"; XSLT and XPath cout "</" << tag Chapter 4 - Validating XML with DTDs and XML Schemas } Chapter 5

- XML Operations with XQuery

This is 6a useful forand serializing anSOAP XML document or fragment as there currently is not a version of Chapter - XML template Messaging RPC with XmlSaveDOM() forItC++. First it sends out Pipeline, the opening angle and tag name. Then it must check for Chapter 7 - Putting All Together with XML JSPs, and bracket XSQL attributes. ThisXML is done with a FOR Part II - Oracle Management for loop DBAsto iterate over them by first getting a pointer, attrefp, to each one and serializing name Started and value. the closing angle bracket is serialized. Since an element can have element Chapter 8 -its Getting withThen the Oracle XML Database

content, text content, or both, an IF statement is created to check for this. By calling getChildNodes() and then - Storing XML Data checking the number returned, you can iterate over them with a FOR loop and either call printSubTree() again for Chapter 10 - Generating and Retrieving XML element nodes or serialize the value for text nodes. Finally, once the node list, lp, is completed, you can serialize the Chapter 11 - Searching XML Data end tag. Chapter 9

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Instantiating the Generic Functions with cppextractForce

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

Once the generic functions are completed, you need to instantiate them in the schema of your application. This is done in cppextractForce.cpp:

Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

#ifndef XMLCTX_CPP_ORACLE #include <xmlctx.hpp> Part IV - Oracle XML for C Developers #endif

Chapter 17 - Developing XML-Based Reusable Components Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

#include "cppextractGen.cpp"

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

unsigned force( char* dname, char* xpath_exp) { Chapter 22 - Getting Started withCXmlCtx, Oracle XML xmlnode>( and C++ return processXPath< dname, xpath_exp); Chapter 23 Build an XML Database OCI C++ Application } Part V - Oracle XML for C++ Developers

Chapter 24 - Building an XML Data-Retrieval Application Part Note VIthat - Oracle this file XML includes for PL/SQL the generic Developers functions created in cppextractGen.cpp.

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Creating the Main Program with cppextractMain

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending PL/SQL XML Functionality with Java

Chapter It is now 28time - Putting to create It Allthe Together user interface for the application. This is done in cppextractMain.cpp. Since this is a

command-line you need passSpecifications in the appropriate parameters, which in this case are the XML file to Appendix - XMLapplication, Standards Bodies andtoOpen query and the XPath expression to use: Glossary Index #include <iostream.h> List #include of Figures<string.h> List of Tables

#ifndef XMLCTX_CPP_ORACLE List of Sidebars #include <xmlctx.hpp> #endif #include "cppextract.hpp" int main( int argc, char* argv[]) { if (argc < 3)


{ cout << "Usage is cppextract <xmlfile> <xpath>\n"; return 1; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

} PL/SQL if (processXPath< CXmlCtx, xmlnode>( argv[2])) by Mark V. Scardina, Ben Chang and Jinyuargv[1], Wang return 1; McGraw-Hill/Osborne © 2004 (600 pages) }

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Besides parsing the command line, the only thing the application needs to do is call your main processXPath() function as it encapsulates the application’s functionality. Obviously, if you were using this function from within a Table Contents moreofsophisticated application, as we will discuss shortly, the processXPath()function could return the actual Oracle Database 10g XML &for SQL—Design, Build & Manage Applications in Java, C, C++ & PL/SQL nodes or subtree DOMs further processing, such asXML performing an XSLT transformation or inserting into a Introduction database. Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Running the cppextract Application PL/SQL

ISBN:0072229527 by Mark V.both Scardina, Ben Chang Jinyu Wang Cppextract implements application types and described in the beginning of the chapter through different sets of © 2004 (600only pages) command-line McGraw-Hill/Osborne parameters: Since cppextract depends upon the C run-time library and the oraxml10library, it can be run withThis no explicit setup from thefocuses command line. XML technologies within Oracle's XML-enabled products, with comprehensive guide on utilizing

emphasis on XML standards, their usage and best practices.

Running cppextract in Extraction Mode

Table of Contents

Oracle UsingDatabase the booklist.xml 10g XML & document SQL—Design, you can Build extract & Manage a variety XML of Applications data by passing in Java,inC, the C++ appropriate & PL/SQLXPath expression

as the XPath parameter. The following are example command lines and their resulting extractions: Introduction Part I - Oracle and the XML Standards cppextract booklist.xml //book/title/text()

Chapter 1

- Introducing XML

Chapter 2 - Accessing with DOM, SAX, JAXB,Quixote and StAX Node Value : TheXML Adventures of Don Chapter Node Value 3 - Transforming : The Iliad XML with XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

booklist.xml number(//book[2]/price/text()) Chapter 5 - XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP

Numeric 5 Together with XML Pipeline, JSPs, and XSQL Chapter 7 -Value Putting : It All Part II - Oracle XML Management for DBAs

cppextract booklist.xml string(//book[2]/@*) Chapter 8 - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

String Value : 5354

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

Running cppextract in Splitter Mode

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

In order to split an XML document with repeating subtrees, you can pass in the XPath expression that points to the element at the root of the subtree as the XPath parameter. Using these specific parameters will return the following Chapter 15 - Creating a Portal Site with XML and Web Services XML documents: Chapter 14 - Building an XML-Powered Web Site

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

cppextract booklist.xml "/bookcatalog/book" Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

<?xml version="1.0" encoding="UTF-8"?> <book ISBN = "7564"> Chapter 19 - Building an XML-Managed Application <title>The Adventures of Don Quixote</title> Chapter 20 - Build an XML Database OCI Application <author_lastname>Cervantes</author_lastname> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <publisher>Oracle Press</publisher> Part V - Oracle XML for C++ Developers <year>2000</year> Chapter 22 - Getting Started with Oracle XML and C++ <price>50.00</price> Chapter 23 - Build an XML Database OCI C++ Application </book> Chapter 18 - Getting Started with Oracle XML and C

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers <?xml version="1.0" encoding="UTF-8"?>

Chapter - Getting Started with Oracle XML and PL/SQL <book 25 ISBN= "5354"> Chapter 26 - Building PL/SQL Web Services <title>The Iliad</title> Chapter 27 - Extending PL/SQL XML Functionality with Java <author_lastname>Homer</author_lastname> Chapter <publisher>Oracle 28 - Putting It All Together Press</publisher>

<year>1000</year> Appendix - XML Standards Bodies and Open Specifications <price>5.00</price> Glossary </book> Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ExtendingOracle the Database Framework PL/SQL

ISBN:0072229527 by the Mark V. Scardina, Ben Chang and Jinyu As mentioned at beginning of this chapter, there are Wang many uses for an application that can extract data from an © 2004 (600 pages) XML documentMcGraw-Hill/Osborne using XPath expressions. While the framework presented here is simple, it is also powerful, as it can easily be extended as described inguide the next sections. This comprehensive focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

An XML Document Pruning Use Case for cppextract

Table of Contents

Oracle Because Database they are 10ghierarchical XML & SQL—Design, with no limits Buildon & the Manage size XML of element Applications content in Java, or theC, number C++ &of PL/SQL attributes, XML

documents can be large. In many cases, the actual data is buried several levels into the hierarchical structure. While Introduction the Iextracting andthe splitting techniques presented can simplify some types of processing, document pruning can Part - Oracle and XML Standards selectively nodes while maintaining a single DOM tree. Chapter 1 -remove Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

This can be accomplished using a variation of the code in cppextract within the printSubTree() template. Since the Chapter 3 - Transforming XML with XSLT and XPath nodes returned as a result of processing the XPath expression are not copies of the document nodes but references Chapter 4 - Validating XML with DTDs and XML Schemas to them, you can perform DOM operations before printing the results. For example, you could produce separate Chapter 5 - XML Operations with XQuery book documents without the price by passing in “//book” and calling removeChild()to remove the <Price> element. Chapter 6 also - XML and RPC with SOAP content. The key point to remember is that you have full access to You can useMessaging similar techniques to replace Chapter 7 Putting It All Together with XML Pipeline, JSPs, and XSQL the DOM tree. Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

A Content-Management Use Case for cppextract Chapter 9 - Storing XML Data Chapter 10 - Generating and Retrieving Since XPath is a rich language that is XML expanding even further in 2.0, you can encapsulate operations on the nodes Chapter 11 extracted - Searching XML the Data or values within expression itself. For example, if you want to find out the number of books listed in Chapter 12 - Managing the Oracle XML Database booklist.xml, the following command line would give you the result in one process step: Part III - Oracle XML for Java Developers

cppextract booklist.xml "count(/bookcatalog/book)" ... Chapter 14 -Value Building:an2.0 XML-Powered Web Site Numeric Chapter 13 - Getting Started with Oracle XML and Java

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter A complete 16 - Developing content-management an XML Gateway extraction Application systemwith could SOAP be put andtogether AQ in a manner similar to the system shown

in the diagram in FigureXML-Based 24-1. This Reusable content-management Chapter 17 - Developing Components system extracts the XML data and metadata by using the Extractor that encapsulates the cppextract functionality and inserts it into the relational database tables in an Part IV - Oracle XML for C Developers Oracle 18 database. XML with dataOracle extraction based on the XPaths stored in an XPath table associated with a DTD Chapter - GettingThe Started XML is and C and uses DTD’s an sysID and docIDApplication or an XML schema’s location URL to retrieve the appropriate set. When Chapter 19 the - Building XML-Managed initializing Extractor, content-management Chapter 20 -the Build an XML the Database OCI Application application retrieves the DTD’s sysID and docID or the XML schema21location URL from the XML document and usesTransformation them to query Engine the XPath table. After it gets a list of XPaths, Chapter - Create an XML-Configured High-Performance

the Vapplication thenfor registers the XPaths to the Extractor and specifies instances of callback functions to receive the Part - Oracle XML C++ Developers

retrieved data. The Extractor retrieves the XML data for each XPath and disseminates the data to the corresponding content handlers. The content handlers then insert the extracted data into either metadata or data tables in the Chapter 23 - Build an XML Database OCI C++ Application database. Chapter 22 - Getting Started with Oracle XML and C++

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars

Figure 24-1: cppextract content-management use case


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 Scardina, Ben Chang andprocessor Jinyu Wang In this chapter by youMark wereV.introduced to the XPath that is included in the Oracle XDK 10g C/C++ library. McGraw-Hill/Osborne © 2004 XPath (600 pages) You used it to build a simple yet powerful data-extraction application that can be used as a basis for broader content-management tasks, as described. You also used the new C++ template architecture for the XMLproducts, interfaces This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled with emphasis on XML standards, their usage and best practices. that replaces the older ones in oraxml.h from Oracle9i.

Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Part VI:Oracle Oracle XML for PL/SQL Developers PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Chapter List

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Chapter 25: Getting Started with Oracle XML and PL/SQL

Table of Contents

OracleChapter Database XML &PL/SQL SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL 26:10g Building Web Services Introduction

PL/SQL XML Functionality with Java Part IChapter - Oracle 27: andExtending the XML Standards Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 28: Putting It All Together

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 25:Database Getting Started with Oracle XML and PL/SQL PL/SQL

Overview

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

PL/SQL is Oracle’s emphasis procedural on XMLlanguage standards, extension their usage to SQL. and best Thepractices. PL/SQL XML support allows Oracle DBAs and database application developers to process XML data within the Oracle database. In Oracle Database 10g, in addition to the PL/SQL packages that generate XML, store XML, and manage the XML DB Repository, three built-in Table of Contents XML PL/SQL packages are available that provide application programatic interfaces: Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction DBMS_XMLPARSER Provides the PL/SQL XML parser APIs for parsing XML documents Part I - Oracle and the XML Standards

Chapter DBMS_XMLDOM 1 - Introducing Provides XML the PL/SQL DOM 1.0 and 2.0 APIs for accessing and updating XML documents Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 4

- Validating XML with DTDs and XML Schemas

DBMS_XSLPROCESSOR Provides the PL/SQL XSLT Processing APIs for transforming XML documents into Chapter 3 - Transforming XML with XSLT and XPath other text formats using XSLT Chapter 5 - XMLwe Operations with XQuery In this chapter, work through examples that show you how to parse XML, retrieve XML data, and transform XML Chapter 6 - XML RPC with SOAP 10g. At the end of the chapter, we discuss how to set up Oracle JVM documents usingMessaging PL/SQL inand Oracle Database Chapter 7 enable - Putting It All Together with XMLwithin Pipeline, JSPs, and XSQL to further Java XML programming the Oracle database. Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Setting Up theDatabase Environment PL/SQL

Mark V. Scardina, Ben Chang and Jinyu Wang Since the threebyXML PL/SQL packages are created during the database installation, you do not need to ISBN:0072229527 perform McGraw-Hill/Osborne 2004 pages) additional setup. During the creation©of the(600 three PL/SQL packages, public synonyms—XMLPARSER, XMLDOM, and XSLPROCESSOR—are created forfocuses DBMS_XMLPARSER, DBMS_XSLPROCESSOR, This comprehensive guide on utilizing XML DBMS_XMLDOM, technologies within and Oracle's XML-enabled products, with XML their usage and best respectively, toemphasis substituteonfor thestandards, XMLPARSER, XMLDOM, andpractices. XSLPROCESSOR packages in Oracle9i Database. The execution privileges of the XML PL/SQL packages are also granted to PUBLIC, which means all users by default are able to run these packages. If you have any security concerns, you need to withdraw these privileges Table of Contents from PUBLIC them to specificBuild users. Oracle Databaseand 10ggrant XML & SQL—Design, & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

To check whether you can run the PL/SQL packages, you can use the following SQL command:

Part I - Oracle and the XML Standards

SQL> desc <PL/SQL package name> - Introducing XML

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX For example, you can check whether you can run the DBMS_XMLPARSER package by using the following Chapter 3 - Transforming XML with XSLT and XPath command: Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

SQL> desc DBMS_XMLPARSER

Chapter 6 - the XMLexecution Messagingprivilege, and RPC you withwill SOAP If you have see the definitions of the procedures and functions defined in the Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL DBMS_XMLPARSER package. Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


OracleProcessing Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XML Techniques PL/SQL

ISBN:0072229527 by privileges Mark V. Scardina, Ben Chang and Jinyu Wang you can use them to process XML data. However, After you get the to run the XML PL/SQL packages, McGraw-Hill/Osborne 2004 (600 to pages) unlike in Oracle9i Database, you do ©not have use these packages in certain cases because Oracle Database 10g has many SQL/XML features available oftenonare easierXML to use than the XML PL/SQL packages to process XML This comprehensive guidethat focuses utilizing technologies within Oracle's XML-enabled products, with emphasis on not XMLnormally standards, usage and best practices. to transform XML documents because the data. For example, you will usetheir DBMS_XSLTPROCESSOR XMLType.transform() function provides the same functionality and is easier to use. Therefore, in this section, we discuss the PL/SQL XML processing techniques only if they are distinct from the SQL/XML functions. Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Parsing XML

Introduction

Part I - Oracle and the XML Standards

Parsing1 XML is an operation Chapter - Introducing XML that reads XML documents, processes the XML documents, and provides programmatic access XML to the XML data. Chapter 2 - Accessing with DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

In Oracle Database 10g, you can use either the DBMS_XMLPARSER package or the XMLType() constructor - Validating XML with DTDs and XML Schemas function to parse XML. The difference is that DBMS_XMLPARSER returns the parsed XML document as a Chapter 5 - XML Operations with XQuery DBMS_XMLDOM.DOMDocumentobject, while the XMLType() function returns parsed XML as an XMLType Chapter - XML to Messaging RPC with SOAP object. 6In order process and the parsed XMLType objects using DBMS_XMLDOM, you can use the Chapter 7 Putting It All Together with XML Pipeline, and XSQL DBMS_XMLDOM.newDOMDocument() function toJSPs, create DBMS_XMLDOM.DOMDocument objects from Part II Oracle XML Management for DBAs XMLTypes objects. Chapter 4

Chapter 8

- Getting Started with the Oracle XML Database

The DBMS_XMLPARSER package in Oracle Database 10g provides three interfaces that allow you to parse XML Chapter 9 - Storing XML Data documents from a string buffer, from aXML CLOB, or from a file that is stored in the local file system, in the XML DB Chapter 10 - Generating and Retrieving Repository, or in a web server: Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

parse (p Parser, url VARCHAR2) Parses XML stored in the given URL or file and returns the built DOM document

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

Chapter 14 - Building Parser, an XML-Powered Web Site Parses XML stored in the given string buffer parseBuffer(p doc VARCHAR2) Chapter 15 - Creating a Portal Site with XML and Web Services

parseClob(p Parser, docGateway CLOB) Parses XMLwith stored in the Chapter 16 - Developing an XML Application SOAP andgiven AQ CLOB Chapter 17 - Developing XML-Based Reusable Components

Since parsing from a string buffer or a CLOB inside the Oracle database is very straightforward, in the following sections, we only explain the techniques of how to parse XML from files using UTL_FILE_DIR, BFILE, and database Chapter 18 - Getting Started with Oracle XML and C URL types. Part IV - Oracle XML for C Developers

Chapter 19 - Building an XML-Managed Application Chapter 20 -XML Build an XML Database OCI Systems Application Parsing from Local File Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

YouVcan eitherXML set for up C++ UTL_FILE_DIR Part - Oracle Developers or use BFILE to parse XML documents from the local file system. Chapter 22 - Getting Started with Oracle XML and C++

Setting Up UTL_FILE_DIR to Parse XML Documents

Chapter 23 - Build an XML Database OCI C++ Application

Chapter 24 -set Building an XML Data-Retrieval When you up UTL_FILE_DIR to parse Application XML documents, you first need to use the following command to set up Part - Oraclesystem XML forparameter, PL/SQL Developers the VI database UTL_FILE_DIR, to include the directory in which the XML documents are stored:

Chapter 25 - Getting Started with Oracle XML and PL/SQL

SQL> ALTER SYSTEM

Chapter 26 - Building PL/SQL Web Services SET UTL_FILE_DIR='D:\xmlbook\Examples\Chapter26\src\xml' SCOPE=SPFILE; Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter In this example, 28 - Putting D:\xmlbook\Examples\Chapter26\src\xml It All Together is setto UTL_FILE_DIR. After you run this command

as a SYS user, have toBodies restartand theOpen Oracle database to make this change take effect. Appendix - XML you Standards Specifications Glossary

After you restart the Oracle database, you can parse XML documents by using DBMS_XMLPARSER. Within your PL/SQL procedure, you first have to initialize an XML parser by using the DBMS_XMLPARSER.newParser() List of Figures function: Index

List of Tables

v_parser DBMS_XMLPARSER.parser; … v_parser := DBMS_XMLPARSER.newParser;

List of Sidebars

You can choose whether to validate XML against a DTD and whether to preserve whitespace in the parsed XML documents by specifying the parsing parameters, as follows: DBMS_XMLPARSER.setValidationMode(v_parser, FALSE); DBMS_XMLPARSER.setPreserveWhiteSpace(v_parser, TRUE);


To parse an XML file from UTL_FILE_DIR, you need to set the XML file directory specified in UTL_FILE_DIR to be the base URL of the XML parser by using DBMS_XMLPASER.setBaseURL() as follows: Oracle Database v_dir VARCHAR2(200) := 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL 'D:\xmlbook\Examples\Chapter26\src\xml'; ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang … McGraw-Hill/Osborne © 2004 (600 pages) DBMS_XMLPARSER.setBaseDir(v_parser, v_dir); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML standards, their usage and best url practices. Then, you can emphasis use the DBMS_XMLPARSER.parse(p Parser, VARCHAR2) procedure to parse XML files. For example, you can parse a contact.xml file stored in this directory as follows: Table DBMS_XMLPARSER.parse(v_parser, of Contents 'contact.xml'); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

You then can get the DBMS_XMLDOM.DOMDocument from the XML parser: Introduction v_xmldoc Part I - Oracle:= andDBMS_XMLPARSER.getDocument(v_parser); the XML Standards Chapter 1

- Introducing XML

You can perform DOM operations on the returned DOM document and we will discuss how you can perform such - Accessing XML with DOM, SAX, JAXB, and StAX operations later in this chapter.

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4 perform - Validating XML with DTDsyou andcan XMLwrite Schemas After you DOM operations, the XML DOM document to a CLOB, a string buffer, or a file by Chapter 5 following - XML Operations with XQuery using the procedures: Chapter 6

- XML Messaging and RPC with SOAP

DBMS_XMLDOM.writetoBuffer() writes XML into a string buffer. Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

DBMS_XMLDOM.writetoClob() writes XML into a CLOB.

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 - Storing XML Data DBMS_XMLDOM.writetoFile() writes XML into a file in the local file system. Chapter 10 - Generating and Retrieving XML

In the following example, document is written to a CLOB whose content is displayed on the SQL*Plus screen Chapter 11 - Searching XMLthe Data and to an file named out.xml that is created in the directory specified in UTL_FILE_DIR: Chapter 12 XML - Managing the Oracle XML Database Part DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION); III - Oracle XML for Java Developers

DBMS_XMLDOM.writetoClob(v_xmldoc, v_out); Chapter 13 - Getting Started with Oracle XML and Java DBMS_XMLDOM.writetoFile(v_xmldoc,v_dir||'/out.xml'); Chapter 14 - Building an XML-Powered Web Site :out := Chapter 15 -v_out; Creating a Portal Site with XML and Web Services DBMS_LOB.freetemporary(v_out); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

In summary, the following is the example PL/SQL program that parses an XML document stored in a local file system by using UTL_FILE_DIR:

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

SET LONG 100000 SET AUTOPRINT ON Chapter 20 - Build an XML Database OCI Application VAR out CLOB Chapter 21 - Create an XML-Configured High-Performance Transformation Engine DECLARE Part V - Oracle XML for C++ Developers v_xmldoc DBMS_XMLDOM.DOMDocument; Chapter 22 - Getting Started with Oracle XML and C++ v_parser DBMS_XMLPARSER.parser; Chapter 23 - Build an XML Database OCI C++ Application v_out CLOB; Chapter 24VARCHAR2(200) - Building an XML Data-Retrieval Application v_dir := Part VI - Oracle XML for PL/SQL Developers 'D:\xmlbook\Examples\Chapter26\src\xml'; Chapter BEGIN 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building -- New parserPL/SQL Web Services Chapter 27 Extending PL/SQL XML Functionality with Java v_parser := DBMS_XMLPARSER.newParser; Chapter 28 - Puttingup It All Together -- Setting the parsing parameters Appendix DBMS_XMLPARSER.setValidationMode(v_parser, - XML Standards Bodies and Open Specifications FALSE); DBMS_XMLPARSER.setPreserveWhiteSpace(v_parser, TRUE); Glossary -- The v_dir has to be a valid directory in the UTL_FILE_DIR Index v_dir); List DBMS_XMLPARSER.setBaseDir(v_parser, of Figures Parsing the XML file List -of Tables 'contact.xml'); List DBMS_XMLPARSER.parse(v_parser, of Sidebars -- Getting the XML DOMDocument v_xmldoc := DBMS_XMLPARSER.getDocument(v_parser); -- Print out the result DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION); DBMS_XMLDOM.writetoClob(v_xmldoc, v_out); DBMS_XMLDOM.writetoFile(v_xmldoc,v_dir||'/out.xml'); :out := v_out; DBMS_LOB.freetemporary(v_out); Chapter 19 - Building an XML-Managed Application


END; / Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

Compared to DBMS_XMLPARSER, theXMLType() function doesn’t allow files to be read from UTL_FILE_DIR. PL/SQL Moreover, by using DBMS_XMLPARSER, you can parse DTDs and use them to validate the XML documents, ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang which is not possible with XMLType(). McGraw-Hill/Osborne © 2004 (600 pages)

Using BFILE This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

In the Oracle database, you can create a database directory and use BFILE to read XML files from the local file system. After loading the data into BFILEs, you then get the data into CLOBs where you can parse them by using Table of Contents either DBMS_XMLPARSER or the XMLType() Oracle Database 10g XML & SQL—Design, Build & function. Manage XML Applications in Java, C, C++ & PL/SQL Introduction

To create a database directory, you need to log in as a SYS user and run the following commands:

Part I - Oracle and the XML Standards

CREATE DIRECTORY xmldir AS 'D:\xmlbook\Examples\Chapter26\src\xml'; - Introducing XML GRANT READ ON DIRECTORY xmldir TO demo;

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 - commands Transforming XML a with XSLT and XPath called xmldir and grant the read privilege to the user demo. These two create database directory Chapter 4

- Validating XML with DTDs and XML Schemas

To load5XML documents using Chapter - XML Operations withBFILE, XQueryyou can use the following PL/SQL procedure after you have connected as demo/demo: Chapter 6 - XML Messaging and RPC with SOAP Chapter 7 OR - Putting It All FUNCTION Together with XML Pipeline, JSPs, andVARCHAR2) XSQL CREATE REPLACE BfileToClob(fname RETURN CLOB IS Part II - Oracle fclob CLOB;XML Management for DBAs

Chapter theBFile 8 - Getting BFILE;Started with the Oracle XML Database

num NUMBER := 0; Chapter 9 - Storing XML Data src_offset NUMBERand := 1; Chapter 10 - Generating Retrieving XML dest_offset NUMBER := 1; Chapter 11 - Searching XML Data lang_context NUMBER := 1; Chapter 12 - Managing the Oracle XML Database BEGIN Part III - Oracle XML for Java Developers DBMS_LOB.createtemporary(fclob,FALSE,DBMS_LOB.SESSION); Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site

theBFile := BFileName('XMLDIR',fname); DBMS_LOB.fileOpen(theBFile); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ DBMS_LOB.loadClobFromFile(dest_lob=>fclob, Chapter 17 - Developing XML-Based Reusable Components src_bfile=>theBFile, Part IV - Oracle XML for C Developers amount=>dbms_lob.getLength(theBFile), Chapter 18 - Getting Started with Oracle XML and C dest_offset=>dest_offset, Chapter 19 - Building an XML-Managed Application src_offset=>src_offset, Chapter 20 - Build an XML Database OCIbfile_csid=>0, Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine lang_context=>lang_context, Part V - Oracle XML for C++ Developerswarning=>num); Chapter 22 - Getting Started with Oracle XML and C++ DBMS_LOB.fileClose(theBFile); Chapter 23 - Build an XML Database OCI C++ Application RETURN fclob; Chapter END; 24 - Building an XML Data-Retrieval Application Part / VI - Oracle XML for PL/SQL Developers Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 25 - Getting Started with Oracle XML and PL/SQL

In this procedure, a BFILE opened in the XMLDIR database directory by using the BFileName() function. To Chapter 26 - Building PL/SQL is Web Services ensure the character set conversion is properly performed, the current language context—the lang_context parameter—is set to 1 for the DBMS_LOB.loadClobFromFile() function.

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

Appendix - XML Standards Open Specifications After the XML document is Bodies loadedand from a BFILE into a CLOB, you can use the DBMS_XMLPARSER.ParseCLOB() Glossary orXMLType() function to parse the document in Oracle Database 10g as follows: Index

SET AUTOPRINT ON

List of Figures VAR out CLOB List of Tables DECLARE Listv_xmldoc of SidebarsDBMS_XMLDOM.DOMDocument;

v_xmltype XMLType; v_out CLOB; BEGIN v_xmltype := XMLType(BFiletoClob('contact.xml')); v_xmldoc :=DBMS_XMLDOM.newDOMDocument(v_xmltype); DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION); DBMS_XMLDOM.writetoClob(v_xmldoc, v_out); :out := v_out;


DBMS_LOB.freetemporary(v_out); END; / Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & show errors; PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

In this example, XMLType() parses the XML in the CLOB returned by the BFiletoClob() procedure.

ISBN:0072229527

This comprehensive focusesboth on utilizing XML technologies within Oracle's XML-enabled products, with If an XML document contains DTDguide references, UTL_FILE_DIR and BFILE approaches might not work properly. emphasis on XML standards, their usage and best practices. For example, assume that you have an XML document, test01.xml, that refers to a DTD document called test01.dtd,as follows: Table of Contents <?xml version="1.0" encoding="UTF-8"?> Oracle Database 10g XMLtype="text/xsl" & SQL—Design, Buildhref="display.xsl"?> & Manage XML Applications in Java, C, C++ & PL/SQL <?xml-stylesheet Introduction <!DOCTYPE SIGNATURE SYSTEM "test01.dtd"> Part I - Oracle and the XML Standards <SIGNATURE>

Chapter 1 - Introducing XML <NAME>&AUTHOR_NAME;</NAME> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <COPYRIGHT>&COPYRIGHT;</COPYRIGHT> Chapter <EMAIL>&AUTHOR_EMAIL;</EMAIL> 3 - Transforming XML with XSLT and XPath

<LAST_MODIFIED>&LAST_MODIFIED;</LAST_MODIFIED> Chapter 4 - Validating XML with DTDs and XML Schemas <PHOTO SOURCE="FUN_IMG">Lovely Kevin</PHOTO> Chapter 5 - XML Operations with XQuery </SIGNATURE> Chapter 6 - XML Messaging and RPC with SOAP Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Parsing this document using BFILE or UTL_FILE_DIR will return the ORA-31001: Invalid Resource Handle or Path Name “/test01.dtd” error.

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9 this - Storing Dataload the DTD files to the XML DB Repository and update the DTD URLs in the XML files To avoid error, XML you can Chapter 10 XMLDBURIs - Generating for andthe Retrieving XML to be the DTD files. Otherwise, you have torewrite the EntityResolvers for the XML parsers. Chapter 11 -27, Searching XML Data InChapter we will discuss how to create Java stored procedures to rewrite the EntityResolvers so that XML Chapter parsers12 can - Managing resolve reference the OracleURLs XML Database in XML by reading data from files in the local file system, from URLs, or even Part fromIII database - Oracle tables. XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

Note Turning off DTD validation does not prevent the DTD lookup as DTDs are also used for entity expansion and whitespace handling. To turn off the lookup for the DTD references in XML when parsing XML Chapter 15 - Creating a Portal Site with XML and Web Services documents, you can use the commandAlter session set events '31156 trace name context Chapter 16 - Developing an XML Gateway Application with SOAP and AQ forever, level 2'; Chapter 14 - Building an XML-Powered Web Site

Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Parsing XML from URLs

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 an - Building an XML-Managed Application To parse XML document from a URL, you can leverage the UriType datatypes that are provided in the Oracle Chapter XML DB, 20 such - Build asan HTTPUriType, XML DatabaseDBUriType, OCI Application and XDBUriType. Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Using HTTPUriType Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

The following example parses an XML document from a web server by using HTTPUriType:

Chapter 23 - Build an XML Database OCI C++ Application

SET LONG 100000 SET AUTOPRINT ON Part VI - Oracle XML for PL/SQL Developers VAR out CLOB Chapter 25 - Getting Started with Oracle XML and PL/SQL DECLARE Chapter 26 - Building PL/SQL Web Services v_xmldoc DBMS_XMLDOM.DOMDocument; Chapter 27 - Extending PL/SQL XML Functionality with Java v_xmltype XMLType; Chapter 28 -CLOB; Putting It All Together v_out Appendix BEGIN - XML Standards Bodies and Open Specifications Glossary v_xmltype := sys.HTTPUriType.createURI( Index 'http://otn.oracle.com/syndication/rss_otn_news.xml').getXML(); List v_xmldoc of Figures :=DBMS_XMLDOM.newDOMDocument(v_xmltype); List DBMS_LOB.createTemporary(v_out,FALSE,DBMS_LOB.SESSION); of Tables DBMS_XMLDOM.writetoClob(v_xmldoc, v_out); List of Sidebars :out:=v_out; DBMS_LOB.freeTemporary(v_out); END; / Chapter 24 - Building an XML Data-Retrieval Application

In this example, an HTTUriTypeobject is created for the XML document with the URL http://otn.oracle.com/syndication/rss_otn_news.xml,as follows:


sys.HTTPUriType.createURI( 'http://otn.oracle.com/syndication/rss_otn_news.xml') Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

To get the XMLPL/SQL document, the HTTPUriType.getXML() function is then used. The content of the XML document is returned in an XMLType, which is then used to create a DBMS_XMLDOM.DOMDocument object for further ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang processing. McGraw-Hill/Osborne © 2004 (600 pages)

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Using XDBUriType emphasis on XML standards, their usage and best practices.

A similar approach to parse an XML document stored in the XML DB Repository is to use XDBUriType. The following procedure assumes that you have loaded contact.xml into the XML DB repository’s /public directory. Table of Contents Oracle SET LONG Database 100000 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

SET AUTOPRINT ON Introduction VARI -out CLOB Part Oracle and the XML Standards DECLARE Chapter 1 - Introducing XML v_xmldoc DBMS_XMLDOM.DOMDocument; Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX v_xmltype XMLType;XML with XSLT and XPath Chapter 3 - Transforming v_out Chapter 4 CLOB; - Validating XML with DTDs and XML Schemas BEGIN - XML Operations with XQuery v_xmltype := Chapter 6 - XML Messaging and RPC with SOAP SYS.XDBUriType.createUri('/public/contact.xml').getXML(); Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL v_xmldoc :=DBMS_XMLDOM.newDOMDocument(v_xmltype); Part II - Oracle XML Management for DBAs DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION); Chapter 8 - Getting Started with the Oracle XML Database DBMS_XMLDOM.writetoClob(v_xmldoc, v_out); Chapter 9 - Storing XML Data :out := v_out; Chapter 10 - Generating and Retrieving XML DBMS_LOB.freetemporary(v_out); Chapter END; 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database / Chapter 5

Part III - Oracle XML for Java Developers

TheXDBUriType object is created using theand SYS.XDBUriType.createUri() function and the XML data is returned Chapter 13 - Getting Started with Oracle XML Java as an XMLType by using the XDBUriType.getXML() function. Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

Setting Up HTTP Proxy and User Authentication

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 -document Developing XML-Based Reusable If an XML has URL references toComponents external files outside the intranet, you need to set up the proxy server to Part IV - Oracle XML for C Developers retrieve them. Otherwise, you will get the ORA-29273: HTTP Request Failed error. To set up a proxy server, you

Chapter - Getting Started with Oracle XML and C as follows: can use18the UTL_HTTP.SET_PROXY() procedure Chapter BEGIN 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application UTL_HTTP.SET_PROXY('proxy.mycompany.com:80', 'mycompany.com'); Chapter END; 21 - Create an XML-Configured High-Performance Transformation Engine Part / V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

The first theDatabase proxy URL inC++ host:port format. The second parameter includes the domains that can be Chapter 23parameter - Build an is XML OCI Application accessed theanproxy server. The proxy will stay in effect for the current database connection session. Chapter 24 -without Building XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

If the URL requires user authentication, you need to create the URL with the username and password in a format as follows:

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

[http://][user[:password]@]host[:port][/]

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix - XML Standards Bodies and by Open Specifications For example, contact.xml is created user demo as a private resource in the /public directory in the XML DB Glossary Repository. To access its content, you need to log in as user demo. If the demo user’s password is demoand the Index HTTP port number for the XML DB Repository is 8080, you need to specify the URL to be List of Figures http://demo:demo@localhost:8080/public/contact.xml. Otherwise, you will get an ORA-29273: HTTP Request List of Tables Failed error. The following example shows how to parse an XML document from an HTTP server that requires user List authentication: of Sidebars

SET LONG 100000 SET AUTOPRINT ON VAR out CLOB DECLARE v_xmldoc DBMS_XMLDOM.DOMDocument; v_xmltype XMLType; v_out CLOB; BEGIN


v_xmltype := sys.httpuritype.createuri( 'http://demo:demo@localhost:8080/public/contact.xml').getXML(); v_xmldoc Oracle :=DBMS_XMLDOM.newDOMDocument(v_xmltype); Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION); PL/SQL DBMS_XMLDOM.writetoClob(v_xmldoc, v_out); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang :out:=v_out; McGraw-Hill/Osborne © 2004 (600 pages) DBMS_LOB.freetemporary(v_out); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with END; emphasis on XML standards, their usage and best practices. / Table Note of Contents Including the username and password in the URL should only be used with caution due to security Oracle Database 10g XML & Manage XML Applications in Java, C, C++ & PL/SQL concerns but it&isSQL—Design, supported inBuild Oracle Database 10g. Introduction

An alternative approach that does not have the security issue is to use UTL_HTTP to get the XML file as follows: Part I - Oracle and the XML Standards Chapter 1 - Introducing set long 100000 XML Chapter 2 - Accessing set autoprint onXML with DOM, SAX, JAXB, and StAX Chapter var out 3 -clob Transforming XML with XSLT and XPath

declare Chapter 4 - Validating XML with DTDs and XML Schemas v_xmldoc DBMS_XMLDOM.DOMDocument; Chapter 5 - XML Operations with XQuery v_xmltype Chapter 6 - XMLXMLType; Messaging and RPC with SOAP v_out Chapter 7 clob; - Putting It All Together with XML Pipeline, JSPs, and XSQL v_req UTL_HTTP.req; Part II - Oracle XML Management for DBAs v_resp Chapter 8 -UTL_HTTP.resp; Getting Started with the Oracle XML Database v_text -VARCHAR2(32767); Storing XML Data BEGIN Chapter 10 - Generating and Retrieving XML v_req := Chapter 11 - Searching XML Data UTL_HTTP.begin_request('localhost:8080/public/contact.xml'); Chapter 12 - Managing the Oracle XML Database UTL_HTTP.set_authentication(r=>v_req, Part III - Oracle XML for Java Developers username=>'demo', Chapter 13 - Getting Started with Oracle XML and Java password=>'demo'); Chapter 14 - Building an XML-Powered Web Site v_resp := UTL_HTTP.get_response(v_req); Chapter 15 - Creating a Portal Site with XML and Web Services UTL_HTTP.read_text(r=>v_resp,data=>v_text); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ UTL_HTTP.end_response(v_resp);v_xmltype :=XMLType(v_text); Chapter 17 - Developing XML-Based Reusable Components v_xmldoc :=DBMS_XMLDOM.newDOMDocument(v_xmltype); Part IV - Oracle XML for C Developers DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION); Chapter 18 - Getting Started with Oracle XML and C v_out); DBMS_XMLDOM.writetoClob(v_xmldoc, Chapter :out:=v_out; 19 - Building an XML-Managed Application DBMS_LOB.freetemporary(v_out); Chapter 20 - Build an XML Database OCI Application END; 21 - Create an XML-Configured High-Performance Transformation Engine Chapter / V - Oracle XML for C++ Developers Part Chapter 9

Chapter 22 - Getting Started with Oracle XML and C++

Both the DBMS_XMLPARSER.PARSE() and XMLType() functions use UTL_HTTP to request the data from remote web servers. Therefore, the proxy setup and the user authentication setup are the same.

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Parsing with DTDs

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter - Building PL/SQL Webcan Services Similar 26 to XML schemas, DTDs be used to define the structure and metadata of XML documents, which then Chapter - Extending PL/SQL XML Functionality can be 27 used to validate XML documents. Whilewith theyJava are not supported to the same extent as XML schemas, you Chapter can control 28 - Putting the useItofAll DTDs Together in Oracle Database 10gusing the following command: Appendix - XML Standards Bodies '31156 and Opentrace Specifications Alter session set events name context forever, level 2'; Glossary

This turns off the DTD parsing and validation when parsing XML in either the XMLType() functions or the Index DBMS_XMLPARSER XML parsing functions. List of Figures List of Tables

In addition, and distinct from XML schemas, DTDs can also define entities for an XML document, which have to be resolved before XML parsers can check the well-formedness of XML documents. In this case, you cannot turn off DTD parsing; therefore, DTD files must have a URL that can be resolved by the Oracle XML DB. In Oracle Database 10g, it should be an XML DB URI like /public/author.dtdpointing to a resource file stored in the Oracle XML DB Repository.

List of Sidebars

Note In Oracle Database 10gR1, DBMS_XMLPARSER.parseDTD(),DBMS_XMLPARSER.parseDTDBuffer(), and DBMS_XMLPARSER.parseDTDClob()are not supported. Therefore, you can’t parse external DTDs and set them to XML parsers.


Processing XML Using DOM After XML documents are parsed10g by DBMS_XMLPARSER or XMLType() constructor functions,inthe XMLC,parser Oracle Database XML & SQL: Design, Build & Manage XML Applications Java, C++ & PL/SQL as in-memory object trees. Therefore, you can navigate the object tree by using the DOM builds XML documents ISBN:0072229527 APIs in the DBMS_XMLDOM by Mark V. Scardina, package Ben to Chang retrieve andXML Jinyudata Wang or to update the object tree by inserting or deleting XML elements or their McGraw-Hill/Osborne content. In this section, © 2004 we (600do pages) not explain every DOM API but rather focus on discussing the solutions for some problems that are encountered when dealing with XML Oracle's using DOM in PL/SQL. This common comprehensive guide focuses on utilizing XML technologies within XML-enabled products, with emphasis on XML standards, their usage and best practices.

Note Oracle Database 10g does not provide built-in SAX XML parsing in PL/SQL. However, in Chapter 27, we will discuss techniques that use Java stored procedures to process XML data using SAX in PL/SQL.

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Dealing with XML Namespaces

Introduction

Part Oracle and the Standards XMLI -namespaces areXML collections of names identified by URI references, which are then used on XML elements and

Chapter 1 to - Introducing attributes qualify XMLXML elements or attributes for different applications. The following example, which uses the Chapter DBMS_XMLDOM 2 - Accessing package, XML with shows DOM,how SAX, you JAXB, can and create StAX an XML element with a namespace in Oracle Database 10g: Chapter 3 OR - Transforming XML with XSLT and XPath CREATE REPLACE FUNCTION appendChild(p_doc xmltype) Chapter 4 XMLType - Validating RETURN ASXML with DTDs and XML Schemas Chapter 5 -DBMS_XMLDOM.DOMDocument; XML Operations with XQuery v_doc Chapter v_docn 6 - XML DBMS_XMLDOM.DOMNode; Messaging and RPC with SOAP

v_lcn Chapter 7 -DBMS_XMLDOm.DOMNode; Putting It All Together with XML Pipeline, JSPs, and XSQL Partv_nelem II - OracleDBMS_XMLDOM.DOMNode; XML Management for DBAs

v_elem DBMS_XMLDOM.DOMElement; Chapter 8 - Getting Started with the Oracle XML Database v_attr DBMS_XMLDOM.DOMAttr; Chapter 9 - Storing XML Data v_nattr DBMS_XMLDOM.DOMNode; Chapter 10 - Generating and Retrieving XML v_tx Chapter 11DBMS_XMLDOM.DOMText; - Searching XML Data v_ntx DBMS_XMLDOM.DOMNode; BEGIN Part III - Oracle XML for Java Developers -- Create DOM document Chapter 13 - Getting Started with Oracle XML and Java v_doc := DBMS_XMLDOM.newDOMDocument(p_doc); Chapter 14 - Building an XML-Powered Web Site v_docn := DBMS_XMLDOM.makeNode( Chapter 15 - Creating a Portal Site with XML and Web Services DBMS_XMLDOM.getDocumentElement(v_doc)); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ -- Locate the element where the new element will be inserted Chapter 17 -:= Developing XML-Based Reusable Components v_lcn DBMS_XMLDOM.getLastChild(v_docn); Chapter 12 - Managing the Oracle XML Database

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and namespace C -- Create a new XML element with Chapter 19 - Building an XML-Managed Application v_elem :=DBMS_XMLDOM.CreateElement(v_doc, Chapter 20 - Build an XML Database OCI Application 'my:notes', Chapter 21 - Create an XML-Configured High-Performance Transformation Engine 'http://www.example.com'); Part V - Oracle XML for C++ Developers

Chapter -- Create 22 - Getting theStarted attribute with Oracle to XML include and C++ namespace declaration

v_attr :=DBMS_XMLDOM.CreateAttribute(v_doc,'xmlns:my'); Chapter 23 - Build an XML Database OCI C++ Application v_nattr := DBMS_XMLDOM.makeNode(v_attr); Chapter 24 - Building an XML Data-Retrieval Application PartDBMS_XMLDOM.setNodeValue(v_nattr, VI - Oracle XML for PL/SQL Developers

'http://www.example.com');

-- Set the attribute theXML XMLandelement Chapter 25 - Getting Started withto Oracle PL/SQL v_attr := DBMS_XMLDOM.setAttributeNode(v_elem, Chapter 26 - Building PL/SQL Web Services v_attr,'http://www.example.com' ); Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

-- Insert Text Node to XML Element - XML Standards Bodies and Open Specifications v_nelem := DBMS_XMLDOM.makeNode(v_elem); Glossary v_tx :=DBMS_XMLDOM.createtextnode(v_doc, 'Address is not complete.'); Index v_ntx:=DBMS_XMLDOM.makenode(v_tx); List of Figures v_ntx:= DBMS_XMLDOM.appendchild(v_nelem, v_ntx); Appendix

List of Tables List -of Sidebars Insert the new element

v_nelem := DBMS_XMLDOM.insertBefore(v_docn, v_nelem, v_lcn); RETURN p_doc; END; / show errors;


This example shows that you can create XML elements or attributes qualified by namespaces in Oracle Database 10g by specifying the third parameter of the DBMS_XMLDOM.CreateElement() or DBMS_XMLDOM.CreateAttribute() In this sample, the new XML element is created with its namespace Oracle Database 10gfunction. XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & to behttp://www.example.com: PL/SQL ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang v_elem :=DBMS_XMLDOM.CreateElement(v_doc, McGraw-Hill/Osborne © 2004 (600 pages) 'my:notes', This comprehensive guide focuses on'http://www.example.com'); utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

However, according to the DOM specification, the namespace declarations are not added by default. Therefore, you need to add the namespace declaration attributes explicitly as shown in the following example, which adds an Table of Contents xmlns:my attribute to the my:note element: Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

v_attr :=DBMS_XMLDOM.CreateAttribute(v_doc,'xmlns:my'); Introduction Partv_nattr I - Oracle := and DBMS_XMLDOM.makeNode(v_attr); the XML Standards

DBMS_XMLDOM.setNodeValue(v_nattr, 'http://www.example.com'); Chapter 1 - Introducing XML -- Set- Accessing the attribute to the XML element XML with DOM, SAX, JAXB, and StAX v_attr := DBMS_XMLDOM.setAttributeNode(v_elem, Chapter 3 - Transforming XML with XSLT and XPath v_attr,'http://www.example.com' ); Chapter 2 Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5 PL/SQL - XML Operations XQuery After the function iswith created, you then test it as follows: Chapter 6

- XML Messaging and RPC with SOAP

set autoprint on Putting It All Together with XML Pipeline, JSPs, and XSQL var out -clob Part II - Oracle XML Management for DBAs BEGIN Chapter 8 - Getting Started with the Oracle XML Database SELECT appendChild(XMLType('<person> Chapter 9 - Storing XML Data <name> John Smith </name> Chapter 10 - Generating and Retrieving XML <address> XYZ street, CA 12345</address> Chapter 11 - Searching XML Data </person>')).getClobVal() INTO :out Chapter 12 - Managing the Oracle XML Database FROM DUAL; Part III - Oracle XML for Java Developers END; Chapter / 13 - Getting Started with Oracle XML and Java Chapter 7

Chapter 14 - Building an XML-Powered Web Site

The output the procedure is the XML with the new element inserted, as follows: Chapter 15 - of Creating a Portal Site with XML and Web Services <person> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <name> John Smith </name> Chapter 17 - Developing XML-Based Reusable Components xmlns:my="http://www.example.com"/> Part<my:notes IV - Oracle XML for C Developers <address> XYZStarted street, CA 12345</address> Chapter 18 - Getting with Oracle XML and C </person> Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

Retrieving XML Data Using XPath

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

TheUPDATEXML() function in Oracle Database 10g can update XML elements selected by XPaths in XMLTypes.

Chapter 22 -instead GettingofStarted with Oracle XML anddocument, C++ However, updating the original XML UPDATEXML() creates a new XML document with the

Chapter 23To - Build an XML Database OCI C++ Application updates. edit and update the original XML document, you need to use DOM APIs provided by DBMS_XMLDOM. Chapter 24 - Building an XML Data-Retrieval Application

InChapter 10, we showed an example that selects XML elements using Part VI - Oracle XML for PL/SQL Developers DBMS_XMLDOM.GetElementsByTagName() and updates their content. In this section, we extend this example on Chapter 25 - Getting Started with Oracle XML and PL/SQL discussing to select XML elements Chapter 26 - how Building PL/SQL Web Servicesusing three XPath functions in the DBMS_XSLPROCESSOR package and update27 the- selected DBMS_XMLDOM. The following are the three XPath interfaces provided in Chapter Extendingcontent PL/SQLusing XML Functionality with Java DBMS_XSLPROCESSOR: Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications SelectNodes (n DOMNode, pattern VARCHAR2, namespace VARCHAR2) Selects nodes from a DOM tree

Glossary that match the given XPath pattern. It returns the result as the DBMS_XMLDOM.NodeListobject. Index

(n DOMNode, pattern VARCHAR2, namespace VARCHAR2) Selects the first node as a List ofSelectSingleNodes Figures object from the DOM tree that matches the given XPath pattern. List ofDBMS_XMLDOM.DOMNode Tables List of Sidebars

ValueOf(n DOMNode, pattern VARCHAR2, value VARCHAR2, namespace VARCHAR2) Retrieves the value of the first node in a string from the DOM tree that matches the given XPath pattern.

To update XML elements using XPath, you need to first select the XML elements by using DBMS_XSLPROCESSOR.SelectNodes(). Before you use this interface, you need to get the DBMS_XMLDOM.DOMDocument object either parsed by DBMS_XMLPARSER or created using the DBMS_XMLDOM.newDocument(). Next, you need to get the document element and create a DOM node using DBMS_XMLDOM.MakeNode()that you can process:


v_doc DBMS_XMLDOM.DOMDocument; v_ndoc DBMS_XMLDOM.DOMNode; … Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & v_ndoc := DBMS_XMLDOM.makeNode(dbms_xmldom.getDocumentElement(v_doc)); PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

Then, you get the first child of the document node, which will be the root of the DOM document:

ISBN:0072229527

v_fnode := This DBMS_XMLDOM.getFirstChild(v_node); comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Next, you can call DBMS_XSLPROCESSOR.SelectNodes()function with the document root node as the first parameter and the XPath as the second parameter, as follows:

Table of Contents

v_nodeList := DBMS_XSLPROCESSOR.selectNodes(v_fnode, '/Txn/Data/@value');

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Introduction A DOM node list will be returned from the DBMS_XSLPROCESSOR.SelectNodes()function. Then, you can iterate Part - Oracle andtothe XML Standards overI each node update the DOM object using the DBMS_XMLDOM.setNodeValue() function:

Chapter 1

- Introducing XML

v_nl := DBMS_XMLDOM.getLength(v_nodeList); - Accessing XML with DOM, SAX, JAXB, and StAX v_sum := 0; Chapter 3 - Transforming XML with XSLT and XPath IF v_nl > 0 THEN Chapter Validating XML with DTDs and XML Schemas FOR 4j -in 0..v_nl-1 LOOP Chapter 2

Chapter 5

- XML Operations with XQuery

Chapter 6 - XML:= Messaging and RPC with SOAP v_node DBMS_XMLDOM.item(v_nodeList,j); Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL DBMS_XMLDOM.setNodeValue(v_node,'<new value>'); Part II -LOOP; Oracle XML Management for DBAs END

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

Processing XML Using XSLT

Chapter 11 - Searching XML Data

Chapter 12 Database - Managing10g, the you Oracle In Oracle canXML useDatabase XMLType.transform() to apply XSL stylesheets on XML documents, which is Part III - Oracle XMLto fortransform Java Developers normally a process XML documents. However, in this section, we discuss how you can leverage XSLT

Chapter 13 - XML Getting Started with Oracle and Java to process data. We compare theXML XSLT approach with the DOM approach. You will see that using XSLT to Chapter process14XML - Building data sometimes an XML-Powered is much Web easier Site than using DOM. Chapter 15 - Creating a Portal Site with XML and Web Services

The example is a process, which gets an input XML document containing a collection of data from an application transaction and needs to calculate the sum of all the data values. The input document is as follows:

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

<Txn> Part IV - Oracle XML for C Developers <Data Chapter 18 -value="18.75"/> Getting Started with Oracle XML and C <Data Chapter 19 -value="17.32"/> Building an XML-Managed Application <Data value="16.45"/> <Data value="15.82"/> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine </Txn> Chapter 20 - Build an XML Database OCI Application Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle C++ nodes, read out the numbers in the value attributes, and add Using DOM, you need to iterate over allXML theand <Data> Chapter 23 - Build an sample XML Database C++ Application them together. The code isOCI as follows: Chapter 24 - Building an XML Data-Retrieval Application

DECLARE v_xmlbuf VARCHAR2(512); Chapter 25 - Getting Started with Oracle XML and PL/SQL v_parser DBMS_XMLPARSER.Parser; Chapter 26 - BuildingDBMS_XMLDOM.DOMDocument; PL/SQL Web Services v_xmldoc Chapter 27 Extending PL/SQL XML Functionality with Java v_outbuf VARCHAR2(600); Chapter 28 - Putting DBMS_XMLDOM.DOMNode; It All Together v_node Appendix - XML Standards Bodies and Open Specifications v_fnode DBMS_XMLDOM.DOMNode; Glossary v_nodeList DBMS_XMLDOM.DOMNodeList; Index v_nl NUMBER; NUMBER; List v_value of Figures NUMBER :=0; List v_sum of Tables ListBEGIN of Sidebars v_xmlbuf := '<Txn><Data value="18.75"/><Data value="17.32"/>' || '<Data value="16.45"/><Data value="15.82"/></Txn>'; -- Initialize the XML parser v_parser := DBMS_XMLPARSER.newParser; -- Parse XML document DBMS_XMLPARSER.parseBuffer(v_parser, v_xmlbuf); v_xmldoc := DBMS_XMLPARSER.getDocument(v_parser); v_node := DBMS_XMLDOM.makenode(v_xmldoc); Part VI - Oracle XML for PL/SQL Developers


v_fnode := DBMS_XMLDOM.getfirstchild(v_node); -- Select <Data> elements Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & v_nodeList:=DBMS_XSLPROCESSOR.selectNodes(v_fnode, PL/SQL '/Txn/Data/@value'); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang v_nl := McGraw-Hill/Osborne DBMS_XMLDOM.getLength(v_nodeList); © 2004 (600 pages) DBMS_OUTPUT.put_line('The length of the node list:'||v_nl); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with -- Iterate the <Data> elements and sumand the attributes emphasis on XML standards, their usage bestvalue practices. v_sum:=0; IF v_nl > 0 THEN Table of Contents for j in 0..v_nl-1 loop Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL v_node := DBMS_XMLDOM.item(v_nodeList,j); Introduction v_value := DBMS_XMLDOM.getNodeValue(v_node); Part I - Oracle and the XML Standards v_sum := v_sum+v_value; Chapter 1 -LOOP; Introducing XML END Chapter 2 Accessing XML with DOM, SAX, JAXB, and StAX DBMS_OUTPUT.put_line('Sum='||v_sum); Chapter 3 - Transforming XML with XSLT and XPath ELSE Chapter 4 - Validating XML with DTDsnode and XML Schemas DBMS_OUTPUT.put_line('No selected'); Chapter - XML Operations with XQuery END 5IF; Chapter END; 6 - XML Messaging and RPC with SOAP / Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL show Part II -errors; Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

The DOM operation requires parsing the XML document, selecting the <Data> elements, and iterating all the Chapter 9 - Storing XML Data <Data> elements to calculate the sum of all the values. Instead of doing that, you can use the following XSL Chapter 10 - Generating and Retrieving XML stylesheet, which can do the same job: Chapter 11 - Searching XML Data

<xsl:stylesheet Chapter 12 - Managing version="2.0" the Oracle XML Database xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> Part III - Oracle XML for Java Developers <xsl:template match="/"> <xsl:value-of select="sum(Txn//Data/@v)"/> Chapter 14 - Building an XML-Powered Web Site </xsl:template> Chapter 15 - Creating a Portal Site with XML and Web Services </xsl:stylesheet> Chapter 13 - Getting Started with Oracle XML and Java

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 operation - Developing Thus, the canXML-Based be done inReusable a single Components SQL command as follows: Part IV - Oracle XML for C Developers

SELECT XMLType('<Txn> <Data value="18.75"/> Chapter 19 - Building an <Data XML-Managed Application value="17.32"/> Chapter 20 - Build an XML Database OCI Application <Data value="16.45"/> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine <Data value="15.82"/> Part V Oracle XML for C++ Developers </Txn>').transform(XMLType('<xsl:stylesheet version="2.0" Chapter 22 - Getting Started with Oracle XML and C++ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> Chapter 23 - Build anmatch="/"> XML Database OCI C++ Application <xsl:template Chapter <xsl:value-of 24 - Building anselect="sum(Txn//Data/@value)"/> XML Data-Retrieval Application Part </xsl:template> VI - Oracle XML for PL/SQL Developers </xsl:stylesheet>')) AS Oracle result Chapter 25 - Getting Started with XML and PL/SQL FROM DUAL; Chapter 26 - Building PL/SQL Web Services Chapter 18 - Getting Started with Oracle XML and C

Chapter 27 - Extending PL/SQL XML Functionality with Java

Using XSLT, you don’t have to write programs to traverse DOM objects, and it is much more efficient. Therefore, XSLT is not limited to transforming XML documents. You sometimes can leverage its functionality, especially using Appendix - XML Standards Bodies and Open Specifications XPath functions, to process XML data. Chapter 28 - Putting It All Together Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Setting Up Oracle JVM PL/SQL

ISBN:0072229527 by Mark V. Scardina, Chang and Jinyuwithin Wang the Oracle database. When you are creating With Oracle JVM, you can leverageBen Java programming © 2004 (600 pages) databases withMcGraw-Hill/Osborne Oracle Database Configuration Assistant (DBCA), Oracle JVM is an option. If you select the Oracle JVM option, the number of loaded guide Java schema objects in the should be Oracle's more than 8000 for Oracle This comprehensive focuses on utilizing XMLdatabase technologies within XML-enabled products, with standards, their usage and best practices. Database 10g emphasis when youon areXML querying as SYS using the following SQL command:

SELECT count (*) Table Contents FROMof user_objects Oracle WHERE Database object_type='JAVA 10g XML & SQL—Design, CLASS'; Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Otherwise, you need connect to the Oracle database as SYS user andrun the Part I - Oracle and the to XML Standards $ORACLE_HOME/javavm/install/initjvm.sql and $ORACLE_HOME/rdbms/admin/catjava.sql scripts, as follows: Chapter 1 - Introducing XML SQL>@javavm/install/initjvm.sql Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX SQL>@rdbms/admin/catjava.sql Chapter 3 - Transforming XML with XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

Note While Oracle XDK Java libraries can be loaded into the SYS user schema by running the - XML Operations with XQuery $ORACLE_HOME/xdk/admin/initxml.sql in SYS, it is not recommended to do so because you may wish Chapter 6 - XML Messaging and RPC with SOAP to reload the libraries to leverage new XDK features or bug fixes in a release on OTN. To simplify the Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL maintenance of XDK Java libraries in Oracle JVM, you can create a new database user, for example XDK, Part II - Oracle XML Management for DBAs and load the Java libraries into this user schema instead of SYS. Chapter 5

Chapter 8

- Getting Started with the Oracle XML Database

Chapter To run 9initjvm.sql - Storing successfully, XML Data you also need reasonable sizes for SHARE_POOL_SIZE and JAVA_POOL_SIZE.

The recommended sizes are as follows: Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data shared_pool_size = 50000000 Chapter 12 - Managing= the Oracle XML Database java_pool_size 20000000 Part III - Oracle XML for Java Developers

After you Oracle JVM, youOracle can load, Chapter 13 install - Getting Started with XML compile, and Java and run Java programs in the Oracle database by creating Java stored procedures. 27, weWeb will Site discuss how you can leverage Java Stored Procedures to process XML Chapter 14 - Building In anChapter XML-Powered using SAX PL/SQL. Chapter 15 - from Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ISBN:0072229527 V. Scardina, and Jinyu and Wang In this chapter,by weMark introduced you toBen theChang SQL XMLType PL/SQL XML functionality within Oracle Database 10g McGraw-Hill/Osborne © 2004 (600 pages) and showed you through several examples how to use the functions to process XML data in the Oracle database. The easy-to-use SQL functions should your first choice when processing XML Oracle XML-enabled Database 10g. You with This comprehensive guidebe focuses on utilizing XML technologies withininOracle's products, on XML standards, theironly usage andyou best practices. should use theemphasis PL/SQL XML processing APIs when require fine-grained XML processing of XML documents that is not available in the SQL/XML or XMLType functions.

Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 26:Database Building PL/SQL Web Services PL/SQL

Overview

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

The open and standards-based emphasis on XML standards, web services their are usage gaining andmore best practices. and more attention in the software industry because they provide a way for heterogeneous systems to interoperate by sharing data over the Internet. In Oracle Database 10g,of web service features are provided to facilitate publishing database data, metadata, and PL/SQL computing Table Contents resources as web services. Additionally, the web service features allow database users to consume external web Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL services within the database server. Introduction

Part I - Oracle and XML Standards In this chapter, wethe work through examples that illustrate how you can publish database resources as web services

Chapter 1 - Introducing XML in Oracle Database 10g. We assume in this discussion that you understand the basic and consume web services Chapter 2 of - Accessing XML with SAX, JAXB, StAX concepts web services, suchDOM, as the format of and SOAP messages and WSDL files. If you are not familiar with these Chapter 3 - Transforming XMLChapter with XSLT and XPath web service protocols, read 6 before you move on to the content in this chapter. Chapter 4

- Validating XML with DTDs and XML Schemas

In the “Extending the Application” section, we discuss in which situations you need to implement a web service Chapter 5 - XML Operations with XQuery inside the database,and how to protect your database from destructive users, and the different kinds of web Chapter 6 -Oracle XML Messaging RPC with SOAP services that you can create. - Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 7

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


OraclePublishing Database 10g XML SQL: Design, Build & Manage XML Applications in Java, C, C++ & Building and the& First Database Web Service PL/SQL

V. Scardina, Ben Chang andfor Jinyu Wang bookstore, Big Barrel Books (BBB), thatISBN:0072229527 In this section, by weMark discuss building a web service a fictitious needs to McGraw-Hill/Osborne © 2004 pages) enable its partners to promote and sell its (600 books. Through web services, BBB’s partners will be able to query and update its catalog books in the Oracle database. Thisof comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Setting Up the Database Schema

Table of Contents

Oracle In realDatabase applications, 10g XML the database & SQL—Design, schema Build that& isManage set upXML to manage Applications a bookstore in Java, may C, C++ be very & PL/SQL complicated. It may

require more than one table, with many columns in each table, such as a separate table to store data for the authors Introduction of the in this example, to help you focus on the techniques of building web services, we have greatly Part I - book. OracleHowever, and the XML Standards simplified definition of these tables. Therefore, the following table, called book, is created to store the records of Chapter 1 the - Introducing XML books: 2 Chapter

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter CREATE 3 TABLE - Transforming book( XML with XSLT and XPath

ISBN PRIMARY KEY, Chapter 4 VARCHAR2(200) - Validating XML with DTDs and XML Schemas author varchar2(200), Chapter 5 - XML Operations with XQuery title Chapter 6 -VARCHAR2(200), XML Messaging and RPC with SOAP price Chapter 7 -FLOAT, Putting It All Together with XML Pipeline, JSPs, and XSQL Partinstock_num II - Oracle XML NUMBER(20) Management for DBAs

); 8 Chapter

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

In addition to the book table, a partner table is created to store information about the bookstore’s partners and a book_sale table is created to store the partners’ transactions that are executed within the database:

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

CREATE TABLE partner( partner_id NUMBER PRIMARY KEY, Part III - Oracle XML for Java Developers partner_name VARCHAR2(200), Chapter 13 - Getting Started with Oracle XML and Java discount_rate NUMBER); Chapter 12 - Managing the Oracle XML Database

Chapter 14 - Building an XML-Powered Web Site

Chapter 15TABLE - Creating a Portal Site with XML and Web Services CREATE book_sale( Chapter 16VARCHAR2(12), - Developing an XML Gateway Application with SOAP and AQ ISBN Chapter 17 - Developing op_time DATE, XML-Based Reusable Components Partpartner_id IV - Oracle XML for C Developers NUMBER,

Chapter 18 - Getting Started with Oracle XML and C checkout_num NUMBER); Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

In this example, a discount rate is assigned for each partner that is stored in the partner table. The book_saletable Chapter 21 - Create an XML-Configured High-Performance Transformation Engine keeps details each Part V - the Oracle XMLof for C++transaction Developerson the book table, including the ISBN of the book, the time of the transaction, the ID of partnerStarted that performs the transaction, Chapter 22the - Getting with Oracle XML and C++and the number of items checked out of the inventory. You can insert the sample data into the book table as follows:

Chapter 23 - Build an XML Database OCI C++ Application

INSERT book Loney, Chapter 24INTO - Building an VALUES('0072225211','Kevin XML Data-Retrieval Application George Koch, Part VI - Oracle XMLTusc','Oracle9i: for PL/SQL DevelopersThe

Complete Reference',74.99,1000); INSERT INTO book VALUES('0072229527', Chapter 25 - Getting Started with Oracle XML and PL/SQL 'Mark 26 Scardina, Ben Chang, Jinyu Wang', Chapter - Building PL/SQL Web Services 'Oracle Database 10g XML and SQL',49.99,1000); Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

You can insert partners into the database as follows:

Appendix

- XML Standards Bodies and Open Specifications

INSERT INTO partner VALUES(1,'book wholesale',0.6);

Glossary

Index This example inserts a sample partner called Book Wholesale and assigns it a 60 percent price discount from this List of Figures bookstore. List of Tables

In the example, two web services will be provided. The first one allows the partners to query the database and list all List of Sidebars the information about the books they can sell, including the title, author, and price of each book. The query shows both the original price and the price the partner can get after applying the discount rate. The second web service is a transactional operation that allows the partners to check out books from the bookstore’s inventory. After each transaction, the transaction information is stored in the book_sale table for later reference. A PL/SQL package called booksale_pkg is created to allow transaction operations as follows: CREATE OR REPLACE PACKAGE booksale_pkg AS FUNCTION query(p_partner_id IN NUMBER) RETURN XMLType; FUNCTION checkout(p_partner_id IN NUMBER, p_isbn in VARCHAR2,


p_book_num IN NUMBER) RETURN VARCHAR2; END booksale_pkg; / Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

The two functions in the PL/SQL package can be used to provide the services, and the PL/SQL package body for ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang booksale_pkg is created as follows: McGraw-Hill/Osborne © 2004 (600 pages)

CREATE OR REPLACE PACKAGE guide BODYfocuses booksale_pkg This comprehensive on utilizing AS XML technologies within Oracle's XML-enabled products, with FUNCTION emphasis query(p_partner_id INtheir NUMBER) RETURN XMLType AS on XML standards, usage and best practices. out XMLType; qryCtx DBMS_XMLGEN.ctxHandle; Table of Contents BEGIN Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL qryCtx := DBMS_XMLGEN.NEWCONTEXT( Introduction 'SELECT b.partner_id AS "@partner_id", a.isbn, a.author, Part I - Oracle and the XML Standards a.title, a.price, a.price*discount_rate AS sale_price Chapter 1 - Introducing XML FROM book a, partner b Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX WHERE b.partner_id=:PARTNER_ID'); Chapter 3 - Transforming XML with XSLT and XPath'PARTNER_ID', p_partner_id); DBMS_XMLGEN.setBindValue(qryCtx, Chapter 4 -:= Validating XML with DTDs and XML Schemas out DBMS_XMLGEN.GETXMLTYPE(qryCtx); Chapter 5 - XML Operations with XQuery DBMS_XMLGEN.closeContext(qryCtx); Chapter 6

- XML Messaging and RPC with SOAP

Chapter RETURN 7 - Putting out;It All Together with XML Pipeline, JSPs, and XSQL PartEND II - Oracle query; XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

FUNCTION checkout(p_partner_id IN NUMBER,p_isbn IN VARCHAR2, Chapter 9 - Storing XML Data p_book_num IN NUMBER) RETURN VARCHAR2 AS Chapter 10 - Generating and Retrieving XML out XMLType; Chapter 11 - Searching XML Data current_num Chapter 12 - Managing NUMBER; the Oracle XML Database BEGIN Part III - Oracle XML for Java Developers INSERT INTO book_sale VALUES(p_isbn,sysdate,p_partner_id, Chapter 13 - Getting Started with Oracle XML and Java p_book_num); Chapter 14 - Building an XML-Powered Web Site UPDATE book Chapter 15 - Creating a Portal Site with XML and Web Services SET instock_num=instock_num-p_book_num Chapter 16 - Developing an XML Gateway Application with SOAP and AQ WHERE isbn=p_isbn; Chapter 17 - Developing XML-Based Reusable Components COMMIT; Part IV - Oracle XML for C Developers RETURN 'OK'; Chapter 18 - Getting Started with Oracle XML and C EXCEPTION Chapter 19 -OTHERS Building an XML-Managed Application WHEN THEN Chapter 20 Build an XML Database OCI Application RETURN 'FAILED'; Chapter 21 Create an XML-Configured High-Performance Transformation Engine RAISE; PartEND V - Oracle XML for C++ Developers checkout; Chapter 22 - Getting Started with Oracle XML and C++ END booksale_pkg; Chapter / 23 - Build an XML Database OCI C++ Application show errors; Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

In the query() function, DBMS_XMLGEN used to generate the result in XML and return it as an XMLType. To get Chapter 25 - Getting Started with Oracle XMLisand PL/SQL the XMLType, you need to use the DBMS_XMLGEN.GETXMLTYPE() function. In the checkout() procedure, the book table is updated by subtracting the requested number of books from the inventory and returning a string in Chapter 27 - Extending PL/SQL XML Functionality with Java VARCHAR2, which returns OK if enough books exist in inventory to fill the order, and otherwise returns FAILED. Chapter 26 - Building PL/SQL Web Services Chapter 28 - Putting It All Together

Appendix XML Standards Bodies and Open Specifications Before you- deploy the PL/SQL package to web services, you need to test it within the Oracle database, because Glossary debugging a web service is difficult. For example, the query to test Book Wholesale can be as follows: Index LONG 10000 List of Figures SET AUTOPRINT ON List of Tables VAR out CLOB List of Sidebars BEGIN

:out := booksale_pkg.query(1).getCLOBVal(); END; /

The output is the listing of the books stored in the book table, including the actual price and the discount price for the Book Wholesale partner: <ROWSET>


<ROW partner_id = "1"> <ISBN>0072225211</ISBN> <AUTHOR>Kevin Loney, George Koch, Tusc</AUTHOR> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <TITLE>Oracle9i: The Complete Reference</TITLE> PL/SQL <PRICE>74.99</PRICE> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <SALE_PRICE>44.994</SALE_PRICE> McGraw-Hill/Osborne © 2004 (600 pages) </ROW> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with <ROW partner_id "1"> emphasis= on XML standards, their usage and best practices. <ISBN>0072229527</ISBN> <AUTHOR>Mark Scardina, Ben Chang, Jinyu Wang</AUTHOR> Table of Contents <TITLE>Oracle Database 10g XML and SQL</TITLE> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL <PRICE>49.99</PRICE> Introduction <SALE_PRICE>29.994</SALE_PRICE> Part I - Oracle and the XML Standards </ROW> Chapter 1 - Introducing XML </ROWSET> Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter A similar 3 test - Transforming applies for the XMLcheckout() with XSLT and function, XPathwhich is provided along with the samples for this chapter. Chapter 4

- Validating XML with DTDs and XML Schemas

So far, we-have built the database schema for a simplified book management system. In the following section, we XML Operations with XQuery publish the PL/SQL package as a web service and show you how to call the web service from its clients.

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Publishing the PL/SQL Web Service Using Oracle JDeveloper 10g

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

The bookstore has XML provided Chapter 9 - Storing Data the PL/SQL functions to operate on the book table and track the transactions. In this section, we discuss how to publish PL/SQL functions as web services. There are different ways to provide web Chapter 10 - Generating and Retrieving XML services, as we will discuss in depth later. However, to create a web service, you need provide at least the following: Chapter 11 - Searching XML Data

Chapter 12 - Managing Oraclewithin XML Database A proxy program,the residing the server, that processes the incoming SOAP messages, calls the PL/SQL Part III - Oracle XML Developers procedure, and for thenJava returns the result to the client via SOAP messages

Chapter 13 - Getting Started with Oracle XML and Java

A dedicated server running the proxy program to receive SOAP messages Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

A WSDL file that describes the web service, so that clients can easily develop client applications to call the service

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Part IV build - Oracle XML for from C Developers If you everything scratch, a lot of work is required. To help you simplify the process, Oracle JDeveloper

Chapter 18 - Getting Started withautomatically Oracle XML and C 10gprovides a wizard that can generate the proxy program, the WSDL file, and the stub program for Chapter - Building an as XML-Managed the web19service client, well as the Application deployment profile, and the required features to debug them. All you need to Chapter do is provide 20 - Build the an name XMLofDatabase the PL/SQL OCI package. Application Therefore, before we present the alternate approach that requires

more work, we will an discuss the procedures for creating PL/SQL web services Chapter 21 - Create XML-Configured High-Performance Transformation Enginevia the wizard. Part V - Oracle XML for C++ Developers

First, open the Oracle JDeveloper 10g project provided along with the book and set up a database connection, as discussed in Chapter 13. For example, create a database connection called demo, which connects to the database Chapter 23 - Build an XML Database OCI C++ Application using the user for whom you just set up the book management schemas. Chapter 22 - Getting Started with Oracle XML and C++

Chapter 24 - Building an XML Data-Retrieval Application

Part VIthe - Oracle XML for Developers After connection is PL/SQL set up, right-click the project name and select New. In the New Gallery dialog box, select

Chapter 25 -Tier Getting Started with Oracle XMLWeb and PL/SQL Business | Web Services | PL/SQL Service. This launches the Oracle JDeveloper 10g wizard that Chapter - Building PL/SQL Web Services enables26you to create PL/SQL web services through which you can access the PL/SQL procedures. Chapter 27 - Extending PL/SQL XML Functionality with Java

After you NextIton Welcome screen, you should see the dialog box shown in Figure 26-1, which requires Chapter 28 click - Putting Allthe Together you to specify the databaseBodies connection, theSpecifications PL/SQL package, the name of the web service, and the name of the Appendix - XML Standards and Open Java package that is used for the generated proxy program.

Glossary Index

List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Figure 26-1: StepXML 1 ofwith the DOM, Create PL/SQL Service wizard Chapter 2 - Accessing SAX, JAXB,Web and StAX Chapter 3

- Transforming XML with XSLT and XPath

Note You can access the same wizard by right-clicking the package itself when it is displayed in the Connection - Validating XML with DTDs and XML Schemas Navigator.

Chapter 4 Chapter 5

- XML Operations with XQuery

Chapter 6 select - XML Messaging andconnection, RPC with SOAP After you the database select the BOOKSALE_PKG from the available PL/SQL packages in the Chapter 7 - list. Putting It All Together with XML Pipeline, JSPs, XSQLservice and the Java package. In the example, drop-down In this step, you can specify any name for and the web Part II - Oracle XML Management DBAs BookSaleService is the name offor the web service and demo is the name of the Java package of the proxy program.

Chapter 8 -after Getting with the Oracle XML Database Click Next you Started have completed the page. Chapter 9

- Storing XML Data

Step 2 10 of the wizard requires you to select Chapter - Generating and Retrieving XML the PL/SQL procedures from the PL/SQL package to publish as part of the web service, as shown in Figure 26-2. In this example, both the checkout() and query() procedures are selected. After selecting the PL/SQL procedures, you can continue by clicking the Next button.

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI Figure - Oracle 26-2: XML Select for PL/SQL the PL/SQL Developers procedures.

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Before 26 you- complete the PL/SQL web service creation step, you are requested to specify the endpoint URL for the Chapter Building PL/SQL Web Services

web service and its target namespace. The endpoint URL needs to reflect the J2EE server you want to deploy the web service to. For example, in the provided sample project, the J2EE application name is set to be Chapter26, and Chapter 28 - Putting It All Together you will deploy the web service to the embedded Oracle J2EE Container (OC4J) of Oracle JDeveloper 10g, which Appendix - XML Standards Bodies and Open Specifications runs on port 8988 by default. Therefore, the endpoint URL for BookSaleService is Glossary http://127.0.0.1:8988/Chapter26/ BookSaleService. You can specify any target namespace here. In this example, Index we usehttp://demo/BookSaleService.wsdl. Chapter 27 - Extending PL/SQL XML Functionality with Java

List of Figures

List After of Tables you complete the wizard, a set of files are created, as shown in Figure 26-3. List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Figure 26-3: Generated web service Chapter 10 - Generating and Retrieving XML for the PL/SQL package Chapter 11 - Searching XML Data

You now have all the prerequisites to build a web service:

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

The proxy program You can download and review the source code via the web service user interface, as

Chapter 13 - Getting with Oracle XML and Java discussed laterStarted in this section. Chapter 14 - Building an XML-Powered Web Site

The running theSite deployed proxy program This is the embedded OC4J in Oracle JDeveloper 10g. Chapter 15server - Creating a Portal with XML and Web Services However, a deployment file, called WebServices.deploy, has AQ been created to allow you to deploy the proxy Chapter 16 - Developing an XML Gateway Application with SOAP and program to other OC4J containers. In the example, this server is the OC4J web server. Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

The WSDL file This file summarizes the signatures of the methods exposed by the web service. To review this file, right-click the BookSaleService description file in the Applications Navigator and choose Go to WSDL.

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Chapter - Build OCI Right-click Applicationthe BookSaleService description file and select Run. In the You are20ready to an runXML the Database web service. Chapter message 21 window - Createof anOracle XML-Configured JDeveloper High-Performance 10g, you will seeTransformation the following messages: Engine Part V - Oracle XML for C++ Developers 04/02/10 11:52:26 Oracle Application

Server Containers for J2EE 10g

Chapter 22 - Getting Started with Oracle XML and C++ (9.0.4.0.0) initialized Chapter 23 - Build an XMLWeb Database OCI C++ Application 04/02/10 11:52:26 service BookSaleService has been started on Chapter 24 - Building an XML Data-Retrieval Application the embedded server Part - Oracle XML forcan PL/SQL Developers at TheVIapplication be accessed

location:

Chapter http://169.254.74.222:8988/Chapter26/BookSaleService 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Pay no27 attention to thePL/SQL IP address that is displayed, because it is the IP address automatically detected by Oracle Chapter - Extending XML Functionality with Java JDeveloper 10g when you run the samples. The IP address will be different when you run it. Now you can launch your browser and enter the URL, http://127.0.0.1:8988/Chapter26/BookSaleService, to access your up-andAppendix - XML Standards Bodies and Open Specifications running web service, as shown in Figure 26-4. Chapter 28 - Putting It All Together Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Figure 26-4: Published web service user interface Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Through this web interface, you can download the Java package and source code for the proxy program, test each - Getting Started with the Oracle XML Database operation, and review the WSDL file.

Chapter 8 Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

Calling the Web Service from Clients

Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database

Because web services are open and standards-based, they have little restriction on the clients that can invoke them. As long as the client follows the standards and sends the SOAP message in the correct format, the web service will Chapter 13 - Getting Started with Oracle XML and Java respond whether it is written in Java, JavaScript, ASP, JSP, or Perl. However, in Oracle JDeveloper 10g, you can Chapter 14 - Building an XML-Powered Web Site easily generate Java client programs that call web services. You just need to right-click the BookSaleService Chapter 15 - file Creating a PortalGenerate Site with Web XML and Web Stub. Services description and choose Service You can also choose Generate Simple Java Client to get a Chapter 16 version - Developing XML program. Gateway Application with SOAP and AQ simplified of thean client Part III - Oracle XML for Java Developers

Chapter 17 - Developing XML-Based Reusable Components

Figure shows dialog box in which you set up the wizard to generate the client stub program by right-clicking Part IV -26-5 Oracle XML the for C Developers the BookSaleService and with choosing Generate Service Stub. Chapter 18 - Getting Started Oracle XML and Web C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List ofFigure Figures26-5: Step 1 of the Generate Web Service Stub/Skeleton wizard List of Tables List of Sidebars

As shown in Figure 26-5, from a given WSDL, you can generate not only client-side stubs but also a server-side skeleton. However, in this example, we need only a simple client stub. After you choose the options shown in Figure 26-5 and click Next, you then need to choose the necessary functions for the client and the package name for the Java package that will be generated. In the example, a BookSaleServiceStub.java file will be created in the oracle.xml .sample.ws package. After the wizard generates the code, you need to update the code so that it can be used within your application. In this example, you first need to modify the generated code so that it can properly handle the XMLType, which will


be returned by the book query service (all the updated content is bold): import oracle.xdb.XMLType; Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang publicXMLType query(BigDecimal pPartnerId) throws Exception McGraw-Hill/Osborne © 2004 (600 pages) { XMLType returnVal = null; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis = on new XML standards, their usage and best practices. URL endpointURL URL(_endpoint); Call call = new Call(); call.setSOAPTransport(m_httpConnection); Table of Contents call.setTargetObjectURI("BookSaleService"); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL call.setMethodName("query"); Introduction Partcall.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Vector params = new Vector(); - Accessing XML with DOM, SAX, JAXB, and StAX params.addElement(new Parameter("pPartnerId", Chapter 3 - Transforming XML with XSLT and XPath java.math.BigDecimal.class, pPartnerId, null)); Chapter 4 - Validating XML with DTDs and XML Schemas call.setParams(params); Chapter 5 - XML Operations with XQuery call.setSOAPMappingRegistry(m_smr); Chapter 2

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Response response = call.invoke(endpointURL, ""); Partif II -(!response.generatedFault()) Oracle XML Management for DBAs

{

Chapter 8 - Gettingresult Started with the Oracle XML Database Parameter = response.getReturnValue(); Chapter 9 - Storing =XML Data returnVal (XMLType)result.getValue(); Chapter 10 - Generating and Retrieving XML } else { Chapter Fault 11 - Searching fault =XML response.getFault(); Data

throw new SOAPException(fault.getFaultCode(), Chapter 12 - Managing the Oracle XML Database fault.getFaultString()); Part III - Oracle XML for Java Developers } 13 - Getting Started with Oracle XML and Java Chapter Chapter 14 - Building an XML-Powered Web Site

return returnVal; Chapter 15 - Creating a Portal Site with XML and Web Services } Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

This proper datatype casting allows better use of XMLType functionality within Oracle XML DB.

Part IV - Oracle XML for C Developers

Chapter 18 the - Getting withyou Oracle and your C Then, for main()Started function, needXML to add code to specify how you call the web service. In the example, Chapter 19 -dump Building XML-Managed Application we simply the an result to the screen: Chapter 20static - Build anvoid XML Database OCI Application public main(String[] args) Chapter 21 - Create an XML-Configured High-Performance Transformation Engine { Parttry V - Oracle XML for C++ Developers {

Chapter 22 - Getting Started with Oracle and BookSaleServiceStub(); C++ BookSaleServiceStub stub XML = new Chapter 23Add - Build an XML OCI C++ Application // your ownDatabase code here. Chapter System.out.println( 24 - Building an XML Data-Retrieval Application Part VI - Oracle stub.checkout(new XML for PL/SQL Developers BigDecimal(1),"0072225211",new

BigDecimal(10)));

System.out.println(stub.query(new BigDecimal(1)).getStringVal()); Chapter 25 - Getting Started with Oracle XML and PL/SQL }catch(Exception ex){ Chapter 26 - Building PL/SQL Web Services ex.printStackTrace(); Chapter 27 - Extending PL/SQL XML Functionality with Java } 28 - Putting It All Together Chapter } Appendix

- XML Standards Bodies and Open Specifications

Glossary

When calling the stub.checkout(), you need to provide the partner_id, ISBN, and number of the book to be checked out. However, the call to stub.query() needs some explanation. The stub.query() function returns the XMLType List Figures the book list in XML for the specified partner. Because the returned content is in the XMLType, which thatofcontains List of Tables provides the XMLType.getStringVal() procedure, the call finally returns the content in String so that it can be List of Sidebars printed. Index

Debugging the Web Service If you follow the instructions, everything should work fine when you generate and call the example web service. However, in the real world, something usually happens that requires you to debug the problem. A useful debug technique is to peek at the SOAP messages that are actually sent and received. In Oracle JDeveloper 10g, you can do this by using TCP Packet Monitor (select View | TCP Packet Monitor). After you open TCP Package Monitor,


click the green Play button to start the monitor. Each SOAP message is then recorded in the History window, and the Data window shows both the incoming and outgoing SOAP message content. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

For the checkout service call, the outgoing SOAP message is shown as follows: PL/SQL

<?xml version = '1.0' encoding = 'UTF-8'?> ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang <SOAP-ENV:Envelope McGraw-Hill/Osborne © 2004 (600 pages) xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" emphasis on XML standards, their usage and best practices. xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> Table of Contents <ns1:checkout xmlns:ns1="BookSaleService" Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> Introduction <pPartnerId xsi:type="xsd:decimal">1</pPartnerId> Part I - Oracle and the XML Standards <pIsbn xsi:type="xsd:string">0072225211</pIsbn> Chapter 1 - Introducing XML <pBookNum xsi:type="xsd:decimal">10</pBookNum> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX </ns1:checkout> Chapter 3 - Transforming XML with XSLT and XPath </SOAP-ENV:Body> Chapter 4 - Validating XML with DTDs and XML Schemas </SOAP-ENV:Envelope> Chapter 5

- XML Operations with XQuery

It returns messageand as RPC follows: Chapter 6 a- SOAP XML Messaging with SOAP Chapter - Putting = It All Together with XML=Pipeline, JSPs, and XSQL <?xml 7version '1.0' encoding 'UTF-8'?> Part II - Oracle XML Management for DBAs <SOAP-ENV:Envelope

Chapter xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 8 - Getting Started with the Oracle XML Database

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Chapter 9 - Storing XML Data xmlns:xsd="http://www.w3.org/2001/XMLSchema"> Chapter 10 - Generating and Retrieving XML <SOAP-ENV:Body> Chapter 11 - Searching XML Data <ns1:checkoutResponse xmlns:ns1="BookSaleService" Chapter 12 - Managing the Oracle XML Database SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> Part III - Oracle XML for Java Developers xsi:type="xsd:string">OK</return> Chapter <return 13 - Getting Started with Oracle XML and Java </ns1:checkoutResponse> </SOAP-ENV:Body> Chapter 15 - Creating a Portal Site with XML and Web Services </SOAP-ENV:Envelope> Chapter 14 - Building an XML-Powered Web Site

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - messages Developing contain XML-Based Components The SOAP a lotReusable of information, including namespaces. However, you do not have to create Part IV -messages Oracle XML for C Developers SOAP yourself. The SOAP messages can be simply generated using the supplied tools in Oracle

Chapter 18 - Getting JDeveloper 10g. Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

So far, 20 the- web protocol and the interoperation between the bookstore owner and its Chapter Buildservice an XMLcommunication Database OCI Application partners beenanset up. From the example, you can see that publishing a PL/SQL web service for Oracle Chapter 21have - Create XML-Configured High-Performance Transformation Engine Database 10gXML can for be C++ a very simple process. Part V - Oracle Developers Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML Within & SQL: Design, & Manage XML Applications in Java, C, C++ & Consuming a Web Service the Build Oracle Database PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wangprocedures as web services, we will discuss Now that you have learned how to build and publish PL/SQL how to McGraw-Hill/Osborne © 2004the (600 pages) database. There are two ways to do this in Oracle Database consume an external web service within Oracle 10g: This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

Generate Java web service clients using Oracle JDeveloper 10g and create Java stored procedures. In this approach, you need to load the Java web service clients and the Oracle SOAP support libraries into the Oracle Table of Contents JVM. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Introduction Send out SOAP messages to the web service providers using the UTL_HTTP or UTL_SMTP PL/SQL Part Ipackages. - Oracle and the XML Standards

Chapter 1

- Introducing XML

Because are many Oracle Technology Chapter 2 there - Accessing XMLexamples with DOM,on SAX, JAXB, and StAX Network that illustrate the first approach, we discuss only the second approach, which require Oracle JVM. In this example, we will use UTL_HTTP to consume the Chapter 3 - Transforming XMLdoes with not XSLT and XPath bookstore serviceXML thatwith you DTDs just built. Chapter 4 -web Validating and XML Schemas Chapter 5

- XML Operations with XQuery

Constructing - XML Messaging SOAP and RPC Messages with SOAP

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

By applying theXML XML processing for techniques discussed in Chapter 10 and Chapter 25, you have several SOAP Part II - Oracle Management DBAs message options Oracle Database 10g. To simplify the example, you can use the PL/SQL string Chapter 8 construction - Getting Started withinthe Oracle XML Database operation to construct a SOAP message as follows (all the customized fields are bold): - Storing XML Data

Chapter 9

<?xml 10 version = '1.0' encoding Chapter - Generating and Retrieving XML = 'UTF-8'?> <SOAP-ENV:Envelope Chapter 11 - Searching XML Data xmslns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" Chapter 12 - Managing the Oracle XML Database Part III xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - Oracle XML for Java Developers

xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> Chapter 14 - Building an XML-Powered Web Site <ns1:query xmlns:ns1="BookSaleService" Chapter 15 - Creating a Portal Site with XML and Web Services SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <pPartnerId xsi:type="xsd:decimal">1</pPartnerId> Chapter 17 - Developing XML-Based Reusable Components </ns1:query> Part IV - Oracle XML for C Developers </SOAP-ENV:Body> Chapter 18 - Getting Started with Oracle XML and C </SOAP-ENV:Envelope> Chapter 13 - Getting Started with Oracle XML and Java

Chapter 19 - Building an XML-Managed Application Chapter The message 20 - Build is assigned an XML Database to a PL/SQL OCI Application variable to be used in your PL/SQL procedure as follows: Chapter 21 - Create:= an '<?xml XML-Configured High-Performance Transformation Engine soap_request version = "1.0" encoding = "UTF-8"?> Part V - Oracle XML for C++ Developers <SOAP-ENV:Envelope

Chapter 22 - Getting Started with Oracle XML and C++ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" Chapter 23 - Build an XML Database OCI C++ Application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Chapter xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 24 - Building an XML Data-Retrieval Application Part VI <SOAP-ENV:Body> - Oracle XML for PL/SQL Developers

<ns1:query xmlns:ns1="BookSaleService" Chapter 25 - Getting Started with Oracle XML and PL/SQL SOAP-ENV:encodingStyle= Chapter 26 - Building PL/SQL Web Services "http://schemas.xmlsoap.org/soap/encoding/"> Chapter 27 - Extending PL/SQL XML Functionality with Java <pPartnerId xsi:type="xsd:decimal">'|| p_partner_id||' Chapter 28 - Putting It All Together </pPartnerId> - XML Standards Bodies and Open Specifications </ns1:query> Glossary </SOAP-ENV:Body> Index </SOAP-ENV:Envelope>'; Appendix

List of Figures

List of Tables In this example, you can update the partner ID in the SOAP messages by using the p_partner_id parameter. List of Sidebars

Sending Out SOAP Messages Using UTL_HTTP After you create the SOAP message, you need to send it to the web service provider by using the UTL_HTTP package as follows: CREATE OR REPLACE FUNCTION query_request(p_partner_id IN number) RETURN XMLType as


soap_request VARCHAR2(32767); soap_respond VARCHAR2(32767); http_req Oracle UTL_HTTP.req; Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & http_respPL/SQL UTL_HTTP.resp; resp XMLType; ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang i NUMBER;McGraw-Hill/Osborne © 2004 (600 pages) len NUMBER; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with BEGIN emphasis on XML standards, their usage and best practices. soap_request := '<?xml version = "1.0" encoding = "UTF-8"?> <SOAP-ENV:Envelope Table of Contents xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Introduction xmlns:xsd="http://www.w3.org/2001/XMLSchema"> Part I - Oracle and the XML Standards <SOAP-ENV:Body> Chapter 1<ns1:query - Introducingxmlns:ns1="BookSaleService" XML Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX SOAP-ENV:encodingStyle= Chapter 3 - Transforming XML with XSLT and XPath "http://schemas.xmlsoap.org/soap/encoding/"> Chapter 4 - Validating XML with DTDs and XML Schemas <pPartnerId xsi:type="xsd:decimal">'|| p_partner_id||' Chapter 5 - XML Operations with XQuery </pPartnerId> Chapter 6</ns1:query> - XML Messaging and RPC with SOAP </SOAP-ENV:Body> Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL </SOAP-ENV:Envelope>'; Part II - Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data -- Invoke the SOAP messageXML using UTL_HTTP package Chapter 10 - Generating and Retrieving

http_req := utl_http.begin_request( Chapter 11 - Searching XML Data 'http://127.0.0.1:8988/Chapter27/BookSaleService', 'POST','HTTP/1.0'); Part III - Oracle XML for Java Developers UTL_HTTP.set_header(http_req, 'Content-Type', 'text/xml'); Chapter 13 - Getting Started with Oracle XML and Java UTL_HTTP.set_header(http_req, 'Content-Length', Chapter 14 - Building an XML-Powered Web Site length(soap_request)); Chapter 15 - Creating a Portal Site with XML and Web Services UTL_HTTP.set_header(http_req, 'SOAPAction', 'query'); Chapter 16 - Developing an XML Gateway Application with SOAP and AQ UTL_HTTP.write_text(http_req, soap_request); Chapter 17 - Developing XML-Based Reusable Components http_resp := UTL_HTTP.get_response(http_req); Part IVUTL_HTTP.read_text(http_resp, - Oracle XML for C Developers soap_respond); Chapter 18 - Getting Started with Oracle XML and C UTL_HTTP.end_response(http_resp); Chapter 19:= - Building an XML-Managed Application resp XMLType.createxml(soap_respond); Chapter 20 Build an XML Database OCI Application resp := resp.extract('/soap:Envelope/soap:Body/child::node()', Chapter 21 Create an XML-Configured High-Performance Transformation Engine 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"'); Part-V - Print Oracle XML for C++result Developers out the Chapter i := 221; - Getting Started with Oracle XML and C++ len 23 :=- Build LENGTH(soap_respond); Chapter an XML Database OCI C++ Application WHILE <= len) LOOP Chapter 24 -(i Building an XML Data-Retrieval Application DBMS_OUTPUT.PUT_LINE(substr(soap_respond, i, 60)); Part VI - Oracle XML for PL/SQL Developers i := + 60;Started with Oracle XML and PL/SQL Chapter 25 -iGetting END 26 LOOP; Chapter - Building PL/SQL Web Services RETURN resp; PL/SQL XML Functionality with Java Chapter 27 - Extending END; Chapter 28 - Putting It All Together / Appendix - XML Standards Bodies and Open Specifications show errors; Chapter 12 - Managing the Oracle XML Database

Glossary Index

List Figures TheofUTL_HTTP package is provided within the Oracle database, allowing you to send out the constructed SOAP List of Tablesvia HTTP. You need to set the HTTP URL for the web service provider, the data transmission method, messages List Sidebars andofthe HTTP version. In this example, the target URL for the web service is

http://127.0.0.1:8988/Chapter26/BookSaleService, the data transmission method is POST, and the HTTP version isHTTP 1.0: http_req := UTL_HTTP.begin_request( 'http://127.0.0.1:8988/Chapter26/BookSaleService', 'POST','HTTP/1.0'); Because SOAP messages are XML messages, the HTTP Content-Type is set to be text/xml: UTL_HTTP.set_header(http_req, 'Content-Type', 'text/xml');


Using the PL/SQL LENGTH() function, you can get the length of the SOAP message: UTL_HTTP.set_header(http_req, 'Content-Length', length(soap_request)); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

TheSOAPAction HTTP request parameter is needed in the HTTP header. In this example, it is the query() function PL/SQL we want to call.byTherefore, the SOAPAction request parameter is set to be query: ISBN:0072229527 Mark V. Scardina, Ben ChangHTTP and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) UTL_HTTP.set_header(http_req, 'SOAPAction', 'query'); This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

After the HTTPemphasis header isonset XML up,standards, the SOAPtheir message usage is and sent best out practices. by calling the UTL_HTTP .WRITE_TEXT() function and the response is received from the web service by using UTL_HTTP.GET_RESPONSE() and UTL_HTTP.READ_TEXT(): Table of Contents UTL_HTTP.write_text(http_req, soap_request); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL http_resp := utl_http.get_response(http_req); Introduction UTL_HTTP.read_text(http_resp, Part I - Oracle and the XML Standards

soap_respond);

UTL_HTTP.end_response(http_resp); Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

After you run the PL/SQL procedure, you can create an XMLType from the SOAP message received in the text:

resp := -xmltype.createxml(soap_respond); Validating XML with DTDs and XML Schemas resp := resp.extract('/soap:Envelope/soap:Body/child::node()', Chapter 5 - XML Operations with XQuery 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"'); Chapter 4 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part - Oracle Management for DBAs ThisIIallows forXML further XML processing on the data. In this example, the XMLType.extract() function is used to

Chapter Getting Started with Oracle XML Database extract 8the- response content. Tothe test the procedure, you can run the following command: Chapter 9

- Storing XML Data SQL> DECLARE

Chapter - Generating and Retrieving XML 2 10 res XMLType; Chapter 11 - Searching XML Data 3 BEGIN Chapter - Managing the Oracle XML Database 4 12 res := query_request(1); Part5III - :out Oracle := XMLres.getClobVal(); for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java 6 END; Chapter 14 - Building an XML-Powered Web Site 7 / Chapter 15 - Creating a Portal Site with XML and Web Services

The following is the result: Chapter 16 - Developing an XML Gateway Application with SOAP and AQ <ns1:queryResponse xmlns:ns1="BookSaleService" Chapter 17 - Developing XML-Based Reusable Components xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" Part IV - Oracle XML for C Developers SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> Chapter 18 - Getting Started with Oracle XML and C <return xmlns:ns2="http://xmlns.oracle.com/xml-soap" Chapter 19 - Building an XML-Managed Application Chapter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 20 - Build an XML Database OCI Application

xsi:type="ns2:DocumentFragment"> Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part<ROWSET> V - Oracle XML for C++ Developers

<ROW partner_id="1"> <ISBN>0072225211</ISBN> Chapter 23 - Build an XML Database OCI C++ Application <AUTHOR>Kevin Loney, George Koch, Tusc</AUTHOR> Chapter 24 - Building an XML Data-Retrieval Application <TITLE>Oracle9i: The Complete Reference</TITLE> Part VI - Oracle XML for PL/SQL Developers <PRICE>74.99</PRICE> Chapter 25 - Getting Started with Oracle XML and PL/SQL <SALE_PRICE>44.994</SALE_PRICE> Chapter 26 - Building PL/SQL Web Services </ROW> Chapter 27 - Extending PL/SQL XML Functionality with Java <ROW partner_id="1"> Chapter 28 -<ISBN>0072229527</ISBN> Putting It All Together Appendix -<AUTHOR>Mark XML Standards Bodies and Open Specifications Scardina, Ben Chang, Jinyu Wang</AUTHOR> Glossary <TITLE>Oracle Database 10g XML and SQL</TITLE> Index <PRICE>49.99</PRICE> List of Figures <SALE_PRICE>29.994</SALE_PRICE> </ROW> List of Tables </ROWSET> List of Sidebars </return> </ns1:queryResponse> Chapter 22 - Getting Started with Oracle XML and C++

Because of the native XML support in Oracle Database 10g, we can integrate the data from web services into the client database environment. For example, in the client database, you can create a MY_BOOK view as follows: CREATE OR REPLACE VIEW MY_BOOK AS SELECT EXTRACT(value(a),'/ROW/ISBN/text()').getNumberVal() AS ISBN, EXTRACT(value(a),'/ROW/AUTHOR/text()').getStringVal() AS AUTHOR,


EXTRACT(value(a),'/ROW/PRICE/text()').getNumberVal() AS PRICE, EXTRACT(value(a),'/ROW/TITLE/text()').getStringVal() AS TITLE, EXTRACT(value(a),'/ROW/SALE_PRICE/text()').getNumberVal() Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & AS PL/SQL SALE_PRICE FROM TABLE(XMLSEQUENCE( ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang query_request(1).extract('ns1:queryResponse/return/ROWSET/ROW', McGraw-Hill/Osborne © 2004 (600 pages) 'xmlns:ns1="BookSaleService"'))) a; This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

In this example, the SOAP request is made by calling the query_request() procedure. The returned XMLType is

Table Contents thenof extracted to create an XMLSEQUENCE, which is used to build a temporary table. Looking at the definition of Oracle Database 10gsee XML & SQL—Design, Build XMLviews Applications in Java, C, C++ & PL/SQL the view, you can that it can be used just &asManage any other in the database: Introduction

SQL> desc my_book; Name Null? Type Chapter 1 - Introducing XML ----------------------------------- -------- ----------------Chapter ISBN 2 - Accessing XML with DOM, SAX, JAXB, and StAX NUMBER Chapter 3 - Transforming XML with XSLT and XPath AUTHOR VARCHAR2(4000) Chapter 4 - Validating XML with DTDs and XML Schemas PRICE NUMBER Chapter 5 - XML Operations with XQuery TITLE VARCHAR2(4000) Chapter 6 - XML Messaging and RPC with SOAP SALE_PRICE NUMBER Part I - Oracle and the XML Standards

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

TheIIdata from XML the web service isfor seamlessly integrated with other data that is locally stored in the Oracle database. Part - Oracle Management DBAs Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ExtendingOracle the Database Application PL/SQL

ISBN:0072229527 by Markweb V. Scardina, Chang the andOracle Jinyu Wang Because the PL/SQL services Ben run within database and share the run-time database resources, McGraw-Hill/Osborne © 2004 (600 pages) there are special considerations when building PL/SQL web services. In this section, we discuss the best practices to implement when using PL/SQL web This comprehensive guideservices. focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

When to Build Web Services in the Database Server

Table of Contents

Oracle You have Database learned 10gthe XML techniques & SQL—Design, for building Build & web Manage services XMLwithin Applications the Oracle in Java, database. C, C++However, & PL/SQL since many midtier

web service products are available, you should consider whether you really need to build a web service inside the Introduction database server, simply leveraging a widely used midtier web service framework. We believe that several Part I - Oracle and instead the XMLof Standards issues 1need to be evaluated Chapter - Introducing XML to make an informed decision. Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 5

- XML Operations with XQuery

The first issue is application complexity and code reuse. If you have many PL/SQL programs in the database and Chapter 3 - Transforming XML with XSLT and XPath you do not want to spend too much development time building a new web service application, you can use the Chapter 4 - Validating XML with DTDs and XML Schemas approach discussed in this chapter to publish the PL/SQL packages or procedures as web services. Chapter 6 - XML Messaging and RPC with SOAP The second issue is data access efficiency. If you want to build new web services that are highly dependent on the Chapter data stored 7 - Putting in the database It All Together and require with XML intensive Pipeline, data JSPs, computation and XSQL or large dataset evaluations, running them close Part to the II -data Oracle within XMLthe Management database server for DBAs can greatly reduce the overhead needed for cross-tier data communication

and synchronization. This sets clean separation of data-centric logic that runs in the database from business logic Chapter 8 - Getting Started withathe Oracle XML Database that runs the middle It also lets you leverage the high-performance and highly scalable PL/SQL computing Chapter 9 in - Storing XMLtier. Data functionality provided by theRetrieving Oracle database. Chapter 10 - Generating and XML Chapter 11 - Searching XML Data

The third issue is operation efficiency. In this chapter, to illustrate the basic techniques, we built web services that perform simple DML operations. However, in real-world applications, you should not build web services to perform Part III - Oracle XML for Java Developers such fine-grained operations, because the benefits of these services do not outweigh the SOAP overhead. Instead, Chapter 13 - Getting Started with Oracle XML and Java web services should be those services, such as data-mining analysis, that require expensive computational Chapter 14 - in Building an XML-Powered Web Site processing the database. Chapter 12 - Managing the Oracle XML Database

Chapter 15 - Creating a Portal Site with XML and Web Services

The fourth is the efficiency for processing SOAP If the web service processes clients that Chapter 16 -issue Developing an XML Gateway Application withmessage SOAP andrequests. AQ send thousands of SOAP messages every minute, you could overload the database by simply collecting the Chapter 17 - Developing XML-Based Reusable Components incoming messages. The Oracle database might have much more important jobs to perform, such as managing and Part IV - Oracle XML for C Developers processing data. In such cases, a better choice would be to build in the middle tier a web service that provides Chapter 18 - the Getting Started with Oracle XML and C advanced load balancingApplication of the incoming messages. Chapter 19 -caching Buildingand an XML-Managed Chapter 20 - Build an XML Database OCI Application

Finally, your decision should not be limited to these considerations. You may also need to evaluate the application design on other issues, such as the security and scalability of your web service application.

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

Setting Up the Security Protection

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

Using web services, you can build an open infrastructure that allows easy cooperation and sharing of data and resources within your organization and among your business partners. However, you may also be open to a Chapter 25 - Getting Started with Oracle XML and PL/SQL destructive user attacking your system. In Oracle Database 10g, the database web service is protected both by the Chapter - Building Services servlet 26 security setupPL/SQL withinWeb the OC4J server and by the username and password for JDBC connections within the Chapter 27 Extending PL/SQL XML Functionality with Java deployed proxy program. Part VI - Oracle XML for PL/SQL Developers

Chapter 28 - Putting It All Together

In addition-to these safeguards, techniques are available to protect your database web services. For example, Appendix XML Standards Bodiesother and Open Specifications you can have security validation of the SOAP messages through either XML Schema validation or other techniques Glossary used when processing the XML messages. Alternatively, before the execution of the PL/SQL web service, your Index application can perform logic-based validations. For example, in the BookSaleService service, you can confirm the List of Figures partner’s validity by requiring them to provide a password.

List of Tables

List of Sidebars Because data is critical to business systems, you need to carefully design your application to protect the data when

you expose it from database web services.

Building Different Types of Web Services The approach we have discussed is not the only way for you to publish database computing and data resources as web services, though it might currently be the simplest way to do it. In this section, we discuss other types of web services you can build.


Synchronous vs. Asynchronous Web Services A web service Oracle is just another type10g of messaging protocol. service that we created in this chapter is aC, C++ & Database XML & SQL: Design,The Build & Manage XML Applications in Java, synchronous service. PL/SQLIt works like a remote procedure call (RPC) where, after the SOAP request, the client-side program keepsby waiting forScardina, the response from the However, this is not the only way to design it. InISBN:0072229527 Oracle Mark V. Ben Chang andserver. Jinyu Wang Database 10g,McGraw-Hill/Osborne you can build asynchronous web services by using Oracle Streams Advanced Queuing. This is a © 2004 (600 pages) useful way for web service providers to use the message in the Oracle database to XML-enabled handle a large numberwith This comprehensive guide focuses on utilizingqueues XML technologies within Oracle's products, of simultaneous requests. emphasis on XML standards, their usage and best practices.

Push vs. Pull Web Services

Table of Contents

Oracle XMLchapter, & SQL—Design, & Manage XML Applications in Java, C, consumers C++ & PL/SQL In theDatabase examples10g of this the webBuild service is in pull mode, where the service request the service Introduction explicitly by sending SOAP messages to the service providers. However, web service communication can be Part I - Oracle which and the XML Standards bidirectional, means that web services can also be implemented in push mode. For example, let’s say the

Chapter 1 - on Introducing XML book table the server side is updated by adding a new column called reviews, which includes the reviews for the Chapter - Accessing XML with JAXB, and StAXthe changes by sending out SOAP messages using the books. 2Then, the bookstore canDOM, notifySAX, its partners about Chapter UTL_HTTP 3 - Transforming package. Additionally, XML with XSLT usingand XSLT XPath 2.0, you can use <xsl:result-document> to send out SOAP

messages writing into the SOAP messages created by the XSLT transformations. Chapter 4 -by Validating XMLURLs with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Scardina, and Jinyu Wang In this chapter,by weMark haveV.shown youBen oneChang very effective and simple way to expose PL/SQL procedures asISBN:0072229527 Web McGraw-Hill/Osborne © 2004in (600 pages)Database 10g simplifies the way you can expose database data Services. Database web service support Oracle and computingThis resources. However, youfocuses need tooncarefully the requirements of yourXML-enabled application so that youwith comprehensive guide utilizingevaluate XML technologies within Oracle's products, XML standards, their usage and best practices. can protect theemphasis data andon ensure that the database runs properly and efficiently. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 27:Database Extending PL/SQL XML Functionality with PL/SQL ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang Java by McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive utilizing(Oracle XML technologies withinprovided Oracle's as XML-enabled products, with Starting with Oracle8i 8.1.5, Oracleguide Javafocuses Virtual on Machine JVM) has been an execution emphasis on XML standards, their usage and best practices. environment for Java code running inside the Oracle databases. This functionality enables you to leverage Java functionality in PL/SQL by writing Java stored procedures. Table of Contents

In thisDatabase chapter, 10g we will you understand to buildXML Java stored procedures to C++ process XML data inside the Oracle XMLhelp & SQL—Design, Buildhow & Manage Applications in Java, C, & PL/SQL database, including how to resolve URL references when parsing the XML data, and how to implement PL/SQL Introduction procedures process XML in SAX. We will further provide suggestions to help you decide when to use Java stored Part I - Oracletoand the XML Standards procedures, and present some debugging and performance tips in the “Best Practices” section. Chapter 1 - Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Creating the Java to Process XML Chapter 3 - Transforming XMLStored with XSLT Procedure and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

To create -a XML JavaOperations stored procedure, you need to follow these general steps, which are described in detail in the with XQuery following sections:

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

1. Implement Java code, and it within a static method (or methods) that can be deployed as a Java Chapter 7 - Puttingthe It All Together with include XML Pipeline, JSPs, and XSQL Part II - stored Oracle procedure. XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

2. Deploy the Java code to Oracle JVM inside the database.

Chapter Generating and Retrieving XML Create 10 the- PL/SQL specification for the Java stored procedure. Chapter 11 - Searching XML Data

After the stored the procedure is created, you can call it in PL/SQL procedures, SQL commands, or database Chapter 12Java - Managing Oracle XML Database triggers, just likeXML anyfor other PL/SQL objects. In fact, the caller of such a stored procedure can ignore that it has been Part III - Oracle Java Developers written 13 and- Getting implemented using thisand section, Chapter Started withJava. OracleInXML Java we follow these steps to create a Java stored procedure that parses and validates XML Schema documents.

Chapter 14 - Building an XML-Powered Web Site

Chapter 15 - Creating a Portal Site with XML and Web Services

Implementing the Java Code

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Before implement Java code that can be deployed as Java stored procedures, you need to understand the Part IV -you Oracle XML forthe C Developers datatype conversions between Java and PL/SQL arguments. A complete list of the available data types and their mapping is provided in the Oracle Database 10g online manuals. With regard to XML processing, XMLType, Chapter 19 - Building an XML-Managed Application VARCHAR2, and CLOB are the three most frequently used data types for storing XML data and they have the Chapter 20 - Build an XML Database OCI Application following mappings: Chapter 18 - Getting Started with Oracle XML and C

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part VXMLType - Oracle XML fortoC++ Developers maps oracle.xdb.XMLType

Chapter 22 - Getting Started with Oracle XML and C++

VARCHAR2 maps oracle.sql.CHAR Chapter 23 - Build an XMLtoDatabase OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

CLOB maps to oracle.sql.CLOB

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting XML and documents PL/SQL For example, if you Started want towith readOracle XML Schema from VARCHAR2, you can create a Java stored Chapter 26 -as Building PL/SQL Web Services procedure follows: Chapter 27java.io.ByteArrayInputStream; - Extending PL/SQL XML Functionality with Java import Chapter 28java.io.StringWriter; - Putting It All Together import Appendix - XML Standards Bodies and Open Specifications import java.lang.Exception; Glossary import oracle.sql.CHAR; Index import oracle.xml.parser.schema.XMLSchema; List import of Figures oracle.xml.parser.schema.XSDBuilder;

import oracle.xml.parser.schema.XSDException; List of Tables List of Sidebars

public class XSDDBBuilder { public static String build(CHAR xsd) { StringWriter sw = new StringWriter(); try { XSDBuilder builder = new XSDBuilder(); byte [] docbytes = xsd.getBytes(); ByteArrayInputStream in = new ByteArrayInputStream(docbytes); XMLSchema schemadoc = (XMLSchema)builder.build(in,null);


sw.write("The input XSD parsed without errors.\n"); } catch(Exception ex) { sw.write("Exception:"+ex.getMessage()); Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & } PL/SQL return by sw.toString(); ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang }

McGraw-Hill/Osborne © 2004 (600 pages)

}

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

In this example, the input parameter is oracle.sql.CHAR, which maps to the VARCHAR2 data type in PL/SQL. You can then get a ByteArrayInputStream and parse it using oracle.xml.parser .schema.XSDBuilder provided by Table of Contents Oracle XDK. The XSDBuilder will not only parse the XML Schema document but also validate the syntax and Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL resolve all the URL references in the XML schema. Introduction

In order to beand exposed as Standards a PL/SQL procedure, the build() method in the XSDDBBuilder class should be a static Part I - Oracle the XML method1in -Java. Chapter Introducing XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

- Transforming XML with XSLT to and the XPathOracle JVM Deploying the Java Code

Chapter 3 Chapter 4

- Validating XML with DTDs and XML Schemas

Oracle 5JVM is both a JRE and JDK; therefore, it not only can run your programs but also compile your Java code. Chapter - XML Operations withaXQuery You can compile theRPC Java code to Oracle JVM by using the following syntax: Chapter 6 deploy - XML and Messaging and with SOAP Chapter CREATE 7 OR - Putting REPLACE It All AND Together COMPILE with XML Pipeline, JSPs, and XSQL Part JAVA II -SOURCE Oracle XML NAMED Management "XSDDBBuilder" for DBAs

AS

{…Java Chapter 8 Code…} - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

After running in SQL*Plus successfully, you will get a Java Created message, which means the Java code is compiled to byte code and stored in Oracle JVM ready for use. If there are any errors, you can use the SHOW Chapter 11 - Searching XML Data ERROR command to show details of the errors. Chapter 10 - Generating and Retrieving XML

Chapter 12 - Managing the Oracle XML Database

Part III - Oracle XML for Java Note You need to set upDevelopers Oracle JVM before you deploy the Java code. Refer to Chapter 25 for the setup

Chapter 13 instructions. - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

Creating the PL/SQL Specification

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17Java - Developing XML-Based Components After the code is deployed to Reusable Oracle JVM, you need to create a PL/SQL call specification. For example, you Part - Oracle XML for C Developers canIV create an xsd_build() specification for XSDDBBuilder.build() as follows:

Chapter 18 - Getting Started with Oracle XML and C

CREATE OR REPLACE FUNCTION xsd_build(xsd IN VARCHAR2) RETURN VARCHAR2

Chapter 19CURRENT_USER - Building an XML-Managed Application AUTHID Chapter 20 - Build an XML Database OCI Application AS LANGUAGE JAVA Chapter - Create an XML-Configured High-Performance Transformation Engine NAME 21 'XSDDBBuilder.build(oracle.sql.CHAR) return java.lang.String'; Part V - Oracle XML for C++ Developers

The AS22 LANGUAGE JAVAwith syntax indicates thatC++ the PL/SQL procedure is created based on a loaded Java class. Chapter - Getting Started Oracle XML and The AUTHID CURRENT_USER syntax limits the running privileges of the procedure to the current user who is Chapter 23 - Build an XML Database OCI C++ Application creating24the specification. this step, you Application need to properly specify the mapping between the PL/SQL and Java Chapter - Building an XMLInData-Retrieval arguments. Otherwise, when executing the procedure, the Oracle database will give you a No Method Found error. Part VI - Oracle XML for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

To simplify the deployment procedure and avoid typographical errors, you can use Oracle JDeveloper 10g to deploy and create Java stored procedures, which we will discuss in later sections.

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Running the Java Stored Procedure PL/SQL

ISBN:0072229527 Mark V. Scardina, and Jinyu Wang you can test it by creating a table that stores After you haveby successfully createdBen the Chang Java stored procedure, the McGraw-Hill/Osborne © 2004 (600 pages) XML Schema documents and loading the sample data in SQL*Plus as follows:

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with CREATE TABLE xsd_tbl( emphasis on XML standards, their usage and best practices. name VARCHAR2(30) PRIMARY KEY, doc VARCHAR2(4000)); Table of Contents Oracle INSERT Database INTO 10g xsd_tbl XML & SQL—Design, VALUES('Product.xsd','<?xml Build & Manage XML Applications version="1.0"?> in Java, C, C++ & PL/SQL

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" Introduction elementFormDefault="qualified"> Part I - Oracle and the XML Standards <xsd:complexType name="ProductType"> Chapter 1 - Introducing XML <xsd:sequence> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX name="Type" type="xsd:string"/> Chapter 3<xsd:element - Transforming XML with XSLT and XPath </xsd:sequence> Chapter 4 - Validating XML with DTDs and XML Schemas </xsd:complexType> - XML Operations with XQuery </xsd:schema>'); Chapter 6 - XML Messaging and RPC with SOAP commit; Chapter 5 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part - Oracle XMLthe Management for DBAs YouIIthen can call xsd_build() Java stored procedure to parse the XML schema document stored in the xsd_tbl

Chapter - Getting Started with the Oracle table by8 using the following PL/SQL code: XML Database Chapter 9

- Storing XML Data

SET AUTOPRINT ON VAR out VARCHAR2(2000) Chapter 11 - Searching XML Data DECLARE Chapter - Managing the Oracle XML Database xsd 12 VARCHAR2(4000); Part III Oracle XML for Java Developers BEGIN Chapter 13 Getting Started with Oracle XML and WHERE Java SELECT doc INTO xsd FROM xsd_tbl name='Product.xsd'; Chapter 14 Building an XML-Powered Web Site :out := xsd_build(xsd); Chapter END; 15 - Creating a Portal Site with XML and Web Services Chapter 10 - Generating and Retrieving XML

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

If there no errors inCthe XML Schema document, you will receive a message stating The Input XSD Parsed Part IV - are Oracle XML for Developers Without18Errors. Otherwise, messages Chapter - Getting Started any witherror Oracle XML and will C be printed on the screen because all messages printed to a StringWriter in a Java program are returned and printed using the DBMS_OUTPUT package.

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XMLUsing Applications in Java, C, C++ & Simplifying Deployment of Java Stored Procedures Oracle PL/SQL JDeveloper 10gV. Scardina, Ben Chang and Jinyu Wang ISBN:0072229527 by Mark McGraw-Hill/Osborne © 2004 (600 pages)

Theprevious section demonstrated how the CREATE OR REPLACE AND COMPILE command is used to deploy This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with the Java code.emphasis The CREATE OR REPLACE AND COMPILE command is useful when you would like to create a on XML standards, their usage and best practices. Java stored procedure from a small piece of Java code. However, if your Java code includes several Java classes, using the loadjava and dropjava command-line utilities included in Oracle Database 10g is a better choice. You can Table of Contents run these utilities by using the following commands: Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

loadjava –resolve –user <UserName>/<Password> <Java Classes or Libraries in jar files> Part I - Oracle and the XML Standards dropjava –resolve –user <UserName>/<Password> <Java Classes or Chapter 1 - Introducing XML Libraries in jar files> Introduction

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 -you Transforming XML with and XPath However, need to properly set XSLT up the Java CLASSPATH before you run these utilities, which can be Chapter complicated 4 - Validating in some environments. XML with DTDsTo and simplify XML Schemas this, you can use Oracle JDeveloper 10gto performthis deployment. Chapter 5

- XML Operations with XQuery

Using the -previous example, you can create a Java class in a file called XSDDBBuilder.java and create a Loadjava XML Messaging and RPC with SOAP and Java Stored Procedures deployment profile by right-clicking on the project name in Oracle JDeveloper and Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL selecting New. In the pop-up dialog box, you then need to select General | Deployment Profiles | Loadjava and Part II - Oracle XML Management for DBAs Java Stored Procedures.After inputting the deployment filename,clickOK, andthe dialog box will ask you to Chapter 8 - Getting Started with the Oracle XML Database specify the classes and libraries that need to be loaded to the Oracle JVM. You can select Java classes and Chapter 9 - Storing XML Data libraries under the Files Groups | Project Output | Filters option. However, before you can select the librariesin Chapter 10 - Generating and Retrieving XML Filters, you need to add the directories storing the libraries by clicking the Add button in the dialog box under the Chapter 11 - Searching XML Data |Contributor option. For example, if you want to load a new version of Files Groups | Project Output Chapter 12 Managing the Oracle XML Database xmlparserv2.jar into Oracle JVM, you can add the $ORACLE_HOME/lib directory to the Contributor option. You Part III Oracle XML for Java Developers then need to select the Java classes and libraries in the Filter option. Chapter 6

Chapter 13 - Getting Started with Oracle XML and Java

After the file has been created, you can compile and load the Java classes into the database by rightChapter 14deployment - Building an XML-Powered Web Site clicking15 on- the filename and selecting Deploy. deploy the Java classes to any Oracle database connections Chapter Creating a Portal Site with XML and You Webcan Services that you16have set up in an Oracle JDeveloper, as discussed in Chapter Chapter - Developing XML Gateway Application with SOAP and AQ13. Chapter 17 - Developing XML-Based Reusable Components

Note Make sure you use xmlparserv2.jar in the $ORACLE_HOME/lib directory when compiling the Java classes in Oracle JDeveloper because it is the library that is loaded into Oracle JVM by default. Otherwise, Chapter 18 - Getting Started with Oracle XML and C you need to make sure the libraries used both inside and outside the Oracle database are consistent. Any Chapter 19 inconsistency - Building an XML-Managed Application Java Call Terminated by Uncaught Java Exception: will result in ORA-29532: Chapter 20 java.lang.NoSuchMethodError. - Build an XML Database OCI Application Part IV - Oracle XML for C Developers

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Using you now do not have to set up Java CLASSPATH when loading the Java classes into Part V - Oracle Oracle JDeveloper XML for C++10g, Developers the Oracle Additionally, you can Chapter 22 - database. Getting Started with Oracle XML use and Oracle C++ JDeveloper to create PL/SQL specifications. You just need to right-click the name the created profile of the Java stored procedure and choose Add Stored Chapter 23 -onBuild an XMLofDatabase OCIdeployment C++ Application Procedures. You cananselect any available static Java methods to create respective Java stored procedures. Chapter 24 - Building XML Data-Retrieval Application Selecting the build() method inDevelopers the oracle.xml.sample.schema.XSDDBBuilder class as an example, you can set Part VI - Oracle XML for PL/SQL the properties for the PL/SQL asand shown in Figure 27-1. Chapter 25 - Getting Started withprocedure Oracle XML PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Figure 27-1: SQL call specification for a Java stored procedure

Chapter 6 - XML Messaging and RPC with SOAPIN VARCHAR2) specification is created. After you click OK, you will see In this example, the PL/SQL xsd_build(xsd Chapter 7 -xsd_build, Putting It All Together Pipeline,file. JSPs, XSQL the name, listed underwith the XML deployment Toand review the generated PL/SQL code, shown next, rightPart - Oracle XML Management DBAs Preview SQL Statement: clickIIon the procedure name andfor choose

Chapter 8 OR - Getting Started with the Oracle XML DatabaseIN VARCHAR2) RETURN VARCHAR2 CREATE REPLACE FUNCTION xsd_build(xsd Chapter 9 CURRENT_USER - Storing XML Data AUTHID Chapter 10 - Generating and Retrieving XML AS LANGUAGE JAVA NAME Chapter 11 - Searching XML Data 'oracle.xml.sample.schema.XSDDBBuilder.build(oracle.sql.CHAR) Chapter return 12java.lang.String'; - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

By using JDeveloper 10g, you can the typographical errors, which may be problematic when debugging Chapter 13Oracle - Getting Started with Oracle XMLavoid and Java Java stored procedures. Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10gOracle XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Processing XML in the JVM PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Wang Having introduced the basic steps for creating JavaJinyu stored procedures, we will present two useful examples for McGraw-Hill/Osborne © 2004shows (600 pages) processing XML data. The first example how to resolve URL references when parsing XML, XSL stylesheets, and XML Schema Theguide second example illustrates to perform SAXOracle's XML processing in Oracle JVM. This documents. comprehensive focuses on utilizing XMLhow technologies within XML-enabled products, with

emphasis on XML standards, their usage and best practices.

Resolving URL References

Table of Contents

Oracle URL references Database 10g areXML widely & SQL—Design, used in XML,Build XSL,&and Manage XMLXML Schema Applications documents in Java, to include C, C++external & PL/SQL data, such as external

entities in XML, external XSL documents included in XSL stylesheets by <xsl:include> and document(), and external Introduction XMLI -Schema documents in XML schemas by <xsd:include> and <xsd:import>. Part Oracle and the XML included Standards Chapter 1

- Introducing XML

When processing XML data, the URL references are resolved by a Java class called EntityResolver. You can set a - Accessing XML with DOM, SAX, JAXB, and StAX base URL by using the setBaseURL()method, and this base URL is used by the EntityResolver to update all the Chapter 3 - Transforming XML with XSLT and XPath relative URLs in XML documents to absolute URLs. Then, the EntityResolver will use these absolute URLs, and use Chapter 4 - Validating XML with DTDs and XML Schemas the Java URL support, to retrieve the data. Chapter 2

Chapter 5

- XML Operations with XQuery

Chapter 6 JVM, - XMLifMessaging and is RPC with SOAP In Oracle external data stored in a file directory, you need to grant the current database user read permission Chapter on that 7directory: - Putting It All Together with XML Pipeline, JSPs, and XSQL PartDBMS_JAVA.GRANT_PERMISSION( II - Oracle XML Management for DBAs

Chapter grantee=>'DEMO', 8 - Getting Started with the Oracle XML Database Chapter permission_type=>'SYS:java.io.FilePermission', 9 - Storing XML Data Chapter permission_name=>' 10 - Generating and Retrieving XML <DirectoryName>', Chapter permission_action=>'read'); 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

If external data XML is stored on aDevelopers web server, you need to grant socket reading permission to the user: Part III - Oracle for Java DBMS_JAVA.GRANT_PERMISSION ( XML and Java Chapter 13 - Getting Started with Oracle 'DEMO', Chapter grantee=> 14 - Building an XML-Powered Web Site Chapter permission_type=>'SYS:java.net.SocketPermission', 15 - Creating a Portal Site with XML and Web Services Chapter permission_name=>'<WebServerorDomainName>', 16 - Developing an XML Gateway Application with SOAP and AQ Chapter permission_action=>'connect,resolve'); 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

However, when the referenced data is stored in database tables, which is common when processing XML data inside Oracle databases, the URL references cannot be resolved without additional help. In other words, in this case, instead Chapter 19 - Building an XML-Managed Application of using the default EntityResolver, you need to implement a customized EntityResolver and register it to an XML Chapter - Build an XMLor Database OCI Application parser,20 XSL processor, XML schema processor. The customized EntityResolver is responsible for resolving the Chapter 21 Create an XML-Configured High-Performance Transformation Engine URL references and retrieving the data for the XML processors. Chapter 18 - Getting Started with Oracle XML and C

Part V - Oracle XML for C++ Developers

For example, in theStarted following company.xsd XML schema file, there are <xsd:include> elements that include two Chapter 22 - Getting with Oracle XML and C++ additional schema Person.xsd and Product.xsd: Chapter 23 -XML Build an XMLfiles, Database OCI C++ Application Chapter - Building an XML Data-Retrieval Application <?xml 24 version="1.0"?> Part VI - Oracle XML for PL/SQL Developers <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

Chapter 25 - Getting targetNamespace="http://www.company.org" Started with Oracle XML and PL/SQL

xmlns="http://www.company.org" Chapter 26 - Building PL/SQL Web Services elementFormDefault="qualified"> Chapter 27 - Extending PL/SQL XML Functionality with Java <xsd:include Chapter 28 - PuttingschemaLocation="Person.xsd"/> It All Together <xsd:include schemaLocation="Product.xsd"/> Appendix - XML Standards Bodies and Open Specifications <xsd:element name="Company"> Glossary <xsd:complexType> <xsd:sequence> List of Figures <xsd:element name="Person" type="PersonType" maxOccurs="unbounded"/> List of Tables <xsd:element name="Product" type="ProductType" maxOccurs="unbounded"/> List of Sidebars </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Index

ThePerson.xsd schema defines the PersonType: <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"


elementFormDefault="qualified"> <xsd:complexType name="PersonType"> <xsd:sequence> Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & <xsd:element name="Name" type="xsd:string"/> PL/SQL <xsd:element type="xsd:string"/> ISBN:0072229527 by Mark V. name="SSN" Scardina, Ben Chang and Jinyu Wang </xsd:sequence> McGraw-Hill/Osborne © 2004 (600 pages) </xsd:complexType> This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with </xsd:schema> emphasis on XML standards, their usage and best practices. TheProduct.xsd schema defines the ProductType:

Table of Contents

<?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" Introduction elementFormDefault="qualified"> Part I - Oracle and the XML Standards <xsd:complexType name="ProductType"> Chapter 1 - Introducing XML <xsd:sequence> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX <xsd:element name="Type" type="xsd:string"/> Chapter 3 - Transforming XML with XSLT and XPath </xsd:sequence> Chapter 4 - Validating XML with DTDs and XML Schemas </xsd:complexType> Chapter 5 - XML Operations with XQuery </xsd:schema>

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter 6

- XML Messaging and RPC with SOAP

All the XML schemaItfiles are stored in XML the created table, which uses the filename as the primary key and Chapter 7 - Putting All Together with Pipeline,xsd_tbl JSPs, and XSQL stores content a VARCHAR2 column. Part II -the Oracle XML in Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

If you use the previously created xsd_build() procedure to parse the XML schema document, you will get a No Chapter 9 - Storing XML Data Protocol error. To solve this problem, you need to set a customized EntityResolver to the XML schema builder: Chapter 10 - Generating and Retrieving XML

XSDBuilder builder = new XSDBuilder(); DBEntityResolver resolver = new DBEntityResolver(); Chapter 12 - Managing the Oracle XML Database builder.setEntityResolver(resolver); Part III - Oracle XML for Java Developers byte [] docbytes = xsd.getBytes(); Chapter 13 - Getting Started with Oracle XML and Java ByteArrayInputStream in = new ByteArrayInputStream(docbytes); Chapter 14 - Building an XML-Powered Web Site XMLSchema schemadoc = (XMLSchema)builder.build(in,null); Chapter 11 - Searching XML Data

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing XMLthat Gateway Application with SOAP and AQ DBEntityResolver is aan class implements the org.xml.sax.EntityResolver interface as follows: Chapter 17java.io.IOException; - Developing XML-Based Reusable Components import Part IV - Oracle XML for C Developers import java.io.InputStream;

Chapter 18java.sql.Connection; - Getting Started with Oracle XML and C import Chapter 19java.sql.DriverManager; - Building an XML-Managed Application import Chapter 20java.sql.PreparedStatement; - Build an XML Database OCI Application import Chapter import 21java.sql.ResultSet; - Create an XML-Configured High-Performance Transformation Engine Part import V - Oracle org.xml.sax.EntityResolver; XML for C++ Developers

import Chapter 22org.xml.sax.InputSource; - Getting Started with Oracle XML and C++ import Chapter 23org.xml.sax.SAXException; - Build an XML Database OCI C++ Application import Chapter 24java.sql.Driver; - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

//Define new custom Chapter 25 - Getting Started EntityResolver with Oracle XML and class PL/SQL using the // internal Oracle JVM KPRB JDBC driver to connect to Chapter 26 - Building PL/SQL Web Services public class DBEntityResolver implements EntityResolver { Connection conn; Chapter 28 - Putting It All Together DBEntityResolver() { Appendix - XML Standards Bodies and Open Specifications try { Glossary Driver d = new oracle.jdbc.driver.OracleDriver(); Index conn = DriverManager.getConnection("jdbc:oracle:kprb:"); List of Figures } catch(Exception ex) { List of Tables ex.printStackTrace(); List of Sidebars } } //Define a method to resolve entities by retrieving schema files //from the xsd_tbl table. public InputSource resolveEntity (String publicId, String systemId) throws SAXException, IOException{ InputSource mySource = null; String location = systemId; InputStream xsd= null; Chapter 27 - Extending PL/SQL XML Functionality with Java


try { PreparedStatement st = Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & conn.prepareStatement("select doc from xsd_tbl where name=?"); PL/SQL st.setString(1,location); ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang ResultSet rset= st.executeQuery(); McGraw-Hill/Osborne © 2004 (600 pages) while(rset.next()) { This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with xsdemphasis = rset.getBinaryStream(1); on XML standards, their usage and best practices. } rset.close(); Table of Contents st.close(); Oracle } Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL catch(Exception ex) { Introduction ex.printStackTrace(); Part I -}Oracle and the XML Standards Chapter 1 Create - Introducing // the XML inputSource with an InputStream as input Chapter 2 Accessing XMLInputSource(xsd); with DOM, SAX, JAXB, and StAX mySource = new Chapter 3 - Transforming XML with XSLT and XPath return mySource; Chapter } 4 - Validating XML with DTDs and XML Schemas } Chapter 5 - XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Once this code has been written, you need to redeploy your Java stored procedure, after modifying your deployment profile so that it includes this new class. The signature of the method to expose as well as the signature of the matching Chapter 8 - Getting Started with the Oracle XML Database PL/SQL procedure remain unchanged. Part II - Oracle XML Management for DBAs

Chapter 9

- Storing XML Data

Chapter 10 -isGenerating and Retrieving This class used by the XML schemaXML processor to resolve the URL references and retrieve referenced data from Chapter 11 - Searching XML Data Since this is an important issue, let’s discuss the code in greater detail. Person.xsd and Product.xsd. Chapter 12 - Managing the Oracle XML Database

First, retrieve dataDevelopers from tables, you need to set up a JDBC connection to connect the Oracle database. Part IIIin- order OracletoXML for Java Therefore, the constructor function the and DBEntityResolver class, a server-side internal JDBC driver is initialized. In Chapter 13 - in Getting Started with OracleofXML Java Oracle 14 Database 10g, are threeWeb JDBC Chapter - Building an there XML-Powered Sitedrivers provided: Chapter 15 - Creating a Portal Site with XML and Web Services

JDBCOracle Call Interface (OCI) driver (also known as thick)with the JDBC link:

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ jdbc:oracle:oci8:<UserName>/<Password> Chapter 17 - Developing XML-Based Reusable Components Part IV JDBC - Oracle thin XML driver for with C Developers the JDBC link:

jdbc:oracle:thin:<UserName>/<Password>@<HostName>:<ListenerPort>:<DBSID> Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

JDBC server-side internal driver with the JDBC link: jdbc.oracle.kprb

Chapter 20 - Build an XML Database OCI Application

Chapter 21 -OCI Create XML-Configured Engine Unlike the andan thin drivers, whichHigh-Performance are used primarilyTransformation by the client applications to connect to the Oracle database, Part - Oracle XML driver for C++ the Vinternal JDBC is Developers used for Java code running inside Oracle JVM. Because it will connect the currently

Chapter 22 - database Getting Started with Oracle XML and C++ it does not require specifying the username or password: connected user running the Java program, Chapter 23 - Build an XML Database OCI C++ Application

Driver d = new oracle.jdbc.driver.OracleDriver();

Chapter 24DriverManager.getConnection("jdbc:oracle:kprb:"); - Building an XML Data-Retrieval Application conn = Part VI - Oracle XML for PL/SQL Developers

Chapter Getting Started with Oracle and PL/SQL This is 25 an -optimally tuned JDBC driver XML that runs directly inside the Oracle database, thereby providing the fastest Chapter access26 to -Oracle Building data PL/SQL from Web JavaServices stored procedures. Chapter 27 - Extending PL/SQL XML Functionality with Java

Next, you need to retrieve data from tables when the XML schema processor needs help to resolve the URL references. In this case, the resolveEntity() method will be called with the URLs passed in as the systemId. You need Appendix - XML Standards Bodies and Open Specifications to overwrite the method by querying the xsd_tbl table using the URLs, which are filenames for the XML schemas, and Glossary return the data as a Java InputSource. Chapter 28 - Putting It All Together

Index

List of Figures Finally, you need to follow the steps discussed in the previous sections to deploy the Java code and create a new Java List of Tables stored procedure specification. This time, the XML schema can be parsed without errors. You can apply the same List approach of Sidebars to resolve URLs for XML document parsing and XSLT transformation.

SAX XML Processing Due to the nature of PL/SQL, it does not support event-based processing such as is required for SAX XML processing. However, in many cases, the large size of your XML documents requires you to use SAX to streamline the XML processing and reduce the strain on memory resources. Additionally, batch-mode SAX XML processing is more efficient than DOM XML processing when your only requirement is to read XML data. In this section, we discuss how to leverage this SAX functionality in the Oracle database.


First, whereas the previous section described how to create a Java stored procedure to parse XML Schema documents, this section discusses how to use the Java stored procedure to validate XML documents in SAX. The Java Oracle Database XML & SQL: Design, & Manage XML Applications in Java, C, C++ & stored procedure is created after10g the Java method, defined Build as follows: PL/SQL

public static String validation(CLOB xml,Wang CHAR xsd) throws Exception ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu { McGraw-Hill/Osborne © 2004 (600 pages) //Build Schema Object This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with XSDBuilder builder new XSDBuilder(); emphasis on XML=standards, their usage and best practices. EntityResolver resolver = new DBEntityResolver(); builder.setEntityResolver(resolver); Table of Contents byte [] docbytes = xsd.getBytes(); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL ByteArrayInputStream in = new ByteArrayInputStream(docbytes); Introduction XMLSchema schemadoc = (XMLSchema)builder.build(in,null); Part I -//Parse Oracle and the XML Standards the input XML document with Schema Validation Chapter 1 Introducing XML SAXParser parser = new SAXParser(); Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX parser.setXMLSchema(schemadoc); Chapter 3 - Transforming XML with XSLT and XPath parser.setValidationMode(XMLParser.SCHEMA_VALIDATION); Chapter 4 - Validating XML DTDs and XML Schemas StringWriter sw with = new StringWriter(); Chapter try 5 -{XML Operations with XQuery Chapter 6parser.parse(xml.getCharacterStream()); - XML Messaging and RPC with SOAP inputwith XMLXML parsed without Chapter 7sw.write("The - Putting It All Together Pipeline, JSPs, anderrors.\n"); XSQL catchXML (XMLParseException Part II}- Oracle Management for DBAs pe) { + pe.getMessage()); Chapter 8sw.write("Parser - Getting Started withException: the Oracle XML"Database } catch (Exception e) { Chapter 9 - Storing XML Data sw.write("NonParserException: " + e.getMessage()); Chapter 10 - Generating and Retrieving XML } Chapter 11 - Searching XML Data return sw.toString(); Chapter 12 - Managing the Oracle XML Database } Part III - Oracle XML for Java Developers

Chapter 13 - Getting with Oracle XML and Java To validate the XMLStarted document, the SCHEMA_VALIDATION option for the SAX XML parser is turned on, and an XML Chapter 14object - Building an XML-Powered WebSAX Site XML parser as follows: Schema is created and set to the Chapter 15 - Creating a Portal Site with XML and Web Services

parser.setXMLSchema(schemadoc); parser.setValidationMode(XMLParser.SCHEMA_VALIDATION);

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 -XML Getting Startediswith Oracleusing XML and C Then, the document retrieved oracle.sql.CLOB.getCharacterStream() and parsed by the SAX parser: Chapter 19 - Building an XML-Managed Application parser.parse(xml.getCharacterStream()); Chapter 20 - Build an XML Database OCI Application

Note oracle.sql.CLOB provides two methods toTransformation retrieve data: Engine getAsciiStream() and getCharacterStream(). Chapter 21 The - Create an XML-Configured High-Performance ThegetAsciiStream() method only supports ASCII characters and returns an InputStream. The Part V - Oracle XML for C++ Developers method Chapter 22 getCharacterStream() - Getting Started with Oracle XMLsupports and C++all characters and returns a Reader. Using getCharacterStream() always unless know there are only ASCII characters stored in the CLOB. Chapter 23 is - Build an recommended, XML Database OCI C++you Application Chapter 24 - Building an XML Data-Retrieval Application

After the Java code is deployed, a Java stored procedure called xsd_validation() can be created by the following statement:

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

CREATE OR REPLACE FUNCTION xsd_validation(xml IN CLOB, xsd IN VARCHAR2) RETURN VARCHAR2 AUTHID CURRENT_USER AS LANGUAGE JAVA NAME Chapter 27 - Extending PL/SQL XML Functionality with Java 'XSDDBBuilder.validation(oracle.sql.CLOB, oracle.sql.CHAR) return Chapter 28 - Putting It All Together java.lang.String'; Chapter 26 - Building PL/SQL Web Services

Appendix

- XML Standards Bodies and Open Specifications

Glossary You can use it to validate XML documents in PL/SQL as follows: Index

SET SERVEROUTPUT ON

List of Figures DECLARE List ofout Tables VARCHAR2(2000); List xsd of Sidebars VARCHAR2(4000);

xml CLOB; BEGIN SELECT doc INTO xsd FROM xsd_tbl WHERE name='company.xsd'; SELECT doc INTO xml FROM xml_tbl WHERE name='company.xml'; out := xsd_validation(xml, xsd); DBMS_OUTPUT.PUT_LINE(out); END;


For this example, the XML documents are stored in the xml_tbl table, created as follows: CREATE TABLE xml_tbl( name VARCHAR2(30) PRIMARY KEY, Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL docCLOB); by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Thecompany.xml can then be inserted into the Oracle database with the following command: McGraw-Hill/Osborne © 2004 (600 pages) INSERT INTOThis xml_tbl comprehensive VALUES('company.xml','<?xml guide focuses on utilizing XML technologies version="1.0"?> within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. <Company xmlns="http://www.company.org"> <Person> <Name>Foo</Name> Table of Contents <SSN>123-45-6789</SSN> Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL </Person> Introduction Part<Product> I - Oracle and the XML Standards <Type>Good Type</Type> Chapter 1 - Introducing XML </Product> Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX </Company>'); Chapter 3 - Transforming XML with XSLT and XPath } Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6 Schema - XML Messaging and RPC with SOAP The XML validation processing is performed in SAX streams. If any error occurs, the error messages will be Chapter Putting It All Together with XML Pipeline, and XSQL completed with an Input XML Parsed Without printed 7on -the screen. Otherwise, the processes willJSPs, be successfully Part II -message. Oracle XML Management for DBAs Errors

Chapter 8

- Getting Started with the Oracle XML Database

Second, needXML to manipulate the XML data, you can also create content handlers and register them to SAX Chapter 9 if -you Storing Data parsers. For example, the following content Chapter 10 - Generating and Retrieving XML handler is created to remove the white spaces in XML documents: public MyDocumentHandler extends XMLSAXSerializer { Chapter 11class - Searching XML Data public MyDocumentHandler(OutputStream out) { Chapter 12 - Managing the Oracle XML Database super(out); Part III - Oracle XML for Java Developers } 13 - Getting Started with Oracle XML and Java Chapter public void characters(char int start, int length) Chapter 14 - Building an XML-Powered Webch[], Site throws SAXException { Chapter 16 - Developing an XML Gateway Application with SOAP and AQ String str = new String(ch, start, length); Chapter 17 - Developing XML-Based Reusable Components //Replace Part IV - Oracle XML for C Developers str = str.replace('\t',' '); Chapter 18 - Getting Started with Oracle XML and C str = str.replace('\n',' '); Chapter 19 - Building an XML-Managed Application str = str.replace('\r',' '); Chapter 20Collapse - Build an XML Database OCI Application // Chapter 21 an XML-Configured High-Performance Transformation Engine str -=Create str.trim(); Part V char[] - Oracle XML for C++ Developers ca = str.toCharArray(); Chapter 22 -i, Getting int j; Started with Oracle XML and C++ Chapter 23 - BuildseenWS an XML Database OCI C++ Application boolean = false; Chapter 24 - Building an j< XMLstr.length(); Data-Retrieval Application for(i=0,j=0; j++) { Part VI - Oracle XML for Developers if(ca[j] !=PL/SQL ' ' || !seenWS) { Chapter 25 -ca[i++] Getting Started = ca[j]; with Oracle XML and PL/SQL == 'Web ') Services Chapter 26 -if(ca[j] Building PL/SQL seenWS PL/SQL = true; Chapter 27 - Extending XML Functionality with Java Chapter 28 -else Putting It All Together seenWS = false; Appendix - XML Standards Bodies and Open Specifications } Glossary } Index super.characters(ca,0,i); List of Figures } List of Tables } Chapter 15 - Creating a Portal Site with XML and Web Services

List of Sidebars

XMLSAXSerializer is a new class in Oracle XDK 10g, which is defined as follows: public class XMLSAXSerializer extends org.xml.sax.helpers.DefaultHandler implements oracle.xml.parser.v2.XMLConstants, org.xml.sax.ext.LexicalHandler {…}

This Java class in Oracle XDK 10g provides serialization for SAX processing. It prints out XML data to an


OutputStream or a PrintWriter with printing formats that can be customized by the users. After implementing the document handler that is handling the SAX events, you can register it to the SAX parser with the following code: public class XMLNormalize { XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle Database 10g PL/SQL public static String normalized(XMLType xml, CLOB[] result) ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang { McGraw-Hill/Osborne © 2004 (600 pages) StringWriter sw = new StringWriter(); SAXParser = guide new focuses SAXParser(); This saxParser comprehensive on utilizing XML technologies within Oracle's XML-enabled products, with try { emphasis on XML standards, their usage and best practices. Writer out =result[0].getCharacterOutputStream(); MyDocumentHandler docHandler = Table of Contents new MyDocumentHandler(new PrintWriter(out)); Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL saxParser.setContentHandler(docHandler); Introduction Part I -saxParser.parse(xml.getInputStream()); Oracle and the XML Standards out.close(); Chapter 1 - Introducing XML } catch(XMLParseException ex) { Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX sw.write("XSD Error:"+ex.getMessage()); Chapter 3 - Transforming XML with XSLT and XPath }catch(Exception ex) { Chapter 4 - Validating XML with DTDs and XML Schemas sw.write("Error:"+ex.getMessage()); Chapter 5 - XML Operations with XQuery } Chapter 6 - XMLsw.toString(); Messaging and RPC with SOAP return Chapter 7 Putting It All Together with XML Pipeline, JSPs, and XSQL } Part II Oracle XML Management for DBAs } Chapter 8

- Getting Started with the Oracle XML Database

In this example, weXML create a Java method that reads the XML document from an XMLType column and uses SAX to Chapter 9 - Storing Data parse and normalize the document. the original XML document is as follows: Chapter 10 - Generating and RetrievingIf XML Chapter 11 - Searching XMLis Data <rootElement> This the test Chapter 12 -<childElement Managing the Oracle test="true"> XML Database Part Value III - Oracle XML for Java Developers

Chapter 13 -</childElement> Getting Started with Oracle XML and Java

</rootElement> Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

After the normalization, the resulting XML document will be as follows:

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

<rootElement>This is the test<childElement Chapter 17 - Developing XML-Based Reusable Components test="true">Value</childElement></rootElement> Part IV - Oracle XML for C Developers

Because Oracle JDeveloper 10gdoesn’t support XMLType when defining Java stored procedures, you need to write your own as follows:

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

CREATE OR REPLACE FUNCTION normalize(p1 IN XMLType, p2 IN OUT NOCOPY CLOB) Chapter 21 - Create an XML-Configured High-Performance Transformation Engine RETURN VARCHAR2 Part V - Oracle XML for C++ Developers AUTHID CURRENT_USER Chapter 22 - Getting Started with Oracle XML and C++ AS LANGUAGE JAVA NAME Chapter 23 - Build an XML Database OCI C++ Application 'oracle.xml.sample.parser.XMLNormalize.normalized(oracle.xdb.XMLType, Chapter 24 - Building an XML Data-Retrieval Application oracle.sql.CLOB[]) return java.lang.String'; Chapter 20 - Build an XML Database OCI Application

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 -you Building PL/SQL Services This time, also need to Web add the $ORACLE_HOME/rdbms/jlib directory in the Files Groups | Project Output | Chapter Contributor 27 - Extending option to PL/SQL load theXML xdb.jar Functionality needed with for XMLType Java processing. Chapter 28 - Putting It All Together

By working- XML through the examples, you should have a better understanding of how to process XML data in SAX using Standards Bodies and Open Specifications Java stored procedures. Because the processing is in SAX streams, you have the advantage of using less memory, Glossary which is especially important when processing large XML documents. Appendix Index

List of Figures List of Tables List of Sidebars


Oracle Database XML &Stored SQL: Design, Build & Manage XML Applications in Java, C, C++ & Developing Your Own10g Java Procedures PL/SQL

ISBN:0072229527 V. Scardina, andtoJinyu Wang In this section, by weMark discuss when to Ben use Chang and how debug Java stored procedures. Since Java stored procedures McGraw-Hill/Osborne © 2004 space (600 pages) run within the Oracle database’s memory and consume database resources, there are special considerations when using Oracle JVM. This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

When to Use Java Stored Procedures

Table of Contents

Oracle In practice, Database because 10g XML the&Oracle SQL—Design, XML DBBuild provides & Manage high-performance XML Applications native in Java, XML C, features, C++ & its PL/SQL use should be your first

choice for XML processing in your applications. If these features do not meet your requirements, you can implement Introduction Java orStandards leverage midtier or client-side XML support. Part I -stored Oracleprocedures and the XML Chapter 1

- Introducing XML

However, for data-intensive Java code that constantly connects to a database, you need to deploy it inside Oracle - Accessing XML with DOM, SAX, JAXB, and StAX JVM and run it as a Java stored procedure. Because Java stored procedures run inside the RDBMS, they have less Chapter 3 - Transforming XML with XSLT and XPath round-trip overheads for data transport. Chapter 2 Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter - XML Operations withround-trip XQuery expenses for Java stored procedures are less than the midtier or clientOn the 5other hand, though the Chapter 6 - XMLthey Messaging andhigh RPCcosts with SOAP side programs, still have for data round trips between Oracle JVM and the database server. This can Chapter be especially 7 - Putting true ifItthere All Together are many with datatype XML Pipeline, conversions JSPs, and between XSQL SQL and Java. Part II - Oracle XML Management for DBAs

Another8 performance bottleneck canOracle resultXML if there is a high number of Java method calls within a Java stored Chapter - Getting Started with the Database

procedure-orStoring overallXML database application. Every Java call needs to be translated into an internal Oracle JVM Data method call. This translation is performed by using a very large lookup table to find the name mapping between Chapter 10 - Generating and Retrieving XML PL/SQL and Java. Even though this table is indexed, the lookup process time can easily exceed the Java code Chapter 11 - Searching XML Data execution time. The trick is to put as much Java code into the Java source file and make very few Java calls from Chapter 12 - Managing the Oracle XML Database the Java stored procedure. Chapter 9

Part III - Oracle XML for Java Developers

Chapter 13 - when Getting Started with XML and Therefore, designing your Oracle Java code, youJava need to make sure to minimize the interactions between the Oracle Chapter 14 and - Building an XML-Powered Site if you would like to use SAX to extract data from an XML document database the Java program. For Web example, Chapter using XPath, 15 - Creating insteadaofPortal designing Site with a Java XMLstored and Web procedure Servicesthat allows the user to pass one XPath expression at a

time, you design it an to allow the user Application to pass in all theSOAP XPath expressions in an array, and let the Java code Chapter 16 can - Developing XML Gateway with and AQ process17all- of them in one batch process. Chapter Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

To tune the performance of the Java stored procedures, you also need to properly set the SHARED_POOL_SIZE, JAVA_POOL_SIZE, and JAVA_MAX_SESSIONSPACE_SIZE. All of these affect the memory usage of Java stored Chapter 19 - Building an XML-Managed Application procedures. To avoid getting Out Of Memory errors from Oracle JVM, you need to give a reasonably large size for Chapter 20 - Build an XML Database OCI Application SHARED_POOL_SIZE and JAVA_POOL_ SIZE and limit the size for JAVA_MAX_SESSIONSPACE_SIZE. These Chapter 21 - Create an XML-Configured High-Performance Transformation Engine are set in your init.ora file and can be changed from Enterprise Manager or in SQL*Plus. Chapter 18 - Getting Started with Oracle XML and C

Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++

How to Debug Java Stored Procedures

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

You can debug Java stored procedures by printing out success and error messages. In these examples, we printed all the messages to a StringWriter and passed the content back as a return value. Alternatively, you can output the Chapter 25 - Getting Started with Oracle XML and PL/SQL debug messages using System.out or System.err. By default, the messages will be printed to the current database Chapter 26 -In Building PL/SQL Services trace files. Chapter 9, weWeb discussed how to check the current session ID to locate the correct trace file in Chapter 27 Extending PL/SQL XML Functionality with Java USER_DUMP_DIR. However, if you want to redirect the output to the SQL*Plus text buffer, you can use the Chapter 28command: - Putting It All Together following Part VI - Oracle XML for PL/SQL Developers

Appendix

Standards Bodies and Open Specifications SQL> SET- XML SERVEROUTPUT ON

Glossary SQL> CALL DBMS_JAVA.SET_OUTPUT(2000); Index List If this of Figures is not sufficient to discover the problem, you can also use the Remote PL/SQL Debugging feature of Oracle

JDeveloper List of Tables 10g to debug Java stored procedures. List of Sidebars

To set up remote PL/SQL debugging you first need to open the Tools | Project Properties dialog box and check theRemote Debugging check box under the Profiles | Development | Debugger | Remoteoption. You then chooseListen for JPDA from the radio buttons and locate an appropriate database connection that you will run the PL/SQL code from. Next, you can set breakpoints in the Java code and click the Debug button to start your debugging session. A dialog box will pop up asking you which port you want to listen on. You can enter any available port, “4000” as an example, and click OK. You will see a Debug Listenicon under the Processes folder in the View | Application Navigator window, which shows that the debugger is listening.


After this, you can open SQL*Plus and issue the following command: ALTER SESSION SETDatabase PLSQL_DEBUG=TRUE Oracle 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & CALL DBMS_DEBUG_JDWP.CONNECT_TCP( '127.0.0.1', '4000' ); PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

The address 127.0.0.1 is the IP address for the machine running Oracle JDeveloper, and 4000 is the port that the McGraw-Hill/Osborne © 2004 (600 pages) debugger is listening on. At this point, the Oracle JDeveloper debugger should have accepted the debugging This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with connection, and you will on seeXML a new debugging under Processes folder. In addition, the log window emphasis standards, theirprocess usage and bestthe practices. should have the message Debugger Accepted Connection From Remote Process On Port 4000. Table Contents You of then can return to SQL*Plus and issue a command that invokes your PL/SQL procedure calling the Java stored Oracle Database 10g the XMLbreakpoints & SQL—Design, Build ManageJDeveloper XML Applications in Java, C, C++ & PL/SQL procedures. When are hit, the& Oracle debugger will stop at the breakpoints and show all Introduction the related debugging information. Part I - Oracle and the XML Standards

Note run the procedure to debug, you need to grant the DEBUG CONNECT SESSION and DEBUG ANY Chapter 1 To - Introducing XML Chapter 2

PROCEDURE privileges to the database user. - Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 -to Transforming XML with and XPath In addition code debugging, youXSLT can check the validity of the Java classes using the database connection in Chapter - Validating XML with DTDs and Oracle 4JDeveloper 10g. Alternatively, youXML can Schemas use the following SQL command to query the USER_OBJECT view, Chapter 5 - XML withowned XQueryby the current DB user and the status of the classes: which shows theOperations Java classes Chapter 6

- XML Messaging and RPC with SOAP SELECT DBMS_JAVA.LONGNAME (object_name), status

Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL FROM USER_OBJECTS Part II - Oracle XML Management forCLASS'; DBAs WHERE OBJECT_TYPE = 'JAVA

Chapter 8

- Getting Started with the Oracle XML Database

Chapter You can 9 use - Storing the ALL_OBJECTS XML Data view to check all the Java classes available to the current user. If the status of any

Java class shown asand INVALID, youXML need to reload the class. Chapter 10 - is Generating Retrieving Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


SummaryOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

by Mark V. Scardina, Ben and Jinyu Wang Using Java stored procedures is one of Chang the options that you can leverage to process XML inside Oracle ISBN:0072229527 Database McGraw-Hill/Osborne © 2004 (600 pages)to the native XML DB functionality and provide additional 10g. It should serve as complimentary functionality development and options when you on areutilizing optimizing performance of your XML-enabled applications. Thisdeployment comprehensive guide focuses XMLthe technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ChapterOracle 28:Database Putting It All Together PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Looking back over the previous chapters, it is obvious that Oracle has an extensive XML platform across all major McGraw-Hill/Osborne © 2004 (600 pages) Oracle development languages. In this chapter, we discuss design and application decisions that you must make This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with when you approach the implementation of your solution on Oracle. First we take a look at the platform from a tier-toemphasis on XML standards, their usage and best practices. tier functionality point of view and the issues associated with performing XML processing on each. Then we discuss XML support in the database and the various strategies, including their advantages and disadvantages. Next we Table Contents focusofon the individual language decision from a functionality and run-time point of view. Finally, we finish up by Oracle Database 10gOracle XML & XML SQL—Design, Buildbe & extended. Manage XML Applications in Java, C, C++ & PL/SQL exploring how the platform can Introduction Part I - Oracle and the XML Standards

The Oracle XML Platform - Introducing XML

Chapter 1

Chapter 2 -been Accessing XML DOM, SAX, andyears StAX and echoed by enterprise customers is that XML What has learned at with Oracle over theJAXB, last five Chapter 3 - Transforming XML XPath processing cannot be done in with one XSLT place.and Thus it is vitally important that XML processing functionality is available on Chapter - Validating XML with DTDstoand Schemas all tiers,4 from the database through theXML client. Figure 28-1 shows the available standards-based support provided Chapter by the Oracle 5 - XML 10g Operations XML platform with XQuery on each tier. Chapter 6

- XML Messaging and RPC with SOAP

As you can- Putting see in Figure 28-1, there is rich XML functionality on every tier that is compliant with open XML It All Together with XML Pipeline, JSPs, and XSQL standards. In many cases this lets you move the XML processing between tiers to optimize performance, as we Part II - Oracle XML Management for DBAs discuss in the next section. Since this support is standards-based, you can move between Oracle’s XML platform Chapter 8 - Getting Started with the Oracle XML Database and others such as IBM and Sun without having to migrate your code. Chapter 7

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

Figure 28-1: Oracle 10g XML platform

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

One thing to note is that Oracle XDK 10g serves as the foundation for XML functionality in all tiers. Therefore, there is a consistent level of functionality to develop against. In the case of the database tier, the XDK’s C libraries are Chapter 22 -the Getting Started withand Oracle XML and C++ XML DB as well as AQ Streams. The Oracle JVM provides linked into RDBMS server are used by Oracle Chapter 23 Build an XML Database OCI C++ Application Java functionality that enables the XDK’s Java libraries to be loaded and called from Java stored procedures. In the Chapter an J2EE XML Data-Retrieval Application middle 24 tier,- Building the Oracle container includes the XDK’s Java libraries and the XSQL Servlet, along with Web Part VI - Oracle for PL/SQL Developers Services. EvenXML Oracle Web Cache has smart XML functionality, as it caches XML message responses and Chapter 25 XSLT - Getting Started with Oracle XMLXDK’s and PL/SQL performs transformations using the C libraries. Finally, rounding out the platform, all of the XDK’s C, Chapter 26 Java - Building PL/SQL Services C++, and libraries can Web be used for client application development. Part V - Oracle XML for C++ Developers

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XML Processing Tier 10g Decisions PL/SQL

ISBN:0072229527 Mark V.application Scardina, Ben Chang and Jinyu Wang A distributed orbyInternet will be successful only if it can scale to meet its peak demands. In the case of McGraw-Hill/Osborne © 2004this (600cannot pages) be guaranteed by simply throwing more and more hardware into XML-enabled applications and services, the deployment. Instead, you needguide to intelligently theXML system to perform XMLOracle's processing on appropriate tiers This comprehensive focuses ondesign utilizing technologies within XML-enabled products, with emphasis their usage and best practices. and you need to choose on theXML rightstandards, type of processing.

First you need to realize that XML moving between tiers can require up to ten times the bandwidth of binary data. Interoperability comes at a cost because metadata is included along with the data. In many data-interchange Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL applications, the metadata, element, and attribute names may be an order of magnitude greater than the data being Introduction conveyed. This is a current issue, as evidenced by the fact that two major analyst groups, Forester Research and Part I - Oracle and the XML Standards Burton Group, both have warned enterprises to consider how XML traffic will likely affect their networks. Even Cisco Chapter 1 - Introducing XML reports that interest is growing in higher-throughput network products due to increasing XML traffic. What does this Chapter 2 your - Accessing XMLapplications? with DOM, SAX, JAXB, and StAX mean for distributed

Table of Contents

Chapter 3

- Transforming XML with XSLT and XPath

This network bandwidth issue thatXML you Schemas need to consider doing XML processing close to the data if remote Chapter 4 - Validating XML withmeans DTDs and processing mean shipping large quantities between tiers. For example, many applications that generate Chapter 5 - would XML Operations with XQuery reports6from large datasetsand produce better throughput by performing XSLT processing in the database where the Chapter - XML Messaging RPC with SOAP application only the with finished the XSQL wire. This is also true if you want to extract only a Chapter 7 - needs PuttingtoItship All Together XML product Pipeline,across JSPs, and small dataManagement from large XML documents stored in the database. Part II subset - OracleofXML for DBAs Chapter 8

- Getting Started with the Oracle XML Database

On the other hand, in situations where XML messages are small and the number of transactions per second is high, Chapter 9 - Storing XML Data you don’t want your database to do anything but inserts. This is where midtier processing has the advantage over Chapter 10 tier - Generating andespecially Retrievingif XML database processing, validation of the XML is required. For example, the XDK’s Java XML schema Chapter 11 Searching XML Data processor performs validation using SAX streaming and performs it significantly faster than the database. If you are Chapter - Managing the XMLknow Database storing 12 in XMLTypes, XMLOracle that you is already well-formed or valid, you should turn off the well-formedness Part III Oracle XML for Java Developers checking on insert because that can significantly reduce throughput. Chapter 13 - Getting Started with Oracle XML and Java

One area consideration that is often missed Chapter 14 of - Building an XML-Powered Web Site is to make sure the correct parsing techniques are being used. Due to its higher standards’ visibility, parsing theServices first choice for most XML document access. In fact, unless the Chapter 15 - Creating a Portal Site DOM with XML and is Web document being modified and written Application back, DOMwith is a SOAP bad choice compared to SAX when it comes to throughput Chapter 16 -isDeveloping an XML Gateway and AQ and scalability. The same holds true for XSLT processing. Since it requires a DOM to be built, large-document processing may be very memory-intensive or may even fail. The Oracle XML DB’s lazy DOM is used by its internal Part IV - Oracle XML for C Developers XSLT processor, eliminating the high memory costs. Chapter 17 - Developing XML-Based Reusable Components Chapter 18 - Getting Started with Oracle XML and C

Chapter 19 XML - Building an XML-Managed Application Because has become more prevalent, its support is being built into many unexpected areas. One such area is Chapter 20 - Build an XML OCI Application web cache. As more andDatabase more demands are placed on having web sites and portal sites that have up-to-the-minute Chapter 21 - data, Create an XML-Configured High-Performance Transformation Engine or -second there is no opportunity to create static pages. XML in combination with XSLT provides this dynamic Part V - Oracle XML for C++ publishing functionality but Developers can be expensive if every request needs to start the process from scratch. Oracle Web

Chapter - Getting Started with Oracle XML and C++transformations on cached XML data, thereby significantly Cache 22 incorporates the capability to perform XSLT Chapter improving 23 -performance. Build an XML Because DatabaseitOCI is written C++ Application in C and runs entirely in memory, Oracle Web Cache’s performance

improvement can bean much than that of Java-based approaches in the middle tier. Chapter 24 - Building XML greater Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

One often-overlooked processing tier is the client. Enhancements to Internet browsers to support XML and XSLT can move the processing off of servers while not dramatically affecting performance. Applets using Oracle XDK’s Chapter 26 - Building PL/SQL Web Services XML JavaBeans can provide rich XML functionality using a JRE plug-in to your Internet browser. Validating XML Chapter 27 - Extending PL/SQL XML Functionality with Java input on the client usually degrades the user experience much less than having a server or the database processing Chapter 28 - Putting It All Together hundreds of documents a minute. Chapter 25 - Getting Started with Oracle XML and PL/SQL

Appendix

- XML Standards Bodies and Open Specifications

Glossary The Oracle 10g XML platform is designed to be thread-safe down to the component level. Since there are some Index XML processes such as DOM parsing, XML Schema validation, and XSLT transformation that can take hundreds of

milliseconds List of Figures or even seconds, designing your application to use multithreading may be critical. Both the DOM and SAX List of parsers Tables can work asynchronously, freeing your application to perform other tasks. List of Sidebars

Finally, data security has to be a consideration for any XML tier-to-tier serialization. XML is, after all, a text-based protocol and therefore vulnerable. New standards such as Digital Signatures and XML Encryption are just being rolled out but have a processing/performance cost. The best security strategy is to not transmit data unless it really needs to be transmitted, and thus perform the processing close to or on the tier on which the data resides. Fortunately, Oracle provides several strategies, including the Oracle JVM, Oracle XDK XMLType support, and external tables, to minimize data exposure as clear, serialized XML. If you create, whenever possible, functional software blocks or even applications that can run on any tier, you improve the likelihood of a successful deployment as you are able to partition the processing to meet load demands.


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Database 10g XML &for SQL:XML Design, Build & Manage XML Applications in Java, C, C++ & Database Oracle Design Decisions PL/SQL

V. Scardina, Ben Chang and Wang are many, and can be daunting for thoseISBN:0072229527 The challengesbyofMark storing and manipulating XML inJinyu a database of you out McGraw-Hill/Osborne © 2004 (600exactly pages) know how. Databases are relational and XML is hierarchical, so there who know it “has” to be done but don’t until recently there been no simple, to integrate the two. Traditionally, developers have had two with This has comprehensive guide elegant focuses way on utilizing XML technologies within Oracle's XML-enabled products, on XML standards, their usage and data best into practices. choices: eitheremphasis use a parser to deconstruct the document relational data and store it as such in the database, or store the entire document as a text file, preserving its text-based structure. Table of Contents

The important thing to remember is that moving XML into the back end with the database is not a one-size-fits-all process. Each storage option has its advantages and disadvantages. Knowing which XML storage model is best for Introduction the purposes of your application, rather than modeling your application after an XML storage model, is critical. Let’s Part I - Oracle and the XML Standards look at each XML storage model’s advantages and disadvantage to help you determine which type to use. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 4

- Validating XML with DTDs and XML Schemas

XMLType CLOB XML with XSLT and XPath Chapter 3 - Transforming

In some sense, using an XMLType CLOB is the simplest way to store an XML file. It treats the XML document as - XML Operations with XQuery exactly that: a document. The file is preserved as a complete text document in storage (with whitespace, comments, Chapter 6 XML Messaging RPC with and so on -intact), by storingand it simply as aSOAP single, character-based entry in the database. Consequently, files of any Chapter 7 Putting It All Together with XML Pipeline, JSPs, and XSQL size and depth can be stored as long as they are well-formed XML. However, although you may have defined data Part II Oracle XML Management for DBAs types in the document for validation against a schema, the data is not typed in the sense that it can be manipulated Chapter 8 - Getting Started with the Oracle XML Database or retrieved using SQL queries. Chapter 5

Chapter 9

- Storing XML Data

Because this clear limitation, the document must be searched using a text search engine—in contrast to SQL Chapter 10 of - Generating and Retrieving XML queries,11which can leverage the functionality of query rewrites, functional indexes, and so on. Efficiently updating the Chapter - Searching XML Data document limited because it involves parsing the entire file into memory using DOM, making the change, and Chapter 12 -isManaging the Oracle XML Database

replacing it. If, however, the primary purpose of your XML documents is to encapsulate content in a structure for Part III - Oracle XML for Java Developers

transformation (as might be the focus in web publishing, content management, document archiving, and so on), and most changes to content are made at a document level, then the XMLType CLOB is your best choice for XML data Chapter 14 - Building an XML-Powered Web Site storage. In these cases, you aren’t likely to need a SQL context for your data, and you get a guarantee of byte-forChapter 15 - Creating a Portal Site with XML and Web Services byte fidelity. Chapter 13 - Getting Started with Oracle XML and Java

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

XMLType Views

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

An alternative to using the XMLType CLOB is to create a virtual XML document on top of a set of relational tables as an XMLType view. This approach permits a user to insert, update, and delete data in the XML file just as though it Chapter 20 - Build an XML Database OCI Application were SQL data. Because you are defining a virtual XML document on top of the data store, you aren’t limited to just Chapter 21 - Create an XML-Configured High-Performance Transformation Engine one representation of the data as with CLOB; rather, you can have multiple XML “documents.” Chapter 19 - Building an XML-Managed Application

Part V - Oracle XML for C++ Developers

Chapter - Getting Started with also Oracle XML and Storing22 data in relational tables means thatC++ you can update individual elements without pulling the entire Chapter document. 23 - In Build general, an XML with Database XMLType OCIviews, C++ Application you get all the advantages and efficiency that come with SQL

operations, becausean theXML relational database engine is optimized for these kinds of retrievals. Finally, you can use the Chapter 24 - Building Data-Retrieval Application SQLVIdatatype on theDevelopers XML data types, instead of treating them simply as text. (For example, a date can Part - Oracle operations XML for PL/SQL be treated a trueStarted date from SQL standpoint, rather than simply a string of characters.) Chapter 25 -as Getting withaOracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

This approach has some disadvantages, however. Defining XMLType views where the structure is deep (that is, deeper than eight to ten tiers) can degrade performance significantly due to table joins. Inserting and updating views Chapter 28 - Putting It All Together requires INSTEAD-OF triggers and these are more difficult to maintain, because you need to include application Appendix - XML Standards Bodies and Open Specifications code in the trigger. The great virtue of the CLOB approach is the complete preservation of structure and byte-forGlossary byte fidelity. But with the XMLType view, you lose the guarantee of strict document order; also, many items (such as Index whitespace comments and processing instructions) will have disappeared while shredding the document data into List of Figures tables. Chapter 27 - Extending PL/SQL XML Functionality with Java

List of Tables

None of this matters, of course, if you are shredding your data for use by data-centric applications that don’t “care” List of Sidebars about document structure. If your goal is to move data in and out of the database, and keep metadata intact only as context, and have all the advantages of DML operations, XMLType views are ideal. You can start from the database schema and generate the corresponding XML schema. Here there is no concept of document order; any required section ordering can be explicitly defined via ROWIDs or other application-specific methods. Functions are provided in the database and XDK to create XML schemas automatically from XMLType views. This method is also especially useful if you are working with several XML schemas of differing tag names and structure and do not want them to define your underlying database schema (as when extending an existing legacy


database application to support XML while preserving its legacy functionality). In a typical example, you can repurpose the same data store for a variety of customers who are dictating formats and templates to you. You simply define an XML Database Type view 10g for each and when you insert the data to in that view, will have Oracle XMLcustomer, & SQL: Design, Build & retrieve ManageorXML Applications Java, C,itC++ & the format appropriate PL/SQL to the corresponding customer. by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

XML Stored in the Oracle XML DB Repository This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML their usage best practices. With regards toemphasis storing XML, it isstandards, possible to have yourand cake and eat it too, at least to an extent: You can store your document as a native XMLType in the Oracle XML DB repository, which will preserve byte-for-byte document fidelity and of also shred it into SQL tables. This approach gives you complete validation while allowing you to do all the DML Table Contents operations on the that you getBuild with&XML views. You still get fine-grained and you can Oracle Database 10gdocument XML & SQL—Design, Manage XML Applications in Java, C, data C++ management, & PL/SQL create multiple views and documents based on the SQL data. When your XML schema is registered, you store your Introduction XML data in your database, by simply inserting an XML document file using SQL, PL/SQL, Java, FTP, HTTP, or Part I - Oracle and the XML Standards WebDAV. Getting XML data out of your database can be as simple as executing a SQL query or reading a file using Chapter 1 - Introducing XML one of those Internet-standard protocols. This functionality is made possible through the built-in query rewrite Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX support, eliminating the need for the INSTEAD-OF triggers. Chapter 3

- Transforming XML with XSLT and XPath

Chapter - Validating XML with DTDs and Besides4 the ease of working with XML in XML eitherSchemas its document or data form, you get an enhancement to the W3CChapter 5 Document - XML Operations XQuery standard Object with Model (DOM) APIs when programmatically using them. When parsing XML from a file, Chapter - XML with SOAP of the entire file in order to manipulate it. (This approach is shared by you can6 build anMessaging in-memoryand treeRPC representation Chapter other XML 7 -processors Putting It Allsuch Together as XSLT.) with XML WithPipeline, the “virtual JSPs, DOM” and XSQL feature of the native XMLType, you build the tree on Part demand—this II - Oracle XML preserves Management resources for DBAs when using DOM APIs and XSLT, and, in cases of large documents or row sets,

your application simply works instead of crashing. Chapter 8 - Getting Started with the Oracle XML Database Chapter 9

- Storing XML Data

There are many advantages to using the Oracle XML DB repository, but its use isn’t right for every application. Overhead is involved in maintaining the relationship between the full document and its shredded data. However, the Chapter 11 - Searching XML Data biggest problem comes with schema evolution. Because the document dictates the storing process (mapping which Chapter 12 - Managing the Oracle XML Database data to which tables), when you want to change the document schema, it is no longer a simple abstraction but is Part III - Oracle XML for Java Developers intimately bound to the database schema whose structure it dictated. That means you can’t do most nontrivial Chapter 13 - Getting Started with Oracle XML and Java changes of either the database or the document schema without having to export all the data and reimport it into the Chapter 14 -Oracle Building an XML-Powered Web than Site 9.2 in this regard; however, it is still an expensive operation and you database. Database 10g is better Chapter - Creating a Portal XML data. and Web Services have to15 decide how to handleSite thewith existing If there is no need for document fidelity, these changes can be Chapter 16 - from Developing an XML Gateway with SOAP andstorage AQ abstracted your database schema Application using the XMLType view model described previously. Chapter 10 - Generating and Retrieving XML

Chapter 17 - Developing XML-Based Reusable Components

By comparing the three different DB storage options for XML data, the preceding discussion should Part IV - Oracle and XMLcontrasting for C Developers give you idea of which most XML appropriate Chapter 18a-better Getting Started withisOracle and C for your purposes. Choosing carefully according to your applications’ needs is important. Application This choice can literally mean the difference between merely creating a Chapter 19 - Building anvery XML-Managed successful andDatabase bringing itOCI successfully Chapter 20 - prototype Build an XML Applicationto production. Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracleand Database 10g XMLDecisions & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Java, C, C++, PL/SQL PL/SQL

ISBN:0072229527 by Mark allows V. Scardina, Ben Chang and Jinyu Wang Oracle’s XML platform development in Java, C, C++, and PL/SQL, thus providing rich XML functionality; McGraw-Hill/Osborne © 2004 (600 in pages) however, all languages are not created equal terms of performance and support on each tier. A survey of the Oracle development community has revealed that usage for XML development follows this order: Java, with This comprehensive guide focuses onlanguage utilizing XML technologies within Oracle's XML-enabled products, emphasis XML their usage and this best is practices. then PL/SQL, then C++,on with C astandards, distant fourth. However, not the order of performance, which in most cases has C in first place. Let’s compare and contrast these languages from a performance and functionality viewpoint.

Table of Contents

Oracle XDK 10g is the first release that brings C XML functionality to all the tiers. Previously, you could not develop OCI programs directly against XMLTypes in the database. Now, with C support on each tier, you can develop with Introduction Oracle’s highest-performance libraries. These libraries are the same ones that are linked into the database kernel Part I - Oracle and the XML Standards and used by Oracle XML DB. They do not have the full range of XML technology support when compared to the Chapter 1 - Introducing XML Java versions. For example, they do not include support for XSLT 2.0, XPath 2.0, or DOM 3.0, nor are the interfaces Chapter 2 - Accessing XML they with do DOM, SAX, full JAXB, and StAX object-oriented; however, include internationalization support as well as the XSLT compiler and virtual Chapter 3 which - Transforming XML with XSLT machine, you can leverage. Whileand the XPath C libraries are platform-specific, they are ported to all platforms that Chapter - Validating XML with DTDs Schemas Oracle 4supports for the database andand theXML interfaces are the same, thus producing cross-platform code usually Chapter - XML Operations XQuery requires5 only compiling andwith linking from a single source with the appropriate headers. Finally, if you are not Chapter 6 - with XML interfacing Messaging to and withdatabase, SOAP concerned anRPC Oracle you can use the XDK C libraries with only the CORE and NLS Chapter libraries, 7 instead - Putting of ItanAllentire Together Oracle with Home. XML Pipeline, JSPs, and XSQL Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Part II - Oracle XML Management for DBAs

The Oracle XDK 10g C++ interfaces are implemented as code wrappers over the C ones. Therefore, there is a oneChapter 8 - Getting Started with the Oracle XML Database to-one mapping of functionality. For version 10g, this extends to support for XMLType, as we have previously - Storing XML Data discussed. One component is not present in the C libraries: the Class Generator, discussed in Chapter 23. Chapter 10 - Generating and Retrieving XML Otherwise, the only additional overhead compared to the performance of C is a function call. Chapter 9

Chapter 11 - Searching XML Data

Chapter 12 -ofManaging the XML Portability C++ code is Oracle an issue forDatabase cross-platform development. Oracle XDK 10g introduces for the first time Part III - Oracle Java Developers namespaces forXML the for C++ packages, to prevent collisions with other libraries or your application’s functions. This is

Chapter 13 - Getting with Oracle XMLthe and Java implemented using Started C++ templates. Since C++ compiler mangles the class and method names into a unique Chapter 14 - Building an XML-Powered Web Site on various platforms. Oracle makes only one compilation available on string, issues may arise with certain compilers Chapter each platform. 15 - Creating This compilation a Portal Sitehas withtoXML be supported and Web Services by your development compilation. For example, the Solaris 32-

bit libraries compiled 2.6Application of Sun’s compiler, Windows Chapter 16 - are Developing anwith XMLversion Gateway with SOAP and AQ with Visual C++ 6.0, etc. Chapter 17 - Developing XML-Based Reusable Components

A tremendous amount of XML development is being done using PL/SQL. As you saw in Chapters 25 to 27, there are numerous built-in PL/SQL XML packages to facilitate XML development. However, they all are not created equal Chapter 18 - Getting Started with Oracle XML and C from both a functionality and performance perspective. Oracle Database 10g has ceased shipping XMLDOM, Chapter 19 - Building an XML-Managed Application XMLPARSER, XSLPROCESSOR, and all other XML packages that are not prefixed with DBMS_, because of the Chapter 20 - Build an XML Database OCI Application migration from Java stored procedures to native C code, which is now exposed in DBMS_XMLDOM, Chapter 21 - Create an XML-Configured High-Performance Transformation Engine DBMS_XMLPARSER, DBMS_XMLSCHEMA, and DBMS_XSLPROCESSOR. Thus, performance of the PL/SQL Part V - Oracle XML for C++ Developers XML packages is greatly improved. There are a couple of XSU packages that still call Java. These are the Chapter 22 - Gettingand Started with Oracle XMLpackages, and C++ but these should be used only if you need functionality that is DBMS_XMLSave DBMS_XMLQuery Chapter 23 Build an XML Database OCI C++ Application not available in the DBMS_XMLStore and DBMS_XMLGEN packages, respectively. Part IV - Oracle XML for C Developers

Chapter 24 - Building an XML Data-Retrieval Application

TheVI biggest issue PL/SQL Developers development is the lack of available XML functionality, as compared to the other Part - Oracle XMLwith for PL/SQL languages. For example, nowith event-driven such as those in SAX or the Pipeline Processor, are available Chapter 25 - Getting Started Oracle XMLinterfaces, and PL/SQL due to the of PL/SQL. Also, there is no support for XSLT 2.0, XPath 2.0, or DOM 3.0. However, there is Chapter 26 -limitations Building PL/SQL Web Services rich functionality for developing against XMLType and the XML DB using DBMS_XDB, DBMS_XDB_VERSION, Chapter 27 - Extending PL/SQL XML Functionality with Java DBMS_XDBT, and It DBMS_XDBZ. Chapter 28 - Putting All Together Appendix

XML Standards Bodies and Open Specifications Finally, we- turn to Java, the most popular XML development language. Within Oracle XDK 10g, the Java libraries

Glossary support the most advanced standards levels, including all three versions of DOM, XSLT 1.0 and 2.0, XPath 1.0 and Index 2.0, XML Pipeline, and the Java extensions, JAXP and JAXB. Much work has been done on the performance side of List of Figures these libraries to both reduce memory resources and increase throughput. List of Tables

One that has been raised since the introduction of JDK 1.4 is why should you not simply use Sun’s XML List of issue Sidebars components that are now included. There are several reasons. First, the XML functionality offered is quite limited compared to Oracle’s, as shown in Table 28-1, and there are object compatibility issues if you attempt to mix and match. As important as functionality in this comparison is technical support. As an Oracle Support customer, you get the same level of support as you would for the Oracle servers, which includes backports, patches, and one-offs. Sun offers only quarterly update releases, except in rare cases, and no backports whatsoever. As an architect or developer faced with this many languages, you may be tempted to simply pick the most


comfortable language and use it regardless of the tier you are running on. This will not produce optimum performance. Just as critical is the decision to apportion your XML processing across tiers so is your decision on the best language Oracle for that Database tier. As the10g XML is serialized between tiers,&itManage is possible toApplications process in theindatabase using& XML & SQL: Design, Build XML Java, C, C++ PL/SQL, deliver to the midtier for Java processing, and ultimately process it in C or C++ on the client. PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


XMLPlatform & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ExtendingOracle the Database Oracle10g XML PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and ways Jinyu in Wang We conclude this chapter with a discussion of the which you can extend the Oracle XML platform. McGraw-Hill/Osborne 2004 important (600 pages) XML characteristics that they are required to be carried through Extensibility and interoperability are ©such to the application This section addresses types ofXML extension: functional and code extension. Thislevel. comprehensive guide focuses two on utilizing technologies withinextension Oracle's XML-enabled products, with

emphasis on XML standards, their usage and best practices.

Oracle Database 10g and Oracle XDK 10g provide many ways in which you can extend the built-in XML functionality. With Oracle Database 10g, when you are using PL/SQL, you can create Java stored procedures to invoke Oracle’s Table of Contents or your own Java code from the Oracle JVM. A great example of this is using the XDK’s Java SAX parser to provide Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL SAX parsing support to PL/SQL, as documented in an excellent code sample that is available on OTN. As long as Introduction you are not making continuous, fine-grained calls to Java—as you would when accessing the DOM—this method Part I - Oracle and the XML Standards works extremely well. Moving to the midtier, you can extend XSLT stylesheets by means of extension elements that Chapter 1 - Introducing XML can invoke Java, which allows you to execute Java methods from an XSLT process. You can create custom XML Chapter - Accessing XML with SAX, and StAX Pipeline2 modules (as shown in DOM, Chapter 17)JAXB, to extend the functionality of the Oracle XML Pipeline Processor. Finally, Chapter - Transforming XML with XSLT to and XPath you can3 create custom action handlers use with the XSQL Servlet to perform special server-side XML processing. Chapter 4

- Validating XML with DTDs and XML Schemas

Code extension or reusability is aXQuery key design goal for cost-efficient, maintainable, and reliable applications. By Chapter 5 - XML Operations with including and its metadata in a with single document, XML offers the capability to build generic functionality that Chapter 6 data - XML Messaging and RPC SOAP derives7its-processing from the metadata. include that key off of a doctype or schema Chapter Putting It All Together with XMLExamples Pipeline, JSPs, andapplications XSQL declaration to determine the typefor of DBAs processing required, such as XPaths to search or a stylesheet to apply, Part II - Oracle XML Management applications whose Started GUI or controls are configured by XML files, and applications that automatically configure Chapter 8 - Getting with the Oracle XML Database

themselves for the client devices they are communicating with. The first five years in the life of XML technology has - Storing XML Data broadened and matured the infrastructure that is necessary for serious enterprise-level XML-enabled application Chapter 10 - Generating and Retrieving XML development. We predict that the next five years will see XML power applications as support is built into hardware, Chapter 11 - Searching XML Data bringing XML processing anywhere…and fast everywhere. Chapter 9

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Appendix: XML Standards Bodies and Open PL/SQL ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang Specifications McGraw-Hill/Osborne © 2004 (600 pages) comprehensive guide utilizing XML technologies within Oracle's XML-enabled products, with Open softwareThis standards are defined asfocuses open toonuse by anybody and standard in the way they specify particular emphasis on XML standards, their usage and best practices. functionality; however, these three simple words convey meaning far beyond what’s stated. For example, in an ideal situation, with open software standards, software developers could write programs with components from different Table of Contents vendors and not fear interoperability problems. The problem of being locked into a particular vendor would go away. Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

The role of the World Web Consortium (W3C) and other standards bodies is to come up with enough quality Introduction functionality satisfy a majority of the software development community. And because requirements change at Part I - Oracleto and the XML Standards different for different Chapter 1 times - Introducing XMLparts of the community, these standards bodies must be constantly attuned to the needs

of their users and respond with additional functionality specifications or risk the possibility of their standards - Accessing XML with DOM, SAX, JAXB, and StAX becoming obsolete. These software standards are especially important when certain industries need to standardize Chapter 3 - Transforming XML with XSLT and XPath on new technologies such as XML. Not having such standards or having deficient standards would make it very Chapter 4 - Validating XML with DTDs and XML Schemas difficult for businesses to interoperate on the Internet. The standards produced by W3C and other standards bodies Chapter 5 - XML Operations with XQuery are the key to pointing the way toward future work and applications. Chapter 2

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Introducing the W3C Specifications

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Currently, the most important standards body for the XML industry is W3C. According to its web site:

Chapter 10 - Wide Generating and Retrieving The World Web Consortium wasXML created in October 1994 to lead the World Wide Web to its full potential by Chapter developing 11 - common Searchingprotocols XML Datathat promote its evolution and ensure its interoperability…. By promoting

interoperability and encouraging an open forum for discussion, W3C commits to leading the technical evolution of Chapter 12 - Managing the Oracle XML Database the III Web. Part - Oracle XML for Java Developers Chapter 13 - Getting Started with Oracle XML and Java

Basically, W3C is a consortium composed of W3C employees and companies, such as Oracle, IBM, Microsoft, and Sun Microsystems, that pay membership dues to place their representatives on a number of committees that Chapter 15 - Creating a Portal Site with XML and Web Services produce open software standards specifications according to which developers in the industries code. In short, it is a Chapter 16 - Developing an XML Gateway Application with SOAP and AQ very powerful consortium. Chapter 14 - Building an XML-Powered Web Site

Chapter 17 - Developing XML-Based Reusable Components

Part IV - Oracle for C companies Developers do not wait for the committees to formalize such specifications before they Although someXML member

Chapter - Getting Started with Oracle and C some APIs—such as the SAX APIs developed by Dave develop18company-proprietary APIs, andXML although Chapter Megginson—don’t 19 - Buildingfall anunder XML-Managed the auspices Application of W3C, developers know when it comes to the Internet that open

standards thean way toDatabase go. WhenOCI W3C comes out with a new API specification, developers flock to it unless the Chapter 20 -are Build XML Application specification is horribly flawed. After the industry developers flock to it, company-proprietary APIs often fall by the Chapter 21 - Create an XML-Configured High-Performance Transformation Engine wayside. The XML implications that many companies can then participate in an industry mechanism, such as an Part V - Oracle for C++are Developers electronic ratherwith thanOracle being XML subjected to one company dictating what all others should do. W3C’s home Chapter 22 -exchange, Getting Started and C++ page is23 located http://www.w3.org, and aApplication free companion tutorial site on the XML family of standards is at Chapter - Buildatan XML Database OCI C++ http://www.w3schools.com. Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

W3C XML Specification

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

The seminal XML specification produced by W3C is Java the XML 1.0 specification, currently in its third edition, which Chapter 27 - Extending PL/SQL XML Functionality with describes class ofItdata objects called XML documents and explains how software modules, such as an XML Chapter 28 -a Putting All Together

parser, are- used by applications to read such documents and provide them with access to the documents’ content XML Standards Bodies and Open Specifications and structure. The URL for the XML 1.0 (third edition) specification is http://www.w3.org/TR/2004/REC-xmlGlossary 20040204/. Appendix Index

List Figures TheofXML 1.1 specification, located at http://www.w3.org/TR/2004/REC-xml11-20040204/,updates the XML 1.0 List of Tables so that it uses the latest Unicode version and adds checking of normalization. If you do not need these specification List of Sidebars features, then you can develop your XML documents per the XML 1.0 specification. XML parsers should be able to

understand both versions of the specification.

W3C DOM Specification DOM is based on an object structure that closely resembles the structure of the documents it models. In DOM, the documents have a logical structure that is similar to a tree, with a root node, leaf nodes, and operations that traverse and extract information from the tree. The DOM 1.0 specification, located at http://www.w3.org/TR/1998/RECDOM-Level-1-19981001/, covers this object structure.


A subsequent version of the DOM specification, the 2.0 specification, splits the specification into the following different modules to address the expanded requirements of the user community:

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

PL/SQL DOM Level 2 Corehttp://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

DOM Level McGraw-Hill/Osborne 2 Viewshttp://www.w3.org/TR/2000/REC-DOM-Level-2-Views-20001113/ © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

DOM Level 2 Events emphasis onhttp://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/ XML standards, their usage and best practices. DOM Level 2 Stylehttp://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/ Table of Contents

Level10g 2 Traversal and RangeBuild http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-RangeOracleDOM Database XML & SQL—Design, & Manage XML Applications in Java, C, C++ & PL/SQL 20001113/ Introduction Part I - Oracle and the XML Standards

DOM Level 2 HTMLhttp://www.w3.org/2003/06/Process-20030618/tr.html#rec-publication

Chapter 1

- Introducing XML

Chapter 2 version - Accessing XML withspecification, DOM, SAX, JAXB, and StAX The final of the DOM the 3.0 specification, addresses further needs of the user community with Chapter 3 - Transforming XML with XSLT and XPath these modules: Chapter 4

- Validating XML with DTDs and XML Schemas

DOM 3 Corehttp://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/ Chapter 5 -Level XML Operations with XQuery Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

DOM Level 3 Load and Savehttp://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/

Part II - Oracle XML Management for DBAs DOM Level 3 Validation http://www.w3.org/TR/2004/REC-DOM-Level-3-Val-20040127/

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data SAX Specification

Chapter 10 - Generating and Retrieving XML Chapter 11 specification - Searching XML Data The SAX is not a W3C specification, but because many XML application developers think that it is, it is Chapter 12in- this Managing theMany Oracle XMLapplication Database developers believe that SAX is a W3C specification because it is a included section. XML Part IIINote - Oracle for Java Developers W3C and XML its APIs and the DOM APIs are the main APIs that they use to access and manipulate XML

Chapter 13 - Getting Startediswith Oracle XML andparsing, Java documents. SAX parsing event-based XML meaning that when certain events occur or are encountered Chapter when processing 14 - Building theanXML XML-Powered document—for Web Site example, when the root node of the document is encountered—the event

handlers functionsa are then invoked through function callbacks. Chapter 15or - Creating Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Compared to DOM parsing, SAX is much faster and less memory-intensive because it does not construct an inmemory tree representation. The documentation for both SAX 1.0 and SAX 2.0 with support for XML Namespaces Part IV - Oracle XML for C Developers and filters is located at http://www.saxproject.org/. Chapter 17 - Developing XML-Based Reusable Components Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application

W3C Namespace Specifications

Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

An XML namespace is a collection of names, identified by a URI reference, that is used in XML documents to differentiate element and attribute names. A namespace is useful when a single XML document contains elements Chapter 22 - Getting Started with Oracle XML and C++ and attributes that are defined for and used by multiple software modules. A namespace is introduced in an XML Chapter 23 - Build an XML Database OCI C++ Application document by defining a special namespace prefix and prepending that prefix (followed by a colon) to the names of Chapter 24 - Building an XML Data-Retrieval Application elements and attributes. Namespace prefixes are attributes that are themselves defined using a special prefix called Part VI - Oracle XML for PL/SQL Developers xmlns. The specification is located at http://www.w3.org/TR/1999/REC-xml-names-19990114/. Part V - Oracle XML for C++ Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

W3C XML Schema Specification

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together

The W3C XML Schema specification describes the XML Schema language, which provides a more structured and

Appendix Standards Bodies Open Specifications informative- XML constraint on the XML and document than a DTD, namely one that also, among other things: Glossary Index Supports both primitive and complex data types List of Figures

Supports restrictions or extensions on data types

List of Tables

List ofIsSidebars written in XML

Divided into two documents, the Structures portion is located at http://www.w3.org/TR/xmlschema-1/ and the Datatypes portion is located at http://www.w3.org/TR/xmlschema-2/. If you need help understanding XML Schema, there is a non-normative Primer at http://www.w3.org/TR/xmlschema-0/.

W3C XML Query Specification The W3C XML Query standards effort is made up of several specifications (at the time of this writing, all are in Last


Call Working Draft form) and provides flexible query facilities to extract data from XML documents, treating collections of XML documents as databases on the Web. It is a query language that is based on expressions, and it is a typed language. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

XQuery 1.0: An XML Query Language is the language specification. Located at by Mark V. Scardina, Ben Chang and Jinyu Wang http://www.w3.org/TR/xquery/.

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

Thisfor comprehensive guide focuses XML technologies Oracle's XML Syntax XQuery 1.0 (XQueryX) is on theutilizing XML syntax specification.within Located at XML-enabled products, with emphasis on XML standards, their usage and best practices. http://www.w3.org/TR/xqueryx/.

XQuery 1.0 and XPath 2.0 Formal Semantics is the formal semantics or algebra specification used by XQuery Table of Contents XPath.10g Located http://www.w3.org/TR/xquery-semantics/. Oracleand Database XML &atSQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

XQuery 1.0 and XPath 2.0 Data Model is the data model specification used by XQuery and XPath. Located at http://www.w3.org/TR/xpath-datamodel/.

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2 - Accessing XML with SAX, JAXB, StAX XQuery 1.0 and XPath 2.0DOM, Functions and and Operators is the functions and operators specification for both Chapter XQuery 3 - Transforming and XPath. Located XML withatXSLT http://www.w3.org/TR/xpath-functions/. and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

XSLT-2.0 and XQuery 1.0 Serialization is the optional serialization specification for XSLT and XQuery. XML Operations with XQuery Located at http://www.w3.org/TR/xslt-xquery-serialization/.

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

Chapter - Putting All Together XML Pipeline, JSPs, and at XSQL To get 7a feel for theItlanguage andwith its capabilities, take a look the use case specification located at Part II - Oracle XML Management for DBAs http://www.w3.org/ TR/xmlquery/query-usecases and the requirements document located at

Chapter 8 - Getting Started with the Oracle XML Database http://www.w3.org/TR/xmlquery/query-requirements. Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

W3C XSLT and XPath Specification

Chapter 11 - Searching XML Data

Chapter 12 -XSL Managing the Oracle XML Database The W3C working group produces several specifications, which are divided into three areas: Formatting Part III - Oracle XML for Java Developers Objects, Transformations, and XPath.

Chapter 13 - Getting Started with Oracle XML and Java

The XSL Objects specification is located at http://www.w3.org/TR/xsl/ and describes in XML the Chapter 14Formatting - Building an XML-Powered Web Site semantics formatting an XML document. Chapter 15 -for Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

The XSL Transformations (XSLT) specification has two versions. XSLT 1.0 (http://www.w3.org/TR/xslt) describes the language for transforming XML documents. XSLT 2.0 (http://www.w3.org/TR/xslt20/), in Last Call Working Part IV - Oracle XML for C Developers Draft form at the time of this writing, introduces not only additional functional support but also the use of XML Chapter 18data - Getting Schema types.Started with Oracle XML and C Chapter 17 - Developing XML-Based Reusable Components

Chapter 19 - Building an XML-Managed Application

Similarly, XMLanPath (XPath) specification has two versions. XPath 1.0 (http://www.w3.org/TR/xpath) Chapter 20 the - Build XMLLanguage Database OCI Application describes expression language used by XSLT to access or describeEngine different parts of the XML document. Chapter 21 -the Create an XML-Configured High-Performance Transformation Version 2.0 (http://www.w3.org/TR/xpath20/) is shared with the XML Query (XQuery) specification but is Part V - Oracle XML for C++ Developers partitioned XSLTStarted 2.0 use. ItsOracle companion functions Chapter 22 - for Getting with XML and C++ and operators specification is located at http://www.w3.org/TR/xpath-functions/, its optional serialization specification is located at Chapter 23 - Build an XML Database OCI C++and Application http://www.w3.org/TR/xslt-xquery-serialization/. Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

W3C XML Pipeline Definition Language Specification

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

The W3C Pipeline Definition specification Chapter 27 -XML Extending PL/SQL XML Language Functionality with Java (http://www.w3.org/TR/2002/NOTE-xml-pipeline20020228/), which It is All stillTogether a W3C Note and not a Recommendation, provides a language in XML to describe the Chapter 28 - Putting

processing- XML relationships between XML resources. A pipeline document would be coded in such a language to allow Standards Bodies and Open Specifications the inputs and outputs to be specified so that a pipeline processor can process this document to get a certain result.

Appendix Glossary Index

W3C XML Protocol

List of Figures List of Tables

The W3C XML Protocol working group, now part of the Web Services working group, has produced the SOAP 1.2 specification. This specification is divided into two parts. Part 1, called Messaging Framework (http://www.w3.org/TR/2003/REC-soap12-part1-20030624/), provides a messaging framework that contains a message construct that can be exchanged over a number of protocols. Part 2, called Adjuncts (http://www.w3.org/TR/2003/REC-soap12-part2-20030624/), covers topics such as the data model, encoding, and SOAP RPC representation.

List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Java Community Process Specifications PL/SQL

ISBN:0072229527 by Mark V. Scardina, under Ben Chang and Jinyu Wang The Java development community Sun Microsystems sponsorship has also come up with a number of McGraw-Hill/Osborne 2004 (600 pages) specifications that are specific to the© Java programming language. Sun embodies some of these specifications in Java Specification (JSRs), to incorporate ideas from developerwithin community through the Java This Requests comprehensive guide focuses on utilizing XMLthe technologies Oracle's XML-enabled products, with emphasis on XML their usage and bestreference practices.implementations within Sun’s JDKs and Community Process. Though thestandards, obvious intent is to package spread their usage, the stated purpose of these additional specifications is to provide Java “friendliness” and additional functionality to the W3C specifications. Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Sun JAXB Specification

Introduction

Part I - Oracle and the XML Standards

The Sun Data Binding Chapter 1 XML - Introducing XML (JAXB) specification, located at http://www.jcp.org/en/jsr/detail?id=31, describes functionality that can bind XML schema to Java Chapter 2 - Accessing XML an with DOM, SAX, JAXB, andclasses StAX so that XML documents that conform to the XML schema3 can be constructed, manipulated programmatically. Chapter - Transforming XMLaccessed, with XSLT and and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

- XML Operations with XQuery Sun JAXP Specification

Chapter 5 Chapter 6

- XML Messaging and RPC with SOAP

The Sun Parsing specification, located JSPs, at http://www.jcp.org/en/jsr/detail?id=5, provides Java APIs Chapter 7 XML - Putting It All(JAXP) Together with XML Pipeline, and XSQL to applications to process and transform Part II - Oracle XML Management for DBAsXML documents independently of the particular XML processor. Chapter 8

- Getting Started with the Oracle XML Database

- Storing XML Data Sun StAX Specification

Chapter 9

Chapter 10 - Generating and Retrieving XML

The Sun API forData XML (StAX) specification, located at http://www.jcp.org/en/jsr/detail?id=173, provides Chapter 11Streaming - Searching XML Java-based APIs to pull-parse Chapter 12 - Managing the OracleXML. XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & ISO SQL/XML Specification PL/SQL

ISBN:0072229527 Mark V. Scardina, Ben Chang The SQL/XML by specification, developed as Partand 14 Jinyu of theWang SQL standard, addresses such issues as the following:

McGraw-Hill/Osborne © 2004 (600 pages)

Representing in XML form, andfocuses vice versa ThisSQL comprehensive guide on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Mapping SQL schemata to and from XML schemata Table of Contents SQL schemas in XML Representing

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Representing SQL actions (insert, update, delete) Introduction Part I - Oracle and the XML Standards

Messaging for XML when used with SQL

Chapter 1

- Introducing XML

Chapter 2 -the Accessing XML withwith DOM, SAX, JAXB, and StAX Using SQL language XML Chapter 3

- Transforming XML with XSLT and XPath

Copies4of -this specification can DTDs be purchased from ISO’s web site at http://www.iso.ch. Chapter Validating XML with and XML Schemas Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle Technical Resources PL/SQL

ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang Oracle has a huge repository of resources located at http://otn.oracle.com. Your first stop should be the XML McGraw-Hill/Osborne © 2004 (600 pages) Technology Center, located at http://otn.oracle.com/tech/xml. This is the location of the following resources:

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Oracle XML Developer’s Kitsstandards, documentation and releases emphasis on XML their usage and best practices. XDK and XML DB forums

Table of Contents

OracleXDK Database and XML 10g DB XMLsamples, & SQL—Design, tutorials, Build and&technical Manage XML papers Applications in Java, C, C++ & PL/SQL Introduction

Technology Preview releases (current XQuery and StAX parser) Part IXML - Oracle and the XML Standards Chapter 1

- Introducing XML You can also find development versions of the latest Oracle product releases at OTN, such as the following:

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter Oracle 3 - Database Transforming 10g, XML athttp://otn.oracle.com/products/database/ with XSLT and XPath Chapter 4

- Validating XML with DTDs and XML Schemas

Oracle- XML Application Server 10g, at http://otn.oracle.com/products/ias/ Operations with XQuery

Chapter 5

Chapter 6 - JDeveloper XML Messaging and with SOAP Oracle 10g, at RPC http://otn.oracle.com/products/jdev/ Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Resources Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Other Helpful PL/SQL

ISBN:0072229527 by software, Mark V. Scardina, Ben Chang and XML JinyuProject Wang at http://xml.apache.org. A good source For open source check out The Apache of industryMcGraw-Hill/Osborne © 2004 (600 pages) specific DTDs or XML schemas is RosettaNet, at http://www.rosettanet.org. For other XML-related standards, go to the OASIS site http://www.oasis-open.org. is a technologies good sourcewithin of XML industry updates and software, Thisat comprehensive guide focuses on XML.org utilizing XML Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. athttp://www.xml.org.

Companies with XML sites and resources include Sun, http://www.sun.com/xml; Microsoft, http://www.microsoft.com/xml; and IBM, http://www.ibm.com/xml.

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Finally, there is a wide array of general Oracle and XML educational sites. Some of our favorites are Part I - Oracle and the XML Standards http://www.zvon.org, http://asktom.oracle.com, and http://www.xmlfiles.com.

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Glossary PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

API

ISBN:0072229527

See This application comprehensive program guide interface. focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

application program interface (API) A set of public programmatic interfaces that consists of a language or message format to communicate Table of Contents with anXML operating system orBuild other&programmatic environment, a database, web server, JVM, Oracle Database 10g & SQL—Design, Manage XML Applications in such Java, as C, C++ & PL/SQL Introduction

and so forth. When formatted as messages, they will typically call functions and methods that are

for application Part I - Oracleavailable and the XML Standards development. Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

A server thatXML is designed toand hostXPath applications and their environments, permitting server applications to - Transforming with XSLT

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 6

- XML Messaging and RPC with SOAP

application server

run. A typical example is Oracle Application Server 10g, which is able to host Java, C, C++, and PL/SQL applications in cases in which a remote client controls the interface. See alsoOracle Chapter 5 - XML Operations with XQuery Application Server. Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL attribute Part II - Oracle XML Management for DBAs

A property of an element that consists of a name and a value separated by an equal sign and contained within the start tag after the element name. In the example <Price units=“USD”>5</Price>,priceis Chapter 9 - Storing XML Data the attribute and USD is its value, which must be in single or double quotes. Elements may have many Chapter 10 - Generating Retrieving XML attributes, and but their retrieval order is not defined. Chapter 8

- Getting Started with the Oracle XML Database

Chapter 11 - Searching XML Data Chapter BFILE 12 - Managing the Oracle XML Database Part III - Oracle XML for Java (LOB) Developers A Large Object data type that is an external binary file that exists outside the database files and

Chapter 13 - Getting Started with Oracle and Java tablespaces residing in theXML operating system. BFILEs are referenced from the database semantics and Chapter 14 - Building XML-Powered WebLOBs. Site are alsoan known as External Chapter 15 - Creating a Portal Site with XML and Web Services

Binary16 Large Object (BLOB) Chapter - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing A LOB data XML-Based type whose Reusable contentComponents consists of binary data. This data is considered raw because its Part IV - Oracle structure XML forisC not Developers recognized by the database.

Chapter 18 - Getting Started with Oracle XML and C

BLOB 19 - Building an XML-Managed Application Chapter SeeBinary Object. Chapter 20 - Build an XMLLarge Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

business-to-business (B2B)

Part V - Oracle XML for C++ Developers

The electronic exchange goods Chapter 22 - Getting Started with Oracleof XML and and C++services between businesses. The software infrastructure to enable referred OCI to asC++ an exchange. Chapter 23 - Build an this XMLisDatabase Application Chapter 24 - Building an XML Data-Retrieval Application

business-to-consumer (B2C)

Part VI - Oracle XML for PL/SQL Developers

The electronic exchange goods services between businesses and consumers in the selling of Chapter 25 - Getting Started with Oracleof XML and and PL/SQL goods and services.

Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

callback

Chapter 28 - Putting It All Together Appendix

A programmatic technique in which one process starts another and then continues. The second process then calls the first as a result of an action, value, or other event. This technique is used in most programs that have a user interface to allow continuous interaction.

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures cartridge

List of Tables A stored program in Java or PL/SQL that adds the necessary functionality for the database to List of Sidebars understand and manipulate a new data type. Cartridges interface through the Extensibility Framework

within Oracle 8i or later.Oracle Text is such a cartridge, adding support for reading, writing, and searching text documents stored within the database. CDATA Seecharacter data. CGI SeeCommon Gateway Interface.


character data (CDATA) Text in a document beDesign, parsed is put within a CDATA section. This allows forC,the Oracle Database that 10g should XML & not SQL: Build & Manage XML Applications in Java, C++ & inclusion PL/SQLof characters that would otherwise have special functions, such as &, <, >, and so on. CDATA sections be used inBen theChang content ofJinyu an element is ISBN:0072229527 by Markcan V. Scardina, and Wang or in attributes. The syntax for element content <![CDATA[ put the text©here ]]>. pages) McGraw-Hill/Osborne 2004 (600 This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Character Large Objecton(CLOB) emphasis XML standards, their usage and best practices.

A LOB data type whose value is composed of character data that corresponds to the database character set. A CLOB may be indexed and searched by the Oracle Text search engine. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

child element

Introduction

An element that is wholly contained within another element, which is referred to as its parent element. For example, <Parent><Child></Child></Parent> illustrates a child element nested within its parent Chapter 1 - Introducing XML element. Part I - Oracle and the XML Standards

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3 - Transforming XML with XSLT and XPath CLASSPATH Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

The operating system environmental variable that the JDK or JRE uses to find the Java source, classes, and resources it needs to run applications.

Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL client/server Part II - Oracle XML Management for DBAsin which the actual application runs on the client but accesses data or other The application architecture

Chapter 8

- Getting Started with the XML Database external processes on aOracle server across a network.

Chapter 9

- Storing XML Data

CLOB 10 - Generating and Retrieving XML Chapter Chapter 11 - Searching XML Data SeeCharacter Large Object. Chapter 12 - Managing the Oracle XML Database

command lineXML for Java Developers Part III - Oracle Chapter 13 - Getting Startedmethod with Oracle XML the and user Java enters commands at the command interpreter’s prompt. The interface in which Chapter 14 - Building an XML-Powered Web Site

Common (CGI) Chapter 15 -Gateway Creating Interface a Portal Site with XML and Web Services Industry-standard programming interfaces enable web servers to execute other programs and pass Chapter 16 - Developing an XML Gateway Application with that SOAP and AQ their outputXML-Based to HTML pages, graphics, audio, and video sent to browsers. Chapter 17 - Developing Reusable Components Part IV - Oracle XML for C Developers

Common Object Request Broker API (CORBA)

Chapter 18 - Getting Started with Oracle XML and C

An Object Management Group standard for communicating between distributed objects across a Chapter 19 - Building an XML-Managed Application network. These CORBA are self-contained software modules that can be used by applications Chapter 20 - Build an XML Database OCIobjects Application that run different platforms or operating systems. CORBA objects and their data formats and Chapter 21 - Create anon XML-Configured High-Performance Transformation Engine

are defined in the Interface Definition Language (IDL), which can be compiled in a variety of Part V - Oraclefunctions XML for C++ Developers languages, including Java, C, C++, Smalltalk, and COBOL.

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application

Common Oracle Runtime Environment (CORE)

Chapter 24 - Building an XML Data-Retrieval Application

The library of functions written in C that enables developers to create code that can be easily ported to virtually any platform and operating system.

Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services CORBA

Chapter 27 - Extending PL/SQL XML Functionality with Java

SeeCommon Object Request Broker API.

Chapter 28 - Putting It All Together

Appendix XML Standards Bodies and Open Specifications Database -Access Descriptor (DAD) Glossary

A virtual path for Oracle’s PL/SQL cartridge and a named set of configuration values used for database access. A DAD specifies information such as the database name or the SQL*Net V2 service name; the List of Figures ORACLE_HOME directory; and the Globalization Support language configuration information, such as List of Tables language, sort type, and date language. Index

List of Sidebars

datagram A text fragment, which may be in XML format, that is returned to the requester embedded in an HTML page from a SQL query processed by the XSQL Servlet. DBUriType The Oracle XML DB data type used for storing instances of the data type that permits XPath-based navigation of database schemas.


DOCTYPE The tag name that designates the DTD or its reference within an XML document. For example, <!DOCTYPE person10g SYSTEM declares the root element name asinperson an & Oracle Database XML & “person.dtd”> SQL: Design, Build & Manage XML Applications Java, and C, C++ PL/SQL external DTD as person.dtd in the file system. Internal DTDs are declared within the DOCTYPE ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang declaration. McGraw-Hill/Osborne © 2004 (600 pages)

Document Object Model (DOM) guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with This comprehensive on tree-based XML standards, their usage and best practices. Anemphasis in-memory object representation of an XML document that enables programmatic access to its elements and attributes. The DOM object and its interface is a W3C recommendation. Table of Contents

Document Type Definition (DTD)

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

A set of rules that defines the allowable structure of an XML document. DTDs are text files that derive

from SGML and can be included in an XML document either by using the DOCTYPE Part I - Oracletheir and format the XML Standards Chapter 1

element or XML by using an external file through a DOCTYPE reference. - Introducing

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

DTD

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

DOM

SeeDocument Object Model.

SeeDocument Type Definition.

Part II - Oracle XML Management for DBAs element

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

The basic logical unit of an XML document that may serve as a container for other elements, such as children, data, and attributes and their values. Elements are identified by start tags, <tagname>, and Chapter 10 - Generating and Retrieving XML end tags, </tagname> or, in the case of empty elements, <tagname/>. Chapter 11 - Searching XML Data

Chapter - Managing the Oracle XML Database empty 12 element Part III - Oracle XML for Java Developers

An element without text content or child elements. It may contain only attributes and their values. Empty

Chapter 13 - Getting Started XML and Javaor <tagname></tagname> (with no space between the tags). elements are ofwith theOracle form <tagname/> Chapter 14 - Building an XML-Powered Web Site

Enterprise Java Beans (EJB) Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XMLprogram Gateway Application with within SOAP and AQ on the server. Oracle Application Server 10g An independent module that runs a JVM Chapter 17 - Developing XML-Based Reusable Components provides the infrastructure for EJBs, and a container layer provides security, transaction support, and Part IV - Oracle XMLcommon for C Developers other functions on any supported server.

Chapter 18 - Getting Started with Oracle XML and C

entity 19 - Building an XML-Managed Application Chapter A string of characters that Application may represent either another string of characters or special characters that Chapter 20 - Build an XML Database OCI are notanpart of the document’s character set. Entities, and the text that is substituted for them by the Chapter 21 - Create XML-Configured High-Performance Transformation Engine are declared in the DTD. Part V - Oracleparser, XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++

ExistNode

Chapter 23 - Build an XML Database OCI C++ Application

The SQL provided in Application Oracle9iand Oracle Database 10g that returns TRUE or FALSE based Chapter 24 - Building anoperator XML Data-Retrieval upon of an XPath expression within an XMLType. Part VI - Oracle XMLthe forexistence PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

Extensible Markup Language (XML)

Chapter 26 - Building PL/SQL Web Services

An open standard developed by W3C for describing data using a subset of the SGML syntax. XML is designed for Internet use. Version 1.0 is the current standard, published as a W3C recommendation in Chapter 28 - Putting It All Together February 1998. Chapter 27 - Extending PL/SQL XML Functionality with Java Appendix

- XML Standards Bodies and Open Specifications

Glossary Extensible Stylesheet Language (XSL) Index

The language used within stylesheets to transform or render XML documents. There are two W3C recommendations covering XSL stylesheets—XSL Transformations (XSLT) and XSL Formatting List of Tables Objects (XSLFO). List of Figures

List of Sidebars

Extensible Stylesheet Language Formatting Objects (XSLFO) The W3C standard specification that defines an XML vocabulary for specifying formatting semantics. Extensible Stylesheet Language Transformations (XSLT) The XSL W3C standard specification that defines a transformation language to convert one XML document into another. Extract


The SQL operator provided in Oracle9i and Oracle Database 10g that retrieves fragments of XML documents stored as XMLTypes. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

function-based index PL/SQL

A by database built on expression, which can be an arithmetic expression or an expression ISBN:0072229527 that Mark V.index Scardina, Benan Chang and Jinyu Wang contains a PL/SQL function, McGraw-Hill/Osborne © 2004 package (600 pages)function, C callout, or SQL function. Function-based indexes also support linguistic sortsguide based on collation keys,XML efficient linguisticwithin collation of SQL statements, and with This comprehensive focuses on utilizing technologies Oracle's XML-enabled products, case-insensitive emphasis on XML sorts. standards, They extend their usage your indexing and bestcapabilities practices. beyond indexing on a column and increase the variety of ways in which you can access data. Table of Contents

HASPATH

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

The SQL operator provided in Oracle9i and Oracle Database 10g that is part of Oracle Text and used for querying XMLType data types for the existence of a specific XPath. Part I - Oracle and the XML Standards Introduction Chapter 1

HTML

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter HTTP 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

SeeHypertext Markup Language.

SeeHypertext Transport Protocol.

Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL HTTPUriType Part II - Oracle XML Management for DBAs

The SQL operator provided in Oracle9i and Oracle Database 10g that is used for storing instances of

Chapter 8

- Getting Started withpermits the Oracle XML Database the data type that XPath-based navigation of database schemas in remote HTTP servers.

Chapter 9

- Storing XML Data

Chapter Hypertext 10 -Markup Generating Language and Retrieving (HTML) XML Chapter 11 - Searching XMLlanguage Data The markup that is used to create the files sent to web browsers and that serves as the basis Chapter 12 - Managing the Oracle XML Database of the World Wide Web. HTML’s next version is XHTML and is an XML application. Part III - Oracle XML for Java Developers

Hypertext Protocol (HTTP)XML and Java Chapter 13 -Transport Getting Started with Oracle Chapter 14 - Building an XML-Powered Web Site HTML files across the Internet between web servers and browsers. The protocol used for transporting Chapter 15 - Creating a Portal Site with XML and Web Services

IDE 16 - Developing an XML Gateway Application with SOAP and AQ Chapter SeeIntegrated Development Environment. Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

iFS 18 - Getting Started with Oracle XML and C Chapter SeeInternet File System. Application Chapter 19 - Building an XML-Managed Chapter 20 - Build an XML Database OCI Application

INPATH

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

SQL operator provided in Oracle9i and Oracle Database 10g that is part of Oracle Text and used to Part V - OracleThe XML for C++ Developers query XMLType data typesXML for and specific Chapter 22 - Getting Started with Oracle C++text within a specific XPath. Chapter 23 - Build an XML Database OCI C++ Application

instantiate

Chapter 24 - Building an XML Data-Retrieval Application

In XML object-based languages such as Java and C++, refers to the creation of an object of a specific class. Part VI - Oracle for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

Integrated Development Environment (IDE)

Chapter 26 - Building PL/SQL Web Services

A set of programs designed to aid in the development of software that is run from a single user interface. Oracle JDeveloper is an IDE for Java development because it includes an editor, compiler, Chapter 28 - Putting It All Together debugger, syntax checker, help system, and so on, to permit Java software development through a Appendix - XML Standards Bodies and Open Specifications single user interface. Chapter 27 - Extending PL/SQL XML Functionality with Java

Glossary

Index Internet File System (iFS) List of Figures The Oracle file system that has a Web GUI and a Java-based development environment (called Oracle List of Tables Content Management SDK) and that runs on a middle tier and provides a means of creating, storing, List of Sidebars and managing multiple types of documents in a single database repository. The Oracle Content

Management SDK is available only in Oracle Application Server. The Oracle Files is only shipped with the Oracle Collaboration Suite. Internet Inter-ORB Protocol (IIOP) The protocol used by CORBA to exchange messages on a TCP/IP network such as the Internet. Java A high-level programming language developed and maintained by Sun Microsystems in which


applications run in a Java Virtual Machine (JVM). The JVM is responsible for all interfaces to the operating system. This architecture permits developers to create Java applications and applets that can runOracle on anyDatabase operating10g system that has a JVM. XMLor & platform SQL: Design, Build & Manage XML Applications in Java, C, C++ & JavaBeans

PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Java objects whose implementations conform to a set of conventions designed to promote modularity McGraw-Hill/Osborne © 2004 (600 pages) and reusability. They are one example of a component-programming andXML-enabled can be deployed in a with This comprehensive guide focuses on utilizing XML technologies withinmodel Oracle's products, servlet, an applet, a JSP page. emphasis on XMLor standards, their usage and best practices. Java Database Connectivity (JDBC)

Table of Contents

The programming API that enables Java applications to access a database through the SQL language. JDBC drivers are written in Java for platform independence but are specific to each database.

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Part I - Oracle and the XML Standards

Java Developer’s Kit (JDK)

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 4

- Validating XML with DTDs and XML Schemas

The collection of Java classes, run-time environment, compiler, debugger, and usually source code that comprises a Java development environment for a particular Java version. JDKs are designated by Chapter 3 - Transforming XML with XSLT and XPath versions, and Java 2 is used to designate versions from 1.2 onward. Chapter 5 - XMLEnvironment Operations with XQuery Java Runtime (JRE) Chapter 6

- XML RPC withclasses SOAP that makes up the JVM on a platform. JREs are designated by TheMessaging collection and of compiled

Chapter 7

- Putting It All Together XMLtoPipeline, JSPs, and XSQL versions, and Java 2 with is used designate versions from 1.2 onward.

Part II - Oracle XML Management for DBAs

Chapter JavaServer 8 - Getting pages Started (JSP) with the Oracle XML Database Chapter 9

- Storing XML Data An extension to the servlet functionality that enables a simple programmatic interface to web pages.

Chapter 10 - Generating and Retrieving XMLspecial tags and embedded Java code that is executed on the web or JSPs are HTML pages with Chapter 11 - Searching XML Datato provide dynamic functionality to HTML pages. JSPs are actually compiled into application server Chapter 12 - Managing servlets when the Oracle first requested XML Database and are run in the server’s JVM. Part III - Oracle XML for Java Developers

Java Virtual Machine (JVM) Chapter 13 - Getting Started with Oracle XML and Java The Java thatWeb converts Chapter 14 - Building an interpreter XML-Powered Site the compiled Java byte code into the machine language of the platformaand runs it. with JVMs canand runWeb on aServices client, in a browser, on a web server, on an application server Chapter 15 - Creating Portal Site XML such as Oracle Application Server 10g,with or on a database Chapter 16 - Developing an XML Gateway Application SOAP and AQ server such as Oracle Database 10g. Chapter 17 - Developing XML-Based Reusable Components

JAXB Class Generator

Part IV - Oracle XML for C Developers

A utilityStarted that accepts an input and Chapter 18 - Getting with Oracle XMLfile and C creates a set of output classes that has corresponding functionality. In the case Application of the XML JAXB Class Generator, which is compliant with JSR-031 XML Chapter 19 - Building an XML-Managed

Binding Specification (JAXB), the input file is an XML schema and the output is a series of Java classes that can be used to create XML documents that conform to the XML schema.

Chapter 20 - Build an XML Database OCI Application

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

JDBC

Chapter 22 - Getting Started with Oracle XML and C++

SeeJava Database Connectivity.

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application JDeveloper Part VI - Oracle XML for PL/SQL Developers

Oracle’s Java IDE that enables application, applet, and servlet development and includes an editor, compiler, debugger, syntax checker, help system, and so on. In version 10g, JDeveloper has been Chapter 26 - Building PL/SQL Web Services enhanced to support XML-based development by including the Oracle XDK’s Java libraries integrated Chapter 27 - Extending PL/SQL XML Functionality with for easy use along with XML support in Java its editor. Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 28 - Putting It All Together Appendix JDK

- XML Standards Bodies and Open Specifications

Glossary

SeeJava Developer’s Kit.

Index

JServer List of Figures List of Tables The JVM that runs within the memory space of the Oracle8i or later database. In Oracle 8i Release 1, List of Sidebars the JVM was Java 1.1 compatible, while Release 2 is Java 1.2 compatible. In Oracle Database 10g, the

JVM is compatible with JDK 1.4. It is also known as the OJVM. JVM SeeJava Virtual Machine. LAN Seelocal area network.


Large Object (LOB) The class of SQL data type that is further divided into Internal LOBs and ExternalLOBs. Internal LOBs include BLOBs, CLOBS, and NCLOBs, while External include See also BFILES, Binary Oracle Database 10g XML & SQL: Design, Build & LOBs Manage XML BFILES. Applications in Java, C, C++ & PL/SQL Large Object,Character Large Object, and Non-Character Large Object. by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

listener

ISBN:0072229527

The This server comprehensive process that guide listens focuses for and on utilizing acceptsXML incoming technologies connection withinrequests Oracle's from XML-enabled client applications. products, with emphasis on XML standards, usage and best practices. Oracle listener processes starttheir up Oracle database processes to handle subsequent communications with the client. Table of Contents

LOB

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

SeeLarge Object.

Part I - Oracle and the XML Standards

local area network (LAN)

Chapter 1

- Introducing XML

Chapter 2

A computer that serves users within a restricted geographical area. LANs - Accessing XMLcommunications with DOM, SAX, network JAXB, and StAX

Chapter 3

consist of servers, workstations, communications hardware (routers, bridges, network cards, and so - Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

on), and a network operating system.

Chapter 5

- XML Operations with XQuery namespace

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

A set of related element names or attributes within an XML document. The namespace syntax and its usage are defined by a W3C recommendation. For example, the <xsl:apply-templates/> element is Part II - Oracle XML Management for DBAs identified as part of the XSL namespace. Namespaces are declared in the XML schema or in the XML Chapter 8 - Getting Started with the Oracle XML Database document before they are used by using the attribute syntaxxmlns:xsl=“http://www.w3.org/TR/WDChapter 9 - Storing XML Data xsl”. Chapter 10 - Generating and Retrieving XML Chapter NCLOB11 - Searching XML Data Chapter 12 - Managing the Oracle Large XML Database SeeNon-Character Object. Part III - Oracle XML for Java Developers

Chapter node 13 - Getting Started with Oracle XML and Java Chapter 14 - Building XML-Powered Web Site in the DOM tree. In XML,an each addressable entity Chapter 15 - Creating a Portal Site with XML and Web Services

Non-Character Large an Object (NCLOB)Application with SOAP and AQ Chapter 16 - Developing XML Gateway Chapter 17 - Developing XML-Based A CLOB that containsReusable Unicode Components characters, with a maximum size of 4GB. Part IV - Oracle XML for C Developers

NOTATION Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building In XML,an theXML-Managed definition of aApplication content type that is not part of the types understood by the XML parser.

These include audio, video, and other multimedia. For example, to include a GIF image in your Chapter 20 - Build antypes XML Database OCI Application XML document you wouldHigh-Performance use <!NOTATION GIF system “image/gif”>. Chapter 21 - Create an XML-Configured Transformation Engine Part V - Oracle XML for C++ Developers

n-tier

Chapter 22 - Getting Started with Oracle XML and C++

The designation for a computer communications network architecture that consists of one or more tiers Chapter 23 - Build an XML Database OCI C++ Application made upanofXML clients and servers. Typically, two-tier systems are made up of one client level and one Chapter 24 - Building Data-Retrieval Application server A three-tier system utilizes two server tiers, typically a database server as one tier and a Part VI - Oracle XML level. for PL/SQL Developers web orStarted application the other tier, along with a client tier. Chapter 25 - Getting with server Oracle as XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

OASIS

Chapter 27 - Extending PL/SQL XML Functionality with Java

SeeOrganization for the Advancement of Structured Information.

Chapter 28 - Putting It All Together

Appendix - XML Standards Bodies and Open Specifications object-relational Glossary Index List of Figures

A relational database system that can also store and manipulate higher-order data types, such as text documents, audio, video files, and user-defined objects.

List of Tables Object Request Broker (ORB) List of Sidebars Software that manages message communications between requesting programs on clients and

between objects on servers. ORBs pass the action request and its parameters to the object and return the results. Common implementations are CORBA and EJB. See also Common Object Request Broker and Enterprise JavaBeans. Object view A tailored presentation of the data contained in one or more object tables or other views. The output of an Object view query is treated as a table. Object views can be used in most places where a table is used.


Oracle Application Server (Oracle AS) The Oracle server that all the core services features for building, deploying, and Oracle Database 10gintegrates XML & SQL: Design, Build & and Manage XMLrequired Applications in Java, C, C++ & managing PL/SQL high-performance, n-tier, transaction- oriented web applications within an open standards framework. ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

Oracle Enterprise Manager

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

A emphasis separate Oracle on XML product standards, thattheir combines usage and a graphical best practices. console, agents, common services, and tools to provide an integrated and comprehensive systems management platform for managing Oracle products. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ORACLE_HOME

Introduction

The operating system environmental variable that identifies the location of the Oracle database installation for use by applications.

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter - Accessing XML with DOM, SAX, JAXB, and StAX Oracle2Text Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

An Oracle tool that provides full-text indexing of documents and the capability to do SQL queries over documents, along with XPath-like searching.

Chapter - XML Oracle6XML DBMessaging and RPC with SOAP Chapter 7

- Putting It All TogetherXML with storage XML Pipeline, JSPs, and XSQL A high-performance and retrieval technology provided with Oracle database server

Part II - Oracle XML Management for DBAs beginning with Oracle9i Release 2. It is based on the W3C XML data model.

Chapter 8

- Getting Started with the Oracle XML Database

Chapter ORB 9

- Storing XML Data

Chapter 10 - Generating Retrieving XML SeeObjectand Request Broker. Chapter 11 - Searching XML Data

Organization for thethe Advancement of Structured Information (OASIS) Chapter 12 - Managing Oracle XML Database Part III - Oracle for Java Developers AnXML organization of members chartered with promoting public information standards through

Chapter 13 - Getting Startedseminars, with Oracle XML and Java conferences, exhibits, and other educational events. Oasis is actively promoting XML as well Chapter 14 - Building as SGML. an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

parent 16 element Chapter - Developing an XML Gateway Application with SOAP and AQ An elementXML-Based that surrounds another element, which is referred to as its child element. For example, Chapter 17 - Developing Reusable Components <Parent><Child></Child></Parent> illustrates a parent element wrapping its child element. Part IV - Oracle XML for C Developers Chapter 18 - Getting Started with Oracle XML and C

Parsed Character Data (PCDATA)

Chapter 19 - Building an XML-Managed Application

The element or attribute consisting of text that should be parsed but is not part of a tag or Chapter 20 - Build an XML Database OCIcontent Application unparsed data (CDATA). High-Performance Transformation Engine Chapter 21 - Create an XML-Configured Part V - Oracle XML for C++ Developers

parser

Chapter 22 - Getting Started with Oracle XML and C++

In XML, a software program that accepts as input an XML document, determines whether it is well formed and, optionally, valid, and provides programmatic access to XML data. The Oracle XML parser Chapter 24 - Building an XML Data-Retrieval Application supports both SAX and DOM, and JAXP interfaces. Chapter 23 - Build an XML Database OCI C++ Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL PCDATA Chapter 26 - Building PL/SQL Web Services

SeeParsed Character Data.

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together PL/SQL Appendix

- XML Standards Bodies and Open Specifications

Glossary

The Oracle procedural database language that extends SQL to create programs that can be run within the database.

Index List prolog of Figures List of Tables The opening part of an XML document that contains the XML declaration, a possible language List of Sidebars encoding, and any DTD or other declarations needed to process the document.

PUBLIC Specifies the Internet location of the reference that follows it. renderer A software processor that outputs a document in a specified format. result set


The output of a SQL query consisting of one or more rows of data. root element

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

The element that encloses all the other elements in an XML document and is located between the PL/SQL optional prolog and epilog. XMLand document is permitted to have only one root element. ISBN:0072229527 by Mark V. Scardina, Ben An Chang Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

SAX

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

See emphasis Simple API on XML for XML. standards, their usage and best practices. schema

Table of Contents

The definition of the structure and& data types within a database. It can also be used to refer to an XML Oracle Database 10g XML & SQL—Design, Build Manage XML Applications in Java, C, C++ & PL/SQL Introduction

document that supports the XML Schema W3C recommendation.

Part I - Oracle and the XML Standards

Secure Sockets Layer (SSL)

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

The primary security protocol on the Internet; utilizes a public key/private key form of encryption between browsers and servers.

Chapter 4 - Validating Server-Side Include XML (SSI)with DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

The HTML command used to place data or other content into a web page before sending it to the requesting browser.

Part II - Oracle XML Management for DBAs servlet

Chapter 8

- Getting with that the Oracle Database A JavaStarted application runs inXML a server, typically a web or application server, and performs processing

Chapter 9

- Storing DataServlets are the Java equivalent to CGI scripts. on thatXML server.

Chapter 10 - Generating and Retrieving XML

session Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XMLbetween Database The active connection two tiers. Part III - Oracle XML for Java Developers

SGML 13 - Getting Started with Oracle XML and Java Chapter Chapter 14 - Building an XML-Powered WebMarkup Site SeeStructured Generalized Language. Chapter 15 - Creating a Portal Site with XML and Web Services

Simple16 API for XML (SAX) Chapter - Developing an XML Gateway Application with SOAP and AQ An XML standard interface provided by XML parsers and used by event-based applications. Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Simple18 Object Access Protocol (SOAP) Chapter - Getting Started with Oracle XML and C Lightweight, XML-based Application protocol for exchanging information in a decentralized, distributed environment. Chapter 19 - Building an XML-Managed Chapter 20 - Build an XML Database OCI Application

SQL

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Structured Query Language. Part V - OracleSee XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++

SQL/XML

Chapter 23 - Build an XML Database OCI C++ Application

Part of the ANSI/ISO SQL standard, SQL/XML provides a number of standards-based functions that Chapter 24 - Building an XML Data-Retrieval Application enable youPL/SQL to query relational data and return XML documents. Part VI - Oracle XML for Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

SSI

Chapter 26 - Building PL/SQL Web Services

SeeServer-Side Include.

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter SSL 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary

SeeSecure Sockets Layer.

Index SOAP List of Figures List of Tables

SeeSimple Object Access Protocol

List of Sidebars Structured Generalized Markup Language (SGML)

An ISO standard for defining the format of a text document, implemented using markup and DTDs. Structured Query Language (SQL) The standard language used to access and process data in a relational database. stylesheet In XML, an XML document that consists of XSL processing instructions used by an XSL processor to


transform or format an input XML document into an output markup text document (XML, HTML, WML, SVG, etc.). Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

SYSTEM

Specifies location on the host operating system of the reference that follows it. by Mark the V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

tag

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

A emphasis single piece on of XML XML standards, markup their that delimits usage and thebest startpractices. or end of an element. A tag starts with < and ends with >. In XML, there are start tags (<tagname>), end tags (</tagname>), and empty tags (<tagname/>). Unlike HTML, XML tags are case sensitive. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

TCP/IP

Introduction

SeeTransmission Control Protocol/Internet Protocol.

Part I - Oracle and the XML Standards

Chapter 1

thread

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

In programming, a single message or process execution path within an operating system that supports multiple operating systems, such as Windows, UNIX, and Java.

Chapter 5 - XMLControl Operations with XQuery Transmission Protocol/Internet Protocol (TCP/IP) Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML mechanism. Pipeline, JSPs, XSQL IP, which provides the routing It and is the standard for Internet communications.

The communications network protocol that consists of TCP, which controls the transport functions, and

Part II - Oracle XML Management for DBAs

Chapter 8 Resource - Getting Started with(URI) the Oracle XML Database Uniform Identifier Chapter 9

- Storing XML Data The address syntax that is used to create URLs and XPaths.

Chapter 10 - Generating and Retrieving XML

Uniform (URL) Chapter 11Resource - SearchingLocator XML Data Chapter 12 - Managing the Oracle XML Database The address that defines the location and route to a file or resource on the Internet. URLs are used by Part III - Oracle XML fortoJava Developers browsers navigate the Web and consist of a protocol prefix, port number, domain name, directory

Chapter 13 - Getting Started with Oracleand XMLthe andfilename. Java and subdirectory names, For example, Chapter 14 - Building http://technet.oracle.com:80/tech/xml/index.htm an XML-Powered Web Site specifies the location and path a browser travels to

find Oracle Technology XMLServices site on the Web. Chapter 15 - Creating a Portal Site withNetwork’s XML and Web Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

URI

Chapter 17 - Developing XML-Based Reusable Components

See Uniform Resource Identifier. Part IV - Oracle XML for C Developers Chapter 18 - Getting Started with Oracle XML and C

URL

Chapter 19 - Building an XML-Managed Application

SeeUniform ResourceOCI Locator. Chapter 20 - Build an XML Database Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

user interface (UI)

Part V - Oracle XML for C++ Developers

The combination of Oracle menus, screens, keyboard commands, mouse clicks, and command language that Chapter 22 - Getting Started with XML and C++ defines how a user interacts with a software application.

Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

valid

Part VI - Oracle XML for PL/SQL Developers

The status of an XML document when its structure and element content is consistent with that declared in its referenced or included DTD or its XML schema.

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Chapter W3C 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

SeeWorld Wide Web Consortium.

- XML Standards Bodies and Open Specifications

Glossary WAN Index

Seewide area network.

List of Figures List well of formed Tables List of Sidebars Describes an XML document that conforms to the syntax of the XML version declared in its XML

declaration. This includes having a single root element, properly nested tags, and so forth. wide area network (WAN) A computer communications network that serves users within a wide geographic area, such as a state or country. WANs consist of servers, workstations, communications hardware (routers, bridges, network cards, and so on), and a network operating system. Working Group (WG)


A committee within W3C that is made up of industry members that implement the recommendation process in specific Internet technology areas. Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ &

World Wide Web Consortium (W3C) PL/SQL

Anbyinternational industry consortium in 1994 to develop standards for the Web. It is located at ISBN:0072229527 Mark V. Scardina, Ben Chang andstarted Jinyu Wang http://www.w3c.org. McGraw-Hill/Osborne © 2004 (600 pages) This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

wrapper

A data structure or software that wraps around other data or software, typically to provide a generic or object interface. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

XML

Introduction

SeeExtensible Markup Language.

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML XML Developer’s Kit (XDK)

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 6

- XML Messaging and RPC with SOAP

The set of libraries, components, and utilities that provides software developers with the standardsbased functionality to XML-enable their applications. In the case of the Oracle XDK for Java, the kit Chapter 4 - Validating XML with DTDs and XML Schemas contains an XML parser, an XSLT processor, the XML JAXB Class Generator, the XML SQL Utility, and Chapter 5 - XML Operations with XQuery the XSQL Servlet. Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL XML Query (XQuery) Part II - Oracle XML Management for aDBAs W3C’s effort to create standard for the language and syntax to query XML documents.

Chapter 8

- Getting Started with the Oracle XML Database

Chapter XML Schema 9 - Storing XML Data Chapter 10 - Generating andtoRetrieving XML W3C’s effort create a standard to express simple data types and complex structures within an XML Chapter 11 - Searching XML Data document. Chapter 12 - Managing the Oracle XML Database

XMLType Part III - Oracle XML for Java Developers Chapter 13 - Getting Started XML and Java An Oracle datawith typeOracle that stores XML data using an underlying CLOB column or object-relational Chapter 14 - Building columnsanwithin XML-Powered a table orWeb view. Site Chapter 15 - Creating a Portal Site with XML and Web Services

XMLType Chapter 16 -views Developing an XML Gateway Application with SOAP and AQ Oracle XML DB provides XMPType views as a way to wrap existing relational and object-relational data Chapter 17 - Developing XML-Based Reusable Components in XML XML for format. This is especially useful if, for example, your legacy data is not in XML but you have to Part IV - Oracle C Developers migrateStarted it to anwith XMLOracle format. Chapter 18 - Getting XML and C Chapter 19 - Building an XML-Managed Application

XPath

Chapter 20 - Build an XML Database OCI Application

The open standard syntaxHigh-Performance for addressing elements within aEngine document used by XSL and XPointer. Chapter 21 - Create an XML-Configured Transformation is currently a W3C recommendation. Part V - OracleXPath XML for C++ Developers Chapter 22 - Getting Started with Oracle XML and C++

XPointer

Chapter 23 - Build an XML Database OCI C++ Application

A reference to an XML document fragment. An XPointer can be used at the end of an XPath-formatted URI. XPointer is also the name of the W3C recommendation that describes the use of XPointers.

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter XQuery25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

SeeXML Query.

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter XSL 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary

SeeExtensible Stylesheet Language.

Index XSLFO List of Figures SeeExtensible Stylesheet Language Formatting Objects. List of Tables

XSLT List of Sidebars SeeExtensible Stylesheet Language Transformations. XSQL The name of the Oracle Servlet providing the ability to produce dynamic XML documents from one or more SQL queries, optionally transform the document in the server using an XSL stylesheet, and provide HTTP session management.


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

A

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Access, initializing XDK for XMLType XOB, 446–447 emphasis on XML standards, their usage and best practices.

Accessing XML using DOM, 17–27 Table of Contents XML with DOM, 15 Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XML with Java binding, 42–45 Introduction XML with JAXB, 15 Part I - Oracle and the XML Standards XML with SAX, 15,28–42 Chapter 1 - Introducing XML XML with StAX, 15,45–47 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 5

- XML Operations with XQuery

Adding Chapter 3 - Transforming XML with XSLT and XPath pagination to FAQ listing, 277–279 Chapter 4 - Validating XML with DTDs and XML Schemas portal functionality, 301–307 Administration creating, Chapter 6 - XMLpage, Messaging and307–311 RPC with SOAP

Advanced 11,101,148, Chapter 7 -Queuing Putting It(AQ), All Together with 314 XML Pipeline, JSPs, and XSQL Part II - OracleXML XMLschema, Management for DBAs Annotations, 165–168

Chapter 8

- Getting Started with the Oracle XML Database

APIs Chapter 9 - Storing XML Data DOM,19–22 Chapter 10 - Generating and Retrieving XML Oracle DOM, 27 Chapter 11 - Searching querying XMLTypeXML withData C++ XDK, 447–449 Chapter 12 Managing the Oracle XML Database SAX, 31–37,37–42 Part XQuery, III - Oracle 92 XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

Application environment setting up C++ OCI XML, 435–437 Chapter 15 - Creating a Portal Site with XML and Web Services setting up OCI, 395–397 Chapter 14 - Building an XML-Powered Web Site

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Application headers, OCI XML, 395–396,435–437

Chapter 17 - Developing XML-Based Reusable Components

Application libraries Part IV - Oracle XML for C Developers OCI18 and C++ XML, 437 with Oracle XML and C Chapter - Getting Started OCI19 XML, 396 an XML-Managed Application Chapter - Building Chapter Application 20 - make Build an files, XML OCI Database XML, 396–397 OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Applications Part building V - Oracle XML for352–360 C++ Developers pipeline,

Chapter 22 - Getting Started with Oracle XML and C++ creating C++ query, 443–444 Chapter 23 - Build an XML386–391 Database OCI C++ Application creating publishcat, Chapter 24 - Building an XML Data-Retrieval Application designing XML databases for messaging, 155–156 Part designing VI - OracleXML XMLdatabases for PL/SQLfor Developers Web, 155

Chapter initializing 25 - Getting C++ database Started with XML, Oracle 438–439 XML and PL/SQL

initializing OCI, 398–401 Chapter 26 - Building PL/SQL Web Services XML27document created byXML Java, 44–45 Chapter - Extending PL/SQL Functionality with Java Chapter 28 - Putting It All Together 452–459 Applications, building cppextract, Appendix - XML Standards Bodies and Open Specifications creating generic functions, 453–458 Glossary instantiating generic functions with cppextractForce, 458–459 Index Applications, building XML data-retrieval, 451–462 List of Figurescppextract application, 452–459 building List of Tables framework, 452 designing List of Sidebars framework, 460–462 extending

running cppextract application, 459–460 Applications, building XML database OCI, 393–408 designing framework, 394–395 initializing OCI application, 398–401 performing unified DOM operations, 406–407 retrieving DOM of record list via OCI, 401–405 running xmlupdate application, 407–408 setting up OCI application environment, 395–397


update application, 397–398 Applications, building XML database OCI C++, 433–450 Oracle XML-managed, Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Applications, building 375–391 PL/SQL creating publishcat application, 386–391 ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang creating XML configuration file, 378–382 McGraw-Hill/Osborne © 2004 (600 pages) creating XSL stylesheets, 383–385 This comprehensive designing framework, 376–377 guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. XML media files, 377–378

Applications, running cppextract, 459–460 running cppextract in extraction mode, 459–460 Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL running cppextract in splitter mode, 460

Table of Contents Introduction

Applications, pipeline, 360–362 Part I - Oracle running and the XML Standards Applications, running xmlupdate, 407–408 Chapter 1 - Introducing XML Chapter 2 - Accessing XML 11, with DOM, SAX, AQ (Advanced Queuing), 101, 148, 314 JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

AQ agents and queues, creating, 325–327

AQ PO process procedures, creating, 328–332 - XML Operations with XQuery

Chapter 5

AQ servlet, 101 Messaging and RPC with SOAP Chapter 6 - XML Chapter 7 - Putting All Together with XML Pipeline, JSPs, and XSQL AQ support, OracleItstreams, 100–101 Part II - Oracle XML Management for DBAs

AQ, XML gateway application with SOAP and, 313–342 - Getting Started with the Oracle XML Database conventional solution, 314–315 Chapter 9 - Storing XML 317–323 Data creating framework, Chapter 10 - Generating and Retrieving XML designing framework, 314–317 Chapter 11 - Searching XML Data extending application’s functionality, 341–342 Chapter 12 - Managing the Oracle XML Database extending framework, 332–340 Part interfacing III - Oracleto XML for Java Developers Internet, 316–317 Chapter 13 - Getting Started with Oracle XML and Java stream-based one-step solution, 315–316 Chapter 8

Chapter Areas 14 - Building an XML-Powered Web Site Chapter 15 - Creating Portal Site with XML and Web Services creating dynamic,a293–300 Chapter 16 - Developing an XML Gateway Application with SOAP and AQ creating login, 302–304 Chapter 17 - Developing XML-Based Reusable Components creating static, 300–301 Part IV - Oracle XML for C Developers

Attribute names, designing element and, 80

Chapter 18 - Getting Started with Oracle XML and C

Attributes, elements vs., 79–80

Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

B

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Beans emphasis on XML standards, their usage and best practices. DBAccess, 111–113 DOMBuilder, 109–111 Tableprocessing of Contents XML with JSPs and XML, 108–115 Oracle Database using XML, 10g 115 XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction XMLCompress,114 Part XMLDBAccess, I - Oracle and the XML Standards 113 Chapter 1 - Introducing XML XMLDiff, 114 Chapter XSDValidator, 2 - Accessing 114–115 XML with DOM, SAX, JAXB, and StAX XSLTransformer, 111 XML with XSLT and XPath Chapter 3 - Transforming Chapter 4 - Validating XML with Binary Large Object (BLOB), 77DTDs and XML Schemas Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Bind variables, 204–205

Binding, accessing XML with Java, 42–45 - Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 7

Bitmap indexes, 227–228 Part II - Oracle XML Management for DBAs Chapter 8 - Getting with BLOB (Binary LargeStarted Object), 77the Oracle XML Database Chapter 9

Body, 6–7

- Storing XML Data

Chapter 10 - Generating and Retrieving XML

Bookcatalog.dtd,377

Chapter 11 - Searching XML Data

B*Tree12 indexes, 227 the Oracle XML Database Chapter - Managing Part III - Oracle XML for web Java site, Developers Building XML-powered 267–288

Chapter 13 - Getting Started with Oracle XML and Java

Built-in datatypes, XML schema, 69–70

Chapter 14 - Building an XML-Powered Web Site

Built-in Java Oracle XSLT extensions, 60

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

C

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

C

Oracle DOM APIs in, 27 Oracle SAX APIs in, 37–42 Table of Contents

C++ applications, building XML database OCI, 433–450 connecting to databases, 440–441 Introduction creating C++ OCI helper class, 437–438 Part I - Oracle and the XML Standards creating C++ query application, 443–444 Chapter 1 - Introducing XML designing framework, 434–435 Chapter 2 - Accessing with DOM, JAXB,up, and441–442 StAX disconnecting fromXML databases andSAX, cleaning Chapter 3 - Transforming XML with XSLT and XPath handling OCI errors, 439–440 Chapter 4 - Validating XML with DTDs and XML 438–439 Schemas initializing C++ database XML application, Chapter 5 - XML Operations with XQuery initializing XDK for XMLType XOB Access, 446–447 Chapter 6 - XML Messaging with SOAP querying XMLType with and C++RPC XDK APIs, 447–449 Chapter running 7 - application, Putting It All449 Together with XML Pipeline, JSPs, and XSQL Part selecting II - Oracleinto XML XMLType, Management 444–446 for DBAs setting C++ OCI XMLwith application environment, 435–437 Chapter 8 -up Getting Started the Oracle XML Database

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter - Storing XML DataVisual, 428–430 C/C++,9setting up Microsoft Chapter 10 - Generating and Retrieving XML

C compile-time environment, setting up, 370, 372

Chapter 11 - Searching XML Data

C++ compile-time environment, setting up, 428

Chapter 12 - Managing the Oracle XML Database

C components Part III - Oracle XML for Java Developers UNIX of XDK, 367–368 Chapter 13setup - Getting Started with Oracle XML and Java Windows setup of 370–371 Web Site Chapter 14 - Building anXDK, XML-Powered Chapter 15 - Creating a Portal Site with XML and Web Services C++ components Chapter UNIX 16setup - Developing of XDK,an 423–424 XML Gateway Application with SOAP and AQ

Windows setup of XDK, 426–427 Chapter 17 - Developing XML-Based Reusable Components Part - Oracle XML C Developers C++IVdatabase XML for application, initializing, 438–439

Chapter 18 - Getting Started with Oracle XML and C

C decisions, 524–526

Chapter 19 - Building an XML-Managed Application

C++ decisions, Chapter 20 - Build524–526 an XML Database OCI Application C libraries, 366–367 Chapter 21 - Oracle Create XDK, an XML-Configured High-Performance Transformation Engine libcoresh10.so, and libcore10.dll, 366 Part libcore10.a, V - Oracle XML for C++ Developers libnls10.a and oranls10.dll, Chapter 22 - Getting Started with367 Oracle XML and C++ libunls10.a and Chapter 23 - Build anoraunls10.dll, XML Database367 OCI C++ Application libxml10.a, libxml10.so, oraxml10.dll, 366 Chapter 24 - Building an XMLand Data-Retrieval Application Part - OracleOracle XML for PL/SQL Developers C++VIlibraries, XDK, 422–423

Chapter 25 helper - Getting Started with Oracle XML and PL/SQL C++ OCI class, creating, 437–438 Chapter 26 - Building PL/SQL Web Services

C++ OCI XML application environment, setting up, 435–437

Chapter 27 - Extending PL/SQL XML Functionality with Java

C++, Oracle XML and, Chapter 28 - Putting It All421–431 Together Oracle -XDK libraries, 422–423 Appendix XML C++ Standards Bodies and Open Specifications

setting up C++ XML development environment, 423–430

Glossary

C, Oracle XML and, 365–374 Index C Figures XML development environment, 367–374 List of Oracle List of TablesXDK C libraries, 366–367 List C++ of query Sidebars application, creating, 443–444

C run-time environment, checking, 368–369, 371 C++ run-time environment, checking, 424–426,427–428 C++ XDK APIs, querying XMLType with, 447–449 C++ XML application libraries, OCI and, 437 C XML development environment, 367–374 checking C run-time environment, 368–369,371


confirming C compile-time environment, 372 setting up C compile-time environment, 370,372 setting up Microsoft Visual C/C++, 372–374 Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & UNIX setupPL/SQL of XDK C components, 367–368 Windows setup of XDK C components, 370–371 ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © setting 2004 (600up, pages) C++ XML development environment, 423–430

Caching, DTD,This 47 comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Canonical mapping, 177–179,199–201 Cdcatalog.dtd, 378 Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Character encoding, 158–159 Introduction Character Large Object (CLOB), 11,77 Part I - Oracle and the XML Standards

Characters, special, 205–206

Chapter 1

- Introducing XML

Classes, 43 DOM, SAX, JAXB, and StAX Chapter 2 generating - AccessingXML, XML with Chapter 3 up, - Transforming XML with XSLT and and, XPath441–442 Cleaning disconnecting from databases Chapter Clients 4

- Validating XML with DTDs and XML Schemas

Chapter 5 -web XMLservice Operations XQuery calling from,with 489–491 Chapter 6 -99 XML Messaging and RPC with SOAP SOAP, Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

CLOB (Character Large Object), 11,77

Part II - Oracle XML Management for DBAs

CLOB, 8XMLType, Chapter - Getting522–523 Started with the Oracle XML Database CLOB XMLTypes, Chapter 9 - Storing 153 XML Data character encoding and for, 158–159 Chapter 10 - Generating Retrieving XML storing documents in, 158–159 Chapter 11 -XML Searching XML Data updating and querying, 158 XML Database Chapter 12 - Managing the Oracle Part III - Oracle XML for Java Developers CLOBs

Chapter XML13documents - Getting Started in, 77 with Oracle XML and Java

XML14documents stored as XMLType, Chapter - Building an XML-Powered Web 13 Site Chapter 15 - Creating a Portal Code, deploying Java, 503 Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Code, implementing Java, 502–503

Chapter 17 - Developing XML-Based Reusable Components

Columns, XMLType, 153–154 Part IV - Oracle XML for C Developers

Command querying 91XML and C Chapter 18 -lines, Getting StartedXML with from, Oracle Chapter 19 - Building an XML-Managed Application Commands, SQL, 169 Chapter 20 - Build an XML Database OCI Application

Common Object Request Broker Architecture/Internet Inter-ORB Protocol (CORBA/IIOP), 96

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Compile-time Part V - Oracle environment XML for C++ Developers C,370,372 C++, 428

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application

Compiling 411–414 Chapter 24 -stylesheets Building anwith XMLxslcompile, Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers Component Palette, creating XDK, 264–266

Chapter 25 - Getting Started with Oracle XML and PL/SQL

Components

Chapter 26 - Building PL/SQL Services installed Oracle XML DB,Web 242–244 Chapter 27setup - Extending XML Functionality with Java UNIX of XDKPL/SQL C, 367–368 Chapter 28setup - Putting It AllC++, Together UNIX of XDK 423–424 Appendix - XML Standards and Open Specifications Windows setup of XDK Bodies C, 370–371 Glossary Windows setup of XDK C++, 426–427 Index Components, developing XML-based reusable, 343–362 List of Figurespipeline applications, 352–360 building List of Tables framework, 344–345 designing List of Sidebars running pipeline application, 360–362

simple pipeline examples, 345–352 Configuration files, creating XML, 378–382 defining profiles, 380–382 XSLT stylesheets, 379–380 Configuring Oracle XML DB, 244–248 xdbconfig.xml, 245–248


Connections creating more secure, 126 setting up database, 261–26410g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle Database PL/SQLuse case for cppextract, 461–462 Content-management by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

Control, version, 175–176

ISBN:0072229527

CORBA/IIOP (Common Object Request Broker Architecture/Internet Inter-ORB Protocol), 96 This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Cppextract content-management use case for, 461–462 in extraction mode, 459–460 Tablerunning of Contents running in mode, 460 Oracle Databasesplitter 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XML document pruning use case for, 460–461 Introduction Part Cppextract I - Oracle applications, and the XML building, Standards 452–459

creating generic functions, 453–458 Chapter 1 - Introducing XML instantiating generic functions withSAX, cppextractForce, 458–459 Chapter 2 - Accessing XML with DOM, JAXB, and StAX Chapter 3 - applications, Transforming running, XML with459–460 XSLT and XPath Cppextract Chapter 4 - cppextract Validating XML with DTDs and XML Schemas running in extraction mode, 459–460 Chapter running 5 - cppextract XML Operations in splitter with XQuery mode, 460 Chapter 6 - XML Messaging and generic RPC with SOAP CppextractForce, instantiating functions with, 458–459 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

CppextractMain, creating main program with, 459

Part II - Oracle XML Management for DBAs

Created8 by- Java application, XML Chapter Getting Started with thedocument, Oracle XML44–45 Database Chapter Creating 9 - Storing XML Data

administration page,and 307–311 Chapter 10 - Generating Retrieving XML AQ 11 agents and queues, 325–327 Chapter - Searching XML Data AQ 12 PO- process procedures, 328–332 Chapter Managing the Oracle XML Database helper 437–438 Part C++ III - OCI Oracle XML class, for Java Developers C++13query application, Chapter - Getting Started443–444 with Oracle XML and Java database schemas, 317–321 Chapter 14 - Building an XML-Powered Web Site

database user, 272 dynamic areas, 293–300 Chapter 16 - Developing an XML Gateway Application with SOAP and AQ FAQ database, 269–274 Chapter 17 - Developing XML-Based Reusable Components FAQ list, 275–277 Part IV - Oracle XML for C Developers generic functions, 453–458 Chapter 18 - Getting Started with Oracle XML and C glossary, 283–287 Chapter 19 - Building an XML-Managed Application glossary schema, 283–284 Chapter 20stored - Buildprocedure an XML Database OCIXML, Application Java to process 502–504 Chapter 21 Create an XML-Configured High-Performance Transformation Engine login area, 302–304 Part main V - Oracle XML for C++ Developers program with cppextractMain, 459 Chapter 22 - Getting Started with Oracle XML and C++ messaging schemas, 324–325 Chapter 23secure - Buildconnections, an XML Database more 126 OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application PL/SQL specification, 504 Part portal VI - Oracle for PL/SQL Developers sites XML with XML, 289–311 Chapter publishcat 25 - Getting application, Started386–391 with Oracle XML and PL/SQL static 300–301 Chapter 26areas, - Building PL/SQL Web Services user27application forms, 304–307 Chapter - Extending PL/SQL XML Functionality with Java user schemas, 301–302 Chapter 28 - Putting It All Together users to run XMLType 138 Appendix - XML Standards samples, Bodies and Open Specifications XDK Component Palette, 264–266 Glossary XML configuration file, 378–382 Index XML-configured transformation engine, 409–418 List of Figures XML messaging gateway, 323–340 List of Tables XML POs (purchase orders), 321–323 List of Sidebars XML schema-based XMLTypes, 186 XMLType views, 211–212 XSL stylesheets, 383–385 Chapter 15 - Creating a Portal Site with XML and Web Services

CRM (customer relationship management), 96 CTXXPATH indexes, 229 Cursor, REF, 204 Customer relationship management (CRM), 96


Cutting and pasting across documents, 48 Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

D

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Data emphasis on XML standards, their usage and best practices. generating XML from SQL, 190–199,199–206 protecting in Oracle XML DB Repository, 248–250 Table of Contents

Data fetching, 202–203

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Data loading, XML, 168–171 Introduction Part I - Oracle and the XML building Standards Data-retrieval application, XML, 451–462

Chapter building 1 - cppextract Introducingapplication, XML 452–459

designing framework, Chapter 2 - Accessing XML452 with DOM, SAX, JAXB, and StAX extending framework, XML 460–462 Chapter 3 - Transforming with XSLT and XPath running application, 459–460 Chapter 4 - cppextract Validating XML with DTDs and XML Schemas Chapter 5 - XML XML, Operations with XQuery Data, retrieving 476–478 Chapter 6 - XML Messaging RPC with SOAP Data, searching XML, 155,and 219–240 Chapter - Putting 239–240 It All Together with XML Pipeline, JSPs, and XSQL best7 practices, Part full II -text Oracle XML Management searching, 230–238 for DBAs

Chapter 8 - Getting Started with the Oracle XML Database XPath-based searches, 220–229 Chapter 9

- Storing XML Data

Data, storing XML, 150–154,157–188 best practices, 185–187 Chapter 11 - Searching XML Data external tables, 184–185 Chapter 12 Managing the schema evolution, 185Oracle XML Database Part storing III - Oracle for Javain Developers XMLXML documents CLOB XMLTypes, 158–159 Chapter 13 Getting Started with Oracle XML and 176–184 Java storing XML documents in relational tables, Chapter 14 Building an XML-Powered Web Site storing XML documents in XML schema-based XMLTypes, 159–176 Chapter 10 - Generating and Retrieving XML

Chapter 15 - Creating a Portal Site with XML and Web Services

Data, updating with XSQL Servlet, 122–125

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Data, XML documents as object-relational, 77, 78

Chapter 17 - Developing XML-Based Reusable Components

Database and standards, XML, 148–149 Part IV - Oracle XML for C Developers Chapter 18 -connection, Getting Started with Oracle XML and C Database setting up, 261–264 Chapter 19 - Building an XML-Managed Application

Database design decisions for XML, 522–526

Chapter 20 - Build an XML Database OCI Application

Database mappings, supported, 76–78

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Database OCIXML applications, building XML, 393–408 Part V - Oracle for C++ Developers designing framework, 394–395 Chapter 22 - Getting Started with Oracle XML and C++ initializing OCIan application, 398–401 Chapter 23 - Build XML Database OCI C++ Application performing unifiedanDOM operations, 406–407 Chapter 24 - Building XML Data-Retrieval Application DOM listDevelopers via OCI, 401–405 Part retrieving VI - Oracle XML of forrecord PL/SQL

running xmlupdate application, 407–408 setting up OCI application environment, 395–397 Chapter 26 - Building PL/SQL Web Services update application, 397–398

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 27 - Extending PL/SQL XML Functionality with Java

Database C++Itapplication, building XML, 433–450 Chapter 28 -OCI Putting All Together Appendix Database -schemas XML Standards Bodies and Open Specifications

creating, 317–321 Glossary Indexinstalling sample, 137–138

mapping List of Figures DTDs to, 75–76 mapping List of Tables XML documents to, 12–14, 76 setting up, 482–485 List of Sidebars

and XML documents, 11–14

Database servers, building web services in, 497–498 Database user, creating, 272 Database web service, publishing first, 482–492 calling web service from clients, 489–491 debugging web service, 491–492 Oracle JDeveloper 10g,485–489


publishing PL/SQL web service, 485–489 setting up database schemas, 482–485 Database XMLOracle application, Database initializing 10g XML C++,&438–439 SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Databases ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang connecting FAQ web sites to XML, 274–277 McGraw-Hill/Osborne © 2004 (600 pages) connecting to, 440–441 focuses on utilizing XML technologies within Oracle's XML-enabled products, with consuming This web comprehensive services withinguide Oracle, 492–497 emphasis on XML standards, their usage and best practices. designing XML, 149,155–156 disconnecting from, 441–442 Tableinstalling of Contents Oracle XML, 133–137 Oracle Database XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Oracle XML,10g 140–148 Introduction querying XML in, 92–93 Part using I - Oracle andand theOracle, XML Standards SOAP 100–103 Chapter XML1 and, - Introducing 11 XML XML2 support in Oracle, 130–132 Chapter - Accessing XML with DOM, SAX, JAXB, and StAX XQuery and Oracle, 92–93 Chapter 3 - Transforming XML with XSLT and XPath XSLT 61 Chapter 4 and, - Validating XML with DTDs and XML Schemas Chapter 5 - XML Operations with XQuery Databases, creating FAQ, 269–274 Chapter creating 6 - XML database Messaging user,and 272RPC with SOAP

designing FAQ schema, 269–271 Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL FAQs, Part loading II - Oracle XML273–274 Management for DBAs registering FAQ Started schema, 272–273 Chapter 8 - Getting with the Oracle XML Database Chapter 9 - Storing Databases, Oracle XML XML,Data 129–156,241–251 Chapter 10 - Generating and Retrieving XML designing XML databases, 149–156 Chapter installed 11 - Searching Oracle XML XML DB Data components, 242–244

Oracle database, 140–148 Chapter 12 -XML Managing the Oracle XML Database management, 248–251 Part security III - Oracle XML for Java Developers setting OracleStarted XML databases, Chapter 13 -up Getting with Oracle 132–140 XML and Java XML14database and 148–149 Chapter - Building an standards, XML-Powered Web Site XML15support in Oracle databases, 130–132 Chapter - Creating a Portal Site with XML and Web Services Chapter Databases, 16 - Developing setting up Oracle an XMLXML, Gateway 132–140 Application with SOAP and AQ

creating users to runXML-Based XMLType Reusable samples,Components 138 Chapter 17 - Developing Oracle XML databases, 133–137 Part installing IV - Oracle XML for C Developers installing sampleStarted database 137–138 Chapter 18 - Getting withschemas, Oracle XML and C setting WebDAV folders, 138–140 Chapter 19 -up Building an XML-Managed Application Chapter 20 - Build XML Database Application Databases, XML an document modelsOCI and, 75–78 Chapter mapping 21 - Create DTDs an to database XML-Configured schemas, High-Performance 75–76 Transformation Engine Part mapping V - OracleXML XMLdocuments for C++ Developers to database schemas, 76

supported database mappings, 76–78 Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Datatypes Chapter 24 -and Building an XML Data-Retrieval Application simple complex, 68–73 Part XML VI - Oracle XML for PL/SQL schema built-in, 69–70Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL

DB components, installed Oracle XML, 242–244

Chapter 26 - Building PL/SQL Web Services

DB, configuring Oracle XML, 244–248

Chapter 27 - Extending PL/SQL XML Functionality with Java

DB Repository Chapter 28 - Putting It All Together Oracle -XML, 147,154,173–176 Appendix XML Standards Bodies and Open Specifications protecting data in Oracle XML, 248–250 Glossary DB Repository interfaces, Oracle XML, 170 Index List of Figures DBAccess bean, 111–113 List of Tables

DBMS_XMLSTORE,182–184

List of Sidebars

DBM_XMLGEN,199–206 DBUri operations, securing, 250–251 Debugging Java stored procedures, 516–517 web services, 491–492 Decisions C,524–526


C++, 524–526 database design, 522–526 Java,524–526 Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL,524–526 PL/SQL XML processing tier,V.521–522 ISBN:0072229527 by Mark Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages) Definitions, displaying glossary, 286–287 Thisdatabase, comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Design decisions, 522–526 emphasis on XML standards, their usage and best practices.

Designing element and attribute names, 80 Table of Contents schemas, 79 Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XML databases, 149–156 Introduction XML databases for messaging applications, 155–156 Part I - Oracle and the XML Standards XML databases for Web applications, 155 Chapter 1

- Introducing XML

Development environment - Accessing XML with DOM, SAX, JAXB, and StAX C XML, 367–374 Chapter 3 - Transforming XML with XSLT and XPath C++ XML, 423–430 Chapter 2 Chapter 4

- Validating XML with DTDs and XML Schemas

Displaying Chapter 5 - XML Operations with XQuery

FAQ and answers, 280–283 - XML Messaging and RPC with SOAP glossary definitions, 286–287

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Document fragments, appendingfor XML, 215–216 Part II - Oracle XML Management DBAs Chapter 8 - Getting with62the Oracle XML Database Document() functionStarted in XSLT, Chapter 9

Storing XML Data Document-models and databases, XML, 75–78

Chapter 10 - Generating and Retrieving XML

Document Object Model (DOM), 16

Chapter 11 - Searching XML Data

Document XML, 460–461 Chapter 12 -pruning, Managing the Oracle XML Database Part III - Oracle XML forXML, Java 221–224 Developers Document, searching

Chapter 13 - Getting Started with Oracle XML and Java

Documents

Chapter 14 -and Building an across, XML-Powered Web Site cutting pasting 48 Chapter 15 - Creating Portal Site11–14 with XML and Web Services database schemaa and XML, Chapter 16 - XML, Developing an XML Gateway Application with SOAP and AQ dividing 180–182 Chapter 17 - Developing inserting XML, 122 XML-Based Reusable Components Part mapping IV - Oracle XML12–14, for C Developers XML, 76

Chapter 18 - and Getting Started with Oracle XML and C parsing binding XML, 16–17 Chapter processing 19 - Building invalid, an360, XML-Managed 362 Application

processing invalid XML, 361 OCI Application Chapter 20 - Build an XML Database processing thatan areXML-Configured valid against remote schema, 361 Chapter 21 - Create High-Performance Transformation Engine XML, 159–176, Part storing V - Oracle XML for C++176–184 Developers valid22XML, 8–9 Started with Oracle XML and C++ Chapter - Getting well-formed XML, 7–8Database OCI C++ Application Chapter 23 - Build an XML XML, 78 Chapter 244–7, - Building an XML Data-Retrieval Application documents as PL/SQL fragment, 78 Part XML VI - Oracle XML for Developers

Documents, querying XML,with 91 Oracle XML and PL/SQL Chapter 25 - Getting Started querying XML from command line, 91 Chapter 26 - Building PL/SQL Web Services querying XML with PL/SQL XQueryX, Chapter 27 - Extending XML91 Functionality with Java running interactive mode, 91 Chapter 28 - in Putting It All Together Appendix DOM (Document - XML Standards Object Model), Bodies16 and Open Specifications

accessing XML using, 17–27 Glossary Indexaccessing XML with, 15

retrieving List of Figures of record list via OCI, 401–405 SAX vs., 108 List of Tables List DOM of Sidebars APIs, 19–22

DOM APIs in C, Oracle, 27 DOM editing, 213–216 appending XML document fragments, 215–216 operating on XMLType DOM, 213–215 DOM Level 2, 22–25 DOM Level 3, 25–27


DOM, operating on XMLType, 213–215 DOM operations, performing unified, 406–407 Oracle 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & DOM, processing XMLDatabase using, 474–478 PL/SQL dealing with namespaces, 475–476 ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang retrieving XML data using XPath, 476–478 McGraw-Hill/Osborne © 2004 (600 pages)

DOM specifications, W3C, 531 This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. DOMBuilder bean, 109–111

DTD caching, 47 Table of Contents

DTDs (Document Type Definitions), 5,64, 186 introducing, 64–66 Introduction loading external, 80–81 Part mapping I - Oracleto and the XMLschemas, Standards75–76 database Chapter 1 Introducing XML parsing with, 474

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

DTDs, validating XML against, 66–68

DTDs, 4validating XML XML with,with 63–81 Chapter - Validating DTDs and XML Schemas

best practices, 79–81 - XML Operations with XQuery introducing DTDs, 64–66 Chapter 6 - XML Messaging and RPC with SOAP simple and complex data types, 68–73 Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL validating XML against DTDs, 66–68 Part II - Oracle XML Management for DBAs XML document models and databases, 75–78 Chapter 5

Chapter 8

- Getting Started with the Oracle XML Database

Dvdcatalog.dtd, 378XML Data Chapter 9 - Storing Dynamic creating, Chapter 10areas, - Generating and293–300 Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

E

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with E-mail confirmation, generating, 341–342 emphasis on XML standards, their usage and best practices.

Editing, DOM, 213–216 appending XML document fragments, 215–216 Table of Contents operating on XMLType DOM, 213–215

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

EJBs (Enterprise Java Beans), 104 Introduction Part I - Oracle and the XML Standards Element and attribute names, designing, 80

Chapter 1 vs. - Introducing Elements attributes,XML 79–80 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Encoding for CLOB XMLTypes, character, 158–159

Engine,4 creating XML-configured transformation, 409–418 Chapter - Validating XML with DTDs and XML Schemas compiling stylesheets with xslcompile, Chapter 5 - XML Operations with XQuery 411–414

designing framework, 410–411 - XML Messaging and RPC with SOAP running XSLT virtual machine with xsbtransform, 414–417

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Engine, OracleXML XQuery, 89–90 for DBAs Part II - Oracle Management setting environment, 89 the Oracle XML Database Chapter 8 -up Getting Started with testing Chapter 9 -installation, Storing XML89–90 Data Chapter Enterprise 10 -Java Generating Beans and (EJBs), Retrieving 104 XML Chapter 11 - Searching XML Data Environment Chapter 12 - Managing the372 Oracle XML Database C compile-time, 370, Part C IIIrun-time, - Oracle 368–369, XML for Java 371 Developers

Chapter 13 -development, Getting Started with Oracle XML and Java C XML 367–374 Chapter 14 - Building an XML-Powered Web Site checking C++ run-time, 424–426,427–428 Chapter JDK, 15 258–260 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing XMLcompile-time, Gateway Application with SOAP and AQ Environment, setting upanC++ 428 Chapter 17 - Developing XML-Based Reusable Components

Environment, setting up C++ OCI XML application, 435–437

Part IV - Oracle XML for C Developers

Environment, setting up C++ XML development, Chapter 18 - Getting Started with Oracle XML and C423–430 Chapter Environment, 19 - Building settingan upXML-Managed OCI application, Application 395–397

OCI20 XML application Chapter - Build an XML headers, Database 395–396 OCI Application OCI21 XML application libraries, 396 High-Performance Transformation Engine Chapter - Create an XML-Configured XML application make files, 396–397 Part OCI V - Oracle XML for C++ Developers Chapter 22 - Getting Started with260–261 Oracle XML and C++ Environment, setting up XDK, Chapter 23 - Build an XML Database OCI C++ Application

Errors, handling OCI, 439–440

Chapter 24 - Building an XML Data-Retrieval Application

Evolution, schema, 185

Part VI - Oracle XML for PL/SQL Developers

Examples, 345–352 Chapter 25 - simple Gettingpipeline, Started with Oracle XML and PL/SQL Chapter 26 - Building ExistsNode(), 208 PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java

Expressions

Chapter 28 - Putting It All Together FLWOR, 86 Appendix - XML Standards Bodies and Open Specifications path,86–87 Glossary predicate,87 IndexXPath, 54–55 List of Figures85–87 XQuery, List of Tablesmarkup language (XML), 4 Extensible List of Sidebars

Extensions built-in Java Oracle XSLT, 60 Oracle XSLT, 59–60 External DTDs, loading, 80–81 External tables, 184–185 Extract(),208 Extraction mode, running cppextract in, 459–460


EXTRACTVALUE(), 208 Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

F

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with FAQ and answers, displaying, 280–283 emphasis on XML standards, their usage and best practices.

FAQ databases, creating, 269–274 creating database user, 272 Table of Contents designing FAQ schema, 269–271 Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL loading FAQs, 273–274 Introduction registering FAQ schema, 272–273 Part I - Oracle and the XML Standards

FAQ listings, adding pagination to, 277–279 Chapter 1 - Introducing XML FAQ lists Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX creating, 275–277 Chapter 3 - Transforming XML with XSLT and XPath filtering, Chapter 4 - 277 Validating XML with DTDs and XML Schemas Chapter 5 - XML Operations with XQuery FAQ schemas Chapter designing, 6 - XML 269–271 Messaging and RPC with SOAP

registering, 272–273 Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL Part IIweb - Oracle FAQ sitesXML Management for DBAs

Chapter 8 - Getting Started with the Oracle XML Database connecting to XML database, 274–277 Chapter 9 - Storing XML Data XML-enabled, 268 Chapter 10 - Generating and Retrieving XML

FAQs (frequently asked questions), 268

Chapter 11 - 273–274 Searching XML Data loading,

Chapter 12 - Managing the Oracle XML Database searching, 287 Part III - Oracle XML for Java Developers

Fetching, data, 202–203

Chapter 13 - Getting Started with Oracle XML and Java

File systems, parsinganXML from local,Web 467–471 Chapter 14 - Building XML-Powered Site Chapter Files 15 - Creating a Portal Site with XML and Web Services

creating XML configuration, 378–382Application with SOAP and AQ Chapter 16 - Developing an XML Gateway loading DTDs from JAR, 80–81 Components Chapter 17 - external Developing XML-Based Reusable XML application 396–397 Part OCI IV - Oracle XML for C make, Developers Chapter 18 - media, Getting377–378 Started with Oracle XML and C Files, XML Chapter 19 - Building 377 an XML-Managed Application bookcatalog.dtd, Chapter cdcatalog.dtd, 20 - Build an 378XML Database OCI Application

dvdcatalog.dtd, 378XML-Configured High-Performance Transformation Engine Chapter 21 - Create an Part V - Oracle XML for86 C++ Developers FLWOR expression,

Chapter 22 - Getting Started with Oracle XML and C++

Folders, setting up WebDAV, 138–140

Chapter 23 - Build an XML Database OCI C++ Application

Formatting, print, 201–202 Chapter 24 - Building an XML Data-Retrieval Application Part Forms, VI - creating Oracle XML user for application, PL/SQL Developers 304–307

Chapter 25 -documents, Getting Started Oracle XML and PL/SQL Fragment XMLwith documents as, 78 Chapter 26 - Building PL/SQL Web Services

Fragments appending XML document, 215–216 Chapter 28 - Putting It All Together dividing XML documents into, 180–182 Appendix - XML Standards Bodies and Open Specifications XML, 212–213 Chapter 27 - Extending PL/SQL XML Functionality with Java

Glossary

Framework, XSQL Page publishing, 116–125

Index

Frequently asked questions (FAQ), 268 List of Figures List Fulloftext Tables searching, 230–238

advanced List of Sidebars text searches, 237–238 optimizing Oracle Text searches, 236 Oracle Text searching, 235–236 searching XML using Oracle Text, 231–234 Function-based indexes, 228–229 Functionality adding portal, 301–307 extending PL/SQL XML, 501–517


simple JSP XML, 126 Functions creating generic, Oracle453–458 Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & document(),PL/SQL 62 ISBN:0072229527 Mark V.458–459 Scardina, Ben Chang and Jinyu Wang instantiatingbygeneric, McGraw-Hill/Osborne © 2004 (600 pages) retrieving using SQL/XML, 206–208 retrieving using This XMLType, comprehensive 206–208 guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. SQL/XML,190–199 Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

G

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Generic functions emphasis on XML standards, their usage and best practices. creating, 453–458 instantiating with cppextractForce, 458–459 Table of Contents

Glossary linking to, 285–286 Introduction loading, 284

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Part I - Oracle and the XML Standards

Glossary, 283–287 Chapter 1 -creating, Introducing XML

creating glossary schema, 283–284 - Accessing XML with DOM, SAX, JAXB, and StAX displaying glossary definitions, 286–287 Chapter 3 - Transforming XML with XSLT and XPath linking to glossary, 285–286 Chapter 4 - Validating XML with DTDs and XML Schemas loading glossary, 284 Chapter 2

Chapter 5

- XML Operations with XQuery

Glossary displaying, 286–287 Chapter 6 definitions, - XML Messaging and RPC with SOAP Glossary 283–284 Chapter 7 schema, - Putting creating, It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

H

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Handlers, SOAP, 100 emphasis on XML standards, their usage and best practices.

Headers, OCI XML application, 395–396,435–437 Helper class, creating C++ OCI, 437–438 Table of Contents Oracle 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL HomeDatabase page, building XSQL, 275 Introduction

HTML (Hypertext Markup Language), 4

Part I - Oracle and the XML Standards

Hypertext -Markup Language (HTML), 4 Introducing XML

Chapter 1 Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

I

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Index, partitions for Oracle Text, 240 emphasis on XML standards, their usage and best practices.

Indexes Bitmap,227–228 Table of Contents B*Tree,227 Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL CTXXPATH,229 Introduction function-based, 228–229 Part I - Oracle and the XML Standards optimizing XPath-based queries using, 227–229 Chapter 1

- Introducing XML

Initializing - Accessing XML with DOM, SAX, JAXB, and StAX C++ database XML application, 438–439 Chapter 3 - Transforming XML with XSLT and XPath OCI applications, 398–401 Chapter 4 - Validating XML with DTDs and XML Schemas Oracle JVM, 135 Chapter 5 - XML Operations with XQuery XDK for XMLType XOB Access, 446–447 Chapter 2

Chapter 6

- XML Messaging and RPC with SOAP

Installed Oracle XML DB components, 242–244 - Putting It All Together with XML Pipeline, JSPs, and XSQL

Chapter 7

Installing Part II - Oracle XML Management for DBAs Oracle databases, 133–137 Chapter 8 -XML Getting Started with the Oracle XML Database sample schemas, 137–138 Chapter 9 - database Storing XML Data XSQL 118 and Retrieving XML Chapter 10 Servlet, - Generating Chapter Instances, 11 - binding Searching to XML, XML Data 43–44 Chapter 12 - Oracle Managing theDB Oracle XML Database Interfaces, XML Repository, 170 Part III - Oracle XML for Java Developers

International Standards Organization (ISO), 4

Chapter 13 - Getting Started with Oracle XML and Java

Internet, 316–317 Chapter 14interfacing - Building to, an XML-Powered Web Site Chapter Invalid 15 documents - Creating a Portal Site with XML and Web Services

processing, 360 Chapter 16 - Developing an XML Gateway Application with SOAP and AQ processing against schemas and change, 362 Chapter 17 - Developing XML-Based Reusable Components Part IV -XML Oracle XML for C processing, Developers 361 Invalid documents,

Chapter 18 - Getting Started with Oracle XML and C

ISO (International Standards Organization), 4

Chapter 19 - Building an XML-Managed Application

ISO SQL/XML specifications, 534

Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

J

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with JAR files, loading external DTDs from, 80–81 emphasis on XML standards, their usage and best practices.

Java API for XML-based RPC (JAX-RPC), 104 Javaofapplication, Table Contents XML document created by, 44–45 Oracle Databaseaccessing 10g XML &XML SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Java binding, with, 42–45 Introduction binding to XML instance, 43–44 Part generating I - Oracle and the XML Standards XML classes, 43

Chapter input 1 XML - Introducing schema, 43 XML

XML2 document created by Java Chapter - Accessing XML with DOM,application, SAX, JAXB, 44–45 and StAX Chapter 3 - Transforming XML with XSLT and XPath Java code Chapter 4 - Validating with DTDs and XML Schemas deploying to OracleXML JVM, 503 Chapter 5 - XML Operations implementing, 502–503 with XQuery Chapter 6 - XML Messaging and RPC with SOAP Java community process specifications, 534 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Java decisions, 524–526

Part II - Oracle XML Management for DBAs

Java, extending PL/SQL XML with,Database 501–517 Chapter 8 - Getting Started withfunctionality the Oracle XML best9 practices, Chapter - Storing515–517 XML Data creating Java storedand procedure to XML process XML, 502–504 Chapter 10 - Generating Retrieving

Oracle JDeveloper 10g,505–507 processing XML in Oracle JVM, 507–515 Chapter 12 - Managing the Oracle XML Database running Java stored procedure, 504–505 Part III - Oracle XML for Java Developers simplifying deployment of Java stored procedures, 505–507 Chapter 11 - Searching XML Data

Chapter 13 - Getting Started with Oracle XML and Java

Java Message Service (JMS), 104 Web Site Chapter 14 - Building an XML-Powered Chapter Java, Oracle 15 - Creating XML and, a Portal 253–266 Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Java Oracle XSLT extensions, built-in, 60 Chapter 17 - Developing XML-Based Reusable Components

Java Specification Request (JSR), 104

Part IV - Oracle XML for C Developers

Java stored procedures Chapter 18 - Getting Started with Oracle XML and C creating to process XML, 502–504Application Chapter 19 - Building an XML-Managed

debugging, 516–517 running,504–505 Chapter 21 - Create an XML-Configured High-Performance Transformation Engine simplifying deployment of, 505–507 Part V - Oracle XML for C++ Developers when to use, 515 Chapter 20 - Build an XML Database OCI Application

Chapter 22 - Getting Started with Oracle XML and C++

Java, XQuery APIanfor, 92Database OCI C++ Application Chapter 23 - Build XML Chapter JAX-RPC 24 -(Java Building APIan forXML XML-based Data-Retrieval RPC),Application 47, 104 Part VI - Oracle XML for104 PL/SQL Developers JAX-RPC, SOAP vs.,

Chapter 25 - Getting Started with Oracle XML and PL/SQL

JAXB, accessing XML with, 15

Chapter 26 - Building PL/SQL Web Services

JAXB (Java Architecture for XML 16 with Java Chapter 27 - Extending PL/SQL XML Binding), Functionality Chapter JDeveloper 28 - 10g, Putting Oracle, It All Together 485–489,505–507 Appendix - XML Standards Bodies and260–266 Open Specifications JDeveloper, using XDK with Oracle, Glossary creating XDK Component Palette, 264–266 Indexsetting up database connection, 261–264 List of Figures setting up XDK environment, 260–261 List of environment, Tables JDK 258–260 List of Sidebars

JMS (Java Message Service), 104 JMS, SOAP vs., 104 JSP XML functionality, simple, 126 JSPs, 105 pages,125 using XML beans in, 115 JSPs and XML beans, processing XML with, 108–115


JSR (Java Specification Request), 104 JVM, Oracle. SeeOracle JVM Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

L

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Language, XML schema, 66–68 emphasis on XML standards, their usage and best practices.

Large Objects (LOBs), 11 Libraries Table of Contents OCI and C++ XML 437 Build & Manage XML Applications in Java, C, C++ & PL/SQL Oracle Database 10g XMLapplication, & SQL—Design, OCI XML application, 396 Introduction XDK C,the 366–367 Part Oracle I - Oracle and XML Standards Oracle C++, 422–423 Chapter 1 -XDK Introducing XML

Oracle -XDK Java, 256–258 Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 2

Lines, querying XML fromXML command, 91 and XPath Chapter 3 - Transforming with XSLT Chapter 4 adding - Validating XML with DTDs277–279 and XML Schemas Listings, pagination to FAQ, Chapter 5

Lists

- XML Operations with XQuery

Chapter 6 - XML creating FAQ,Messaging 275–277 and RPC with SOAP Chapter 7 - FAQ, Putting It All Together with XML Pipeline, JSPs, and XSQL filtering 277 Part record, II - Oracle XML Management for DBAs 401–405

Chapter 8

- Getting Started with the Oracle XML Database

Loading Chapter 9 - Storing XML Data external DTDs from JAR files, 80–81 Chapter 10 - Generating and Retrieving XML XML data, 168–171 Chapter 11 - Searching XML Data

LOBs (Large Objects), 11

Chapter 12 - Managing the Oracle XML Database

Local systems, from, 467–471 Part IIIfile - Oracle XMLparsing for JavaXML Developers Chapter 13 - Getting Started with Oracle XML and Java Login area, creating, 302–304 Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

M

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Main program, This creating, 459 emphasis on XML standards, their usage and best practices.

Make files, OCI XML application, 396–397 Management, resource, 174–175 Table of Contents Oracle Databasesecurity, 10g XML248–251 & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Management, Introduction protecting data in Oracle XML DB Repository, 248–250 Part securing I - OracleDBUri and the XML Standards operations, 250–251

Chapter 1 DTDs - Introducing XML schemas, 75–76 Mapping to database Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 4

- Validating XML with DTDs and XML Schemas

Mapping XML documents, 12–14 Chapter 3 - Transforming XML with XSLT and XPath to database schemas, 76 Mappings Chapter 5 - XML Operations with XQuery

canonical, 177–179,199–201 - XML Messaging and RPC with SOAP supported database, 76–78

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Media XML, Part II -files, Oracle XML377–378 Management for DBAs Chapter 8 - Getting Started with the Oracle XML Database Messages Chapter 9 - Storing XML 493 Data constructing SOAP, Chapter enqueuing 10 - Generating and dequeuing, and Retrieving 101–103 XML

submitting SOAP, XML 341 Data Chapter 11 - Searching Chapter 12 - applications, Managing thedesigning Oracle XML Database Messaging XML databases for, 155–156 Part III - Oracle XML for Java Developers

Messaging gateway, creating XML, 323–340

Chapter 13 - Getting Started with Oracle XML and Java

Messaging 324–325 Chapter 14 - schemas, Building ancreating, XML-Powered Web Site Microsoft C/C++, setting 372–374, Chapter 15 Visual - Creating a Portal Siteup, with XML and428–430 Web Services Chapter Models16 - Developing an XML Gateway Application with SOAP and AQ Chapter - Developing XML-Based Reusable Components XML17document, 75–78 Part XSLT IV - Oracle XML56 for C Developers process,

Chapter 18 - Getting Started with Oracle XML and C

Modes

Chapter 19 - cppextract Building an in XML-Managed Application running extraction, 459–460 Chapter 20 - cppextract Build an XML OCI Application running in Database splitter, 460 Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Multiple transformations, overall performance of XSLT for, 62

Part V - Oracle XML for C++ Developers

Multistage processing, 107–108 Chapter 22 -XML Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

N

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Names, designing element and attribute, 80 emphasis on XML standards, their usage and best practices.

Namespace specifications, W3C, 532 Namespaces, 475–476 Table of Contents specifying, Oracle Database186–187 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XML, 9–11 Introduction Part I - Oracle and the XML Standardsstored as, 14 Native XMLTypes, XML documents

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

O

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Object-relational data, XML documents as, 77,78 emphasis on XML standards, their usage and best practices.

Object tables, XMLType, 153–154 Object views, 179–180 Table of Contents Oracle Database 10g application XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL OCI and C++ XML libraries, 437 Introduction

OCI application environment, setting up, 395–397 OCI XML application headers, 395–396 Chapter - Introducing OCI1XML applicationXML libraries, 396 Chapter 2 Accessing XML with files, DOM,396–397 SAX, JAXB, and StAX OCI XML application make Part I - Oracle and the XML Standards

Chapter 3

- Transforming XML with XSLT and XPath

OCI applications, building XML database, 393–408 - Validating XML with DTDs and XML Schemas designing framework, 394–395 Chapter 5 - XML Operations with XQuery initializing OCI application, 398–401 Chapter 6 - XML Messaging RPC with406–407 SOAP performing unified DOMand operations, Chapter 7 Putting It All Together with XML Pipeline, JSPs, and XSQL retrieving DOM of record list via OCI, 401–405 Part running II - Oracle XML Management for DBAs xmlupdate application, 407–408 Chapter 8 -up Getting Started with the Oracle XML Database setting OCI application environment, 395–397 Chapter 9 -application, Storing XML397–398 Data update Chapter 4

Chapter 10 - Generating and Retrieving XML

OCI applications, initializing, 398–401

Chapter 11 - Searching XML Data

OCI C++ applications, building XML database, 433–450 connecting to databases, 440–441 Part III - Oracle XML for Java Developers creating C++ OCI helper class, 437–438 Chapter 13 - Getting Started with Oracle XML and Java creating C++ query application, 443–444 Chapter 14 - Building an XML-Powered Web Site designing framework, 434–435 Chapter 15 - Creating a Portal Site with XML and Web Services disconnecting from databases and cleaning up, 441–442 Chapter 16 - Developing XML Gateway Application with SOAP and AQ handling OCI errors,an439–440 Chapter 17 Developing XML-Based Reusable Components initializing C++ database XML application, 438–439 Part initializing IV - OracleXDK XMLfor forXMLType C Developers XOB Access, 446–447 Chapter 18 - Getting Started XML and C querying XMLType with with C++ Oracle XDK APIs, 447–449 Chapter 19 Building an XML-Managed Application running application, 449 Chapter 20 - Build an XML Database OCI Application selecting into XMLType, 444–446 Chapter setting 21 -up Create C++ an OCIXML-Configured XML application High-Performance environment, 435–437 Transformation Engine Chapter 12 - Managing the Oracle XML Database

Part V - Oracle XML for C++ Developers

OCI errors, handling, 439–440

Chapter 22 - Getting Started with Oracle XML and C++

OCI helper class, creating C++, 437–438

Chapter 23 - Build an XML Database OCI C++ Application

OCI (Oracle Class Interface), 394 Chapter 24 - Building an XML Data-Retrieval Application Part VIretrieving - Oracle XML Developers OCI, DOMfor ofPL/SQL record list via, 401–405

Chapter 25 application - Getting Started with Oracle XML and PL/SQL OCI XML Chapter 26 - Building PL/SQL Web Services headers, 395–396, 435–437 Chapter 27 - Extending PL/SQL XML Functionality with Java libraries, 396 Chapter 28files, - Putting It All Together make 396–397 Appendix

- XML Standards Bodies and Open Specifications OCI XML application environment, setting up C++, 435–437

Glossary

Operations performing unified DOM, 406–407 List of Figures securing DBUri, 250–251 List of Tables XML, 83–94 Index

List of Sidebars

Oracle AQ (Advanced Queuing), 148 Oracle Class Interface (OCI), 394 Oracle databases consuming web services within, 492–497 using SOAP and, 100–103 XML support in, 130–132 XQuery and, 92–93


Oracle DOM APIs in C, 27 Oracle JDeveloper 10g,485–489,505–507 Oracle Database 10g260–266 XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle JDeveloper, using XDK with, PL/SQL

Oracle JVM by Mark V. Scardina, Ben Chang and Jinyu Wang ISBN:0072229527 deploying Java code to, 503 McGraw-Hill/Osborne © 2004 (600 pages) initializing, 135 This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with setting up, 480 emphasis on XML standards, their usage and best practices. Oracle JVM (Oracle Java Virtual Machine), 130 Table of Contents Oracle JVM, processing XML in, 507–515 Oracle Database 10greferences, XML & SQL—Design, resolving URL 507–511 Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction SAX XML processing, 511–515 Part I - Oracle and the Standards Oracle SAX APIs in C,XML 37–42

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Oracle streams AQ support, 100–101

Oracle 3technical resources, Chapter - Transforming XML535 with XSLT and XPath Chapter Oracle 4Text, - Validating 147–148 XML with DTDs and XML Schemas Chapter - XML Operations Oracle 5Text index, partitionswith for,XQuery 240 Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Oracle Text searches, 235–236,239

Oracle XML using, Part II - Text, Oraclesearching XML Management for 231–234 DBAs Chapter Oracle 8XDK - Getting Started with the Oracle XML Database

C libraries, 366–367 Chapter 9 - Storing XML Data C++10libraries, 422–423 Chapter - Generating and Retrieving XML Java 256–258 Chapter 11libraries, - Searching XML Data using and, 99–100 Chapter 12SOAP - Managing the Oracle XML Database Part III -XML Oracle for Java Developers Oracle andXML C, 365–374

Chapter - Getting Started with Oracle XML and Java Oracle 13 XML and C++, 421–431 Chapter 14 -XDK Building XML-Powered Web Site Oracle C++an libraries, 422–423 Chapter 15 -up Creating a Portal Site with environment, XML and Web 423–430 Services setting C++ XML development Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Oracle XML and Java, 253–266

Chapter 17 - Developing XML-Based Reusable Components

Oracle and PL/SQL, 465–480 Part IV -XML Oracle XML for C Developers

PL/SQL XML processing techniques, 466–479 setting up environment, 466 Chapter 19 - Building an XML-Managed Application setting up Oracle JVM, 480 Chapter 18 - Getting Started with Oracle XML and C

Chapter 20 - Build an XML Database OCI Application

Oracle 21 XML databases, 129–156 Chapter - Create an XML-Configured High-Performance Transformation Engine 140–148 Part defined, V - Oracle XML for C++ Developers designing XML databases, Chapter 22 - Getting Started with149–156 Oracle XML and C++

installing,133–137 Oracle XML database, 140–148 Chapter 24 - Building an XML Data-Retrieval Application setting up Oracle XML databases, 132–140 Part VI - Oracle XML for PL/SQL Developers XML database and standards, 148–149 Chapter 25 - Getting Started with Oracle XML and PL/SQL XML support in Oracle databases, 130–132 Chapter 23 - Build an XML Database OCI C++ Application

Chapter 26 - Building PL/SQL Web Services

Oracle 27 XML databases, setting up,Functionality 132–140 with Java Chapter - Extending PL/SQL XML

creating users to run XMLType samples, 138 installing Oracle XML databases, 133–137 Appendix - XML Standards Bodies and Open Specifications installing sample database schemas, 137–138 Glossary setting up WebDAV folders, 138–140 Chapter 28 - Putting It All Together

Index

Oracle XML DB (Oracle XML database 10g), 190 List of Figures Oracle XML DB components, installed, 242–244 List of Tables List of Sidebars Oracle XML DB, configuring, 244–248

configuring xdbconfig.xml, 245–248 xdbconfig.xml, 245 Oracle XML DB Repository, 147,154,173–176 interfaces,170 protecting data in, 248–250 XML stored in, 524 Oracle XML platform, 520–521,527


Oracle XQuery engine, 89–90 Oracle XSLT extensions, 59–60 Oracle Database Oracle XSLT extensions, built-in 10g Java,XML 60 & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

ORA_NLS10,367, 423–424 by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages) ORA_XML_MESG, 368,424 This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Output, transforming XSQL, 119–121 emphasis on XML standards, their usage and best practices.

Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

P

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Pages emphasis on XML standards, their usage and best practices. building XSQL home, 275 creating administration, 307–311 TableJSPs, of Contents 125 Oracle Database 10g 125 XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XSQL, 116–117, Introduction

Pagination, adding to FAQ listing, 277–279

Part I - Oracle and the XML Standards

Palette,1 creating XDK Component, 264–266 Chapter - Introducing XML Parsing, Chapter 2 107–108 - Accessing XML with DOM, SAX, JAXB, and StAX and3checking for differences, 348–352 Chapter - Transforming XML with XSLT and XPath with4DTDs, 474 XML with DTDs and XML Schemas Chapter - Validating and5printing, SAX, 346–348 Chapter - XML Operations with XQuery XML, Chapter 6 467–474 - XML Messaging and RPC with SOAP

XML from local file systems, 467–471 - Putting It All Together with XML Pipeline, JSPs, and XSQL XML from URLs, 471–474 Part II - Oracle XML Management for DBAs Chapter 7

Partitions OracleStarted Text index, 240Oracle XML Database Chapter 8 for - Getting with the Chapter - Storing XML Datacutting and, 48 Pasting9across documents, Chapter 10 - Generating and Retrieving XML

Path expression, 86–87

Chapter 11 - Searching XML Data

PATH_SECTION_GROUP, 231–232

Chapter 12 - Managing the Oracle XML Database

Pipeline application, running, 360–362 Part III - Oracle XML for Java Developers local13and remoteStarted XSDs, with 361 Oracle XML and Java Chapter - Getting processing documents valid against remote Chapter 14 - Building an XML-Powered Web Site schema, 361 processing invalida documents, 360XML and Web Services Chapter 15 - Creating Portal Site with

processing invalid documents against schemas and change, 362 processing invalid XML documents, 361

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Pipeline applications, 352–360 Part IV - Oracle XML forbuilding, C Developers XSDConditionalValProcess 357–360 Chapter 18 - Getting Started with process, Oracle XML and C XSDSchemaBuilder process, 354 Application Chapter 19 - Building an XML-Managed XSDValProcess 354–357 Chapter 20 - Build an process, XML Database OCI Application Pipeline21examples, simple, 345–352 High-Performance Transformation Engine Chapter - Create an XML-Configured and checking forDevelopers differences, 348–352 Part parsing V - Oracle XML for C++ SAX22parsing andStarted printing, 346–348 Chapter - Getting with Oracle XML and C++ Chapter - Build an XML Pipeline23Processor, XML,Database 106–108OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application

PL/SQL decisions, 524–526 Chapter 25 - Getting Started with Oracle XML and PL/SQL specifications, 504 Chapter 26 Building PL/SQL using SOAP from, 103 Web Services Part VI - Oracle XML for PL/SQL Developers

Chapter 27 - Extending PL/SQL XML Functionality with Java

PL/SQL, Oracle XML and, 465–480 PL/SQL XML processing techniques, 466–479 Appendix - XML Standards Bodies and Open Specifications setting up environment, 466 Glossary setting up Oracle JVM, 480 Chapter 28 - Putting It All Together

Index

PL/SQL web services, building, 481–499 consuming web services within Oracle databases, 492–497 List of Tables extending application, 497–499 List of Sidebars publishing first database web service, 482–492 List of Figures

PL/SQL web services, publishing, 485–489 PL/SQL XML functionality, extending with Java, 501–517 best practices, 515–517 creating Java stored procedure to process XML, 502–504 Oracle JDeveloper 10g,505–507 processing XML in Oracle JVM, 507–515 running Java stored procedure, 504–505


simplifying deployment of Java stored procedures, 505–507 PL/SQL XML processing techniques, 466–479 parsing XML, Oracle 467–474 Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & processing PL/SQL XML using DOM, 474–478 ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang processing by XML using XSLT, 478–479 McGraw-Hill/Osborne © 2004 (600 pages)

Platform, extending Oracle XML, 527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with

Platform, Oracle XML, 520–521 emphasis on XML standards, their usage and best practices. PO process procedures, creating AQ, 328–332 Table of functionality, Contents Portal adding, 301–307

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Portal sites, creating with XML, 289–311

Introduction

Portal sites, creating with XML web services adding portal functionality, 301–307 Chapter 1 - Introducing XML creating administration page, 307–311 Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX designing framework, 290–293 Chapter 3 - Transforming XML with XSLT and XPath designing static and dynamic areas, 293–301 Part I - Oracle and the XML Standards

Chapter 4

- Validating XML with DTDs and XML Schemas

POs (purchase orders), 314 - XML Operations with XQuery creating XML, 321–323,321–323 Chapter 6 - XML Messaging and RPC with SOAP handling xsi:types in, 341 Chapter 5 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Predicate expression, 87 Part II - Oracle XML Management for DBAs Chapter 8 - Getting Started with the Oracle XML Database Print formatting, 201–202 Chapter 9 SAX - Storing XML Data Printing, parsing and, 346–348 Chapter 10 - Generating and Retrieving XML

PrintSubTree() template, 457–458

Chapter 11 - Searching XML Data

Procedures Chapter 12 - Managing the Oracle XML Database Java stored, 502–504 Part creating III - Oracle XML for Java Developers debugging JavaStarted stored, with 516–517 Chapter 13 - Getting Oracle XML and Java

running Java stored, 504–505 simplifying deployment of Java stored, 505–507 Chapter 15 - Creating a Portal Site with XML and Web Services when to use Java stored, 515 Chapter 14 - Building an XML-Powered Web Site

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Processes Chapter 17 - Developing XML-Based Reusable Components 357–360 Part XSDConditionalValProcess, IV - Oracle XML for C Developers XSDSchemaBuilder, 354with Oracle XML and C Chapter 18 - Getting Started XSDValProcess,354–357

Chapter 19 - Building an XML-Managed Application

Processing Chapter 20 - Build an XML Database OCI Application multistage XML,an107–108 Chapter 21 - Create XML-Configured High-Performance Transformation Engine XML, XML 511–515 Part SAX V - Oracle for C++ Developers SQL/XML, 146–147 Chapter 22 - Getting Started with Oracle XML and C++ XML23using DOM, 474–478 Chapter - Build an XML Database OCI C++ Application XML using XSLT, 478–479 XML with JSPs and XML beans, 108–115 Part VI - Oracle XML for PL/SQL Developers

Chapter 24 - Building an XML Data-Retrieval Application

Processing techniques, PL/SQL XML, 466–479 Chapter 25 - Getting Started with Oracle XML and PL/SQL parsing 467–474 Chapter 26 - XML, Building PL/SQL Web Services processing XML using DOM, Chapter 27 - Extending PL/SQL XML474–478 Functionality with Java processing XMLItusing XSLT, 478–479 Chapter 28 - Putting All Together Processors Appendix - XML Standards Bodies and Open Specifications programmatic invocation of XSLT, 51–53 Glossary IndexXML Pipeline, 106–108 List of Figures ProcessXPath() template, 453–457 List of Tables Profiles, defining, 380–382 List of Sidebars

Program, creating main, 459 Prolog,5–6 Prolog, query, 87–88 Protection, setting up security, 498 Protocol, W3C XML, 533–534 Publishcat application, creating, 386–391


Publishing framework, XSQL Page, 116–125 Purchase orders (POs), 314 creating XML, Oracle 321–323 Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Q

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Queries emphasis on XML standards, their usage and best practices. optimizing XPath-based, 227–229 submitting to XSQL Servlet, 118–119 Table of Contents

Query application, creating C++, 443–444

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Query prolog, 87–88 Introduction Part I - Oracle and theW3C XML Standards Query specification, XML, 532–533

Chapter 1 XML - Introducing XML Querying Chapter - Accessing XML from2 command line, 91 with DOM, SAX, JAXB, and StAX Chapter 3 - Transforming in database, 92–93 XML with XSLT and XPath Chapter 4 - Validating XML with DTDs and XML Schemas documents, 91 Chapter - XML Operations with XQuery with5XQueryX, 91 Chapter 6 XMLType - XML Messaging and RPCAPIs, with SOAP Querying with C++ XDK 447–449 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

R

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

focuses on utilizing XML technologies within Oracle's XML-enabled products, with Record list via This OCI,comprehensive retrieving DOMguide of, 401–405 emphasis on XML standards, their usage and best practices.

REF cursor, 204 References, resolving URL, 507–511 Table of Contents Oracle Database 10gschema, XML & SQL—Design, Registration, XML 160–165 Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Relational tables storing XML documents in, 176–184 Chapter 1 - Introducing XML XMLType or, 150–152 Part I - Oracle and the XML Standards

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Remote procedure call (RPC), 96

Remote4 schema, processing documents against, 361 Chapter - Validating XML with DTDs and valid XML Schemas Chapter Repository 5 - XML Operations with XQuery

protecting data in Oracleand XML DB, 248–250 Chapter 6 - XML Messaging RPC with SOAP XML7 stored in Oracle XML DB,with 524XML Pipeline, JSPs, and XSQL Chapter - Putting It All Together Part II - Oracle XML Management forDB, DBAs Repository interfaces, Oracle XML 170

Chapter 8

- Getting Started with the Oracle XML Database

Repository, Oracle XML DB, 147,154,173–176 Chapter 9 - Storing XML Data resource management, 174–175 Chapter 10 - control, Generating and Retrieving XML version 175–176 Chapter 11 - Searching XML Data

Resource management, 174–175

Chapter 12 - Managing the Oracle XML Database

Resources, Oracle 535 Part III - Oracle XMLtechnical, for Java Developers Chapter 13 -components, Getting Started with Oracle XML and Java Reusable developing XML-based, 343–362 Chapter 14 - Building an XML-Powered Web Site RPC (remote procedure call), 96 Chapter 15 - Creating a Portal Site with XML and Web Services

RPC with SOAP, XML messaging and, 95–104 best practices, 104 Chapter 17 - Developing XML-Based Reusable Components introducing SOAP, 96–98 Part IV - Oracle XML for C Developers using SOAP and Oracle database, 100–103 Chapter 18 - Getting Started with Oracle XML and C using SOAP and Oracle XDK, 99–100

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

Chapter 19 - Building an XML-Managed Application

Run-time environment C,368–369,371 Chapter 21 - Create an XML-Configured High-Performance Transformation Engine checking C++, 424–426,427–428 Chapter 20 - Build an XML Database OCI Application Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

S

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Sample database schemas, installing, 137–138 emphasis on XML standards, their usage and best practices.

Samples, creating users to run XMLType, 138 SAXof (Simple API for XML), 16 Table Contents Oracle XML & SQL—Design, SAX, Database accessing10g XML with, 15,28–42 Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

SAX APIs, 31–37

Part I - Oracle and the XML Standards

SAX APIs -inIntroducing C, Oracle, XML 37–42

Chapter 1

SAX Level and Level 2, 28–31 Chapter 2 - 1Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 - Transforming with XSLT and XPath SAX parsing and printing,XML 346–348 Chapter 4

- Validating XML with DTDs and XML Schemas SAX specification, 531–532

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

SAX vs. DOM, 108

SAX XML 511–515 Chapter 7 -processing, Putting It All Together with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs Schema annotations, XML, 165–168

Chapter 8

- Getting Started with the Oracle XML Database Schema-based types, XML, 153

Chapter 9

- Storing XML Data

Schema-based XMLTypes, creating XML, 186

Chapter 10 - Generating and Retrieving XML

Schema datatypes, XML, 69–70 Chapter 11built-in - Searching XML Data Chapter 12evolution, - Managing the Oracle XML Database Schema 185 Part III - Oracle XML for Java Developers

Schema language, XML, 66–68

Chapter 13 - Getting Started with Oracle XML and Java

Schema registration, XML, 160–165

Chapter 14 - Building an XML-Powered Web Site

Schema W3C XML, 532XML and Web Services Chapter 15specification, - Creating a Portal Site with Chapter 16validation, - Developing an 172–173 XML Gateway Application with SOAP and AQ Schema XML, Chapter 17 - Developing XML-Based Reusable Components Schemas Part creating IV - Oracle XML for 317–321 C Developers database,

Chapter 18 - Getting Started with Oracle XML and C creating glossary, 283–284 Chapter 19 - Building an XML-Managed Application creating messaging, 324–325 Chapter 20 - Build XML Database OCI Application creating user, an 301–302 Chapter 21 - Create database, 11–14an XML-Configured High-Performance Transformation Engine Part designing, V - Oracle 79 XML for C++ Developers

Chapter designing 22 - Getting FAQ, Started 269–271with Oracle XML and C++

generating XML, 209–210 Chapter 23 - Build an XML Database OCI C++ Application input 43 an XML Data-Retrieval Application Chapter 24XML, - Building sample database, 137–138 Part installing VI - Oracle XML for PL/SQL Developers mapping database, 12–14 Chapter 25 - Getting Started with Oracle XML and PL/SQL mapping DTDs toPL/SQL database, Chapter 26 - Building Web 75–76 Services mapping XML documents to database, 12–14, 76Java Chapter 27 - Extending PL/SQL XML Functionality with

processing documents valid against remote, 361 registering FAQ, 272–273 Appendix - XML Standards Bodies and Open Specifications setting up database, 482–485 Glossary validating XML with XML, 63–81 Chapter 28 - Putting It All Together

Index

Searches List of Figures

advanced text, 237–238 optimizing Oracle Text, 236 List of Sidebars Oracle Text, 239 List of Tables

Searches, XPath-based, 220–229,239 optimizing XPath-based queries using indexes, 227–229 searching XML document using XPath, 221–224 XPath-based searching, 224–226 Searching, full text, 230–238 advanced text searches, 237–238 optimizing Oracle Text searches, 236


Oracle Text searching, 235–236 searching XML using Oracle Text, 231–234 Searching XMLOracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL data,155,219–240 ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang documents by using XPath, 221–224 McGraw-Hill/Osborne © 2004 (600 pages) using Oracle Text, 231–234 This comprehensive Searching, XPath-based, 224–226guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Secure connections, creating more, 126 Security management, 248–251 Table of Contents protecting Oracle XML DB Repository, 248–250 Oracle Databasedata 10g in XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL securing DBUri operations, 250–251 Introduction Part Security I - Oracle protection, and the setting XML Standards up, 498

Chapter 1 - Introducing Serialization, 107–108 XML Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 5

- XML Operations with XQuery

Servers Chapter 3 - Transforming XML with XSLT and XPath building web services in database, 497–498 Chapter 4 - Validating XML with DTDs and XML Schemas SOAP,99–100

Services - XML Messaging and RPC with SOAP debugging web, 491–492 Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL publishing first database web, 482–492 Part II - Oracle XML Management for DBAs publishing PL/SQL web, 485–489 Chapter 8 - Getting Started with the Oracle XML Database web,289–311 Chapter 6

Chapter 9

- Storing XML Data

Services, building different types of web, 498–499

Chapter 10 - Generating and Retrieving XML

Services, PL/SQL web, 481–499 Chapter 11 building - Searching XML Data consuming web services within Oracle databases, 492–497 Chapter 12 - Managing the Oracle XML Database application, 497–499 Part extending III - Oracle XML for Java Developers publishing first database webOracle service, 482–492 Chapter 13 - Getting Started with XML and Java Chapter Servlets 14 - Building an XML-Powered Web Site

AQ,15 101- Creating a Portal Site with XML and Web Services Chapter inserting XML documents XSQL,Application 122 Chapter 16 - Developing an XMLwith Gateway with SOAP and AQ installing XSQL, 118XML-Based Reusable Components Chapter 17 - Developing 118–119 Part submitting IV - Oracle queries XML forto C XSQL, Developers updating data with XSQL, 122–125 Chapter 18 - Getting Started with Oracle XML and C Chapter SGML 19 (Standard - Building Generalized an XML-Managed MarkupApplication Language), 4 Chapter 20 - Build an XML Database OCI Application SOAP (Simple Object Access Protocol), 11,96 Chapter 21and - Create andatabase, XML-Configured High-Performance Transformation Engine using Oracle 100–103 Part using V - Oracle for C++ fromXML PL/SQL, 103Developers

Chapter 22 - Getting104 Started with Oracle XML and C++ vs. JAX-RPC, Chapter 23 - Build vs. JMS, 104 an XML Database OCI C++ Application Chapter 24 - AQ, Building XML Data-Retrieval Application SOAP and XMLan gateway application with, 313–342 Part conventional VI - Oracle XML for PL/SQL Developers solution, 314–315

Chapter 25 - Getting Started with Oracle XML and PL/SQL creating framework, 317–323 Chapter 26 - Building PL/SQL Web Services designing framework, 314–317 Chapter 27 - Extending PL/SQL XML Functionality with Java extending application’s functionality, 341–342 Chapter 28 - Putting It All Together extending framework, 332–340 Appendix interfacing - XML to Standards Internet, 316–317 Bodies and Open Specifications

stream-based one-step solution, 315–316 Glossary Index SOAP and Oracle XDK, using, 99–100 List of Figures

SOAP clients, 99

List of Tables

SOAP handlers, 100

List of Sidebars

SOAP, introducing, 96–98 literal, encoded SOAP messages, 96–98 one-way, two-way SOAP messaging and RPCs, 98 SOAP messages constructing, 493 sending out using UTL_HTTP, 494–497 submitting, 341


SOAP servers, 99–100 SOAP, XML messaging and RPC with, 95–104 best practices, Oracle 104Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & introducing PL/SQL SOAP, 96–98 ISBN:0072229527 Mark V. Scardina, Ben100–103 Chang and Jinyu Wang using SOAPbyand Oracle database, McGraw-Hill/Osborne © 2004 (600 pages) using SOAP and Oracle XDK, 99–100 This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Special characters, 205–206 emphasis on XML standards, their usage and best practices.

Specifications creating PL/SQL, 504 Table of Contents ISO SQL/XML, 534 Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Java community process, 534 Introduction SAX, 531–532 Part I - Oracle and the XML Standards W3C, 530–534 Chapter 1 DOM, - Introducing XML W3C 531 Chapter 2 Accessing XML W3C namespace, 532 with DOM, SAX, JAXB, and StAX Chapter 3 XML, - Transforming W3C 530–531 XML with XSLT and XPath Chapter 4 XML - Validating with DTDs and XML Schemas W3C PipelineXML Definition Language, 533 Chapter 5 XML - XML Operations with XQuery W3C query, 532–533 Chapter W3C 6 XML - XML schema, Messaging 532and RPC with SOAP W3C and ItXPath, 533 with XML Pipeline, JSPs, and XSQL Chapter 7 XSLT - Putting All Together Part II - Oracle XML for DBAs Specifications, XMLManagement standards bodies and open, 529–535

Chapter - Gettingspecifications, Started with the Oracle XML Database ISO8SQL/XML 534 Chapter 9 community - Storing XML Data specifications, 534 Java process Chapter 10 - Generating and Retrieving535 XML miscellaneous helpful resources, Chapter Oracle 11 -technical Searching resources, XML Data 535

W3C Chapter 12specifications, - Managing the530–534 Oracle XML Database Part III -mode, Oraclerunning XML forcppextract Java Developers Splitter in, 460

Chapter 13 - Getting Started with Oracle XML and Java

SQL command, 169

Chapter 14 - Building an XML-Powered Web Site

SQL data, 190–199, 199–206 Chapter 15 -generating Creating a XML Portalfrom, Site with XML and Web Services SQL utility, 177–182 Chapter 16 - XML, Developing an XML Gateway Application with SOAP and AQ canonical mapping, XML-Based 177–179 Reusable Components Chapter 17 - Developing XML documents into fragments, 180–182 Part dividing IV - Oracle XML for C Developers object 179–180 Chapter 18 views, - Getting Started with Oracle XML and C Chapter 19 -functions, Building an XML-Managed Application SQL/XML 190–199, 206–208 Chapter 20 -processing, Build an XML Database OCI Application SQL/XML 146–147 Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

SQL-XML, XQuery versus, 94

Part V - Oracle XML for C++ Developers

SQL*Loader, 170–171 Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 Generalized - Build an XML Database OCI C++ Application Standard Markup Language (SGML), 4 Chapter 24 - XML Building an XMLand, Data-Retrieval Standards, database 148–149 Application Part VI - Oracle XML for PL/SQL Developers

Static areas, creating, 300–301

Chapter 25 - Getting Started with Oracle XML and PL/SQL

StAX (Streaming APIPL/SQL for XML), 45 Chapter 26 - Building Web16, Services accessing XML with, 15,45–47 Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter Stored 28 procedures - Putting It All Together

creating Java, 502–504Bodies and Open Specifications Appendix - XML Standards debugging Java, 516–517 Glossary Indexrunning Java, 504–505

simplifying List of Figures deployment of Java, 505–507 when to use Java, 515 List of Tables Storing XML data, 150–154,157–188 List of Sidebars Streaming API for XML (StAX), 45 Stylesheets compiling with xslcompile, 411–414 creating XSL, 383–385 transforming XSQL output with, 119–121 XSLT, 55–56,379–380 Systems, parsing XML from local file, 467–471


SYS_XMLAGG(), 197 SYS_XMLGEN(),193 Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

T

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Tables emphasis on XML standards, their usage and best practices. external, 184–185 storing XML documents in relational, 176–184 TableXMLType of Contents object, 153–154 Oracle Database XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XMLType or10g relational, 150–152 Introduction

Tags, skipping <!DOCTYPE>, 47

Part I - Oracle and the XML Standards

Technical Oracle, Chapter 1 -resources, Introducing XML 535 Techniques, PL/SQL XML processing, 466–479 Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 - Transforming XML with XSLT and XPath Templates Chapter 4 - Validating XML with DTDs and XML Schemas printSubTree(), 457–458 Chapter 5 - XML Operations processXPath(), 453–457with XQuery Chapter XSL, 656- XML Messaging and RPC with SOAP Chapter 7 - trees, Putting59 It All Together with XML Pipeline, JSPs, and XSQL Temporary Part II - Oracle XML Management for DBAs

Text, Oracle, 147–148

Chapter 8

- Getting Started with the Oracle XML Database

Text searching Chapter 9 - Storing XML Data advanced, 237–238 and Retrieving XML Chapter 10 - Generating full, 230–238 Chapter 11 - Searching XML Data Oracle,235–236

Chapter 12 - Managing the Oracle XML Database

Text, XMLfor using 231–234 Part IIIsearching - Oracle XML JavaOracle, Developers Chapter 13 - Getting Started with Oracle XML and Java Transformation engines, creating XML-configured, 409–418 Chapter 14 - Building an XML-Powered Web Site compiling stylesheets with xslcompile, 411–414 Chapter designing 15 - Creating framework, a Portal 410–411 Site with XML and Web Services

running virtualanmachine with xsbtransform, 414–417 Chapter 16 - XSLT Developing XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Transformations, 107–108 Part IV - Oracle XML for C Developers

Transformations, overall performance of XSLT for multiple, 62

Chapter 18 - Getting Started with Oracle XML and C

TransX19 utility, 182 an XML-Managed Application Chapter - Building Trees, 20 temporary, 59XML Database OCI Application Chapter - Build an Chapter Types 21 - Create an XML-Configured High-Performance Transformation Engine Part simple V - Oracle for C++ Developers andXML complex data, 68–73

Chapter - Getting Started with Oracle XML and C++ XML22schema-based, 153 Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

U

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

focuses on utilizing XML technologies within Oracle's XML-enabled products, with UNIX setup of This XDKcomprehensive C components,guide 367–368 emphasis on XML standards, their usage and best practices.

UNIX setup of XDK C++ components, 423–424 UPDATEXML(), Table of Contents197–199 Oracle Databaseresource 10g XMLlocator), & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL URL (uniform 64 Introduction

URL references, resolving, 507–511

Part I - Oracle and the XML Standards

URLs, parsing XML from, 471–474 - Introducing XML

Chapter 1

User application forms, creating, 304–307 Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX Chapter 3 - Transforming with XSLT and XPath User schemas, creating, XML 301–302 Chapter 4

Users

- Validating XML with DTDs and XML Schemas

Chapter 5 - XML Operations creating database, 272 with XQuery Chapter 6 - XML Messaging RPC with SOAP creating to run XMLTypeand samples, 138 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Utilities TransX,182 Chapter 8 - Getting Started with the Oracle XML Database XML SQL, 177–182 Part II - Oracle XML Management for DBAs

Chapter 9

- Storing XML Data

UTL_HTTP, sending out SOAP messages using, 494–497

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data

Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

V

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with Validation,107–108 emphasis on XML standards, their usage and best practices. XML schema, 172–173

Variables, bind, 204–205

Table of Contents

Version control,10g 175–176 Oracle Database XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Views Part creating I - OracleXMLType, and the XML Standards 211–212

Chapter object, 1 179–180 - Introducing XML

XML2 documents as XMLType, Chapter - Accessingstored XML with DOM, SAX,13 JAXB, and StAX XMLType, 145,523–524 Chapter 3 - Transforming XML with XSLT and XPath Chapter 4 - Validating XML with DTDs and XML Schemas Virtual machine, running XSLT, 414–417 Chapter 5

- XML Operations with XQuery Visual C/C++, setting up Microsoft, 372–374,428–430

Chapter 6 - XMLprojects, Messaging and RPC with SOAP configuring 372–374

Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL creating new project, 372 Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

W

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with W3C DOM specifications, 531 emphasis on XML standards, their usage and best practices.

W3C namespace specifications, 532 W3Cofspecifications, 530–534 Table Contents SAX specification, 531–532 Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL W3C DOM specifications, 531 Introduction namespace Part W3C I - Oracle and the specifications, XML Standards 532 W3C Pipeline Definition Language specification, 533 Chapter 1 XML - Introducing XML W3C XML Protocol, 533–534 - Accessing XML with DOM, SAX, JAXB, and StAX W3C XML query specification, 532–533 Chapter 3 - Transforming XML with XSLT and XPath W3C XML schema specification, 532 Chapter 4 - Validating XML with DTDs and XML Schemas W3C XML specification, 530–531 Chapter 5 - XML Operations with XQuery W3C XSLT and XPath specification, 533 Chapter 2

Chapter 6

- XML Messaging and RPC with SOAP

W3C XML- Putting It All Together with XML Pipeline, JSPs, and XSQL Pipeline Definition Language specification, 533 Part II - Oracle XML Management for DBAs Protocol,533–534 Chapter 8 - Getting Started with the Oracle XML Database query specification, 532–533 Chapter 9 - Storing XML Data schema specification, 532 Chapter 10 - Generating and Retrieving XML specification,530–531 Chapter 7

Chapter 11 - Searching XML Data

W3C XSLT and XPath specification, 533

Chapter 12 - Managing the Oracle XML Database

W3C Wide Consortium), 4,530 Part III(World - Oracle XMLWeb for Java Developers Chapter 13 - Gettingdesigning Started with Oracle XML and Web applications, XML databases for,Java 155 Chapter 14 - Building an XML-Powered Web Site

Web services, 289–311 calling from clients, 489–491 Chapter 16 - Developing an XML Gateway Application consuming within Oracle databases, 492–497 with SOAP and AQ Chapter 17 Developing XML-Based Reusable Components debugging, 491–492 Part publishing IV - Oraclefirst XMLdatabase, for C Developers 482–492 Chapter 18 - Getting Started with Oracle XML and C publishing PL/SQL, 485–489 Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 19 - Building an XML-Managed Application

Web services, building different types of, 498–499

Chapter 20 - Build an XML Database OCI Application

Web services, building in database servers, 497–498

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

Web building PL/SQL, 481–499 Part V services, - Oracle XML for C++ Developers consuming web Started serviceswith within Oracle Chapter 22 - Getting Oracle XMLdatabases, and C++ 492–497 extending application, 497–499OCI C++ Application Chapter 23 - Build an XML Database publishing first database web service, 482–492 Chapter 24 - Building an XML Data-Retrieval Application Part VIservices, - Oracle XML for PL/SQL Developers Web creating portal site with XML

Chapter adding 25 -portal Getting functionality, Started with 301–307 Oracle XML and PL/SQL

creating administration 307–311 Chapter 26 - Building PL/SQLpage, Web Services designing framework, 290–293 Chapter 27 - Extending PL/SQL XML Functionality with Java designing static It and Chapter 28 - Putting All dynamic Togetherareas, 293–301 Appendix Web sites - XML Standards Bodies and Open Specifications Glossary connecting FAQ, 274–277 IndexXML-enabled FAQ, 268 List of Figures Web sites, building XML-powered, 267–288 List of Tablespagination to FAQ listing, 277–279 adding List of Sidebars FAQ web site to XML database, 274–277 connecting

creating FAQ database, 269–274 creating glossary, 283–287 designing framework, 268–269 displaying FAQ and answers, 280–283 searching FAQs, 287 XML-enabled FAQ web site, 268 WebDAV folders, setting up, 138–140


Windows setup of XDK C components, 370–371 of XDK C++Oracle components, 426–427 Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL World Wide Web Consortiums (W3C), 4 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Index

Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

X

by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Xdbconfig.xml,This 245 comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Xdbconfig.xml, configuring, 245–248 XDKof (XML Developer’s Kit), 130 Table Contents Oracle Database 10g XML Kit & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XDK (XML Developer’s 10g),106 Introduction

XDK APIs, querying XMLType with C++, 447–449

Part I - Oracle and the XML Standards

XDK C components - Introducing XML UNIX setup of, 367–368 Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX Windows setup of, 370–371 Chapter 1 Chapter 3

- Transforming XML with XSLT and XPath

XDK C++ Chapter 4 -components Validating XML with DTDs and XML Schemas UNIX 423–424with XQuery Chapter 5 setup - XMLof, Operations

Windows setup of, 426–427 - XML Messaging and RPC with SOAP

Chapter 6

XDK C 7libraries, Oracle, 366–367 with XML Pipeline, JSPs, and XSQL Chapter - Putting It All Together libcoresh10.so, libcore10.dll, 366 Part libcore10.a, II - Oracle XML Managementand for DBAs libnls10.a and oranls10.dll, Chapter 8 - Getting Started with367 the Oracle XML Database libunls10.a and oraunls10.dll, 367 Chapter 9 - Storing XML Data libxml10.a, libxml10.so, oraxml10.dll, 366 Chapter 10 - Generating and and Retrieving XML XDK C++ Oracle, 422–423 Chapter 11 -libraries, Searching XML Data Chapter 12 - Managing the Oracle XML264–266 Database XDK Component Palette, creating, Part III - Oracle XML for Java Developers

XDK environment, setting up, 260–261

Chapter 13 - Getting Started with Oracle XML and Java

XDK, initializing for XMLType XOB Access, 446–447 Chapter 14 - Building an XML-Powered Web Site XDK Java Chapter 15 -libraries, CreatingOracle, a Portal256–258 Site with XML and Web Services Chapter 16 - Developing XML Gateway Application with SOAP and AQ XDK, using with Oraclean JDeveloper, 260–266 Chapter 17 - Developing XML-Based Reusable Components creating XDK Component Palette, 264–266 Part setting IV - Oracle XML for Cconnection, Developers 261–264 up database

Chapter 18 -up Getting Started with Oracle XML and C setting XDK environment, 260–261 Chapter 19 - Building an XML-Managed XML (extensible markup language), 4Application Chapter 20 - Build an DOM, XML Database accessing using 17–27 OCI Application Chapter 21 - Create XML-Configured High-Performance Transformation Engine accessing with an DOM, 15 Part accessing V - Oracle XML C++ Developers with for SAX, 28–42

Chapter 22 - Getting Started accessing with StAX, 15with Oracle XML and C++ Chapter 23 - Build XML procedure Database OCI C++ Application creating Java an stored to process, 502–504 Chapter creating 24 - Building portal sites an XML with,Data-Retrieval 289–311 Application Part database VI - Oracle schema XML forand PL/SQL XML Developers documents, 11–14

introducing, 3–14Started with Oracle XML and PL/SQL Chapter 25 - Getting parsing, Chapter 26 - 467–474 Building PL/SQL Web Services parsing local file systems, 467–471 Chapter 27 - from Extending PL/SQL XML Functionality with Java parsing URLs, Chapter 28 - from Putting It All471–474 Together querying fromStandards commandBodies line, 91 Appendix - XML and Open Specifications querying in database, 92–93 querying with XQueryX, 91 Index retrieving and generating, 155 List of Figures valid XML documents, 8–9 List of Tables validating against DTDs, 66–68 List of Sidebars validating with DTDs, 63–81 validating with XML schemas (XSDs), 63–81,73–74 well-formed XML documents, 7–8 XML and databases, 11 XML documents, 4–7 XML namespaces, 9–11 Glossary

XML, accessing with Java binding, 42–45 binding to XML instance, 43–44


generating XML classes, 43 input XML schema, 43 XML document created by Java 44–45 Oracle Database 10gapplication, XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL XML, accessing with JAXB, 15 by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

XML, accessing with StAX, 15,45–47

ISBN:0072229527

XML and C++,This Oracle, 421–431 comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. XML and C, Oracle, 365–374 C XML development environment, 367–374 XDK C libraries, 366–367 TableOracle of Contents Oracle Database 10g XML XML and databases, 11 & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction XML and Java, Oracle, 253–266 Part I - Oracle and the XML Standards

XML application environment, setting up C++ OCI, 435–437

Chapter 1

- Introducing XML

XML application headers, 395–396, Chapter 2 - Accessing XML OCI, with DOM, SAX,435–437 JAXB, and StAX Chapter 3 - Transforming XML with XSLT and438–439 XPath XML application, initializing C++ database, Chapter 4 - Validating XML with DTDs and XML Schemas XML application libraries Chapter - XML Operations with XQuery OCI,5396 Chapter - XML and RPC with SOAP OCI6and C++,Messaging 437 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

XML application make files, OCI, 396–397

Part II - Oracle XML Management for DBAs

XML-based reusable components, 343–362 Chapter 8 - Getting Started with the developing, Oracle XML Database building- pipeline applications, 352–360 Storing XML Data designing framework, 344–345 Chapter 10 - Generating and Retrieving XML running pipeline application, 360–362 Chapter 11 - Searching XML Data simple pipeline examples, 345–352 Chapter 9

Chapter 12 - Managing the Oracle XML Database

XMLIIIbeans in JSPs, using, Part - Oracle XML for Java115 Developers Chapter XML beans, 13 - Getting processing Started XML with with Oracle JSPsXML and, and 108–115 Java Chapter 14 - Building an XML-Powered Web Site XML classes, generating, 43 Chapter 15 - Creating a Portal Site with XML and Web Services

XML configuration file, creating, 378–382 defining profiles, 380–382 Chapter 17 - Developing XML-Based Reusable Components XSLT stylesheets, 379–380

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Part IV - Oracle XML for C Developers

XML-configured transformation engine, creating, 409–418 compiling stylesheets with xslcompile, 411–414 Chapter 19 - Building an XML-Managed Application designing framework, 410–411 Chapter 20 - Build an XML Database OCI Application running XSLT virtual machine with xsbtransform, 414–417 Chapter 18 - Getting Started with Oracle XML and C

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

XMLV data loading, 168–171 Part - Oracle XML for C++ Developers Chapter XML data-retrieval 22 - Getting application, Started withbuilding, Oracle XML 451–462 and C++

building application, 452–459 Chapter 23 - cppextract Build an XML Database OCI C++ Application designing framework, 452 Chapter 24 - Building an XML Data-Retrieval Application 460–462 Part extending VI - Oracleframework, XML for PL/SQL Developers running application, 459–460 Chapter 25 - cppextract Getting Started with Oracle XML and PL/SQL Chapter 26 -retrieving Building PL/SQL Web Services XML data, using XPath, 476–478 Chapter 27 -searching, Extending PL/SQL XML Functionality with Java XML data, 155,219–240 Chapter - Putting 239–240 It All Together best28practices, Appendix XML Standards Bodies and Open Specifications full text- searching, 230–238 Glossary XPath-based searches, 220–229 Index

XML data, storing, 150–154,157–188

List of Figures best practices, 185–187

List of Tables tables, 184–185 external List of Sidebars schema evolution, 185

storing XML documents in CLOB XMLTypes, 158–159 storing XML documents in relational tables, 176–184 storing XML documents in XML schema-based XMLTypes, 159–176 XML database and standards, 148–149 XML database, connecting FAQ web site to, 274–277 XML, database design decisions for, 522–526


XML database OCI application, building, 393–408 XML database OCI C++ application, building, 433–450 connecting Oracle to databases, Database 440–441 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL creating C++ OCI helper class, 437–438 ISBN:0072229527 byquery Mark V. Scardina, 443–444 Ben Chang and Jinyu Wang creating C++ application, McGraw-Hill/Osborne © 2004 (600 pages) designing framework, 434–435 disconnecting Thisfrom comprehensive databases and guide cleaning focuses up, on utilizing 441–442XML technologies within Oracle's XML-enabled products, with emphasis on XML their usage and best practices. initializing C++ database XMLstandards, application, 438–439 initializing XDK for XMLType XOB Access, 446–447 XMLType with C++ XDK APIs, 447–449 Tablequerying of Contents running application, Oracle Database 10g XML449 & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL selecting into XMLType, 444–446 Introduction up and C++the OCI XML application environment, 435–437 Part setting I - Oracle XML Standards Chapter XML databases 1 - Introducing XML

designing, 149–156, 155–156 Chapter 2 - Accessing XML with DOM, SAX, JAXB, and StAX installing Oracle, 133–137 Chapter 3 - Transforming XML with XSLT and XPath Oracle, Chapter 4 -140–148 Validating XML with DTDs and XML Schemas Chapter 5 - XML Operations with XQuery XML databases, Oracle, 129–156 Chapter designing 6 - XML XML Messaging databases, and149–156 RPC with SOAP

installed Oracle It XML DB components, Chapter 7 - Putting All Together with XML242–244 Pipeline, JSPs, and XSQL XMLXML database, 140–148 Part Oracle II - Oracle Management for DBAs setting OracleStarted XML databases, 132–140 Chapter 8 -up Getting with the Oracle XML Database XML9 database 148–149 Chapter - Storingand XMLstandards, Data XML10support in Oracle 130–132 Chapter - Generating anddatabases, Retrieving XML Chapter XML databases, 11 - Searching Oracle, XML241–251 Data

installed Oracle XML components, 242–244 Chapter 12 - Managing theDB Oracle XML Database management, 248–251 Part security III - Oracle XML for Java Developers Chapter 13 - Getting Started Oracle XML and Java XML databases, setting up with Oracle, 132–140 Chapter 14 - Building Web Site138 creating users to an runXML-Powered XMLType samples, Chapter 15 - Creating a Portal Site with133–137 XML and Web Services installing Oracle XML databases, Chapter installing 16 - Developing sample database an XML schemas, Gateway Application 137–138 with SOAP and AQ

setting WebDAVXML-Based folders, 138–140 Chapter 17 -up Developing Reusable Components Part - Oracle for C Developers XMLIVDB (XML XML Database), 130

Chapter 18 - Getting Started with Oracle XML and C

XML DB components, installed Oracle, 242–244

Chapter 19 - Building an XML-Managed Application

XML DB, Oracle, 244–248 Chapter 20 configuring - Build an XML Database OCI Application configuring xdbconfig.xml, 245–248 xdbconfig.xml, 245 Part V - Oracle XML for C++ Developers

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine

XML DB interfaces, 170 and C++ Chapter 22Repository - Getting Started with Oracle, Oracle XML Chapter 23Repository, - Build an XML Database OCI173–176 C++ Application XML DB Oracle, 147,154, Chapter 24 - Building an XML174–175 Data-Retrieval Application resource management, Part version VI - Oracle XML 175–176 for PL/SQL Developers control,

Chapter 25Repository, - Getting Started with data Oracle and 248–250 PL/SQL XML DB protecting in XML Oracle, Chapter 26 - Building PL/SQL Web Services

XML DB Repository, XML stored in Oracle, 524

Chapter 27 - Extending PL/SQL XML Functionality with Java

XML, designing databases for Web applications, 155 Chapter 28 - Putting It All Together Appendix XML Developer’s - XML Standards Kit 10g (XDK), Bodies106 and Open Specifications Glossary XML development environment IndexC, 367–374 List of Figures setting up C++, 423–430 List of Tables

XML document created by Java application, 44–45

List of Sidebars

XML document fragments, appending, 215–216 XML document models and databases, 75–78 mapping DTDs to database schemas, 75–76 mapping XML documents to database schemas, 76 supported database mappings, 76–78 XML document pruning use case for cppextract, 460–461 XML documents


in CLOB XMLTypes, 158–159 in CLOBs, 77 database schema 11–1410g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle and, Database dividing intoPL/SQL fragments, 180–182 as fragmentbydocuments, 78 ISBN:0072229527 Mark V. Scardina, Ben Chang and Jinyu Wang inserting with XSQL Servlet, 122© 2004 (600 pages) McGraw-Hill/Osborne mapping, 12–14 This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with mapping to emphasis databaseon schemas, 76 XML standards, their usage and best practices. as object-relational data, 77,78 parsing and binding, 16–17 Table of Contents processing invalid, 361 Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL searching using XPath, 221–224 Introduction stored as native XMLTypes, 14 Part I - Oracle and the XML Standards stored as XMLType CLOBs, 13 Chapter 1 - Introducing XML stored as XMLType views, 13 Chapter 2 -inAccessing XML with DOM, SAX, JAXB, and StAX storing CLOB XMLTypes, 158–159 Chapter 3 -inTransforming XML with XSLT and XPath storing relational tables, 176–184 Chapter 4 -inValidating XML with DTDs and XML Schemas storing XML schema-based XMLTypes, 159–176 Chapter 5 8–9 - XML Operations with XQuery valid, Chapter 6 - XML7–8 Messaging and RPC with SOAP well-formed, Chapter as XMLTypes, 7 - Putting78 It All Together with XML Pipeline, JSPs, and XSQL Part - Oracle XML Management XMLIIdocuments defined, 4–7 for DBAs

Chapter 8 6–7 - Getting Started with the Oracle XML Database body, Chapter 9 5–6 - Storing XML Data prolog, Chapter 10 - Generating and Retrieving XML

XML documents, querying, 91 querying XML from command line, 91 Chapter 12 - Managing Oracle XML querying XML withthe XQueryX, 91 Database Part III - Oracle XML for Java Developers running in interactive mode, 91 Chapter 11 - Searching XML Data

Chapter 13 - Getting Started with Oracle XML and Java

XML-enabled FAQ web site, 268

Chapter 14 - Building an XML-Powered Web Site

XML fragments, 212–213 Chapter 15 - Creating a Portal Site with XML and Web Services Chapter XML functionality, 16 - Developing simple anJSP, XML Gateway 126 Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components XML gateway application with SOAP and AQ, 313–342 Part conventional IV - Oracle XML for C Developers solution, 314–315

Chapter 18 - Getting Started with Oracle XML and C creating framework, 317–323 Chapter 19 - Building an XML-Managed designing framework, 314–317 Application Chapter 20 - Build an XML Database OCI Application extending application’s functionality, 341–342 Chapter extending 21 - Create framework, an XML-Configured 332–340 High-Performance Transformation Engine Part interfacing V - Oracle XML to Internet, for C++316–317 Developers

stream-based one-step solution, 315–316 Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an Database OCI C++ Application XML, generating andXML retrieving, 189–218 Chapter - Building216–217 an XML Data-Retrieval Application best24practices, Part creating VI - Oracle XML forviews, PL/SQL Developers XMLType 211–212

Chapter 25 - Getting Started with Oracle XML and PL/SQL DBM_XMLGEN, 199–206 Chapter generating 26 - Building XML from PL/SQL SQL Web data, Services 190–199,199–206

generating XML schemas, 209–210 Chapter 27 - Extending PL/SQL XML Functionality with Java processing XML,It 212–216 Chapter 28 - Putting All Together retrieving using SQL/XML function, 206–208 Appendix - XML Standards Bodies and Open Specifications retrieving using XMLType function, 206–208 Glossary IndexSQL/XML functions, 190–199

XML, generating from SQL data, 190–199,199–206 List of Figures List of instance, Tables XML binding to, 43–44 List of Sidebars

XML-managed application, building, 375–391 creating publishcat application, 386–391 creating XML configuration file, 378–382 creating XSL stylesheets, 383–385 designing framework, 376–377 XML media files, 377–378 XML media files, 377–378 bookcatalog.dtd,377


cdcatalog.dtd,378 dvdcatalog.dtd,378 XML messaging Oracle and RPC Database with SOAP, 10g XML 95–104 & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL best practices, 104 ISBN:0072229527 Mark 96–98 V. Scardina, Ben Chang and Jinyu Wang introducing by SOAP, McGraw-Hill/Osborne © 2004 (600 pages) using SOAP and Oracle database, 100–103 using SOAPThis andcomprehensive Oracle XDK, 99–100 guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

XML messaging gateway, creating, 323–340 XML namespaces, 9–11

Table of Contents

XML, Database navigating10g with XPath, 54–55 Oracle XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction XML operations with XQuery, 83–94 Part best I - Oracle practices, and the 93–94 XML Standards

Oracle engine, Chapter 1 -XQuery Introducing XML89–90 querying XML documents, Chapter 2 - Accessing XML with91 DOM, SAX, JAXB, and StAX XQuery, Chapter 3 - 84–89 Transforming XML with XSLT and XPath XQuery OracleXML database, 92–93 Chapter 4 - and Validating with DTDs and XML Schemas Chapter XML pipeline, 5 - XML 105 Operations with XQuery Chapter 6 - XML Messaging106–108 and RPC with SOAP XML Pipeline Processor, Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

XML platform, Oracle, 520–521,527

Part II - Oracle XML Management for DBAs

XML POs orders), creating, 321–323 Chapter 8 -(purchase Getting Started with the Oracle XML Database Chapter XML-powered 9 - Storing web XML site, Data building, 267–288

adding FAQ listing, 277–279 Chapter 10 -pagination Generatingtoand Retrieving XML connecting FAQ web to XML database, 274–277 Chapter 11 - Searching XMLsite Data creating FAQ database, 269–274 Chapter 12 - Managing the Oracle XML Database glossary, 283–287 Part creating III - Oracle XML for Java Developers designing framework, 268–269 Chapter 13 - Getting Started with Oracle XML and Java displaying FAQ and answers, 280–283 Chapter 14 - Building an XML-Powered Web Site searching FAQs, 287 XML-enabled FAQ web site, 268

Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

XML processing. See also SQL/XML processing Chapter 17 - Developing XML-Based Reusable Components Part multistage, IV - Oracle 107–108 XML for C Developers

tier 18 decisions, 521–522 Chapter - Getting Started with Oracle XML and C Chapter XML, processing, 19 - Building 212–216 an XML-Managed Application

dealing fragments, 212–213 Chapter 20 - with BuildXML an XML Database OCI Application DOM 213–216 Chapter 21editing, - Create an XML-Configured High-Performance Transformation Engine JSPs XML and XML beans, 108–115 Part with V - Oracle for C++ Developers Chapter 22 - Getting with Oracle XML and C++ XML, processing in Started Oracle JVM, 507–515 Chapter 23 - Build XML Database OCI C++ Application resolving URLan references, 507–511 Chapter SAX24XML - Building processing, an XML 511–515 Data-Retrieval Application Part - Oracle XML for PL/SQL Developers XMLVIprocessing techniques, PL/SQL, 466–479

Chapter 25 - Getting Started with Oracle XML and PL/SQL

XML, processing using DOM, 474–478 dealing with namespaces, 475–476 Chapter 27 - Extending PL/SQL XML Functionality with Java retrieving XML data using XPath, 476–478 Chapter 26 - Building PL/SQL Web Services Chapter 28 - Putting It All Together

XML, processing using XSLT, 478–479 - XML Standards Bodies and Open Specifications

Appendix

XML query specification, W3C, 532–533 Glossary Index XML schema List of Figures annotations, 165–168 List of built-in Tables datatypes, 69–70

input, 43 List of Sidebars language,66–68 registration,160–165 validation, 172–173 XML schema-based types, 153 XML schema-based XMLTypes creating, 186 storing XML documents in, 159–176


XML Schema Definition (XSD), 5 XML schema specification, W3C, 532 XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & XML schemas Oracle (XSD), Database generating,10g 209–210 PL/SQL

XML schemas by (XSD), XML with, 63–81, ISBN:0072229527 Mark validating V. Scardina, Ben Chang and73–74 Jinyu Wang best practices, 79–81 McGraw-Hill/Osborne © 2004 (600 pages) introducing This XMLcomprehensive schema language, 66–68 guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with simple and emphasis complex data types, 68–73 on XML standards, their usage and best practices. validating XML against DTDs, 66–68 validating XML with XML schemas (XSDs), 73–74 Table of Contents XML document models and databases, 75–78 Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

XML, searching using Oracle Text, 231–234 Introduction Part XMLI -specification, Oracle and the W3C, XML530–531 Standards

Chapter 1 -utility, Introducing XML XML SQL 177–182 Chapter 2 - Accessing with DOM, SAX, JAXB, and StAX canonical mapping,XML 177–179 Chapter 3 - XML Transforming XMLinto with XSLT and 180–182 XPath dividing documents fragments, Chapter 4 views, - Validating XML with DTDs and XML Schemas object 179–180 Chapter 5 - XML bodies Operations XML standards and with openXQuery specifications, 529–535 Chapter - XML Messaging and RPC with SOAP ISO6SQL/XML specifications, 534 Chapter 7 community - Putting Itprocess All Together with XML Pipeline, JSPs, and XSQL Java specifications, 534 Part miscellaneous II - Oracle XMLhelpful Management for DBAs resources, 535

Chapter 8 -technical Getting Started with 535 the Oracle XML Database Oracle resources, Chapter 9 specifications, - Storing XML Data W3C 530–534 Chapter 10 - Generating and DB Retrieving XML 524 XML stored in Oracle XML Repository, Chapter 11 - Searching XML Data

XML support in Oracle databases, 130–132

Chapter 12 - Managing the Oracle XML Database

XML, XSLTDevelopers and XPath, 49–62 Part IIItransforming - Oracle XMLwith for Java best13practices, Chapter - Getting61–62 Started with Oracle XML and Java navigating XML with XPath, 54–55Web Site Chapter 14 - Building an XML-Powered

Oracle XSLT extensions, 59–60 programmatic invocation of XSLT processors, 51–53 Chapter 16 - Developing an XML Gateway Application with SOAP and AQ tuning tips for XSLT, 61–62 Chapter 17 - Developing XML-Based Reusable Components XSL templates, 56 Part IV - Oracle XML for C Developers XSLT 2.0, 57–59 Chapter 18 - Getting Started with Oracle XML and C XSLT and databases, 61 Chapter 19 - Building an XML-Managed Application XSLT process model, 56 Chapter 20 stylesheets, - Build an XML Database OCI Application XSLT 55–56 Chapter 21 Create an XML-Configured High-Performance Transformation Engine XSLTVM (XSLT Virtual Machine), 60–61 Chapter 15 - Creating a Portal Site with XML and Web Services

Part V - Oracle XML for C++ Developers

XML web services, creating portal site with adding portal functionality, 301–307 Chapter 23 - Build an XML Database OCI C++ Application creating administration page, 307–311 Chapter 24 - Building an XML Data-Retrieval Application designing framework, 290–293 Part VI - Oracle XML for PL/SQL Developers designing static and dynamic areas, 293–301 Chapter 22 - Getting Started with Oracle XML and C++

Chapter 25 - Getting Started with Oracle XML and PL/SQL

XML with SAX, accessing, 15

Chapter 26 - Building PL/SQL Web Services

XMLAGG(), 196 Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It 192 All Together XMLATTRIBUTES(), Appendix - XML Standards XMLCOLATTVAL(), 197 Bodies and Open Specifications Glossary

XMLCompress bean, 114

Index

XMLCONCAT(), 196 List of Figures List XMLDBAccess of Tables bean, 113 List of Sidebars XMLDiff bean, 114

XMLELEMENT(), 192 XMLFOREST(),194–195 XML_SECTION_GROUP,232–233 XMLSEQUENCE(),195–196 XMLType, 141–145 CLOB,522–523


columns, 153–154 object tables, 153–154 or relationalOracle tables,Database 150–152 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & querying with C++ XDK APIs, 447–449 PL/SQL selecting into, 444–446 ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang views,145,211–212, 523–524 McGraw-Hill/Osborne © 2004 (600 pages) XMLType CLOBs, This XML comprehensive documentsguide stored focuses as, 13on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

XMLType DOM, operating on, 213–215

XMLType function, retrieving using, 206–208

Table of Contents

XMLType samples, creating users to run, 138& Manage XML Applications in Java, C, C++ & PL/SQL Oracle Database 10g XML & SQL—Design, Build Introduction XMLType views, XML documents stored as, 13 Part I - Oracle and the XML Standards XMLType XOB Access, initializing XDK for, 446–447

Chapter 1

- Introducing XML

XMLTypes - Accessing XML with DOM, SAX, JAXB, and StAX character encoding for CLOB, 158–159 Chapter 3 - Transforming XML with XSLT and XPath CLOB,153 Chapter 4 - Validating XML with DTDs and XML Schemas creating XML schema-based, 186 Chapter 5 -XML XML documents Operations with XQuery storing in CLOB, 158–159 Chapter 6 XML Messaging and RPC with SOAP storing XML documents in XML schema-based, 159–176 Chapter 7 - Putting It All Together with XML Pipeline, JSPs, and XSQL updating and querying CLOB, 158 Part XML II - Oracle XML Management for DBAs documents as, 78 Chapter 2

Chapter 8

- Getting Started with the Oracle XML Database

XMLTypes, XML documents stored as Chapter 9 - Storing XML Data native,14

Chapter 10 - Generating and Retrieving XML

Xmlupdate application, running, 407–408

Chapter 11 - Searching XML Data

XOB Access, initializing forXML XMLType, 446–447 Chapter 12 - Managing theXDK Oracle Database Part III - Oracle XML for Java Developers XPath

Chapter 13 - Getting Started with Oracle XML and Java expressions, 54–55 Chapter navigating 14 - Building XML with, an XML-Powered 54–55 Web Site

retrieving XML data using,Site 476–478 Chapter 15 - Creating a Portal with XML and Web Services searching XML document 221–224 Chapter 16 - Developing an XMLusing, Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Basedusing Reusable Components XPath-based queries, optimizing indexes, 227–229 Part IV - Oracle XML for C Developers

XPath-based searches, 220–229,239 optimizing XPath-based queries using indexes, 227–229 Chapter 19 - Building an XML-Managed Application searching XML document using XPath, 221–224 Chapter 20 Build an XML Database OCI Application workings of, 224–226 Chapter 21 - Create an XML-Configured XPath-based searching, 224–226 High-Performance Transformation Engine Chapter 18 - Getting Started with Oracle XML and C

Part V - Oracle XML for C++ Developers

XPath specifications, W3C XSLT and, 533

Chapter 22 - Getting Started with Oracle XML and C++

XPath, 23 transforming XMLDatabase with XSLT and, 49–62 Chapter - Build an XML OCI C++ Application

best practices, 61–62 navigating XML with XPath, 54–55 Part VI - Oracle XML for PL/SQL Developers Oracle XSLT extensions, 59–60 Chapter 25 - Getting Started with Oracle XML and PL/SQL programmatic invocation of XSLT processors, 51–53 Chapter 26 - Building PL/SQL Web Services tuning tips for XSLT, 61–62 Chapter 27 - Extending PL/SQL XML Functionality with Java XSL templates, 56 Chapter 28 - Putting It All Together XSLT 2.0, 57–59 Appendix - XML Standards61 Bodies and Open Specifications XSLT and databases, Glossary XSLT process model, 56 IndexXSLT stylesheets, 55–56 List of Figures (XSLT Virtual Machine), 60–61 XSLTVM Chapter 24 - Building an XML Data-Retrieval Application

List of Tables

XQuery, 84–89

List of Sidebars API for Java, 92

basics,85 expressions,85–87 introducing XQueryX, 88–89 and Oracle database, 92–93 query prolog, 87–88 versus SQL-XML, 94 versus XSLT 2.0, 93


XQuery engine, Oracle, 89–90 setting up environment, 89 testing installation, 89–90 Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL with, 83–94 XQuery, XML operations ISBN:0072229527 by Mark V. Scardina, Ben Chang and Jinyu Wang best practices, 93–94 McGraw-Hill/Osborne © 2004 (600 pages) Oracle XQuery engine, 89–90 querying XML Thisdocuments, comprehensive 91 guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML standards, XQuery andemphasis Oracle database, 92–93 their usage and best practices.

XQueryX, 88–89 Tablequerying of Contents XML with, 91 Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Xsbtransform, running XSLT virtual machine with, 414–417

Introduction

XSDI -(XML Schema 5,64 Part Oracle and theDefinition), XML Standards XSDConditionalValProcess Chapter 1 - Introducing XML process, 357–360 Chapter - Accessing XML361 with DOM, SAX, JAXB, and StAX XSDs, 2local and remote, Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

XSDSchemaBuilder process, 354

XSDValidator bean, 114–115 - XML Operations with XQuery

Chapter 5

XSDValProcess process, 354–357 Chapter 6 - XML Messaging and RPC with SOAP Chapter 7 -handling Putting It Together Xsi:types, in All POs, 341 with XML Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

XSL stylesheets, creating, 383–385

Chapter 8

- Getting Started with the Oracle XML Database

XSL templates, 56 Chapter 9 - Storing XML Data

XSL Transformation (XSLT), 108 Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching Data Xslcompile, compiling XML stylesheets with, 411–414 Chapter 12 - Managing the Oracle XML Database

XSLT 2.0, 57–59 function definitions, 58 Chapter 13 - Getting Started with Oracle XML and Java grouping, 57 Chapter 14 Building an XML-Powered multiple result documents, 58–59 Web Site Chapter 15 - Creating a Portal Site with XML and Web Services temporary trees, 59 Part III - Oracle XML for Java Developers

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ

XSLT 2.0, XQuery versus, 93

Chapter 17 - Developing XML-Based Reusable Components

XSLT databases, Part IV and - Oracle XML for61 C Developers

XSLT and with, Chapter 18 -XPath, Gettingtransforming Started with XML Oracle XML49–62 and C best19practices, Chapter - Building61–62 an XML-Managed Application navigating XML 54–55 Chapter 20 - Build anwith XMLXPath, Database OCI Application Oracle extensions, 59–60 High-Performance Transformation Engine Chapter 21 -XSLT Create an XML-Configured of XSLT processors, 51–53 Part programmatic V - Oracle XMLinvocation for C++ Developers tuning for XSLT, 61–62 Chapter 22 tips - Getting Started with Oracle XML and C++

XSL templates, 56 XSLT 2.0, 57–59 Chapter 24 - Building an XML Data-Retrieval Application XSLT and databases, 61 Part VI - Oracle XML for PL/SQL Developers XSLT process model, 56 Chapter 25 - Getting Started with Oracle XML and PL/SQL XSLT stylesheets, 55–56 Chapter 26 - Building PL/SQL Web Services XSLTVM (XSLT Virtual Machine), 60–61 Chapter 23 - Build an XML Database OCI C++ Application

Chapter 27 - Extending PL/SQL XML Functionality with Java

XSLT, document() function in, 62

Chapter 28 - Putting It All Together

XSLT extensions Appendix - XML Standards Bodies and Open Specifications built-in Java Oracle, 60 Glossary IndexOracle, 59–60 List XSLT of Figures for multiple transformations, overall performance of, 62 List of Tables XSLT process model, 56 List of Sidebars <xsl:apply-imports/>, 56

<xsl:apply-templates/>,56 XSLT, processing XML using, 478–479 XSLT processors, programmatic invocation of, 51–53 XSLT stylesheets, 55–56,379–380 XSLT, tuning tips for, 61–62 XSLT virtual machine


running,414–417 running with xsbtransform, 414–417 XSLT Virtual Machine Oracle Database (XSLTVM),10g 60–61 XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

XSLT (XSL Transformation), 108

by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

XSLTransformer bean, 111 McGraw-Hill/Osborne © 2004 (600 pages) XSLTVM (XSLT Virtual Machine), 60–61 This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with XSQL,105

emphasis on XML standards, their usage and best practices.

XSQL home page, building, 275

Table of Contents

XSQLDatabase output, transforming with stylesheets, Oracle 10g XML & SQL—Design, Build 119–121 & Manage XML Applications in Java, C, C++ & PL/SQL XSQL Page publishing framework, 116–125 Introduction Part I - Oracle the XML XSQL pages,and 116–117, 125Standards

Chapter 1

- Introducing XML

XSQL Servlets - Accessing XML with DOM, SAX, JAXB, and StAX inserting XML documents with, 122 Chapter 3 - Transforming XML with XSLT and XPath installing,118 Chapter 4 - Validating with DTDs and XML Schemas submitting queries XML to, 118–119 Chapter 5 XML Operations with XQuery updating data with, 122–125 Chapter 2

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & List of Figures PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Chapter 3: Transforming XML with XSLT and XPath This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with XML standards, their usage and best practices. Figure 3-1:emphasis The JavaonXSLT processor architecture Table of Contents

Chapter 6: XML Messaging and RPC with SOAP

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction

Figure 6-1: SOAP message format

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 7: Putting It All Together with XML Pipeline, JSPs, and XSQL - Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

Figure- 7-1: Example output in JDeveloper that uses the DOMBuilder bean Validating XML with DTDs and XML Schemas

Chapter 4

Chapter 5 - 7-2: XML XSQL Operations XQuery Figure pagewith process Chapter 6

- XML Messaging and RPC with SOAP

Figure Formatted output with fromXML the SearchAuthor.xsql page Chapter 7 - 7-3: Putting It All Together Pipeline, JSPs, and XSQL Part II - Oracle XML Management for DBAs

- Getting Started with the Oracle with XML Database Chapter 8: Getting Started the Oracle XML Database

Chapter 8 Chapter 9

- Storing XML Data

Chapter 10 - 8-1: Generating XML Figure Oracle and Net Retrieving Services status Chapter 11 - Searching XML Data

Figure WebDAV folder created Chapter 12 - 8-2: Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Figure 8-3: Example Oracle XML DB Repository

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - 8-4: Building an XML-Powered Site Figure Oracle database XMLWeb support

Chapter 15 - Creating a Portal Site with XML and Web Services

Figure Decision for storing XML in Oracle Chapter 16 - 8-5: Developing anflowchart XML Gateway Application with SOAPXML and DB AQ Chapter 17 - Developing XML-Based Reusable Components

Figure 8-6: XML-based web application architecture

Part IV - Oracle XML for C Developers

Chapter 18 - 8-7: Getting with Oracle XML and C Figure XMLStarted messaging application Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application

Chapter 10: Generating and Retrieving XML

Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Figure 10-1: HTTP access of XDB (XML DB) repository

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application

Chapter 13: Getting Started with Oracle XML and Java

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Figure XDK librarywith dependencies Chapter 25 - 13-1: Getting Started Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Figure 13-2: Selecting your project properties’ libraries

Chapter 27 - Extending PL/SQL XML Functionality with Java

Chapter 28 - 13-3: Putting It All Together Figure JDeveloper database connection selection Appendix

- XML Standards Bodies and Open Specifications

Figure 13-4: Adding a JavaBeans XDK Components list Glossary Index

Figure 13-5: XDK Component Palette

List of Figures List of Tables

Chapter 14: Building an XML-Powered Web Site

List of Sidebars

Figure 14-1: FAQ web site Figure 14-2: FAQ answer in HTML

Chapter 15: Creating a Portal Site with XML and Web Services Figure 15-1: Finished Oracle XML Development Group portal site


Figure 5-2: Development Group portal administrative page Figure 15-3: User Database application10g formXML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Oracle PL/SQL

Figure 15-4: XDK users theirand status by Listing Mark V.ofScardina, Benand Chang Jinyu Wang

ISBN:0072229527

McGraw-Hill/Osborne © 2004 (600 pages)

Figure 15-5: Update form for users

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Chapter 16: Developing an XML Gateway Application with SOAP and AQ Table of Contents

Figure 16-1: Stream-based XML processing solution

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Figure 16-2: PO messaging gateway architecture Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 17: Developing XML-Based Reusable Components - Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 2 Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Figure 17-1: Book listing streaming pipeline

Chapter 18:Messaging Getting Started with Oracle XML and C - XML and RPC with SOAP

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Figure 18-1: New Projects window Part II - Oracle XML Management for DBAs Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Figure 18-2: Project Settings: C/C++ window

Chapter 10 - 8-3: Generating Retrieving Figure Project and Settings: Link XML window Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database

Chapter 19: Building an XML-Managed Application

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java

Figure 19-1: DVD listing on WML phone

Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services

Chapter 22: Getting Started with Oracle XML and C++

Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Figure 22-1: New window Part IV - Oracle XML forprojects C Developers Chapter 18 - Getting Started with Oracle XML and C

Figure 22-2: Project Settings: C/C++ window

Chapter 19 - Building an XML-Managed Application

Chapter 20 - 22-3: Build Project an XML Settings: Database Link OCI Application Figure window Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 24: Building an XML Data-Retrieval Application

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 - Build an XML Database OCI C++ Application

Figure 24-1: cppextract content-management use case

Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 26: Building PL/SQL Web Services

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services

Figure 26-1: Step 1 of the Create PL/SQL Web Service wizard

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - 26-2: Putting It All the Together Figure Select PL/SQL procedures. Appendix

- XML Standards Bodies and Open Specifications

Figure 26-3: Generated web service for the PL/SQL package Glossary Index

Figure 26-4: Published web service user interface

List of Figures

List ofFigure Tables26-5: Step 1 of the Generate Web Service Stub/Skeleton wizard List of Sidebars

Chapter 27: Extending PL/SQL XML Functionality with Java Figure 27-1: SQL call specification for a Java stored procedure

Chapter 28: Putting It All Together Figure 28-1: Oracle 10g XML platform


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices. Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & List of Tables PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

ISBN:0072229527

Chapter 2: Accessing XML with DOM, SAX, JAXB, and StAX This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with on XML their Java usageand andPL/SQL best practices. Table 2-1: emphasis DOM Types with standards, Corresponding Oracle Types

2-2: DOM Types with Corresponding C and C++ Oracle Types Table Table of Contents Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Table 2-3: Oracle DOM APIs in C

Introduction

Part ITable - Oracle the XMLImplemented Standards 2-4:and Interfaces by Applications

Chapter 1

- Introducing XML

Table OracleXML SAXwith Helper Classes Chapter 2 -2-5: Accessing DOM, SAX, JAXB, and StAX Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Table 2-6: SAX Callback Functions

Chapter 3: Transforming XML with XSLT and XPath - XML Messaging and RPC with SOAP

Chapter 6 Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Table 3-1: Example Xpath Expressions

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 4: Validating XML with DTDs and XML Schemas Chapter 9 - Storing XML Data Chapter 10 - Generating and Retrieving XML

Table XML Schema Built-in Datatypes Chapter 11 -4-1: Searching XML Data Chapter 12 - Managing the Oracle XML Database

Chapter 7: Putting It All Together with XML Pipeline, JSPs, and XSQL

Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 -7-1: Building an XML-Powered Web Site Table Attribute Options for the <xsl:query> Element Chapter 15 - Creating a Portal Site with XML and Web Services

Table Attributean Options for the <?xml-stylesheet?> Element Chapter 16 -7-2: Developing XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components

Table 7-3: Action Elements and Their Functions for XSQL Pages

Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C

Chapter 8: Getting Started with the Oracle XML Database

Chapter 19 - Building an XML-Managed Application

Chapter 20 - Build an XML Database OCI Application

Table XMLanFeatures in Oracle Database Chapter 21 -8-1: Create XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Table 8-2: Basic Functions for SQL XML Processing

Chapter 22 - Getting Started with Oracle XML and C++

Chapter 23 -Table8-3: Build an XML OCI C++ Table XMLDatabase DB Standards andApplication Functionality Chapter 24 - Building an XML Data-Retrieval Application

Table 8-4: XML Comparison of XML Storage Part VI - Oracle for PL/SQL Developers Chapter 25 - Getting Started with Oracle XML and PL/SQL

Chapter 9: Storing XML Data

Chapter 26 - Building PL/SQL Web Services

Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 -9-1: Putting All Together and Data-Loading Utilities Table XMLItData-Storage Appendix

- XML Standards Bodies and Open Specifications

Glossary

Chapter 10: Generating and Retrieving XML

Index

List of Figures

Table 10-1: ISO/IEC SQL/XML Functions

List of Tables

List ofTable Sidebars 10-2: Oracle-Provided SQL/XML Functions

Table 10-3: XMLType Member Functions

Chapter 12: Managing the Oracle XML Database Table 12-1: Oracle XML DB Dictionary Tables Table 12-2: PL/SQL Package Specifications and Functionality


Table 12-3: Access Control Entry Definitions Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & Chapter 13: Getting Started with Oracle XML and Java PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang

ISBN:0072229527

Table 13-1:McGraw-Hill/Osborne Windows XDK Environment for env.bat © 2004 (600Variables pages) comprehensive guide focuses on for utilizing XML technologies within Oracle's XML-enabled products, with Table 13-2:This UNIX XDK Environment Variables env.csh emphasis on XML standards, their usage and best practices.

Chapter 14: Building an XML-Powered Web Site

Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL

Table 14-1: XML Datatypes Needed to Describe FAQ

Introduction

Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Oracle Database 10g XML & SQL: Design, Build & Manage XML Applications in Java, C, C++ & List of Sidebars PL/SQL by Mark V. Scardina, Ben Chang and Jinyu Wang McGraw-Hill/Osborne © 2004 (600 pages)

Chapter 8: Getting Started with the Oracle XML Database

ISBN:0072229527

This comprehensive guide focuses on utilizing XML technologies within Oracle's XML-enabled products, with emphasis on XML standards, their usage and best practices.

Initializing the Oracle JVM Table of Contents

Oracle Database 10g XML & SQL—Design, Build & Manage XML Applications in Java, C, C++ & PL/SQL Introduction Part I - Oracle and the XML Standards

Chapter 1

- Introducing XML

Chapter 2

- Accessing XML with DOM, SAX, JAXB, and StAX

Chapter 3

- Transforming XML with XSLT and XPath

Chapter 4

- Validating XML with DTDs and XML Schemas

Chapter 5

- XML Operations with XQuery

Chapter 6

- XML Messaging and RPC with SOAP

Chapter 7

- Putting It All Together with XML Pipeline, JSPs, and XSQL

Part II - Oracle XML Management for DBAs

Chapter 8

- Getting Started with the Oracle XML Database

Chapter 9

- Storing XML Data

Chapter 10 - Generating and Retrieving XML Chapter 11 - Searching XML Data Chapter 12 - Managing the Oracle XML Database Part III - Oracle XML for Java Developers

Chapter 13 - Getting Started with Oracle XML and Java Chapter 14 - Building an XML-Powered Web Site Chapter 15 - Creating a Portal Site with XML and Web Services Chapter 16 - Developing an XML Gateway Application with SOAP and AQ Chapter 17 - Developing XML-Based Reusable Components Part IV - Oracle XML for C Developers

Chapter 18 - Getting Started with Oracle XML and C Chapter 19 - Building an XML-Managed Application Chapter 20 - Build an XML Database OCI Application Chapter 21 - Create an XML-Configured High-Performance Transformation Engine Part V - Oracle XML for C++ Developers

Chapter 22 - Getting Started with Oracle XML and C++ Chapter 23 - Build an XML Database OCI C++ Application Chapter 24 - Building an XML Data-Retrieval Application Part VI - Oracle XML for PL/SQL Developers

Chapter 25 - Getting Started with Oracle XML and PL/SQL Chapter 26 - Building PL/SQL Web Services Chapter 27 - Extending PL/SQL XML Functionality with Java Chapter 28 - Putting It All Together Appendix

- XML Standards Bodies and Open Specifications

Glossary Index List of Figures List of Tables List of Sidebars


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.