Page 1 of 1

Example on how to use XMLWriterService

Posted: Thu Jun 23, 2022 7:13 pm
by Joop
Hi All,

I was wondering if someone could provide me with an example of how to use the (Lansa 14) XMLWriterService? The documentation lacks in providing a proper example that includes a resulting XML file.

I'm trying to create an XML file like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="catalogus.xslt"?>
<productgroepen>
   <title>ZON productcatalogus</title>
   <productgroep>
       <id>100</id>
	   <omschrijving>Komkommers</omschrijving>
	   <partijen>
		   <partij>
			  <nummer>1902</nummer>
			  <artikelnummer>20448900</artikelnummer>
			  <artikelomschrijving>KOMK 61-71 I-S Ds</artikelomschrijving>
			  <veileenheid>stuks</veileenheid>
			  <verpakkingid>21300</verpakkingid>
			  <verpakkingomschrijving>KOMKOMMERDOOS 60/75</verpakkingomschrijving>
			  <palletcode>200</palletcode>
			  <palletomschrijving>EURO PALLETS</palletomschrijving>
			  <palletbeladingmin>30</palletbeladingmin>
			  <palletbeladingmax>90</palletbeladingmax>
			  <opslagpercollo>1,326</opslagpercollo>
			  <fotos>
				 <foto>
					<naam>catalogus/1902-1.jpg</naam>
					<thumbnail>catalogus/th1902-1.jpg</thumbnail>
				 </foto>
			  </fotos>
		   </partij>
		   <partij>
			  <nummer>1906</nummer>
			  <artikelnummer>20448700</artikelnummer>
			  <artikelomschrijving>KOMK 51-61 I-S Ds</artikelomschrijving>
			  <veileenheid>stuks</veileenheid>
			  <verpakkingid>21500</verpakkingid>
			  <verpakkingomschrijving>KOMKOMMERDOOS 50/60</verpakkingomschrijving>
			  <palletcode>200</palletcode>
			  <palletomschrijving>EURO PALLETS</palletomschrijving>
			  <palletbeladingmin>30</palletbeladingmin>
			  <palletbeladingmax>108</palletbeladingmax>
			  <opslagpercollo>1,239</opslagpercollo>
			  <fotos>
				 <foto>
					<naam>catalogus/1906-1.jpg</naam>
					<thumbnail>catalogus/th1906-1.jpg</thumbnail>
				 </foto>
			  </fotos>
		   </partij>
	   </partijen>
    </productgroep>
</productgroepen>

Re: Example on how to use XMLWriterService

Posted: Fri Jun 24, 2022 6:54 am
by Dino
Hi Joop

The XMLWriterService is old and used Woodstox API to generate it. I would suggest you to instead use the XMLBindFileService which is simpler and easier to use, and it was also available in V14.
https://docs.lansa.com/14/en/lansa093/i ... 7_0010.htm

You can use LANSA Integrator Studio, create a new project, create a new solution for the project using the XML Binding Wizard, select your sample xml,
xmlbin01.png
xmlbin01.png (21.59 KiB) Viewed 4706 times
select outbound, assign FIELDS, FRAGMENTS, LITS to the different sections of your XML document, save, build, generate, compile,
xmlbin02.png
xmlbin02.png (187.98 KiB) Viewed 4706 times
and it will generate a sample code for you:
xmlbin03.png
xmlbin03.png (358.8 KiB) Viewed 4706 times

Re: Example on how to use XMLWriterService

Posted: Fri Jun 24, 2022 8:28 pm
by Joop
Hi Dino,

Thanks for your extensive reply! I will definitely look into the XMLBindFileService. It seems fairly easy to use.