Presentation is loading. Please wait.

Presentation is loading. Please wait.

D Copyright © 2004, Oracle. All rights reserved. Using Oracle XML Developer’s Kit.

Similar presentations


Presentation on theme: "D Copyright © 2004, Oracle. All rights reserved. Using Oracle XML Developer’s Kit."— Presentation transcript:

1 D Copyright © 2004, Oracle. All rights reserved. Using Oracle XML Developer’s Kit

2 D-2 Copyright © 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Describe XDK List the XDK components Describe class generator Explain TransX Utility

3 D-3 Copyright © 2004, Oracle. All rights reserved. Overview of XML Developer’s Kit Oracle XML Developer’s Kit (Oracle XDK): Is designed for integrating XML data into applications Can read and write data formatted as XML to and from the database Is a powerful API for developing e-commerce applications

4 D-4 Copyright © 2004, Oracle. All rights reserved. XML Trees XML data is highly structured in a tree form. Parsing an XML document makes it possible to operate on the tree structure of the data to: Traverse this tree programmatically Access the components of the document in random order Rearrange or remove the components of the document Directly access data

5 D-5 Copyright © 2004, Oracle. All rights reserved. XML Trees: Example 100 King AD_PRES 24000 101 Kochhar AD_VP 17000 id last_name job salary employees employee id employee :

6 D-6 Copyright © 2004, Oracle. All rights reserved. XML Developer’s Kit Components Oracle XDK consists of: XML Parsers XSLT Processor XML Schema Processor XML Class Generator XML Transviewer JavaBeans XML SQL Utility XSQL Servlet SOAP The TransX Utility XML Compressor

7 D-7 Copyright © 2004, Oracle. All rights reserved. Notes Only

8 D-8 Copyright © 2004, Oracle. All rights reserved. XML Parsers XML Parsers are the components that provide programmatic access to XML documents. Parsed XML DOM/SAX parser XSL stylesheet Transformed document Parsed XSL commands XSLT Processor Original XML document XML Parser for Java

9 D-9 Copyright © 2004, Oracle. All rights reserved. XSL Transformation (XSLT) Processors Transform one XML document to another through stylesheets. XSL XSL stylesheet object java.io.Reader java.io.inputStream XMLDocument java.net.URL Write to an output stream. Create an XML document object. Report as SAX events. XML XSL processor XSL processor object methods: removeParam() resetParam() setParam() setBaseURL() setEntityResolver() setLocale()

10 D-10 Copyright © 2004, Oracle. All rights reserved. Notes only

11 D-11 Copyright © 2004, Oracle. All rights reserved. Oracle XML Schema Processors Oracle XML Schema Processor: Validates the use of data types within XML documents Provides supports for: –The full W3C XML Schema specifications –Simple data types and structures within XML documents –XML Schema definition files (.xsd ) –Streaming (SAX) processing, with constant memory usage, and linear processing time Is built on Oracle XML Parser for Java v2

12 D-12 Copyright © 2004, Oracle. All rights reserved. Using XML Schema Processors XML Schema document SAX SAX + PSV + Default value Error messages Instance document Schema DOM tree DOM parser Schema DOM parser SAX parser Schema validator DOM builder or application

13 D-13 Copyright © 2004, Oracle. All rights reserved. XML Class Generators Oracle XML Class Generator: Creates XML class files that are used to construct XML documents with data type support For Java, creates Java source files from an XML DTD or XML Schema definition Supports XML Schema definition files (.xsd ) and DTDs Are based on the DOM APIs in Oracle XML Parser V2

14 D-14 Copyright © 2004, Oracle. All rights reserved. Using XML Class Generators DTD or XML Schema Parsed DTD or XML Schema Java classes based on DTD or XML Schema (one class per element) Valid XML document based on DTD or XML Schema Java application XML Class Generator for Java XML Parser for Java

