我有一个简单的转换来创建这样的 XML 文件:
<?xml version="1.0" encoding="utf-16"?>
<ORDEREXPORT xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<cbc:EXPORTDATE>2020-07-21</cbc:EXPORTDATE>
<cbc:EXPORTTIME>10:10:46</cbc:EXPORTTIME>
<xs:EXPORTUSER>STACKY</xs:EXPORTUSER>
</ORDEREXPORT>
但是我的转换会生成一个像这样的文件:
<?xml version="1.0" encoding="utf-16"?>
<ORDEREXPORT xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<cbc:EXPORTDATE xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">2020-07-21</cbc:EXPORTDATE>
<cbc:EXPORTTIME xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">10:10:46</cbc:EXPORTTIME>
<xs:EXPORTUSER xmlns:xs="http://www.w3.org/2001/XMLSchema">STACKY</xs:EXPORTUSER>
</ORDEREXPORT>
我希望所有命名空间都位于<ORDEREXPORT>
元素中。
我怎样才能做到这一点?
我的转变:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns:ddic="http://www.sap.com/abapxml/types/dictionary"
xmlns:def="http://www.sap.com/abapxml/types/defined">
<tt:root name="ORDEREXPORT" type="ddic:ZORDEREXPORT_TYPE"/>
<tt:template match="NewDataSet">
<ORDEREXPORT xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" >
<cbc:EXPORTDATE tt:value-ref=".ORDEREXPORT.EXPORTDATE"/>
<cbc:EXPORTTIME tt:value-ref=".ORDEREXPORT.EXPORTTIME"/>
<xs:EXPORTUSER tt:value-ref=".ORDEREXPORT.EXPORTUSER"/>
</ORDEREXPORT>
</tt:template>
</tt:transform>