p rd · Sep 14, 2017

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?

    xmlns:xsi="" 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>
        <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">
            <county value="DPQDSF"></county>
            <city value="SWERS"></city>
            <state value="SCSSD"></state>
        <addr use="H">
            <state value="SCSSD"></state>
        <addr use="P">
           <city value="SWERS"></city>
            <state value="SCSSD"></state>
        <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=""></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=""></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>

0 511
Discussion (1)0
Log in or sign up to continue

Conversion of XML to objects is a standard function in Caché.
start with

and continue

the principle steps

  • generate a package o classes from XML Schema
  • import your XML File to this package
  • - - -  change whatever you want to change
  • use %XML.Writer  to generate a new export file.

a different approach could be to use XSLT to transform your XML file

Whatever better fits to reach your goal.