Java Class Generator
Hi
I found an example code for generating Java class based on the xml file.
i just want to know which package the following classes belongs to.Here the the classes
1. DTD
2.ClassGenarator
Thanks in advance
Balaji
Hi !
I am facing a similar problem
I am using classgen version 1.0.1.0.0
and xmlparser version 2.0.0.1.0....
everythings in the CLASSPATH...
I could compile the SampleMain.java in the classgen/samples directory .
But when i run it with any dtd or the provided widl.dtd i get the following error
XML Class Generator: Error Attribute Value should start with quote
Attribute Value should start with quote
at oracle.xml.parser.v2.XMLError.flushErrors(XMLError.java:191)
at oracle.xml.parser.v2.XMLError.error(XMLError.java:97)
at oracle.xml.parser.v2.XMLError.error(XMLError.java:135)
at oracle.xml.parser.v2.NonValidatingParser.parseAttrValue(Compiled Code
at oracle.xml.parser.v2.ValidatingParser.parseAttr(ValidatingParser.java
:418)
at oracle.xml.parser.v2.NonValidatingParser.parseAttributes(Compiled Cod
e)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(Compiled Code)
at oracle.xml.parser.v2.ValidatingParser.parseRootElement(ValidatingPars
er.java:89)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingP
arser.java:181)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:142)
at SampleMain.main(SampleMain.java:45)
please help !
thanks
amit
null
Similar Messages
-
Java stored proc from proxy Java classes generated from a web service?
Hi gurus,
I have searched "Java Stored Procedure" on this forum but could not find what I am looking for, so I have to post again.
I need to use a web service and my client app is written in PowerBuilder 11 (Sybase), which claims that it will create a datawindow from a web service. Well, it turned out that PB can only handle simple stuff (it works with a very simple wsdl from the internet) but can't handle more complex ones that we need to use. So I am thinking about using Oracle JDeveloper(JDev) to create the web service proxy for the web service and then load it into Oracle as a Java stored procedure so that PowerBuilder can call the procedure. JDev succsfully generated the proxy and a few Java classes. My question is, do I need to load all the classes into the database? If yes, will the reference to the package work? For example, in a JDev generated class (the soap client class), it has package MyJdev.proxy; at the top. Or, will it work if I load all the classes included in package /MyJdev/proxy into the database?
Thank you very much for any help.
BenFor the java stored proc called from pl/sql, the example above that uses dynamic sql should word :
CREATE OR REPLACE PACKAGE MyPackage AS
TYPE Ref_Cursor_t IS REF CURSOR;
FUNCTION get_good_ids RETURN VARCHAR2 ;
FUNCTION get_plsql_table_A RETURN Ref_Cursor_t;
END MyPackage;
CREATE OR REPLACE PACKAGE BODY MyPackage AS
FUNCTION get_good_ids RETURN VARCHAR2
AS LANGUAGE JAVA
NAME 'MyServer.getGoodIds() return java.lang.String';
FUNCTION get_plsql_table_A RETURN Ref_Cursor_t
IS table_cursor Ref_Cursor_t;
good_ids VARCHAR2(100);
BEGIN
good_ids := get_good_ids();
OPEN table_cursor FOR 'SELECT id, name FROM TableA WHERE id IN ( ' | | good_ids | | ')';
RETURN table_cursor;
END;
END MyPackage;
public class MyServer{
public static String getGoodIds() throws SQLException {
return "1, 3, 6 ";
null -
Recursivity in Oracle Java Class Generator from XML
I am about to start using Oracle XDK for marshalling/unmarshaling XML documents but
I need to know if the generator will be able to create correctly the java classes
from a DTD that is recursive :
<!-- #[START] -->
<!ELEMENT node ( date, symbol, node* ) >
<!ATTLIST node
name ID #REQUIRED
ref IDREF #IMPLIED >
<!ELEMENT date (#PCDATA) >
<!ELEMENT symbol (#PCDATA) >
<!-- #[END] -->
and also, if given a recursive XML (e.g. one compliant with the DTD presented above)
it will be able to parse correctly the XML into the java classes.
cheers
francescwell, after having had to try out myself this specific functionality of the
product, I'm happy to say that YES it works and unlike JAXB
(maybe I didn't try hard enough with SUN JAXB) it allows recursivity of complex types.
However, I'm not so happy with the lack of replies in this unattended (or so it seems!) forum
cheers -
Can I load Java classes generated by the Web Service Proxy Wizard?
Hi gurus,
I am very new to Oracle JDeveloper and I have mainly used it to create and debug PL/SQL procedures. My client app is written in PowerBuilder 11 (Sybase), which claims that it will create a datawindow from a web service. Well, it turned out that PB can only handle simple stuff (it works with a very simple wsdl from the internet) but can't handle more complex ones that we need to use. So I am thinking about using JDev to create the web service proxy for the web service and then load it into Oracle as a Java stored procedure so that PowerBuilder can call the procedure. JDev succsfully generated the proxy and a few Java classes. My question is, do I need to load all the classes into the database? If yes, will the reference to the package work? For example, in a JDev generated class (the soap client class), it has package MyJdev.proxy; at the top. Or, will it work if I load all the classes included in package /MyJdev/proxy into the database?
Thank you very much for any help.
BenThanks again, Bruce.
What I meant by SOAPElement is that one genereated Java class has this and this class also has the setter for this like this,
public void setSelection(javax.xml.soap.SOAPElement selection) {
this.selection = selection;
And here is the whole class,
public class CaseSearchByPartyRequest implements java.io.Serializable {
protected java.lang.String schemaVersion;
protected java.util.Calendar messageProducedDateTime;
protected javax.xml.soap.SOAPElement selection;
protected Restriction restriction;
public CaseSearchByPartyRequest() {
public java.lang.String getSchemaVersion() {
return schemaVersion;
public void setSchemaVersion(java.lang.String schemaVersion) {
this.schemaVersion = schemaVersion;
public java.util.Calendar getMessageProducedDateTime() {
return messageProducedDateTime;
public void setMessageProducedDateTime(java.util.Calendar messageProducedDateTime) {
this.messageProducedDateTime = messageProducedDateTime;
public javax.xml.soap.SOAPElement getSelection() {
return selection;
public void setSelection(javax.xml.soap.SOAPElement selection) {
this.selection = selection;
public Restriction getRestriction() {
return restriction;
public void setRestriction(Restriction restriction) {
this.restriction = restriction;
this.selection is the request that I think I need. And here is the static main method of the soap client class genereated.
public static void main(String[] args) {
try {
MyJdev.proxy.SoapClient myPort = new MyJdev.proxy.SoapClient();
System.out.println("calling " + myPort.getEndpoint());
// Add your own code here
} catch (Exception ex) {
ex.printStackTrace();
So, if I need to send the request to the web service, do I need to create the request, correct? I have done it through AQ and Messaging Gateway and works fine by manually creating the request xml in PL/SQL, but now I need to get it to work sychronously from the UI. I believe that I need the request (SOAPElement) because that is the only way that I can supply the parameters. I have not see any setters for the parameters other than some setters for user name and password.
Did I get something wrong here? If I don't supply the "selection", will JDev do it?
Thanks.
Ben -
How to compile the Java classes generated in JAXB
I am using Windows 2000 Operating System. I found a xjc
batch file on the sun's java forum.
I used that to generate classes from XML. After generating
the classes I could not compile
the classes each depends on other AND THEY REQUIRE BOTH
CLASS FILES.
I will attach the schema file and dtd . Can you explaine me the problem.
#<transactions.dtd>
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT transactions (cardtocard*)>
<!ELEMENT cardtocard (tocard, fromcard, fromcardver, amount, transdate, transid)
>
<!ELEMENT tocard (#PCDATA)>
<!ELEMENT fromcard (#PCDATA)>
<!ELEMENT fromcardver (#PCDATA)>
<!ELEMENT amount (#PCDATA)>
<!ELEMENT transdate (#PCDATA)>
<!ELEMENT transid (#PCDATA)>
transactions.xjs
<xml-java-binding-schema>
<element name="transactions" type="class" root="true"/>
<element name="cardtocard" type="class"/>
</xml-java-binding-schema>
XML file
?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XML Spy v4.4 U (http://www.xmlspy.com)-->
<transactions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\My Documents\Xml\SVTConcord.xsd">
<cardtocard>
<tocard>1111222233334444</tocard>
<fromcard>6666777788889999</fromcard>
<fromcardver>567</fromcardver>
<amount>100.00</amount>
<transdate>2002-06-04 00:00:00.000</transdate>
<transid>1111222202</transid>
</cardtocard>
</transactions>
the XJC compiler for windows is
@echo off
echo JAXB Schema Compiler
echo --------------------
if "%JAVA_HOME%" == "" goto errorJVM
if "%JAXB_HOME%" == "" goto errorJAXB
set JAXB_LIB=%JAXB_HOME%\lib
set JAXB_CLASSES=%JAXB_HOME%\classes
echo %JAVA_HOME%\bin\java.exe -jar %JAXB_LIB%\jaxb-xjc-1.0-ea.jar %1 %2 %3 %4 %5
%JAVA_HOME%\bin\java.exe -jar %JAXB_LIB%\jaxb-xjc-1.0-ea.jar %1 %2 %3 %4 %5
goto end
:errorJVM
echo ERROR: JAVA_HOME not found in your environment.
echo Please, set the JAVA_HOME variable in your environment to match the
echo location of the Java Virtual Machine you want to use.
echo For example:
echo set JAVA_HOME=c:\jdk1.4.0_01
goto end
:errorJAXB
echo ERROR: JAXB_HOME not found in your environment.
echo Please, set the JAXB_HOME variable in your environment to match the
echo location of the JAXB installation directory.
echo For example:
echo set JAXB_HOME=c:\jdk1.4.0_01\jaxb-1.0-ea
:endWhen you compile the generated classes, be sure to put jaxb-rt-1.0-ea.jar in your classpath!
-
Generic Populating the XML document using Java Class Generator and Reflection
I am looking for a generic source code in order to convert the data parsed from any tabular text form ( tab delimited for example that maps certain XML Schema created form Database Schema for Oracle.
I know it is possible to generate XML DTD or XSD from Oracle database table schema by XSU utility from XDK. And also it is possible to create Java source files from an XML DTD or XSD by using XML Clas Generator.
I believe there must be some generic code that parses tabular text data and converts them to XML format using above mentioned generated Java source files and may be Java reflection mechanism.
If anyone has any tool or knows any free ware that helps me, I would like to know about it, and I would really appreciate it.1. Read the XML file into a DMO object, walk the DOM to find the list, insert your new entry as a child, write the DOM back to a file.
2. If the XML is not in a file, but in a string, then you can do the same with string input and output. -
Generate Java class from Oracle Type defined in Package w/ JPublisher
I was wondering if its possible to generate a Java class for an Oracle Type defined in a Package? I know passing the package name to JPublisher (SQL <package_name>) causes all Oracle Types in the Package to have a Java class generated for them but I'd like to be able to do this for an individual Type defined in a Package (something like SQL <package_name>.<type_name>).
Thanks for any information you can give me.Hi Marinel,
The support for XSD import is limited on 10.1.2. If you can, you should consider moving to the 10.1.3 preview as the support for document style web services has improved. The other option will be to inline the schema in your WSDL.
Eric. -
Apt ant task suceeded but did not generate wrapper java/classes
Hi,
This is the first time I use apt task. Could someone help me out here.
Thanks.
Ant build suceeded but did not generate wrapper java/classes. Warning message I got is
[apt] warning: Bad annotation processor factory: java.lang.ClassCastException: com.sun.istack.ws.AnnotationProcessorFactoryImpl cannot be cast to com.sun.mirror.apt.AnnotationProcessorFactory
[apt] warning: Bad annotation processor factory: java.lang.ClassCastException: com.sun.istack.internal.ws.AnnotationProcessorFactoryImpl cannot be cast to com.sun.mirror.apt.AnnotationProcessorFactory
[apt] warning: Annotation types without processors: [javax.jws.WebService]
[apt] [total 725ms]
[apt] 3 warnings
I turned on verbose="true" and cut the command line apt -d .. -s ..
from the ant build output.
I executed that command line. Command suceeded, java/classes generated correctly. No warning
<target name="run_apt" depends = "build_config_classes">
<apt
debug="true"
verbose="true"
destdir="${build_classes}"
sourcedestdir="${apt.generated.dir}"
sourcepath="${config.src}">
<classpath refid="apt.classpath"/>
<source dir="${config.src}">
<include name="${config.pkg}/Configuration.java"/>
</source>
</apt>
</target>try adding fork=true to apt task
-
Hi!, I'm using Fop to PDF generation from XML file and XSL:FO file, the last one is xsl with namespaces fo.
My problem is that, I get, from java class, generatting a PDF file from fo file, but, I want to get a PDF file from XML file and XSL:FO file. So, what is the best class of API FOP that I can use in which, pass it like a parameters the XML and XSL:FO files, this class generates directly the pdf file?
Anybody can help me writting an example?.
Thaks a lot.
I'm sorry for my english, I know that is quite poor.Hello,
I am also new using FO within Java. I looked on the infos and links on xml.apache.org (the links you gave), but my problems comes by addapting the servlet example to a local application (it means, local PDF generation and no via server, by given XML and XSL files).
Since I want to generate a lot of PDF Files, I wrote a small program for it instead of using the provided fop.bat. It compiles fine, but by running it appears a message telling it that the Logger class can't be found. where is the problem? thanks in advance. -
Java Class Gen gives "Expected EOF"
i'm trying to run the Java class generator using the command line utility, but keep getting an XMPParseException: Expected 'EOF'.
This happens with the dtd file included in the sample directory.
The class gen is 2.0.0.0 Beta, and it was bundled with the v2 parser. Any suggestions?I got this error trying to generate classes based on schema definition file with namespace declaration. The catch here is to create a directory for each namespace declared and specify it before the schema file, i.e
oracg -p pakagename -s schemafile
if you switch the order of these arguments, you'll get EOF error.
vadim -
Class generated by genInterface ant task does not compile
I am trying to build a web service from existing wsdl using genInterface and topDownAssemble ant tasks.
The wsdl contains following type definition. Java class generated from this type (see below) does not compile. The problem is that there are two class members named
'value'. Is this an issue with Web Services Assembly tool or there is some way to get
around it?
<s:simpleType name="quantityType">
<s:restriction base="s:string">
<s:enumeration value="summation"/>
<s:enumeration value="demand"/>
<s:enumeration value="value"/>
<s:enumeration value="consumption"/>
</s:restriction>
</s:simpleType>
// Version = Oracle WebServices (10.1.3.3.0, build 070610.1800.23513)
public class QuantityType implements java.io.Serializable {
private java.lang.String value;
private static final String _summationString = "summation";
private static final String _demandString = "demand";
private static final String _valueString = "value";
private static final String _consumptionString = "consumption";
public static final java.lang.String summation = new java.lang.String(summationString);
public static final java.lang.String demand = new java.lang.String(demandString);
public static final java.lang.String value = new java.lang.String(valueString);
public static final java.lang.String consumption = new java.lang.String(consumptionString);
public static final QuantityType summation = new QuantityType(_summation);
public static final QuantityType demand = new QuantityType(_demand);
public static final QuantityType value = new QuantityType(_value);
public static final QuantityType consumption = new QuantityType(_consumption);
AndreiPls set debug attribute of JWSC ant task to true or on, e.g.
<jwsc srcdir="." destdir="${output.dir}" debug="on" keepGenerated="true">
</jwsc> -
How to produce Java class from xsd programmatically?
As titled, I want to generage Java class/interface from xml schema via a program. There is a tool "xjc" that can do this manually.
I saw a sample that generates xsd file from Java class programmatically, I am figuring out if there is such a API to do the similar thing vice versa.
Thank you in advance!You may want to check out this Java EE 5 Tutorial: http://docs.oracle.com/javaee/5/tutorial/doc/bnbah.html
It has an example of generating JAXB Java classes from an XML schema.
Can you provide a sample xsd schema and the resulting Java class/classes you want to have produced?
XMLBeans can use an xsd and generate Java classes for containing/manipulating XML objects, though I don't think that is what you are wanting.
You can also write an XSLT stylesheet that generates Java classes based on parameters that you provide to the stylesheet but there is no xsd schema involved. We used this at a major national bank to produce Java classes for batch processing of files sent/received between the bank and third pary companies. The Java classes generated were used to read/write delimited files, xml files and fixed format files to/from Java bean classes with the necessary getters/setters for manipulating the data.
Without a sample of what you are trying to doi it is hard to offer much help. -
Hi!, I'm using Fop to PDF generation from XML file and XSL:FO file, the last one is xsl with namespaces fo.
My problem is that, I get, from java class, generatting a PDF file from fo file, but, I want to get a PDF file from XML file and XSL:FO file. So, what is the best class of API FOP that I can use in which, pass it like a parameters the XML and XSL:FO files, this class generates directly the pdf file?
Anybody can help me writting an example?.
Thaks a lot.
I'm sorry for my english, I know that is quite poor.look at http://xml.apache.org/fop/index.html
I never used it, so I wont be able to help you. -
JAXB - generation of extra java class.
Hi Everyone,
JDK 5, JWSDP 1.6
My XML Schema is:
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:element name="Participant">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ParticipantID" type="xsd:string"/>
<xsd:element name="FirstName" type="xsd:string"/>
<xsd:element name="LastName" type="xsd:string"/>
<xsd:element name="Location" type="xsd:string"/>
<xsd:element name="RoleID" type="xsd:string"/>
<xsd:element name="EmailAddress" type="xsd:string"/>
<xsd:element name="MobileNumber" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>When I run JAXB I get an extra Participant.java class generated along with a ParticipantType.java class. Participant.java extends ParticipantType.java. Why is it necessary to generate this extra interface? Wouldn't ParticipantType.java suffice?
TIA,
Claire.probably, but using interfaces reduces the dependencies between client code and jaxb implementation, so as always, interfaces are a good thing.
-
ANN: XML Class Generator for Java Available
The Oracle XMCL Class Generator for Java is now available as an
initial beta release on the Oracle Technology Network at
http://technet.oracle.com. Select 'xml' from the Technology menu.
The XML Class Generator will generate a set of Java source files
based on an input DTD. The generated Java source files can then
be used to construct, optionally validate, and print a XML
document that is compliant to the DTD specified. This is an early
beta release and has the following features:
* Creates Java Classes from DTDs to enable the programmatic
construction of XML documents.
* Supports validation mode to assist debugging.
* Works with the Oracle XML Parser in Java.
* Creates documents conforming to the W3C XML 1.0
Recommendation.
* Supports creating documents in the following encodings:
UTF-8
UTF-16
ISO-10646-UCS-2
ISO-10646-UCS-4
US-ASCII
EBCDIC-CP-US
ISO-8859-1
Shift_SJIS
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
nullThanks,
Rob
Oracle XML Team wrote:
: First, the link has been fixed. As to your access exception,
we
: have traced it to a difference between JDK 1.1.x and JDK 1.2.
: You can solve it by using a 1.1.x version of the JDK or wait
till
: our production version of our XML Parser becomes available
within
: a week which will work with 1.2.
: Oracle XML Team
: http://technet.oracle.com
: Rob Edagr (guest) wrote:
: : 1) The HREF on the download page for the NT version points
to
: : the version 102 parser not the classgen.
: : 2) After downloading and installing the classgen (by
guessing
: : what the url was) I ran it and get the following
: : C:\jdk1.2\xml\ora\classgen\sample>java SampleMain -root
: : wddxPacket wddx_0090.dtd
: : Exception in thread "main" java.lang.IllegalAccessError: try
to
: : access class oracle/xml/parser/XMLNode from class
: : oracle/xml/classgen/ClassGenerator
: : at oracle.xml.classgen.ClassGenerator.generate
(Compiled
: : Code)
: : at SampleMain.main(SampleMain.java:65)
: : Any idea on what the problem is (same error with sample dtd)
: : Rob
: : Oracle XML Team wrote:
: : : The Oracle XMCL Class Generator for Java is now available
as
: : an
: : : initial beta release on the Oracle Technology Network at
: : : http://technet.oracle.com. Select 'xml' from the
Technology
: : menu.
: : : The XML Class Generator will generate a set of Java source
: : files
: : : based on an input DTD. The generated Java source files can
: : then
: : : be used to construct, optionally validate, and print a XML
: : : document that is compliant to the DTD specified. This is
an
: : early
: : : beta release and has the following features:
: : : * Creates Java Classes from DTDs to enable the
programmatic
: : : construction of XML documents.
: : : * Supports validation mode to assist debugging.
: : : * Works with the Oracle XML Parser in Java.
: : : * Creates documents conforming to the W3C XML 1.0
: : : Recommendation.
: : : * Supports creating documents in the following
encodings:
: : : UTF-8
: : : UTF-16
: : : ISO-10646-UCS-2
: : : ISO-10646-UCS-4
: : : US-ASCII
: : : EBCDIC-CP-US
: : : ISO-8859-1
: : : Shift_SJIS
: : : Oracle XML Team
: : : http://technet.oracle.com
: : : Oracle Technology Network
: Oracle Technology Network
null
Maybe you are looking for
-
Best practices: Looking for advice
My imac has a 750GB HD. Today I have received what took me a while to decide on as teh best separtae backup drive - I got myself the 1TB Guardian by Newertech. Here is how I propose to keep my files backed up and wanted to know if this makes sense or
-
Cannot download more than one photo file...
I am having trouble with my 80GB's photo capabilities. Everytime I try to load pictures onto it, iTunes automatically deletes any pictures that were already on my iPod.
-
Itunes failing to find msvcr80.dll
Ran the update for the latest version of iTunes on Windows Vista. After install completes, it returns the error "This applicatio has failed to start because MSCVCR80.dll was not found. Re-installing the application may fixe the problem." Tried rei
-
Invoice Workbench Form giving error
Hi, I have done a customization on the Standard Invoice Work bench Form. Now When I am entering the lines detail for the non PO based header and closing the form it is giving me error like APP-SQLP-10186:Please Commit or clear your Changes before con
-
Personalization in PO_LINE FORM
Hi All, I've defined a value i.e. 'Services' in PO_LINE_TYPE, and my requirement is that when i pick this value then system automatically set the value 'PO' in Invoice Match Option. Trigger Event= WHEN-NEW-ITEM-INSTANCE Trigger Object= PO_LINES.LINE_