5 1 10 XML Namespace

LANSA Integrator

5.1.10 XML Namespace

XML namespaces provide a simple method for qualifying element and attribute names used in Extensible Markup Language documents by associating them with namespaces identified by URI references.

Refer to Namespaces in XML 1.0

Apache recommend avoiding the use of default namespaces.

If you are looking for nodes in a namespace, the XPath expression must include a namespace prefix that you have mapped to the namespace with an xmlns declaration.

If you have declared a default namespace, it does not have a prefix.

In order to construct XPath expressions to retrieve nodes from this namespace, you must add a namespace declaration that provides a prefix you can include in the XPath expressions.

Suppose, for example, you want to locate nodes in a default namespace declared as follows:

 

xmlns="http://my-namespace"

 

Add a namespace declaration with a prefix to the style sheet xsl:transform element:

 

xmlns:xyz="http://my-namespace"
 
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:rdml="http://www.lansa.com/2000/XML/Function"
  xmlns:xalan="http://xml.apache.org/xalan"
  xmlns:xyz="http://my-namespace">

 

Then you can use xyz: in your XPath expression:

 

<rdml:field name="FIELD" value="{/xyz:order/@name}"/>

 

 

For more information refer to:

Apache frequently asked questions