Book Image

Processing XML documents with Oracle JDeveloper 11g

Book Image

Processing XML documents with Oracle JDeveloper 11g

Overview of this book

XML is an open standard for creating markup languages and exchanging structured documents and data over the Internet. JDeveloper 11g presents an effective, quick, and easy-to-use means of processing XML documents. Inspired by the author's previous XML articles for the Oracle community, this expanded hands-on tutorial guides newcomers and intermediate users through JDeveloper 11g and XML document development. It offers up-to-date information on working with the latest version of JDeveloper, and brand new information on JAXB 2.0 support in JDeveloper 11g. Filled with illustrations, explanatory tables, and comprehensive instructions, this book walks the reader through the wide assortment of JDeveloper's capabilities. Oracle's JDeveloper 11g is an Integrated Development Environment that provides a visual and declarative approach to application development. Over the course of 14 chapters, readers will get hands-on with JDeveloper as the comprehensive and self-contained tutorials provide clear instruction on the key XML tasks that JDeveloper can accomplish. Filled with practical information and illustrated examples, this book shows the reader how to create, parse, and store XML documents quickly, as well as providing step-by-step instructions on how to construct an XML schema and use the schema to validate an XML document. Oracle's XML Developer Kit (XDK) offers a set of components, tools, and utilities for developing XML-based applications, and developers will find the detailed XDK coverage invaluable. Later chapters are given over to using XPath, transforming XML with XSLT, and using the JSTL XML Tag Library. Moving through the book, a chapter on the JAXB 2.0 API shows you how to bind, marshal and unmarshal XML documents, before we finally delve into comparing XML documents, and converting them into PDF and Excel formats. In all, this book will enable the reader to gain a good and wide-ranging understanding of what JDeveloper has to offer for XML processing.
Table of Contents (19 chapters)
Processing XML documents with Oracle JDeveloper 11g
About the Author
About the Reviewers


While a number of books on XML are available, none covers XML support in Oracle JDeveloper. Welcome to Processing XML documents with Oracle JDeveloper 11g, a book that will teach you about using Oracle XML technologies in Oracle JDeveloper. XML is the standard medium of data exchange. Examples of data exchange using XML are web feeds, which include RSS feeds and Atom feeds, and XML messages in web services. Java is the language most commonly used to process XML. Among the IDEs, Oracle JDeveloper has the most XML features. Some of the graphical XML features in JDeveloper are an XML editor to create an XML document, an XML schema editor to model an XML schema, and an XPath explorer to process XPath expressions. JDeveloper also provides built-in support for JAXB compilation. JDeveloper includes an integrated application server—the WebLogic Server—for running XML-based applications. Oracle XML Developer Kit (XDK) provides a set of components, tools, and utilities for developing XML-based applications. The XDK 11g libraries are included with Oracle JDeveloper 11g.

The objective of this book is to discuss XML development in Oracle JDeveloper. We shall use JDeveloper 11g, the latest version of JDeveloper. As developers commonly use an IDE for processing XML and developing XML applications, the book covers all aspects of XML development, which include:

  • Creating an XML document

  • Validating an XML document with an XML schema

  • Transforming an XML document

  • Addressing elements/attributes in an XML document using XPath

We shall use the Oracle XDK 11g for Java to develop XML applications. We shall also discuss Oracle XML Publisher and Oracle Berkeley DB XML. By the end of this book, you should know everything there is to know about XML and JDeveloper.

What this book covers

Chapter 1: We discuss creating an XML document using Oracle's XML Developer Kit (XDK) 11g in Oracle JDeveloper. We also discuss parsing an XML document using SAX and DOM Java APIs, which are also included in XDK 11g.

Chapter 2: We create an XML schema in the XML schema editor of Oracle JDeveloper. An XML schema represents the structure of an XML document. Subsequently, we instantiate an XML document from the XML schema.

Chapter 3: We discuss validating an XML document with an XML schema using the built-in feature to validate the schema and the XDK 11g schema validation APIs. We discuss three different APIs for schema validation: the XSDValidator, the SAX parser, and the DOM parser.

