OriginalPostID-255853
Discussion posts and replies are publicly visible
Is there any update on this?
Typically would like to generate an xml file with dynamic date (coming from record) based on an xsd
What would be the most efficient way to do so?
I've tried them without success so yes it seems like there will be no choice than using substitute unless someone has a better solution
Could you post your code here? Stefan solutions seems to be correct..... Maybe there is some kind of error in your code?
toxml( value:a!map( one:rule!ZMK_GetDEMANDEByIddemande(1), two: now() ), format:true, name:"root", namespace:"root2")
and the result is
"<n1:root xmlns:n1="root2" xmlns:a="http://www.appian.com/ae/types/2009" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <one xmlns:n2="urn:com:appian:recordtype:datatype" xsi:type="n2:4d150a11-17bc-4370-b1d6-5db2f05a6bda"> <iddemande xsi:type="xsd:int" uuid="f7dfcec7-9a6f-44f2-ac39-651317a0cf9d">1</iddemande> <statut xsi:type="xsd:string" uuid="f41f320f-ff4a-4077-a59b-75960d9310c7">NEW</statut> <dateStatut xsi:type="xsd:string" uuid="76b39c40-b653-44e6-901d-6697f1281513" /> <statusId xsi:nil="true" xsi:type="xsd:int" uuid="76534201-8a54-4fc0-a951-0459d7d690d8" /> <idremise xsi:nil="true" xsi:type="xsd:int" uuid="63dd9e79-b738-40d1-af3b-a452e470b4e6" /> <topUrgence xsi:nil="true" xsi:type="xsd:boolean" uuid="0bbc73b0-88dd-4bbb-8f6f-68fe62e72f90" /> <createdBy a:id="" xsi:type="a:User" uuid="c4af67cd-1d10-44ce-9b92-3000ffe0a602" /> <createdOn xsi:nil="true" xsi:type="xsd:dateTime" uuid="b173133d-de4d-4c94-9dbc-5667a57a507a" /> <modifiedBy a:id="" xsi:type="a:User" uuid="1692f2fd-e43b-46ae-beb3-2b4fb9cb88ac" /> <modifiedOn xsi:nil="true" xsi:type="xsd:dateTime" uuid="11eff0d9-0aa6-44ff-b0ab-fdb9cc98397e" /> </one> <two xsi:type="xsd:dateTime">2024-02-27T14:36:20.060Z</two> </n1:root>
With no formatting , UUID instead of field names and still have the xmlns and xsi2:type metadata...
That seems to be the standard with record type data. Did you try to cast the data to maps?
cast( type!Map, <your data> )
much better now!
last to remove are the "xsi:type" data and the
<n1:root xmlns:n1="root2" xmlns:a="">www.appian.com/.../2009" xmlns:xsd="">www.w3.org/.../XMLSchema" xmlns:xsi="">www.w3.org/.../n1:root>
<n1:root xmlns:n1="root2" xmlns:a="">www.appian.com/.../2009" xmlns:xsd="">www.w3.org/.../XMLSchema" xmlns:xsi="">www.w3.org/.../XMLSchema-instance">
<one xsi:type="a:Map">
<two xsi:type="xsd:dateTime">2024-02-27T16:13:19.700Z</two>
</n1:root>
possible with parameters only?
Use regular expressions in order to remove the namespaces from the resulting xml, for example
\sxmlns[^"]+"[^"]+"
thanks David,
Could you please give a more detailed example?
I am not too familiar with regular expressions in Appian
like how to remeove the header and footer from previous generated xml
<n1:root xmlns:n1="root2" xmlns:a="">www.appian.com/.../2009" xmlns:xsd="">www.w3.org/.../XMLSchema" xmlns:xsi="">www.w3.org/.../
n1:root>
thanks
Regexes in Appian are not different to other languages. Get the plugin installed and check stackoverflow or other resources.
a!localVariables( local!valor: "<n1:root xmlns:n1=""root2"" xmlns:a="">www.appian.com/.../2009"" xmlns:xsd="">www.w3.org/.../XMLSchema"" xmlns:xsi="">www.w3.org/...></n1:root>", regexreplaceall("\sxmlns[^""]+""[^""]+""", local!valor, "") )
Try this....
Thanks a lot