spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / xml / column81

XML Features of Oracle 8i and 9i

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

XML class generator

This is a tool which converts an input DTD into a set of corresponding java source or class files, which can then be used to create valid XML documents for use with the database.

import oracle.xml.parser.*;
import oracle.xml.classgen.*;

// generate the Java files...
ClassGenerator generator = new ClassGenerator();

// set output directory
generator.setOutputDirectory(".");

// generate java src
generator.generate(dtd, doctype_name);

If a DTD was used corresponding to the employee table emp above, the resulting classes could be used to create valid XML documents containing updated or new employees e.g

public class CreateEmployees {
  EMP EMPLIST = new EMP();
  DTD dtd = EMPLIST.getDTDNode(); // get static from base document

  // New employee emp_row1
  EMP_ROW emp_row1 = new EMP_ROW(1); // create row and set ROWNO
  EMPNO empno1 = new EMPNO("7654");
  ENAME ename1 = new ENAME("MARTIN");
  JOB job1 = new JOB("SALESMAN");
  ...
}

XML in this case would be:

<?xml version="1.0"?>
<!DOCTYPE EMP SYSTEM "employee.dtd">
<EMP>
  <EMP_ROW ROWNO = "1">
    <EMPNO>7654</EMPNO>
    <ENAME>MARTIN</ENAME>
    <JOB>SALESMAN</JOB>
    <MGR>7698</MGR>
    <HIREDATE>1981-09-28 00:00:00.0</HIREDATE>
    <SAL>1250</SAL>
    <COMM>1400</COMM>
    <DEPTNO>30</DEPTNO>
  </EMP_ROW>
<EMP>

Last but nor least the transviewer...


Produced by Michael Claßen

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

URL: http://www.webreference.com/xml/column81/5.html
Created: May 10, 2003
Revised: May 10, 2003