Altova XMLSpy 2024 Enterprise 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.

 

Methods


Name

Description

ic_method

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 https://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20021022/namespaces-algorithms.html.

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

© 2017-2023 Altova GmbH