Altova MapForce 2024 Professional Edition

This class provides methods for manipulating XML elements from your schema. Methods of this class can be called on elements, not on the XML document itself. Note that, in order to call methods of this class, you don't need to instantiate the class directly. Any element created using the Append() or AppendWithPrefix() methods is of [ElementType] type.






void DeclareNamespace(string prefix, string nsURI)

This method takes two arguments that are both of string type: the prefix and the namespace URI that you want to use. The prefix supplied as argument will be mapped to the namespace URI value supplied as argument. If the prefix supplied as argument is empty, the method creates or overrides the default namespace declaration in the element.


For example, let's assume that the XML document has an XML element called "purchase". If you call


purchase.DeclareNamespace("ord", "http://OrderTypes");


then the XML document becomes


<purchase xmlns:ord="http://OrderTypes" />


Another example, if you call:


purchase.DeclareNamespace("", "http://OrderTypes");


then the XML document becomes


<purchase xmlns="http://OrderTypes" />


Note:The declared namespace is used when appending subsequent child elements or attributes, according to the following rules:


1.If the child namespace is the default, then use empty prefix.

2.If the child namespace is equal to the parent one, then use the parent prefix.

3.Otherwise, search for nearest prefix from parent to top, using the lookup algorithm described in section "B.2: Namespace Prefix Lookup" at

4.If there is no prefix for element namespace found, then use empty prefix.

© 2018-2024 Altova GmbH