Renaming elements in XML output | Uniface 9 | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

—  Results per page  —








— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters
For a group of consecutive words like 'end of support' use Match phrase

sp_Feed Topic RSS sp_TopicIcon
Renaming elements in XML output
06 Nov 2018
5:32 pm
Avatar
Theo Neeskens
Member
Forum Posts: 371
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Hi,

I have a situation where I need to:
– retrieve lots of related data in a Uniface service
– create a struct using componenttostruct
– create XML using structtoxml
– dump the XML as a file on disk 
 
It works fine so far, but I need to rename some of the XML tags.

Lets say that in Uniface I have a field CUSTNR and my XML tag should be CUSTOMERNUMBER.

I have read the documentation a couple of times and I now think it is possible with structtoxml/schema. But since I havent used XSD for output before, I am unsure.

Am I on the right track? Can somebody explain in plain English what I need to do?

Theo Neeskens, Uniface Consultant and general problem solver at ITBLOCKZ
07 Nov 2018
2:22 pm
Avatar
Lauterbach
Member
Forum Posts: 59
Member Since:
06 Dec 2012
sp_UserOfflineSmall Offline

Hi Theo,

the simplest solution should be the following :

 

– retrieve lots of related data in a Uniface service
– create a struct using componenttostruct

 

vStruct->*->CUSTNR->$name = “CUSTOMERNUMBER”

 

– create XML using structtoxml
– dump the XML as a file on disk 

 

Regards

Norbert

07 Nov 2018
3:53 pm
Avatar
Theo Neeskens
Member
Forum Posts: 371
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Thank you Norbert!

That is what I was looking for.

 

I think I have done this before but it slipped too far to the back of my mindLaugh

Theo Neeskens, Uniface Consultant and general problem solver at ITBLOCKZ
08 Nov 2018
7:12 pm
Avatar
Knut
Member
Forum Posts: 229
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

another way..

structtoxml – where-ever you store the raw xml….
for example
variables
string vs_xml
endvariables
vs_xml = $replace(vs_xml, 1, “CUSTNR”, “CUSTOMERNUMBER”, -1)

Don’t know which one is the fastest one thou Wink

Knut

09 Nov 2018
9:33 am
Avatar
Lauterbach
Member
Forum Posts: 59
Member Since:
06 Dec 2012
sp_UserOfflineSmall Offline

Knut

With $replace there is the Risk, that you replace a word that is in a textfield.

So you have to use 3 replace Statements :

vs_xml = $replace(vs_xml, 1, “<CUSTNR>”, “<CUSTOMERNUMBER>”, -1)

vs_xml = $replace(vs_xml, 1, “</CUSTNR>”, “</CUSTOMERNUMBER>”, -1)

vs_xml = $replace(vs_xml, 1, “<CUSTNR/>”, “<CUSTOMERNUMBER/>”, -1)

 

Regards

Norbert

09 Nov 2018
8:24 pm
Avatar
Knut
Member
Forum Posts: 229
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Wink

vs_xml= $replace($replace($replace(vs_xml, 1, "<CUSTNR>","<CUSTOMERNUMBER>",-1),1,"</CUSTNR>","</CUSTOMERNUMBER>",-1),1,"<CUSTNR/>","<CUSTOMERNUMBER/>",-1)

Laugh

Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 131

Currently Online:
26 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ulrich-merkel: 1890

Iain Sharp: 680

Theo Neeskens: 371

gianni: 357

Adrian Gosbell: 318

istiller: 299

rogerw: 272

Knut: 229

lalitpct: 197

Arjen van Vliet: 184

Member Stats:

Guest Posters: 3

Members: 10982

Moderators: 0

Admins: 6

Forum Stats:

Groups: 1

Forums: 62

Topics: 2323

Posts: 10052

Newest Members:

greentipodent1976, NicolasHib, gipipufen1981, Alfredvax, Lesterpioto, crystalst3, otogsa12, Ramonmaw, harolddz1, Lariskawo

Administrators: admin: 23, diseli: 1045, Nico Peereboom: 84, richiet: 406, Mike Taylor: 38, JanCees: 39