Ensemble XML and objects are converted to each other
I need to convert the following XML file (with namespace) into an object in Ensemble. After processing the data, you also need to convert the object to an XML file (keep the namespace). During this time, the XML structure does not change, Only the data will change. How can i do it?
<ClinicalDocument
xmlns="urn:sc-wst:v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:sc-wst:v2 SD.xsd">
<id root="1.1.2" extension="071AE299-E3AD-4D33-AE43-7D07B4485474"></id>
<code code="C0004" displayName="xiyao" codeSystem="WS/T 445-2014" codeSystemName="xxx"></code>
<effectiveTime value="20170911164900"></effectiveTime>
<patient>
<sourceid value="68417800-1"></sourceid>
<id root="1.35" extension="xxxxas"></id>
<id root="1.19" extension="1eeqwww"></id>
<id root="1.11" extension="11222321112"></id>
<id root="1.20" extension="2334557765432"></id>
<id root="1.13" extension="21245675432"></id>
<addr use="B">
<houseNumber></houseNumber>
<streetName></streetName>
<township></township>
<county value="DPQDSF"></county>
<city value="SWERS"></city>
<state value="SCSSD"></state>
<postalCode></postalCode>
</addr>
<addr use="H">
<houseNumber></houseNumber>
<streetName></streetName>
<township></township>
<county></county>
<city></city>
<state value="SCSSD"></state>
<postalCode></postalCode>
</addr>
<addr use="P">
<houseNumber></houseNumber>
<streetName></streetName>
<township></township>
<county></county>
<city value="SWERS"></city>
<state value="SCSSD"></state>
<postalCode></postalCode>
</addr>
<item xsi:type="ST" nid="HDSD00.04.014" name="EWRU" value="DSAF"></item>
<item xsi:type="CD" nid="HDSD00.04.020" name="SEX" value="2" codeSystem="2.3.3.4"></item>
<item xsi:type="PQ" nid="HDSD00.04.017" name="SDFDS" unit="FDSAFADS" value="2"></item>
<item xsi:type="PQ" nid="HDSD00.04.018" name="DFSAF" unit="FDSA" value="9"></item>
<item xsi:type="ST" nid="HDSD00.04.005" name="FSDAFSDFSAFSD" value="EKMZ"></item>
<item xsi:type="CD" nid="HDSD00.04.029" name="DSAFDSAFASFDS" value="68417800-1" codeSystem="2.3.4.1"></item>
<guardian use="FDSAFDSACZXCXZCXZ">
<addr use="F">
<houseNumber value="18"></houseNumber>
<streetName value="fdsazds"></streetName>
<township value="cxvzcx"></township>
<county value="qwwrt"></county>
<city value="cxvbcx"></city>
<state value="vcioklx"></state>
<postalCode value="610000"></postalCode>
</addr>
</guardian>
</patient>
</ClinicalDocument>
Conversion of XML to objects is a standard function in Caché.
start with http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...
and continue http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...
the principle steps
a different approach could be to use XSLT to transform your XML file
http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...
Whatever better fits to reach your goal.