2024 Aug 23 2:22 PM
Hi,experts.
How to set a constant attribute to xml transformation.
For example i have only sender field and want to get an xml = <issuance xmlns="http://www.w3schools.com" sender="700069297">
</issuance>
I found how to set an sender attribute by ref, but how to set a constant of xmlns?
<?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="ROOT" type="ddic:ZVA_ESCHF_GET"/>
<tt:template>
<issuance>
<tt:attribute name="sender" value-ref="ROOT.SENDER"/>
</issuance>
</tt:template>
</tt:transform>
2024 Aug 23 5:48 PM
Why would you want to define a namespace as a variable? Transformations refer 99.9% of the time to fixed namespaces. If you want a special transformation, completely dynamic, use XSLT.
2024 Aug 23 6:42 PM
What do u mean by "namespace variable", sender is always different, xmlns is always the same, should i use xslt?
2024 Aug 23 8:25 PM
No. If it's a constant namespace, did you try this directly in the simple transformation?
<issuance xmlns="http://www.w3schools.com">
2024 Aug 26 6:08 AM
2024 Aug 26 7:08 AM - edited 2024 Aug 26 7:10 AM
I couldn't get a closing tag even withount xmlns tag :
Mine xml, i want to get : <issuance sender="700069297"></issuance>
mine trans :
<?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="ROOT" type="ddic:ZVA_ESCHF_GET"/>
<tt:template>
<issuance>
<tt:attribute name="sender" value-ref="ROOT.SENDER"/>
</issuance>
</tt:template>
</tt:transform>
2024 Aug 26 7:24 AM - edited 2024 Aug 26 7:28 AM
I guess you want to obtain this:
<issuance xmlns="http://www.w3schools.com" sender="700069297">
</issuance>
Your expectation is incorrect, both forms are valid and strictly identical, and will be accepted by all the XML readers I know.
There's no way you can obtain the end tag.
2024 Aug 28 10:53 AM
Ok, but what if some of xml documents have different headers?
For example
1)
<issuance xmlns="http://www.w3schools.com" sender="400052406">
2)
<issuance xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3schools.com" xsi:schemaLocation="http://www.w3schools.com" sender="300062307">
only 'sender' is attribute, as i understand.
How to setup an xml transformation in this case?
2024 Aug 28 2:25 PM
Why would you want to define a namespace as a variable? Transformations refer 99.9% of the time to fixed namespaces. If you want a special transformation, completely dynamic, use XSLT.