cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

XSLT split string by delimiters

Former Member
0 Likes
539

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

View Entire Topic
Former Member
0 Likes

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.