cancel
Showing results for 
Search instead for 
Did you mean: 

Getting entire source structure via udf

Former Member
0 Kudos

Hi Experts,

Below is my source structure.

<record> 

<first> 

<second>

<third> 

<fourth>

.

.

.

.

<record>

It has around 100 fields. I want to write a udf by having these 100 fields as arguments (Also i don't want to give the filed names one by one in the arguments). Is there any other way to get all these values without adding all of them in the arguments?

Is it possible to get them via <record>?

Thanks in advance!

Regards,

Senthil J

Accepted Solutions (0)

Answers (5)

Answers (5)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Senthil,

In your message mapping editor, right-click on the record and then select ReturnAsXML and then pass this to your UDF (make sure to parse the XML input though).

Regards,

Mark

iaki_vila
Active Contributor
0 Kudos

Hi Senthil,

You could also to use a simply XSL:


<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

    <xsl:template match="./child::*">

        <xsl:copy-of select="*"/>

    </xsl:template>

</xsl:stylesheet>

Regards.

Former Member
0 Kudos

Instead you can do coding in a java mapping and get values from xml tags using DOM or SAX parsers.

It would be difficult to have 100 inputs in UDF and also difficult while passing (mapping) inputs, testing it.

Regards,

Pranav

anupam_ghosh2
Active Contributor
0 Kudos

Hi Senthil,

                It is possible to get all fields from parent node <record>, but then you need a java mapping instead of UDF. Check out this example using DOM parser http://www.drdobbs.com/jvm/easy-dom-parsing-in-java/231002580

Regards

Anupam


former_member184720
Active Contributor
0 Kudos

Such a complex conversion

Sorry but i don't think there is an alternative.

May be you can go with Java mapping