cancel
Showing results for 
Search instead for 
Did you mean: 

Using a DOM Document in Graphical Mapping

Former Member
0 Kudos

Hi,

I have the following scenario:

A string stream is received from a SOAP adapter. From this I extract a part that is in essence a XML document.

I then parse this into a DOM Document object.

I want to pass this XML structure on to other graphical mapping functions so that I can map parts of this document to other structures. I cannot add it to the 'result' object in an 'Advanced user defined function'

Do I have to add it to some component of the 'container' object passed to the function ?. If not - any ideas of how I would do this ?.

Thanks

Andre

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Andra,

You can have multiple message mapping for a single Interface mapping.

All you have to do is:

message Mapping1: struc1 Dom mapping Struc2

Message Mapping2: struc2 Graphical mapping struc3

One Interface mapping

struc1 DOM mapping struc3

Graphical mapping

Hope this helps.

Regards

Vijaya

former_member184154
Active Contributor
0 Kudos

No (easy) way to get the DOM working in graphical mapping and UDF...

Your DOM stuff must be put in a Java mapping.

Then assemble both transformations in your interface mapping, as said above.

Alex

Former Member
0 Kudos

Hi Vijaya,

I'm not completely following what you are trying to explain.

My problem is the following :



try {
	DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance( );
	DocumentBuilder builder = factory.newDocumentBuilder( );

	ByteArrayInputStream inputStr = new  ByteArrayInputStream( request[0].getBytes( ) );
	Document document = builder.parse( inputStr );

	<b>result.addValue( document );</b>

} catch (Exception e) {
	MappingTrace trace = container.getTrace( );
	trace.addInfo( e.getMessage( ) );
}
 

The result.aadvalue method call results in a compilation error as it seems that result can only tke String values.

Where would I put the 'document' to be able to use it in latter parts of the mapping.

Thanks

Andre

Former Member
0 Kudos

Hi Vijaya,

I'm not completely following what you are trying to explain.

My problem is the following :



try {
	DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance( );
	DocumentBuilder builder = factory.newDocumentBuilder( );

	ByteArrayInputStream inputStr = new  ByteArrayInputStream( request[0].getBytes( ) );
	Document document = builder.parse( inputStr );

	<b>result.addValue( document );</b>

} catch (Exception e) {
	MappingTrace trace = container.getTrace( );
	trace.addInfo( e.getMessage( ) );
}
 

The result.addvalue method call results in a compilation error as it seems that result can only tke String values.

Where would I put the 'document' to be able to use it in latter parts of the mapping.

Thanks

Andre

former_member184154
Active Contributor
0 Kudos

Andre,

Either you don't read, or my English is really awful

YOU CANNOT DO SOMETHING LIKE THAT!

What can get out of one UDF is basically a String, or an array of Strings... for sure not a DOM document...

Former Member
0 Kudos

Hi Vijaya,

Sorry - get the idea as Alex said - USE A JAVA MAPPING !!.

Will do.

Thanks

Andre

0 Kudos

Hi Andre,

It looks to me like you have an XML document with another XML document embedded (and encoded) inside some element. Something like:

<outerDoc>
 <element>
  &lt;innerDoc&gt; ...more embedded XML... &lt;/innerDoc&gt;
 </element>
</outerDoc>

It is not possible to both "unwrap" the inner document and continue to work on it in a graphical mapping. The simplest approach is to have 2 mapping steps in your interface mapping:

1. A pure Java mapping in which you get the complete outer document as input, parse your way through and extract the inner document, which is the output of this first mapping step.

2. A graphical mapping which has your inner document as input and your final result as output.

Hope that clarifies it somewhat

Best regards,

Thorsten

Answers (0)