TemplateDocument element of a template definition file

For each inbound XML message, there must be at least one template document defined in the message. This is defined in the TemplateDocument element.

The TemplateDocument element has four sub-elements:

DocumentType (with optional version attribute)
This part specifies the XML document name, or root element name, and the "version" attribute of the root element, if it exists. The following is an example of the DocumentType element:
<DocumentType version='1.0'>Reset_Password</DocumentType>
StartElement
This part specifies the element from which the XML message mapper starts the tag mapping. This must correspond to an element in the DTD for the message. The tag mapping generates the name value pairs which are used as command parameters. The following is an example of the usage of StartElement:
<StartElement>PasswordInfo</StartElement>
In this example, there should be an element named PasswordInfo defined in the DTD file for this message. For example, the DTD file should contain a line such as the following that defines a PasswordInfo element:
<!ELEMENT PasswordInfo (Password, ConfirmPassword)>
TemplateTagName
This part specifies which tag mapping is to be used for the message. The tag mapping is defined elsewhere in the template definition file under the TemplateTag element. This means that the value of the TemplateTagName element should match the name attribute of a TemplateTag element that appears somewhere in the template definition file. Refer to the section on the TemplateTag element for more details. The following example illustrates the use of the TemplateTagName element:
<TemplateTagName>PasswordReset10Map</TemplateTagName>
In this example, the following TemplateTag element should exist elsewhere in the template definition file:
<TemplateTag name='PasswordReset10Map'>
 ...
 </TemplateTag>
The elements between the start and end tags depend on the mapping of the message.
CommandMapping
This element determines which commands are invoked by the message. The element contains one sub-element called Command. The Command element is used to indicate the HCL Commerce controller command that is run when the message is successfully mapped. It contains one mandatory attribute called CommandName, which is used to indicate the name of the command. The value of this attribute must correspond to an existing command that is registered in the Struts configuration files. For example, you could associate a message with the command that resets a password using the following syntax:

<CommandMapping>
     <Command CommandName='ResetPassword'/>
</CommandMapping>
For more information, see customizing the HCL Commerce Struts-based Web application configuration.

You can also associate multiple commands with the same message. To do this, you need to use the following additional attributes of the Command element:

  • Condition attribute: The syntax for condition is as follows ( [] means it is optional, * means it can be repeated):
    fieldName [="fieldValue "] [AND fieldName [="fieldValue "]]*
    fieldName
    fieldName="fieldValue "
    A value in the XML message is set to the field in fieldName. When the message is mapped, if the value is same as fieldValue, the condition is true.
    fieldName1="fieldValue1" AND fieldName1="fieldValue2"
    The values in the XML message are set to the field fieldName1 and fieldName2 when the message is parsed. If the values are same as fieldValue1 and fieldValue2 respectively, then the condition is true.
TemplateTagName attribute
If you specify the TemplateTagName attribute for this Command element, whenever the Condition becomes true, a new tag template with the name defined in TemplateTagName will be used for the rest of the inbound XML message.
Constant Element the list of constants to be put in the TypedProperty for that command.
  • Field: The field name of the name value pair which will be put into the TypedProperty.
  • FieldInfo: See the definition in TemplateTag. The value should be placed between Constant tags.
The following is a simple example of how you could use the multiple Command elements to map to multiple commands:
<CommandMapping>
   <Command CommandName='ResetPassword' Condition='Verb="Reset" AND  Noun="Password"'/>
   <Command CommandName='AdminResetPassword' Condition='Verb="Reset" AND Noun="AdminPassword"'/>
  </CommandMapping>

In this example, you there should be Noun and Verb elements defined in the DTD file for the message.