Chapter 4: We discuss XPath, which is used to address nodes in an XML document. We use XPath in the XPath Search GUI tool in Oracle JDeveloper 11g. We also use the XPath Java API in XDK 11g.

Chapter 5: We transform an XML document using the Transformation API for XML (TrAX), which is included in XDK 11g. We also discuss the XSLT extension functions.

Chapter 6: We parse and transform XML using the JSTL XML tag library in JDeveloper 11g.

Chapter 7: We load, save, and filter an XML document using the DOM 3.0 Load and Save APIs, which are provided in XDK 11g.

Chapter 8: We construct and validate an XML document using the DOM 3.0 Validation API, which is also included in XDK 11g.

Chapter 9: We discuss another built-in feature of JDeveloper 11g, the JAXB 2.0 compiler. We bind an XML schema to Java classes using the JAXB 2.0 compiler. Subsequently, we unmarshal an XML document and marshal an XML document using the compiled Java classes.

Chapter 10: We compare XML documents using the XMLDiff Java API included in XDK 11g.

Chapter 11: We convert an XML document to a PDF document using the Apache FOP Java API in JDeveloper.

Chapter 12: We create an MS Excel spreadsheet from an XML document in JDeveloper using the Apache POI Java API.

Chapter 13: We store an XML document in Oracle Berkeley DB XML, and subsequently query and update the XML document using both the Berkeley DB XML command shell and the Berkeley DB XML Java API. The Berkeley DB XML API is used in JDeveloper 11g.

Chapter 14: We create PDF reports in JDeveloper 11g using the Oracle XML Publisher Java API. We also merge PDF documents. We also create an XML report from a database table using the Data Engine API.

What you need for this book

The book is based on the Windows Install of Studio Edition of Oracle JDeveloper 11g. Therefore, you need to download and install JDeveloper 11g (jdevstudio11110install.exe) from The Windows Install requires Windows XP, 2003, or 2000. If you have Linux, the book may still be used (though it has not been tested with Linux) with slight modifications with the Linux Install. For example, the directory paths on Linux would be different than those of Windows used in the book. Other than Oracle JDeveloper 11g, you would need chapter-specific software. For example, for Chapter 11 you would need the Apache FOP binary distribution, for Chapter 12 you need to download the Apache POI HSSF API, for Chapter 13 you need to download Oracle Berkeley DB XML, and for Chapter 14 you need to download Oracle Database 10g or 11g and Oracle XML Publisher Enterprise 5.6.2.

Who is this book for?

The target audience of the book is XML application developers who want to learn about Oracle XML technologies and the XML features in Oracle JDeveloper 11g. Those who are already using Oracle XML technologies will learn about using the Oracle XML technologies in Oracle JDeveloper 11g. We won't be discussing the database-based XML technologies XSQL and XML SQL Utility, which were discussed in the book JDBC 4.0 and Oracle JDeveloper for J2EE Development (Packt Publishing). This book is suitable for professional XML developers. It is also suitable for an intermediate-level course in applied XML. The target audience is expected to have prior, albeit beginners', knowledge about XML such as: what an XML document is, what XSLT is, what XPath is, and what an XML schema is.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The XSDValidator class is used to validate an XML document that has been built into a DOM tree."

A block of code will be set as follows:

InputStream inputStream=new FileInputStream(new File("catalog.xsd"));
InputSource inputSource=new InputSource(inputStream);
XMLSchema schema =;

Any command-line input and output is written as follows:

dbxml>createContainer catalog.dbxml

New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "In the New Gallery window select Categories | General and Items | Generic Application."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an email to , making sure to mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code for the book

Visit to directly download the example code.

The downloadable files contain instructions on how to use them.


Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide the location address or web site name immediately so we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with some aspect of the book, and we will do our best to address it.

Copyright credit

Some of the contents of this book were originally published by Oracle Technology Network. They are republished with the permission of Oracle.