Formatting addresses and names in the tools

Address and name formatting in the HCL Commerce tools uses XML files to encapsulate the address or name format control information. The XML files hold the address or name control information such as what fields are required, the number of lines that constitute an address or name format, the sequence, and nature of address or name attributes that should be displayed on one line, and so on.


  1. Create an XML file to hold your address format information. For example:
    <line0 elements="nickName"/>
    <line1 elements="title,space,firstName,space,lastName"/>
    <line2 elements="address1,space,address2,space,address3"/>
    <line3 elements="postalCode,space,city"/>
    <line4 elements="region,comma,space,country"/>
    <line5 elements="phoneNumber"/>

    For a sample implementation, see:

    • HCL Commerce Developerworkspace_dir\wc\xml\tools\order\addressFormats.xml
  2. Use the tools framework XMLUtil.get(Hash table tree, String path) to parse your XML file. This method is one of the utility classes to read and write XML files and strings contained in the tools framework. When reading XML files and strings, these parsers convert the XML data into a hash table.
  3. Use the address format control information stored in the hash table created in the previous step to display the formatted address attributes to the end user as shown in the following is an example:
    • HCL Commerce Developerworkspace_dir\CommerceAccelerator\WebContent\tools\order\OrderBillingAddressPage.jsp