cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT split string by delimiters

Former Member
0 Kudos

Hi ,

I have to split the string into different fields based on the delimiters. I guess i can use XSLT for this

my source format is

<ns:EDIFACT xmlns:ns="urn:ABG.com/EDI/Invoices">

<Recordset>

<KEY>

<Line>UNHCK66XINVOIC:D:93A:UN:EDIT30</Line>

</KEY>

</Recordset>

My target format should be

<ns:EDIFACT xmlns:ns="urn:ABG.com/EDI/Invoices">

<Recordset>

<KEY>

<Line>

<Element> UNH </Element>

<Element>CK66X</Element>

<SubelemtTitle> <Subelemt>INVOIC</Subelemt>

<Subelemt>D</Subelemt>

<Subelemt>93A</Subelemt>

<Subelemt> UN</Subelemt>

<Subelemt>EDIT30</Subelemt>

</SubelemtTitle>

</Line>

</KEY>

As you can see the delimiters are + for element and : for Subelement.

I thought using XSLT for this is a good option. But i am not an XSLT expert. Can any XSLT experts out there help me out

Thanks a lot

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks for your responses . i am using a Java UDF instead to achieve it.

Former Member
0 Kudos

Hi,

have a look to http://totaledi.org

Regards

Matthias

henrique_pinto
Active Contributor
0 Kudos

> As you can see the delimiters are + for element and

> : for Subelement.

you do FCC for this, right?

You could evalue one of the delimiters there (for example, +).

At mapping time, you would just have to handle the other one (, and that could be easily done with simple UDFs.

Regards,

Henrique.

Former Member
0 Kudos

Hi,

I would suggest using a User Defined Function in mapping as opposed to XSLT.

You can use the Java 'String.indexOf()' method and 'String.substring()' method to get different elements. You can also use the StringTokenizer class.