Renaming elements in XML output
Author: tneeskens@itblockz.nl (Theo Neeskens)
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?
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
Author: Lauterbach (norbert.lauterbach@infraserv.com)
Renaming elements in XML output
Author: tneeskens@itblockz.nl (Theo Neeskens)
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?
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 mind
Author: Theo Neeskens (tneeskens@itblockz.nl)
Renaming elements in XML output
Author: tneeskens@itblockz.nl (Theo Neeskens)
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?
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
Knut
Author: Knut (knut.dybendahl@gmail.com)
Renaming elements in XML output
Author: tneeskens@itblockz.nl (Theo Neeskens)
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?
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
Author: Lauterbach (norbert.lauterbach@infraserv.com)
Renaming elements in XML output
Author: tneeskens@itblockz.nl (Theo Neeskens)
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?
vs_xml= $replace($replace($replace(vs_xml, 1, "<CUSTNR>","<CUSTOMERNUMBER>",-1),1,"</CUSTNR>","</CUSTOMERNUMBER>",-1),1,"<CUSTNR/>","<CUSTOMERNUMBER/>",-1)
Author: Knut (knut.dybendahl@gmail.com)