05-09-2022 1:11 PM
I am trying to create a Simple Transformation, but am stuck with the issue of having to ignore an attribute in the root element.
This is my XML data:
<?xml version="1.0" encoding="utf-8"?>
<ExportData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="PostProcessor.SaveToXML" rootItemNumber="503620-000">
<TimeStamp>2021-12-22T09:30:42.927665+01:00</TimeStamp>
<Items>
<Item>
<ItemNumber type="String" value="061243-JBP"/>
<VersionNumber type="Numeric" value="9"/>
</Item>
</Items>
</ExportData>
I would like to ignore or skip the attribute "rootItemNumber".
I'm using the ST code below.
<?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="EXPORTDATA" type="ddic:ZCA_EXPORTDATA"/>
<tt:template>
<ExportData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" rootItemNumber="503620-000" xmlns="NTI.Vault.Pro.BOMExport.PostProcessor.SaveToXML">
<TimeStamp tt:value-ref=".EXPORTDATA.TIMESTAMP"/>
<Items>
<tt:loop ref=".EXPORTDATA.ITEM">
<Item>
<ItemNumber>
<tt:attribute name="value" value-ref="ITEMNUMBER"/>
</ItemNumber>
<VersionNumber>
<tt:attribute name="value" value-ref="VERSIONNUMBER"/>
</VersionNumber>
</Item>
</tt:loop>
</Items>
</ExportData>
</tt:template>
</tt:transform>
05-09-2022 3:45 PM
Just this?
<ItemNumber>
<tt:cond>
<tt:attribute name="value"/>
</tt:cond>
</ItemNumber>
05-11-2022 11:31 AM
Hello sandra.rossi
I changed the attributes to conditional as you suggested. But this throws an error with "System expected element '<ExportData>'".
I think that this is because the ST code has no attributes in the <ExportData> element, and the XML contains four attributes in the element?
<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="EXPORTDATA" type="ddic:ZCA_VAULT_EXPORTDATA"/>
<tt:template>
<!-- <ExportData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" rootItemNumber="503620-000" xmlns="SaveToXML">-->
<ExportData>
<tt:cond>
<tt:attribute name="xsd"/>
<tt:attribute name="xsi"/>
<tt:attribute name="rootItemNumber" value-ref=".EXPORTDATA.ROOTITEMNUMBER"/>
<tt:attribute name="xmlns"/>
</tt:cond>
05-11-2022 12:16 PM
You don't need to indicate <tt:attribute...> for the attributes defining the namespaces.
You probably have an issue with the element <ExportData> which belongs to the namespace URI "SaveToXML".
...
<xyz:ExportData xmlns:xyz="SaveToXML" >
...
05-11-2022 12:44 PM
Thank you sandra.rossi ,
This led me on the right track. And now it works. I added namespace to the elements.
And I also noticed that the test-XML-file I had been supplied with was missing three additional elements, that I had expected in the ST program. This also led me astray 🙂