Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Inject multiple XML records
Inject multiple XML records [message #776878] Mon, 09 January 2012 12:56 Go to next message
Sangeeta Tripathy is currently offline Sangeeta TripathyFriend
Messages: 16
Registered: December 2011
Junior Member
Hi,

Can an XML injection accept multiple XML documents as input? My problem is to correlate multiple XML input documents (based on same metamodel) into lesser number of output XML documents based on some parameters in the input. For this I need to input multiple XML files that need to be correlated to the ATL transformation. How can I do this?

[Updated on: Mon, 09 January 2012 13:20]

Report message to a moderator

Re: Inject multiple XML records [message #778211 is a reply to message #776878] Wed, 11 January 2012 17:39 Go to previous messageGo to next message
Sangeeta Tripathy is currently offline Sangeeta TripathyFriend
Messages: 16
Registered: December 2011
Junior Member
I tried out the XML injection of multiple XML documents, and it works up to this point:


1. Source XML Documents -> Source XML Ecore Documents
2. Source XML Ecore Documents -> Source XMI Documents
3. Source XMI Documents -> Target XMI Documents
4. Target XMI Documents -> Target XML Ecore Documents


But the last step:

5. Target XML Ecore Documents -> Target XML Documents

which is using the AM3 XML Extraction tool, is only extracting one (the first) XML Document, and not all.

Could anyone help me with this? When I go through the source code of the XML Extractor it does seem to extract more than one root document, so why is it not working?


Re: Inject multiple XML records [message #778213 is a reply to message #778211] Wed, 11 January 2012 17:47 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You can divide you last model into many models each with only 1 root.
Re: Inject multiple XML records [message #778262 is a reply to message #778213] Thu, 12 January 2012 02:57 Go to previous messageGo to next message
Sangeeta Tripathy is currently offline Sangeeta TripathyFriend
Messages: 16
Registered: December 2011
Junior Member
Thanks Sylvain,

does that mean that I use Java code to extract the individual XML documents after this step:
4. Target XMI Documents -> Target XML Ecore Documents

Java: Extract individual XML Ecore Documents

5. Iterate: One XML Ecore Document -> One Target XML


When I go throuhg code of the XML Extractor, there is a similiar piece of code in the "extract" function which seems to be doing the same thing (pasted below). Or I am mistaken? I dont mind using Java to extract, but I want to be sure there is no API already existing :

Extract:

public void extract(IModel sourceModel, OutputStream target, Map<String, Object> options)
throws ATLCoreException {
PrintStream outStream = new PrintStream(new BufferedOutputStream(target));
outStream.println("<?xml version = '1.0' encoding = 'ISO-8859-1' ?>");

EMFModel xmlModel = (EMFModel) sourceModel;
EClass rootClass = (EClass) xmlModel.getReferenceModel().getMetaElementByName("Root");
Set<EObject> rootElements = xmlModel.getElementsByType(rootClass);
serializeContent(
rootElements.iterator().next(),
xmlModel, outStream, "");

outStream.close();
}
Re: Inject multiple XML records [message #778272 is a reply to message #778262] Thu, 12 January 2012 05:21 Go to previous message
Sangeeta Tripathy is currently offline Sangeeta TripathyFriend
Messages: 16
Registered: December 2011
Junior Member
It turns out there is a bug in the XMLExtractor code, which I fixed by changing the code as below:


Extract:

public void extract(IModel sourceModel, OutputStream target, Map<String, Object> options)
throws ATLCoreException {
PrintStream outStream = new PrintStream(new BufferedOutputStream(target));
outStream.println("<?xml version = '1.0' encoding = 'ISO-8859-1' ?>");
EMFModel xmlModel = (EMFModel) sourceModel;
EClass rootClass = (EClass) xmlModel.getReferenceModel().getMetaElementByName("Root");
Set<EObject> rootElements = xmlModel.getElementsByType(rootClass);

//Inserted code

Object eArray = rootElements.toArray();
for (int i=0;i<rootElements.size();i++){

//serializeContent(
//rootElements.iterator().next(),
//xmlModel, outStream, "");

serializeContent( (EObject)eArray[i],xmlModel,outStream,"");

}

outStream.close();
}

[Updated on: Thu, 12 January 2012 05:22]

Report message to a moderator

Previous Topic:Migration of new profile definition does not work
Next Topic:[ATL] Error loading file: ... The feature 'DFSResource' is not a valid feature
Goto Forum:
  


Current Time: Thu Apr 25 22:51:38 GMT 2024

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

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

Back to the top