15 D-15 Copyright © 2004, Oracle. All rights reserved. Oracle XDK for JavaBeans A set of XML visual and nonvisual JavaBeans for building XML-enabled applications Transviewer Beans: –DOMBuilder Bean –XSLTransformer Bean –Treeviewer Bean –XMLSourceView Bean –XMLTransformPanel Bean –DBViewer Bean –DBAccess Bean –XMLDiff Bean

16 D-16 Copyright © 2004, Oracle. All rights reserved. Notes Only

17 D-17 Copyright © 2004, Oracle. All rights reserved. XML SQL Utility XML SQL Utility (XSU): Generates XML results from SQL queries Generates XML Schema definition files (.xsd ) Transforms data retrieved from object-relational database tables or views into XML Inserts data from an XML document in canonical form into related columns of a table or view Can update and delete rows based on the XML data in canonical form by using the API

18 D-18 Copyright © 2004, Oracle. All rights reserved. Applications of XSU Generate XML documents from any SQL query. Dynamically generate DTDs. Dynamically generate XML Schemas. Generate XML documents in their string or DOM representations. Insert XML into database tables or views. Update or delete records. Easily generate complex nested XML documents. Create object views over flat tables and query over these views.

19 D-19 Copyright © 2004, Oracle. All rights reserved. XSU Command-Line Utility XSU provides a command-line front end, for access to XML generation and insertion operations. XSU command-line utility: Is invoked by using the syntax: Requires the CLASSPATH, which includes: –Oracle XML Parser Java library ( xmlparserv2.jar ) –JDBC library ( classes12.jar if using xsu12.jar or classes111.jar if using xsu111.jar ) –A JAR file for XMLType ( xdb.jar ) java OracleXML command options

20 D-20 Copyright © 2004, Oracle. All rights reserved. Using the OracleXML Utility The OracleXML command can be used for: Generating XML from a query with getXML : –Add the –withSchema option to generate an XML Schema for the query. –Suppress XML data with a condition that returns no rows. Inserting an XML document by using putXML with the –fileName option to identify the XML document: java OracleXML getXML -user "HR/HR" "SELECT * FROM EMPLOYEES WHERE department_id=10" java OracleXML putXML -user "HR/HR" -fileName "code_apd_21_newdept.xml" departments

21 D-21 Copyright © 2004, Oracle. All rights reserved. Notes Only

22 D-22 Copyright © 2004, Oracle. All rights reserved. Updating and Deleting by Using XSU API Rows can be updated and deleted by using the XSU programmatic interface API, and not by using the command-line utility. For updating, supply element and values for: –The key columns in the target table –The columns to be updated For deleting, supply element value for the key columns Note: A single XML element can affect zero or more rows in an UPDATE or DELETE operation if the key columns are not supplied.

23 D-23 Copyright © 2004, Oracle. All rights reserved. Generating an XML Schema with XSU To generate an XML Schema based on a database table, use the getXML command: With the –withschema option: With the XML Schema only, use the –withSchema option and a query condition that returns no rows: java OracleXML getxml -user "HR/HR" –withschema "SELECT * from REGIONS" java OracleXML getxml -user "HR/HR" –withschema "SELECT * from REGIONS WHERE 1=2"

24 D-24 Copyright © 2004, Oracle. All rights reserved. Notes Only

25 D-25 Copyright © 2004, Oracle. All rights reserved. TransX Utiliity Simplifies the loading of translated seed data and messages into a database Reduces internationalization costs by: –Preparing strings to be translated –Translating the strings –Loading the strings to the database Minimizes translation data format errors Accurately loads translation contents into the database

26 D-26 Copyright © 2004, Oracle. All rights reserved. Using TransX Utility The TransX command-line utility syntax is: java oracle.xml.transx.loader [options] connect_string username password datasource [datasource]

27 D-27 Copyright © 2004, Oracle. All rights reserved. Notes Only

28 D-28 Copyright © 2004, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Describe XDK List the XDK components Describe class generator Describe TransX Utility


Download ppt "D Copyright © 2004, Oracle. All rights reserved. Using Oracle XML Developer’s Kit."

Similar presentations


Ads by Google