Click or drag to resize
[Namespaces] section
Print this page

To input data from an XML file that contains one or more namespaces, you must define them in the [Namespaces] section of your template. The [Namespaces] section is supported in Create, Update, CreateOrUpdate, and Delete templates.

For the name/value pairs in this section:

  • The name portion (left side) declares the namespace prefix.
  • The value portion (right side) defines the prefix’s URI.

This topic contains the following sections:

Example: Defining a namespace

A namespace declaration in an XML file includes a prefix and a namespace identifier (URI) as shown in the example below:

<t:Root xmlns:t="https://api.telogis.com/xml">

To declare this namespace in a template, set the left side to the prefix and the right side to the URI:

[Namespaces]
t = https://api.telogis.com/xml
Example: Referring to a namespace throughout a template

In the following XML input file, everything prefixed by t is part of the same namespace:

XML
<?xml version="1.0" encoding="utf-8"?>
<t:Root xmlns:t="https://api.telogis.com/xml">
  <t:Marker>
    <t:Id>1</t:Id>
    <t:Tag>tag1</t:Tag>
  </t:Marker>
  <t:Marker>
    <t:Id>2</t:Id>
    <t:Tag>tag2</t:Tag>
  </t:Marker>
</t:Root>

Use the t prefix when you refer to these items within your template:

Update template
[Template]
TemplateVersion = 1.0
TableID = Marker-1.0
TemplateName = UpdateMarkerWithXmlNamespace
Intent = Update
Format = XPath
ElementName = t:Root/t:Marker    # The base element path 

[Namespaces]
t = https://api.telogis.com/xml  # Defines the namespace

[Output]
Id(MyId) = Input.[t:Id]  # The Id element in the namespace
Tag = Input.[t:Tag]      # The Tag element in the namespace
Example: Defining multiple namespaces

If your XML input contains elements from more than one namespace, then each one must be defined within your template.

In the following input file, two namespaces are declared: t1 and t2.

XML
<?xml version="1.0" encoding="utf-8"?>
<t1:Root xmlns:t1="https://api.telogis.com/xml1" xmlns:t2="https://api.telogis.com/xml2" >
  <t1:Marker>
    <t2:Id>5</t2:Id>
    <t2:Tag>tag5</t2:Tag>
  </t1:Marker>
</t1:Root>

Within your template, you must define both namespaces and refer to the appropriate prefixes within the ElementName and [Output] section lines.

Update template
[Template]
TemplateVersion = 1.0
TableID = Marker-1.0
TemplateName = UpdateMarkerWith2XmlNamespacesMB
Intent = Update
Format = XPath
ElementName = t1:Root/t1:Marker 

[Namespaces]
t1 = https://api.telogis.com/xml1
t2 = https://api.telogis.com/xml2

[Output]
Id(MyId) = Input.[t2:Id] 
Tag = Input.[t2:Tag]