0

I am trying to generate a xml file in python using the scham class generated using "generateDS" module, but when the xml file is generated it does not include the xml declaration in it. can anyonne help me with this

This is what I am trying:

step_xml = STEP_ProductInformation()
step_xml.set_ContextID(step_util.CONTEXT1)
step_xml.set_WorkspaceID(step_util.MAIN)
step_xml.set_AttributeList(attribute_list_xml)
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
output_file = open(str(Path(output_filepath) / f"converted_{timestamp}.xml"), "w")
step_xml.export(output_file, 0)

This is what I get:

<STEP-ProductInformation  xmlns:None="http://www.stibosystems.com/step"  ContextID="Context1" WorkspaceID="Main">
    <AttributeList>
        <Attribute FullTextIndexed="true" ID="DESCRIPTION" ProductMode="Property">
            <Name>Description</Name>
            <Validation MaxLength="3000" MinValue="" BaseType="Text" MaxValue=""/>
        </Attribute>
    </AttributeList>
</STEP-ProductInformation>

This is what I am expecting:

**<?xml version = "1.0" encoding = "UTF-8" ?>**
<STEP-ProductInformation  xmlns:None="http://www.stibosystems.com/step"  ContextID="Context1" WorkspaceID="Main">
    <AttributeList>
        <Attribute FullTextIndexed="true" ID="DESCRIPTION" ProductMode="Property">
            <Name>Description</Name>
            <Validation MaxLength="3000" MinValue="" BaseType="Text" MaxValue=""/>
        </Attribute>
    </AttributeList>
</STEP-ProductInformation>

0 Answers0