How can generate xml without prefix?


#1

I want get xml like
<?xml version="1.0" encoding="UTF-8"?>\n<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"\n xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="era">\n\n <process id="demandProcess" version="1.0.0" isExecutable="true">\n <startEvent id="StartEvent"/>\n <endEvent id="EndEvent"/>\n <receiveTask id="Task_0l5iagn" name="">\n <extensionElements>\n <extensionElement id="pageCode" value="demandCut"></extensionElement>\n </extensionElements>\n </receiveTask>\n <receiveTask id="Task_0jqpcxd" name="">\n <extensionElements>\n <extensionElement id="pageCode" value="demandDev"></extensionElement>\n </extensionElements>\n </receiveTask>\n <sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent" targetRef="Task_0l5iagn"/>\n <sequenceFlow id="SequenceFlow_3" sourceRef="Task_0l5iagn" targetRef="Task_0jqpcxd"/>\n <sequenceFlow id="SequenceFlow_4" sourceRef="Task_0jqpcxd" targetRef="EndEvent"/>\n </process>\n</definitions>
what should I do?


#2

I have resolved it. :smirk:


#3

Hi @qintao741

If you can, please share your solution.

Thank you


#4

Hi,you can find it in moddle-xml / test /spec /writer.js

it('via xsi:type / no namespace', function() {

        // given
        var writer = createWriter(datatypesModel);

        var root = datatypesModel.create('dt:Root', { xmlns: 'http://datatypes' });

        root.set('bounds', datatypesModel.create('dt:Rect', { y: 100 }));

        // when
        var xml = writer.toXML(root);

        // then
        expect(xml).to.eql(
          '<root xmlns="http://datatypes">' +
            '<bounds y="100" />' +
          '</root>');
      });