I am trying to create an XML file within my RPG program and am trying to
implement something similar to the following java code:

 // Creation of an XML document
 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
 DocumentBuilder db = dbf.newDocumentBuilder();

My prototype declaration looks like this:

d documentBuilderFactory...
d                 S               O   CLASS(*JAVA:'javax.xml.-
d                                     parsers.DocumentBuilderFactory')

 * create newInstance of DocumentBuilderFactory
d makeDocumentBuilderFactory...
d                 PR              O   STATIC EXTPROC(*JAVA:'javax.xml.-
d                                     parsers.DocumentBuilderFactory':
d                                     'newInstance')
d                                     CLASS(*JAVA:'javax.xml.-
d                                     parsers.DocumentBuilderFactory')

d documentBuilder...
d                 S               O   CLASS(*JAVA:'javax.xml.-
d                                     parsers.DocumentBuilder')

 * create newInstance of DocumentBuilder
d makeDocumentBuilder...
d                 PR              O   STATIC EXTPROC(*JAVA:'javax.xml.-
d                                     parsers.DocumentBuilderFactory':
d                                     'newDocumentBuilder')
d                                     CLASS(*JAVA:'javax.xml.-
d                                     parsers.DocumentBuilder')

in my free format code, i've got the following..

   documentBuilderFactory = makeDocumentBuilderFactory();
   documentBuilder = makeDocumentBuilder();


The first statement works ok, but I get the following error on the second
statement.

 Message . . . . :   Java exception received when calling Java method.
 Cause . . . . . :   RPG procedure JAVAXML2 in program RJOSEPH/JAVAXML2
   received Java exception "java.lang.NoSuchMethodError:
newDocumentBuilder"
   when calling method "newDocumentBuilder" with signature
   "()Ljavax.xml.parsers.DocumentBuilder;" in class
   "javax.xml.parsers.DocumentBuilderFactory".


Can anyone point out anything obvious that I am missing here? I am
convinced that this error occurs because I am creating a DocumentBuilder
out of an object that is not initialised, but is there anyway I can use my
documentBuilderFactory created in the first statement to generate the
DocumentBuilder (like in the java code)?

Thanks in advance.

Roshan


This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.