cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Element's name in Message mapping

Former Member
0 Kudos

Hi,

I need to Access the Element's name in Message mapping (Using graphical tool or in user defined function).

For Example:

Element: <Company_Name>XYZ Co </Company_Name>

I need to access the Element's name(i.e.)<b>"Company_Name"</b>. So that I can map it as

<Element>Company_Name</Element>

<Element_Value>XYZ Co </Element_Value>

in the target message.

Kindly provide your inputs.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You will definitely know the name of the node when u are doing the mapping for that particular source to target structure. So what is the special need to get the elements name.

Regards,

Sudharshan

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Thanks for your Inputs on reading Source element's name.

How to read the target element's name?, kindly explain

stefan_grube
Active Contributor
0 Kudos

When you have a simple function, you can use:

LeafStructureNode node =((LeafStructureNode)container.getParameter("STRUCTURE_NODE"));

return node.getQName();

Here the original thread, where I took it from:

Regards

Stefan

stefan_grube
Active Contributor
0 Kudos

Hi Santhosh,

this is definitively not possible.

The mapping tool does not store the name of the source tag, so you cannot access the name.

The only thing you can read is the name of the target tag, but I think this will not help you in your case.

Regards

Stefan

Former Member
0 Kudos

Hi,

Thanks for your input.I am not using Java mapping in this case.So how can I access the element's name inside a User Defined function which inturn can be helpful in Graphical mapping.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Santhosh,

I am not very sure if this can be done in your normal graphical mapping.

Even while writing a user defined function, in Graphical mapping, the input to that function is going to be the value of an element and not the name of the element.

Consider,

<b><elem> yyy </elem></b>

if this is given as the input to your user defined function, the value <b>yyy</b> will be passed as an input and <b>not the name of the element</b> "elem".

So, the most logical solution would be to go for java mapping.

Regards,

Bhavesh

Former Member
0 Kudos

Hi Bhavesh,

Did you get the solution for it?

thanks,

rakesh

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Santhosh,

I am not sure if this can be done using your Graphical Mapping, but this is possible using JAVA mapping. Your SAX and DOM parsers for JAVA mapping provides methods like getChildNodes, getElementName using which you can get the name of the element.

Check this link for the methods available for Java Mapping,

http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/package-summary.html

I think the same can also be done using XSL mapping. Though, I am not sure what method should be used for the same.

Hope this helps,

Regards,

Bhavesh

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Santhosh,

For a list of all the methods available and their description for a DOM parser for JAVA Mapping, chek out these links,

http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Document.html

http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html

Using these methods, you will be definitely be able to access the element name.

Regards,

Bhavesh

Former Member
0 Kudos

Hi,

Thanks for your input. I don't want to use a Constant with the Element's name and map it to target <Element>, but instead I need to access the Element's name and then map it.

I need to map nearly 220 elements like this, So I am looking at accessiing the elements's name to make the mapping easier.