Oracle9i XML Developer's Kits Guide - XDK Release 2 (9.2) Part Number A96621-01 |
|
This chapter contains the following sections:
Oracle9i provides several components, utilities, and interfaces you can use to take advantage of XML technology in building your Web-based database applications. Which components you use depends on your application requirements, programming preferences, development, and deployment environments.
Starting with XDK 9.0.2 (shipped with iAS v2) and XDK 9.2 (shipped with Oracle9i Release 2), XSLStylesheet is thread-safe and can be used across threads in multiple XSLProcessor.processXSL
calls. But XSLProcessor, a light-weight object, will not be made thread safe.
The following XML components are provided with Oracle9i and Oracle9i Application Server:
The following figures schematically illustrate how the XDK components can be used to generate XML:
XDK Component | Languages | Description |
---|---|---|
XML Parser |
Java, C, C++, PL/SQL |
Creates and parses XML using Internet standard DOM and SAX interfaces. |
XSLT Processor |
Java, C, C++, PL/SQL |
Transforms or renders XML into other text-based formats such as HTML and WML |
XML Schema Processor |
Java, C, C++, PL/SQL |
Enables the use of XML simple and complex datatypes by means of your XML Schema definitions. |
XML Class Generator |
Java, C++ |
Automatically generates Java and C++ classes from DTDs and XML Schemas to send XML data from Web forms or applications. |
XML Transviewer JavaBeans |
Java |
View and transform XML documents and data through Java components. |
XML SQL Utility (XSU) |
Java, PL/SQL |
Generates XML documents, DTDs, and XML Schemas from SQL queries. |
XSQL Servlet |
Java |
Combines XML, SQL, and XSLT in the server to deliver dynamic Web content. |
TransX Utility |
Java |
Loads data encapsulated in XML into the database with additional SQL functionality useful for installations. |
Oracle SOAP Server |
Java |
See also Chapter 11, "Using XDK and SOAP" |
XML Compressor |
Java |
See also "XML Compressor". |
The following list includes Oracle's XML-enabled development tools:
Oracle Text: A querying, search and retrieval tool.
Oracle JDeveloper9i and BC4J: JDeveloper9i is an integrated development tool for building Java web-based applications. Oracle Business Components for Java (BC4J) is a Java, XML-powered framework that enables productive development, portable deployment, and flexible customizing of multitier, database-savvy applications from reusable business components. These applications can be deployed as CORBA Server Objects or EJB Session Beans on enterprise-scale server platforms supporting Java technology.
XDK for Java is composed of the following components:
XDK for JavaBeans is composed of the following component:
XDK for C is composed of the following component:
XDK for C++ is composed of the following:
XDK for PL/SQL is composed of the following:
The Oracle XML parser includes implementations in C, C++, PL/SQL, and Java for the full range of platforms on which Oracle9i runs.
Based on conformance tests, xml.com
ranked the Oracle parser in the top two validating parsers for its conformance to the XML 1.0 specification, including support for both SAX and DOM interfaces. The SAX and DOM interfaces conform to the W3C recommendations 2.0.
Version 2 (v2) of the Oracle XML parser provides integrated support for the following features:
The parsers are available on all Oracle platforms.
Figure 1-2 illustrates the Oracle XML Parser for Java. Figure 1-3 illustrates the Oracle XML parsers' overall functionality.
See Also:
Chapter 4, "XML Parser for Java" and Chapter A, "XDK for Java: Specifications and Quick References". |
The Oracle XSLT engine fully supports the W3C 1.0 XSL Transformations recommendation. It has the following features:
The Oracle XML Parsers, Version 2 include an integrated XSL Transformation (XSLT) Processor for transforming XML data using XSL stylesheets. Using the XSLT processor, you can transform XML documents from XML to XML, HTML, or virtually any other text-based format.
How to use the XSLT Processor is described in Chapter 4, "XML Parser for Java".
XML Class Generator creates a set of Java or C++ classes for creation of XML documents corresponding to an input DTD or XML Schema. Figure 1-4 shows Oracle XML Class Generator functionality.
How to use the XML Class Generators is described in the following chapters:
Oracle XML Transviewer JavaBeans are a set of XML components that constitute XML for JavaBeans. These are used for Java applications or applets to view and transform XML documents.
They are visual and non-visual Java components that are integrated into Oracle JDeveloper to enable the fast creation and deployment of XML-based database applications. In this release, the following beans are available:
As standard JavaBeans, they can be used in any graphical Java development environment, such as Oracle JDeveloper. The Oracle XML Transviewer Beans functionality is described in Chapter 10, "XDK JavaBeans".
XSQL Servlet is a tool that processes SQL queries and outputs the result set as XML. This processor is implemented as a Java servlet and takes as its input an XML file containing embedded SQL queries. It uses XML Parser for Java, XML- SQL Utility, and Oracle XSL Transformation (XSLT) Engine to perform many of its operations.
You can use XSQL Servlet to perform the following tasks:
XSQL Servlet has been tested with the following servlet engines:
JavaServer Pages can use <jsp:forward>
or <jsp:include>
to collaborate with XSQL Pages as part of an application. The following JSP platforms have been tested to support XSQL Servlet:
In general, it should work with the following:
XSQL Servlet is a tool that processes SQL queries and outputs the result set as XML. This processor is implemented as a Java servlet and takes as its input an XML file containing embedded SQL queries. It uses XML Parser for Java and XML SQL Utility to perform many of its operations.
Figure 1-5 shows how data flows from a client, to the servlet, and back to the client. The sequence of events is as follows:
<query></query>
tags) to XML SQL Utility. The page processor also passes any XSL processing statements to the XSLT Processor.<query>
tags.HTTP_USER_AGENT
information is obtained from the client through an HTTP request.Oracle XML SQL Utility (XSU) supports Java and PL/SQL.
XML SQL Utility Java classes can be used for the following tasks:
Figure 1-6 shows the Oracle XML SQL Utility overall functionality.
XML SQL Utility for Java consists of a set of Java classes that perform the following tasks:
Figure 1-7 shows how XML SQL Utility processes SQL queries and returns the results as an XML document.
The structure of the resulting XML document is based on the internal structure of the database schema that returns the query results:
The XML SQL Utility (XSU) generates either of the following:
You can also use the XML SQL Utility (XSU) to generate a DTD based on the schema of the underlying table or view being queried. You can use the generated DTD as input to the XML Class Generator for Java or C++. This generates a set of classes based on the DTD elements. You can then write code that uses these classes to generate the infrastructure behind a Web-based form. See also "XML Class Generator".
Based on this infrastructure, the Web form can capture user data and create an XML document compatible with the database schema. This data can then be written directly to the corresponding database table or object view without further processing.
See Also:
Chapter 8, "XML SQL Utility (XSU)" and Oracle9i XML Case Studies and Applications, the chapter, "B2B XML Application: Step by Step", for more information about this approach. |
Note: To write an XML document to a database table, where the XML data does not match the underlying table structure, transform the XML document before writing it to the database. For techniques on doing this, see Chapter 8, "XML SQL Utility (XSU)". |
TransX Utility is a data transfer utility that enables you to populate your database with multilingual data. It uses XML to specify the data, so that you can take advantage of easy data transfer from XML to the database, a simple data format that is intuitive for both developers and translators, and validation capability that is less error prone than previous techniques.
Oracle Text extends Oracle9i by indexing any text or documents stored in Oracle9i. Use Oracle Text to perform searches on XML documents stored in Oracle9i by indexing the XML as plain text, or as document sections for more precise searches, such as find Oracle WITHIN title
where title
is a section of the document.
See Also:
For more information on using Oracle Text and XML, see:
|
XML Gateway is a set of services that enables easy integration with the Oracle e-Business Suite to create and consume XML messages triggered by business events. It integrates with Oracle Advanced Queuing to enqueue/dequeue a message which is then transmitted to/from the business partner through any message transport agent.
Figure 1-8 through Figure 1-11 illustrate the relationship of the Oracle XML components and how they work together to generate XML documents from Oracle9i through a SQL query. The options are depicted according to language used:
Figure 1-8 shows the Oracle XML Java components and how they can be used to generate an XML document. Available XML Java components are:
In the Java environment, when a user or client or application sends a query (SQL), there are three possible ways of processing the query using the Oracle XML components:
Regardless of which way the stored XML data is generated from the database, the resulting XML document output from the XML Parser is further processed, depending on what you or your application needs it for.
The XML document is formatted and customized by applying stylesheets and processed by the XSLT.
Figure 1-9 shows the Oracle XML C language components used to generate an XML document. The XML components are:
SQL queries can be sent to the database by OCI or as embedded statements in the Pro*C/C++ precompiler.
The resulting XML data can be processed in the following ways:
This XML data is optionally transformed by the XSLT processor, viewed directly by an XML-enabled browser, or sent for further processing to an application or AQ Broker.
Figure 1-10 shows the Oracle XML components used to generate an XML document. The XDK for C++ components used here are:
In the C++ environment, when a user or client or application sends a SQL query, there are two possible ways of processing the query using the XDK for C++:
Figure 1-11 shows the XDK for PL/SQL components used to generate an XML document:
In the PL/SQL environment, when a user or client or application sends a SQL query, there are two possible ways of processing the query using the Oracle XML components:
This section includes general questions about Oracle XML-enabled technology in the following categories:
There are Frequently Asked Questions at the end of several other chapters in this manual.
I am going to develop a small application using XML and Oracle. Here is the scenario: Company A has is a central purchasing system with Departments B, C, and D. Company A gets purchase orders in XML format from B, C, and D.
Company A needs to collect all purchase orders and store them in an Oracle database. Then, it has to create another request for proposal for its preferred vendors in XML. I am writing queries to insert or update into the database. What XML components do I need to install in Oracle?
Answer: Assuming you are using Java, you need the XML Parser and XML SQL Utility. If you are using a Java-based front end to generate the purchase orders, then the XML Class Generator can provide you with the classes you need to populate your purchase orders. Finally, the XSQL Servlet can help you build a Web interface.
I have a CGI, Perl, and Oracle7 application on SolarisTM Operating Environment 2.6 and I want to convert it to an XML/XSL, Java, and Oracle application. I know most parts of the technologies, for example, SGML, XML, and Java, but I don't know how to start it in Oracle. What software do I need from Oracle? Specifically,
UTL_HTTP
?Answer:
My project requires converting master-details data to XML for clients.
Answer:
I know that the XSLT will translate from XML to XML, HTML, or another text-based format. What about the other way around?
Answer: For HTML, you can use utilities like Tidy or JTidy to turn HTML into well-formed HTML that can be transformed using XSLT. For unstructured text formats, you can try utilities like XFlat at the following Web site:
http://www.unidex.com/xflat.htm
.
Is it possible to generate a database schema in Oracle using a script with CREATE TABLE
, from an XML file generated by a Rational Rose design tool?
Answer: All the parser and generator files (such as petal files, XML, and so on) are developed in our project. All the components are designed for reuse, but developed in the context of a larger framework. You have to follow some guidelines, such as modeling in UML, and you must use the base class to get any benefit from our work.
Oracle only generates object types and delivers full object-oriented features such as inheritance in the persistence layer. If you do not need this, the Rational Rose petal file parser and Oracle packages, as the base of the various generators, may interest you.
Does Oracle have any tools for creating XML documents based on DTDs or the XML schema definition DOM, or for editing XML documents with DTD or schema validation?
Answer: JDeveloper9i has an integrated XML schema-driven code editor for working on XML schema-based documents such as XML schemas and XSLT stylesheets, with tag insight to help you easily enter the correct elements and attributes as defined by the schema.
I have been asked to take stored XML docs in release 8.1.6 and format them as PDF. We are using JDeveloper release 3.1.1.2 as our development environment and the client wants to stick to OAS 4082 on Windows NT if possible. Any suggestions or recommended resources?
Answer: Oracle XSQL Pages release 1.0.2 supports integration with Apache FOP 0.14.0 for rendering PDF output from XML or SQL input.
It is possible to format XML into PDF using Formatting Object (FOP). See information on this at the following Web sites:
I have a large (27 MB) data-centric XML document. I could not load it into the database when it was split into relational tables with the XML SQL utility, because the DOM parser failed due to a memory leak during the XSLT processor execution. Do you have a work-around for this problem? Should I use the SAX parser? How do I use the XSLT processor and the Sax parser?
Answer: If this is a one time load, or if the XML document always has the same tags, then you might consider using the SQL*Loader (direct path). All you have to do is compose a loader control file. See the Oracle9i Database Utilities manual, Chapter 3, for examples. You can use the enclosed by
option to describe the fields. For example, in the files list, enter something like the following:
(empno number(10) enclosed by "<empno>" and "</empno>",...)
Except for the data parsing, which has to be done the same regardless of what you are using, the actual loading into the database will be fastest with SQL*Loader, as the direct path writes data straight to data blocks, bypassing the layers in between.
If the document is 27 MB because it is a very large number of repeating sub-documents, then you can use the sample code that comes in Chapter 14, of the book Building Oracle XML Applications by Steve Muench (O'Reilly) to load XML of any size into any number of tables. In this chapter, called "Advanced XML Loading Techniques," the example builds an XML Loader utility that does what you are looking for.
If you have the following scenario:
... <something> <price>10.00</price> </something> ... ... ... <somethingelse> <price>55.00</price> </somethingelse>
Is there a way to uniquely identify the two <price>
elements?
Answer: Not really. The field description in the control file can be nested, which is part of the support for object relational columns. The data record to which this maps is, of course, flat but using all the data field description features of the SQL*Loader one can get a lot done. For example:
sample.xml
<resultset> <emp> <first>...</first> <last>...</last> <middle>....</middle> <emp> <friend> <first>...</first> <last>...</last> <middle>....</middle> </friend> </resultset>
sample.ctl
-- field definition part of the SQL Loader control file
field list .... ( emp COLUMN OBJECT .... ( first char(30) enclosed by "<first>" and "</first>", last char(30) enclosed by "<last>" and "</last>", middle char(30) enclosed by "<middle>" and </middle>" ) friend COLUMN OBJECT .... ( first char(30) enclosed by "<first>" and "</first>", last char(30) enclosed by "<last>" and "</last>", middle char(30) enclosed by "<middle>" and </middle>" )
Keep in mind that the COLUMN OBJECT
field names have to match the object column in the database. You will have to use a custom record terminator, otherwise it defaults to newline
(that is, the newline
separates data for a complete database record).
If your XML is more complex and you are trying to extract only select fields, you can use FILLER
fields to reposition the scanning cursor, which scans from where it has left off toward the end of the record (or for the first field, from the beginning of the record).
The SQL*Loader has a very powerful text parser. You can use it for loading XML when the document is very big.
I am currently investigating SAX. I understand that both the Oracle and IBM parsers use DOM and SAX from W3C.
Answer: You will not have to change your code if you stick to SAX interfaces or DOM interfaces for your implementation. That is what the standard interfaces are in place to assist you with.
We are currently architecting some of our future systems to run on XML-based interfaces. Our current systems are all running Oracle release 8.0.6, and we would like to have some of our XML concepts implemented on the existing systems due to high demand. Are there current or future plans to support XML-based code within the database, or are there any adapters or cartridges that we can use to get by?
Answer: All of our XML Developer's Kit components, including the XML Parser, XSLT Processor, XSQL Servlet, and utilities like the XML SQL Utility all work outside the database against Oracle 8.0.6. However, you will not be able to run XML components inside the database or use Oracle Text XML searching, which are both features in Oracle8i and higher.
My company has Oracle release 7.3.4 and my group is thinking of using XML for some data transfers between us and our vendors. From what I could see from this Web site, it looks like we would need to move to Oracle8i or higher in order to do so. Is there any way of leveraging Oracle release 7 to do XML?
Answer: As long as you have the appropriate JDBC 1.1 drivers for Oracle release 7.3.4 you should be able to use the XML SQL Utility to extract data in XML.
For JDBC drivers, refer to the following Web site for information about Oracle7 JDBC OCI and JDBC Thin Drivers:
http://otn.oracle.com/tech/java/sqlj_jdbc/
If I am using an Oracle version earlier than Oracle8i, can I supply XML based applications using Oracle XML tools? If yes, then what are the licensing terms?
Answer: The Oracle XDKs for Java, C, and C++ can work outside the database, including the XML SQL Utility and XSQL Pages framework. Licensing is the same, including free runtime. See OTN for the latest licenses.
Is Oracle XML technology suitable for creating magnetic tape files where the file is just a string of characters like 'abcdefg........
' in a particular format? Is it is possible to create a stylesheet that will create these kind of files?
Answer:
Yes. Just use <xsl:output method="text"/>
to output plain text.
Answer: The following browsers support the display of XML:
We are considering implementing EDI to communicate requirements with our vendors and customers. I understand that XML is a cheaper alternative for smaller companies. Do you have any information on the advantages of XML over EDI?
Answer: Here are some thoughts on the subject:
The next question then becomes: is XML going to replace EDI? Probably not. The technologies will likely coexist, at least for a while. Large companies with an existing investment in EDI will probably use XML as a way to extend their EDI implementation, which raises a new question of XML and EDI integration.
XML is a compelling approach for smaller organizations, and for applications where EDI is inflexible.
What B2B XML standards (such as ebXML, cxml, and BizTalk) does Oracle support? What tools does Oracle offer to create B2B exchanges?
Answer: Oracle participates in several B2B standards organizations:
For B2B exchanges, Oracle provides several alternatives depending on customer needs, such as the following:
Oracle Internet Platform provides an integrated and solid platform for B2B exchanges.
Answer: Oracle Corporation's XML strategy is to use XML in ways that exploit all of the benefits of the current Oracle technology stack. Today you can combine Oracle XML components with the Oracle8i (or higher) database and Advanced Queueing (AQ) to achieve conflict resolution, transaction verification, and so on. Oracle is working to make future releases more seamless for these functions, as well as for functions such as distributed two phase commit transactions.
XML data is stored either object-relational tables or views, or as CLOBs. XML transactions are transactions with one of these datatypes and are handled using the standard Oracle mechanisms, including rollback segments, locking, and logging.
From Oracle9i, Oracle supports sending XML payloads using AQ. This involves making XML queriable from SQL.
Oracle is active in all XML standards initiatives, including W3C XML Working Groups, Java Extensions for XML, Open Applications Group, and XML.org
for developing and registering specific XML schemas.
Answer: Oracle is participating in the W3C Working Group for XML Query. Oracle is considering plans to implement a language that enables querying XML data, such as in the XQL proposal. While XSLT provides static XML transformation features, a query language will add data query flexibility similar to what SQL does for relational data.
Oracle has representatives participating actively in the following 3C Working Groups related to XML and XSL: XML Schema, XML Query, XSL, XLink/XPointer, XML Infoset, DOM, and XML Core.
We have implemented Oracle8i and the XDK. Where can we find basic, standard DTDs to build on for orders, shipments, and acknowledgements?
Answer: A good place to start would be this Web site, which has been set up for that purpose:
http://www.xml.org
Is there any support for XML messages enclosing BLOBs, or I should do it on an application level by encoding my binary objects in a suitable text format such as UUENCODE with a MIME wrapper?
Answer: XML requires all characters to be interpreted, therefore there is no provision for including raw binary data in an XML document. That being said, you can UUENCODE the data and include it in a CDATA section. The limitation on the encoding technique is to be sure it only produces legal characters for a CDATA section.
If we store XML files as CLOBs in the Oracle database, what is the maximum file size?
Answer: The maximum file size is 2 GB. See the Oracle9i Application Developer's Guide - Large Objects (LOBs) for more information on LOBs and CLOBs. For sample code, see:
http://otn.oracle.com/tech/java/sqlj_jdbc/index2.htm?Code&files/advanced/advanced.htm
Answer: There are no XML limitations to an XML file size.
Is there a maximum size for an XML document to provide data for PL/SQL (or SQL) across tables, given that no CLOBs are used?
Also, what is the maximum size of XML document generated from Oracle to an XML document?
Answer:
The size limit for an XML document providing data for PL/SQL across tables should be what can be inserted into an object view.
The size limit for an XML document generated from Oracle to an XML document should be what can be retrieved from an object view.
To select data for display and insert data to tables by XML what software do I need? We are using Oracle8i on SolarisTM Operating Environment.
Answer: You need the following software:
The first three can be obtained from Oracle. The fourth can be obtained from Sun Microsystems. If you want to perform the tasks from a browser, you will also need the following:
Is there a whitepaper that discusses the performance of XML and Oracle?
Answer: Currently, we do not have any official performance analyses due to the lack of a performance standard or benchmark for XML products.
I have a database with millions of records. I give a query based on some 4/5 parameters, and retrieve the records corresponding to that. I have added indexes in the database for faster retrieval of the same, but since the number of records returned is quite high and I planned to put a Previous and Next link to show only 10 records at a time, I had to get the count(*)
of the number of records that match.
Since there are so many records, and count(*)
does not consider the indexes, it takes nearly 30 seconds for the retrieved list to be seen on the browser window. If I remove that count(*)
, the retrieval is quite fast, but then there is no Previous and Next as I had linked them to count(*)
.
Answer: I presume you are referring to finding a faster way to retrieve XML documents. The solution is to use the SAX interface instead of DOM.
Make sure to select the COUNT(*)
of an indexed column (the more selective the index the better). This way the optimizer can satisfy the count query with a few I/Os of the index blocks instead of a full-table scan.
My application requires communication with outside entities that may have a totally different language system. If I need to put information in other languages (for instance, Chinese) into XML, do I need to treat and process them differently? For example, do I need to know which encoding they use, or would the parser be able to recognize it? Would there be any problems when dealing with the database?
Answer: XML inherently supports multiple languages in a single document. Each entity can use a different encoding from the others; that is, you can add a Chinese entity encoded in a Chinese encoding to the rest of the document. You can also treat all portions uniformly, regardless of the language used, by encoding in Unicode. Using the former, you must have an encoding declaration in the XML text declaration.
Oracle XML parsers are designed to be able to handle most external entities and recognize a wide range of encoding, including most widely used ones from all over the world.
The database should support all the languages you are going to use on XML. Chinese character sets such as ZHS16GBK and ZHT16BIG5 are a superset of ASCII so you may be able to use one of them to serve for English and Chinese, but you may want to use Unicode to use more languages.
Here are some other XML Frequently Asked Question sites of interest:
Answer:
http://www.oreilly.com/catalog/orxmlapp/
http://metalab.unc.edu/xml/books/bible/
far a good understanding of XSLT. Downloading this chapter is free.
http://www.osborne.com/oracle/
|
Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|