Split XML

Post Reply
Kalle Rajand
Newbie
Posts: 6
Joined: Tue Jun 19, 2018 10:52 pm

Split XML

Post by Kalle Rajand »

I am working on simple Switch flow for vdp using new barcode action from PitStop Server.
I have incoming xml with barcode values, I inject template pdf and needed barcode is generated by PS perfectly. No problems with this part.
But I find it really difficult to split incoming xml into several xml files named by barcode values. Could xsl transform do the job?
One option is to use csv and CSV2XML app from appstore instead but I would like to solve it without additional tools.
Can anyone guide me how to split xml without serious scripting or using additional tools?

Sample of xml I am using:

<field-list>
<field>
<tag>barcode</tag>
<type>string</type>
<required>true</required>
<value>01-01-01</value>
</field>
<field>
<tag>barcode</tag>
<type>string</type>
<required>true</required>
<value>01-02-01</value>
</field>
<field>
<tag>barcode</tag>
<type>string</type>
<required>true</required>
<value>01-03-01</value>
</field>
<field>
<tag>barcode</tag>
<type>string</type>
<required>true</required>
<value>01-04-01</value>
</field>
</field-list>
User avatar
vernonvd
Member
Posts: 38
Joined: Tue Oct 09, 2012 9:21 am
Location: Pretoria, South Africa

Re: Split XML

Post by vernonvd »

You can use Saxon with a xslt transform to split the xml.
jan_suhr
Advanced member
Posts: 591
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Split XML

Post by jan_suhr »

I have made an App called Excel to XML. In the documentation of this app there is an example XSLT that will help you create an XSLT for Saxonica that will split your XML to single ones per record.

https://www.enfocus.com/en/appstore/pro ... cel-to-xml
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
Kalle Rajand
Newbie
Posts: 6
Joined: Tue Jun 19, 2018 10:52 pm

Re: Split XML

Post by Kalle Rajand »

Thanks vernonvd, Freddy and Jan, Saxon did the job perfectly.
I will test your app as well Jan, I already got a trial.
JohnnyMoss
Newbie
Posts: 5
Joined: Sat Jun 30, 2018 6:08 am

Re: Split XML

Post by JohnnyMoss »

Do you have an example of the xslt code you used? I have a very similar project and have not been able to find a solution. I am using the built in xslt tool in switch, is there a reason to use saxon over the build in tool?
jan_suhr
Advanced member
Posts: 591
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Split XML

Post by jan_suhr »

Yes the Saxonica uses XSLT 2.0 and the built in only uses XSLT 1.0. Enfocus decided that it was better to use a third party well established solution than to develop its own that could handle XSLT 2.0.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
Post Reply