Example on how to use XMLWriterService

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Joop
Posts: 26
Joined: Tue Dec 01, 2015 2:38 am
Location: The Netherlans
Contact:

Example on how to use XMLWriterService

Post 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>
--
Regards,
Joop Roseboom
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Example on how to use XMLWriterService

Post 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 4704 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 4704 times
and it will generate a sample code for you:
xmlbin03.png
xmlbin03.png (358.8 KiB) Viewed 4704 times
Joop
Posts: 26
Joined: Tue Dec 01, 2015 2:38 am
Location: The Netherlans
Contact:

Re: Example on how to use XMLWriterService

Post by Joop »

Hi Dino,

Thanks for your extensive reply! I will definitely look into the XMLBindFileService. It seems fairly easy to use.
--
Regards,
Joop Roseboom
Post Reply