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:
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:<StartElement>PasswordInfo</StartElement>
<!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:
- 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:
For more information, see customizing the HCL Commerce Struts-based Web application configuration.<CommandMapping> <Command CommandName='ResetPassword'/> </CommandMapping>
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):
fieldNamefieldName [="fieldValue "] [AND fieldName [="fieldValue "]]*
- 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.
- Condition attribute: The syntax for condition is as follows (
[] means it is optional, * means it can be repeated):
- 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.