Namespaces in XML Detection

Detection is the process of matching or identifying input documents with the proper Partner Agreements. EC does this in three ways: XML, Flat, and Channel Detection. We will focus on XML detection for our discussion on namespace changes.

In earlier EC versions, detection was done without using namespaces, even if your XML document has, or is using namespace. Detection was handled by a namespace ignorant XML Path. The following figure shows the Detection tab in IEC v9.0.1.0.

Without using namespace:

The <Envelope> on the second line is a simple example with no namespace.


<?xml version="1.0"?>
		<Enveloe>
			<Header>
				<delivery>
					<from>
						<address> this is detected!</address>
					<from>
. . .

Using a namespace:

The namespace "env" on the third line is defined by URI http://www.intentia.com/MBM Envelope


<?xml version="1.0"?>
<Envelope xmlns="http://www.intentia.com/MBM"
xmlns:env="http://www.intentia.com/MBM_Envelope"
xmlns:xsi="http://www.w3.org/2001/SMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://www.intentia.com/MBM MBM_Test_20_in.xsd">
		<Header>
			<env:delivery>
				<env:from>
					<env:address> this is detected!</address>
				</env:from>
. . . 

Using another namespace:

The namespace "env" on the third line is defined by URI

http://www.intentia.com/MBM Another Envelope


<?xml version="1.0"?>
<Envelope xmlns="http://www.intentia.com/MBM"
xmlns:env="http://www.intentia.com/MBM_Another_Envelope"
xmlns:xsi="http://www.w3.org/2001/SMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://www.intentia.com/MBM MBM_Test_20_in.xsd">
		<Header>
			<env:delivery>
				<env:from>
					<env:address>this is detected!</address>
				</env:from>
. . .

New fields in the Detections tab

Three new fields in the Detections tab were introduced to support the use of namespaces.

Field Description
Actual Xpath This field is automatically generated. It displays the internal representation of EC for the XPath
Default Namespace URI This field represents the default namespace. A default namespace is applied to all elements with out prefix.
Namespace Prefix and Namespace URI Other namespaces are defined here. You must type this information for every target XML detection item.

Example

Using the namespace, look at how the following new setting will affect our previous scenarios. Here are the XML target settings we will use:

  • Name=env:from

  • Default Namespace URI=http://www.intentia.com/MBM

  • Other Namespaces

    • Namespace Prefix = env
    • Namespace URI = http://www.intentia.com/MBM_Envelope

A. Without namespace:

On the third line, the <Envelope>is a simple example with no namespace.


<?xml version="1.0"?>
<Envelope>
		<Header>
			<delivery>
				<from>
					<address>this is NOT detected!</address>
				</from>
. . .

B. Using namespace:

On the third line, namespace env is defined by the URI:

http:// www.intentia.com/MBM Envelope


<?xml version="1.0"?>
<Envelope xmlns="http://www.intentia.com/MBM"
xmlns:env="http://www.intentia.com/MBM_Envelope"
xmlns:xsl="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://www.intentia.com/MBM MBM_Test_20_in.xsd">
			<Header>
				<env:delivery>
					<env:from>
						<env:address>this is STILL detected!</address>
					</env:from>
. . .

Note: 

The prefix env does not have to match the prefix used in the detections tab. It could be a different element and can still be identified.

C. Using another namespace:

On the third line, namespace env is defined by the URI :

http:// www.intentia.com/MBM Another Envelope

The elements are not in a different namespace and will not match.


<?xml version="1.0"?>
<Envelope xmlns="http://www.intentia.com/MBM"
xmlns:env="http://www.intentia.com/MBM_Another_Envelope"
xmlns:xsi="http://www.w3.org/2001/SMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://www.intentia.com/MBM MBM_Test_20_in.xsd">
		<Header>
			<env:delivery>
				<env:from>
					<env:address>this is NOT detected!</address>
				</env:from>
. . .

D. Using a default namespace:

This is another trivial scenarios that will match our defined settings.

On the second line, elements Envelope and Header still match the URI from the settings in Detection. Elements delivery, from, and address (although now in the default namespace) still match the URI from the settings in Detection.


<?xml version="1.0"?>
<Envelope xmlns="http://www.intentia.com/MBM"
xmlns:env="http://www.intentia.com/MBM"
xmlns:xsi="http://www.w3.org/2001/SMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://www.intentia.com/MBM MBM_Test_20_in.xsd">
		<abc:Header>
			<delivery>
				<from>
					<address>this is STILL detected!</address>
				</from>
. . .

E. Using a different prefix:

On the third line, the namespace abc is defined by URI:

http:/ www.intentia.com/MBM Envelope

which is similar to the URI in Detection.


<?xml version="1.0"?>
<abc:Envelope xmlns="http://www.intentia.com/MBM"
xmlns:abc="http://www.intentia.com/MBM"
xmlns:xsi="http://www.w3.org/2001/SMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://www.intentia.com/MBM MBM_Test_20_in.xsd">
		<Header>
			<abc:delivery>
				<abc:from>
					<abc:address>this is STILL detected!</address>
				</abc:from>
. . .