SAP ST TT NAMESPACE



Get Example source ABAP code based on a different SAP table
  


• namespace ABAP_ST_ELEMENT

ABAP_ST - tt:namespace, Namespaces

ABAP_SYNTAX
< tt:namespace name='prefix'$|name=''/>

What does it do?
The ST statement tt.namespace declares an explicit namespace.
By default, in serializations, namespace declarations are written to the resulting XML data only if the associated namespace prefix is used as part of the name in a literal XML element or attribute or in a non-literal attribute. A namespace declaration is written into the exact element in which it is needed. Namespace declarations whose prefix is not used explicitly are ignored in serializations. In deserializations, the binding of the namespace prefix to the correct URI is checked.
For XML elements of the resulting XML data in which a namespace declaration is required even though the relevant namespace prefix is not part of a name but used, for example, as content of an attribute, this can be forced in serializations by using the statement tt:namespace . The statement can be specified one or more times within a literal XML element before its subelements. Each statement declares a namespace for the current XML element with the namespace prefix specified after the attribute name. The namespace prefix must be known in the current context, that is, it must have been defined in a surrounding XML element with xmlns:prefix='uri'.

Serializing Namespace Declarations
If a surrounding element does not yet contain a declaration of the namespace, the statement tt:namespace name='prefix' inserts the definition xmlns:prefix='uri' into the definition of the literal XML element and thus applies it to all its subelements. The statement tt:namespace name='' inserts the definition xmlns='uri' if defined in a surrounding XML element. Within the XML element, no other declarations of this namespace are created. In particular, other tt:namespace statements within the same XML element are ignored.

Deserializing Namespace Declarations
In deserializations, the statement tt:namespace is ignored.

ABAP_EXAMPLE_VX5
The ST program DEMO_ST_NAMESPACE1 below shows how namespaces are handled by default:
TRNS DEMO_ST_NAMESPACE1
The definition of the namespace with the prefix abc in element context1 is not needed in standard XML and is omitted in serializations. In the subelements abc:X and xyz:Y of context2, the declaration of namespaces is needed and inserted in serializations. The result of a serialization is as follows:
< X0>
< context1 attr='abc:uvw'>
< X >
...
< /X>
< /context1>
< context2>
< abc:X
xmlns:abc='www.abc.com'
xmlns:xyz='www.xyz.com' xyz:attr='xyz'>
...
< /abc:X>
< xyz:Y xmlns:xyz='www.xyz.com'>
...
< /xyz:Y>
< /context2>
< /X0>
The ST program DEMO_ST_NAMESPACE2 below contains explicit namespace declarations:
TRNS DEMO_ST_NAMESPACE2
The tt:namespace statements are used to explicitly insert namespace declarations for the prefixes abc and xyz into the elements context1 and context2. Now the content of attribute attr of context1 can be evaluated with specific reference to the namespace and the declaration of namespaces is no longer needed in the elements abc:X and xyz:Y of context2.
ABAP_EXAMPLE_END