× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks everyone for your help.

I have created a simple test java program and I've got a problem:

This is a VERY simple program - everything is static (methods and variables) and I've got the static methods defined in my RPG program. Any passed data is byte arrays or return ints.

What I do:
I create a transformer (passing a byte array) - once!
I create a streamResult (passing a byte array) - once!
I create a streamSource (passing a byte array) - lots!
I perform a transformation of the streamSource to the streamResult - lots!

The transformed data is being placed in the result file - but my SQL processing service program can't see the file. If I use wrklnk I can see it, but my RPG app can't. Funnily, if I take option 5 to look at the contents of the file I can see them, but the file name is missing from the top of the screen? What am I doing wrong? Do I need to do something to release this object within java - could it be locked? It doesn't make sense to me. Should I put some code in the createResult method to create the empty result file object and not rely on the transformer creating it - just let it populate it? Is this a serialization issue? Jeez!

The Java code is at the foot of this mail, the RPG code is simply calls to these methods (I can post it if you wish), followed by a call to a procedure within the SQL processing service program (which gets passed the result file path).

Any help would be MOST appreciated!

Cheers

Larry Ducie

import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;

/**
* @author Peter L Ducie
*
* Read an XML file and use an XSLT file to convert the data to a SQL transaction...
*/
public class ODOF_XML2SQL {


public static TransformerFactory transFact;
public static Transformer trans;
public static Source xsltSource;
public static Result result;
public static Source xmlSource;

/**
* Create a transformer object.
*/
public static int createTransformer(byte[] passedTransformer) {

        try {
                // create a xslt transformer source object...
                xsltSource = new StreamSource(new File(new 
String(passedTransformer)));

                // create an instance of TransformerFactory...
                transFact = TransformerFactory.newInstance();

                // create a transformer object...
       trans = transFact.newTransformer(xsltSource);

                // catch exception anr return error code...
        } catch (Exception e) {
                return -1;
        }

        // return completion code...
      return 0;
}

/**
* Create a streamResult object...
*/
public static int createResult(byte[] passedResult) {

        try {
                // create a streamResult object...
                result = new StreamResult(new File(new String(passedResult)));

                // catch exception and return error code...
        } catch (Exception e) {
                return -1;
        }

        // return complete OK code...
        return 0;

        }

/**
* Create an XML streamSource object...
*/
public static int createSource(byte[] passedSource) {

        try {
                // create an XML streamSource object...
                xmlSource = new StreamSource(new File(new 
String(passedSource)));

        // catch exception and return error code...
        } catch (Exception e) {
                return -1;
        }

        // return complete OK...
        return 0;
}

/**
* Perform the transformation...
*/
public static int transform() {

        try {
                trans.transform(xmlSource, result);

                // catch exception and return error code...
        } catch (Exception e) {
                return -1;
        }

        // return complete OK...
        return 0;
}
} //end class



As an Amazon Associate we earn from qualifying purchases.

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-2024 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.