Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Black-box problem with XML(Problem - read a XML-File in Java and return via Black-box a result to QVTO )
[QVTO] Black-box problem with XML [message #690854] Thu, 30 June 2011 10:28
bugzilla87 is currently offline bugzilla87Friend
Messages: 1
Registered: June 2011
Junior Member
Hi there,

I try to make a ecore M2M-Transformation with qvto.
To make the transformation I need a specific value from an xml-File.
Therefor I use XPath in Java.
Via Blackbox in qvto I try to use the function in Java and return the value as a String.

The call of the java function from qvto works and its also possible to return a string.
The java function to read from the xml file also works in java and returns the specific value.
Only if I call the function from qvto and want to return the specific value it doesn't work.

I focused the problem to the last line.
public static String getInstallPart(String os, String db, String shortname, int installPart) {
	DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    	DocumentBuilder builder = null;
    	Document doc = null;
    	XPath xpath = null;
    	XPathExpression expr = null;
    	Object result = null;
	try {
		builder = domFactory.newDocumentBuilder();
	} catch (ParserConfigurationException e) {
		// TODO Auto-generated catch block
	try {
		doc = builder.parse(xmlPath);
	} catch (SAXException e) {
		// TODO Auto-generated catch block
	} catch (IOException e) {
		// TODO Auto-generated catch block
    	xpath = XPathFactory.newInstance().newXPath();
	try {
		expr = xpath.compile("//OS[@name='"+ os +"']/DB[@name='"+ db +"']/SAP[@name='"+ shortname +"']/InstallPart["+ installPart +"]/@name");
	} catch (XPathExpressionException e) {
		// TODO Auto-generated catch block
	try {
		result = expr.evaluate(doc, XPathConstants.STRING);
	} catch (XPathExpressionException e) {
		// TODO Auto-generated catch block

    	return result.toString() + "test";

If I call this function from a java main method with the same parameter then from qvto it works fine and the result is the resultString + "test".

But if I call this function from qvto it returns nothing. Not even the "test"-String.
If I change the last line to:
return "test";

it returns the String to qvto.

So it has to be a problem with the conversion of the variable result from an Object to a String.
But I don't have an idea what to change to make it work.

Can anyone help me?

Thanks a lot!
Previous Topic:[ATL] BPMN to BPEL simple rules transformation problem
Next Topic:QVTO iteration() operation, acc returns nothing
Goto Forum:

Current Time: Sat Mar 06 02:04:51 GMT 2021

Powered by FUDForum. Page generated in 0.02243 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top