Answer Mapping XML

This table contains details of the XML tags used to create an answer mapping XML file, including attributes and child nodes for each tag. A completed Answer Mapping XML example appears at the end of this article.

For more information on Answer Mapping, please see:

XML Tag Details Example

<MappingData>  

The root node. <MappingData>...</MappingData>
  Attributes    Attributes Description
  None     
  Child Nodes Child Node Description
  <DataSource> Contains details of the data source objects to be mapped.
     

<DataSource>  

The DataSource node contains all the information for a specific connection to a data source. It will contain a connection string to the data source and one or more Command objects that define a specific command to run. Answer Mapping XML files may contain multiple Data Sources.   <DataSource ID="1" Name="Northwind" Type="SQL">...</DataSource>
  Attributes Attribute Description
  ID A unique ID number for the Data Source.
  Name A unique text name for the Data Source object.
  Type Must be SQL. SQL is a database to which you can make an Ole DB query.
  Child Nodes Child Node Description
  <ConnectionString> Contains the connection string to the data source.
  <Command> A command object that runs a command to query information from a database and relate it to answers in HotDocs.
     

<ConnectionString>  

The connection string used to access the database. <ConnectionString>provider=SQLNCLI10;user id=sa;password=sa;data source=(local)\SQLEXPRESS;initial catalog=Integration</ConnectionString>  
  Attributes    Attributes Description
  None     
  Child Nodes Child Node Description
  None     
     

<Command>

 

 

  

    

  

  

 

The Command node defines a specific query to the data source, including any filters, and then lists all the columns in the query with the related HotDocs answer name and type. Multiple Commands can exist in a single Answer Mapping XML file. You can make a command a:

  • A Table command — the name of the required table. The processing code will Select all from the table or view specified.
  • A Stored Procedure name
  • An SQL query

You can embed Command nodes for repeated data in HotDocs, or related data in a database. When you are embedding Command nodes, you need to make the filter type Join, to relate to the parent Command using a specific value from its parent. HotDocs only supports up to four levels of repeat, so the mapping will only allow the same and will produce a warning on more than four levels of embedded command objects.

Embedding Command nodes is only supported for the command type Table for an SQL data source.

<Command ID="1" Name="EmployeeSelect" Type="AnswerSource" Refresh="True">...</Command>  
  Attributes Attribute Description
  ID A unique numeric identifier for the Command.
  Name A unique text name for the Command object.
  Type

There are two types of Command:

  • Select — retrieve data from a database before the interview.
  • AnswerSource — use this Command in the Answer Source page. Not used during a read from the database either before or after the interview.
  Refresh [Optional] Either True or False. Causes the Command to re-query the answers upon use (for example, you use a Command earlier that should set an answer required by the current Command). Default value is False if not specified.
  Prompt [AnswerSource types] The prompt text that Workspace shows at the top of the Answer Source pop-up web page.
  Prerequisite  [AnswerSource types] Specifies another Command item that Workspace must show before the current Command. Workspace shows the prerequisite Command and, after selection, the Answer Source page will redirect back to the current Command.
  PrereqAnsName [AnswerSource types] The Answer Name of the prerequisite value Workspace uses for the filter.
  PrereqPrompt  [AnswerSource types] Prompt the prerequisite value shows in the Answer Source.
  Child Nodes Child Node Description
  <Query> Specifies the query for the Command.
  <Filter> Specifies any filters you can apply to the Query.
  <Mapping> Contains a list of the mapping Items.
     
<Query> The Query node specifies a query made to the database. There are three types of queries allowed:
  • Table — a table name to query.
  • Command — a specific Ole DB SQL query. If there are parameters in the query, use "?" as a placeholder for filter values that apply.
  • StoredProcedure — the name of a stored procedure. If there are required parameters, you must create it as a filter Item (see below).

The inner text of the node contains the query information, whether a Table, a Stored Procedure name, or the query text.

<Query Type="Table">Employee</Query>
  Attributes Attribute Description
  Type One of the three types described above: Table; Command or StoredProcedure.
  Child Nodes Child Node Description
  None     
     
<Filter> Contains one or more <Item> nodes that define filters for the Command object.  
  Attributes Attribute Description
  None     
  Child Nodes Child Node Description
  <Item> A specific Item to apply in the filter.
     
<Item>
 (Filter)

Defines a specific Filter Item Workspace will apply when it executes the query. The Column attribute specifies the database column on which to perform the query. After Workspace retrieves the data, it writes it to the Answer File according to the specified Answer Name and Answer Type attributes. There are two Filter Item types:

  • Answer — retrieves a value from the current set of answer values. Answer filters can define a DefaultValue attribute for a value that Workspace uses when the answer doesn't exist.
  • TableJoin — embeds a Filter Item within another Filter Item. This should never be specified for a top-level Filter node. When using TableJoin, you must specify the Column and ParentColumn attributes (see below).
<Item Name="FullName" Type="Answer" AnswerName="Employee Name" AnswerType="1" Column="FullName" DefaultValue="Andrew Seaton"></Item>
  Attributes Attribute Description
  Name A unique text name for the Filter Item object.
  Type One of the three answer types: User; Answer; or TableJoin.
  AnswerName An answer name in HotDocs used to query the data source. If the Filter Item Type is User, this is the answer name to which Workspace writes the user-input value.
  AnsType

A numeric value specifying the type of the variable in the AnswerName attribute.

  • 1 (Text)
  • 2 (Number)
  • 3 (Date)
  • 5 (True / False)
  • 6 (Multiple Choice)
  PrimaryKey Either True or False. Specifies if the Column being queried is the Primary Key of the table.
  Display Either True or False. Determines whether Workspace displays the item in the Answer Source window.
  Column The name of the column in the database you want to query.
  DefaultValue The default value to use for the Filter Item, if no value is found.
  Child Nodes Child Node Description
  None     
     
<Mapping> This contains a list of Mapping Item nodes that define the relationship between Mapping Items from the data source and HotDocs answers.  
  Attributes Attribute Description
  None     
  Child Nodes Child Node Description
  Item Defines a specific Item Mapping, i.e. a relationship between a column/field in the data source and a HotDocs answer.
     
<Item> (Mapping) The mapping Item node defines a specific relationship between the field/column name in the data source and a HotDocs Answer. The FieldName, AnsName, and AnsType must always be provided. Workspace provides additional attributes to allow for proper display in answer sources.     
  Attributes Attribute Description
  FieldName The field/column name in the data source.
  AnsName The answer name in HotDocs to relate to the data source field/column.
  AnsType

A numeric value specifying the type of the variable in the AnsName attribute.

  • 1 (Text)
  • 2 (Number)
  • 3 (Date)
  • 5 (True / False)
  • 6 (Multiple Choice)
  PrimaryKey Either True or False. Specifies if the column/field being mapped is the Primary Key of the table.
  Prompt [Optional] The text to display in the column header for the Item when using an Answer Mapping Command.
  Display  [Optional] Either True or False. Display the column in the selection list for the Answer Mapping. Default value is False if not specified.
  Child Nodes   Child Node Description
  None     
     

Example

<?xml version="1.0" encoding="utf-8" ?>

 

<MappingData>  

<DataSource ID="1" Name="Northwind" Type="SQL">

 

<ConnectionString>provider=SQLNCLI10;user id=sa;password=sa;data source=(local)\SQLEXPRESS;initial catalog=Integration</ConnectionString>

    

<Command ID="1" Name="EmployeeSelect" Type="AnswerSource">

<Query Type="Table">Employee</Query>

<Filter></Filter>

<Mapping>

<Item FieldName="FullName" AnsName="Employee Name"  AnsType="1" PrimaryKey="True" Display="false" Prompt="Name"></Item>

<Item FieldName="Gender" AnsName="Employee Gender"  AnsType="6" PrimaryKey="False" Display="false" Prompt="Gender"></Item>

<Item FieldName="FirstName" AnsName="" AnsType="1" PrimaryKey="False" Display="true" Prompt="Firstname(s)"></Item>

<Item FieldName="Surname" AnsName="" AnsType="1" PrimaryKey="False" Display="true" Prompt="Surname"></Item>

</Mapping>

</Command>

 

<Command ID="2" Name="PickAndy" Type="Select" Refresh="True">

<Query Type="Table">Employee</Query>

<Filter>

<Item Name="FullName" Type="Answer" AnswerName="Employee Name" AnswerType="1" Column="FullName" DefaultValue="Andrew Seaton"></Item>

</Filter>

<Mapping>

<Item FieldName="FullName" AnsName="Employee Name"  AnsType="1" PrimaryKey="True" Display="false" Prompt="Name"></Item>

<Item FieldName="Gender" AnsName="Employee Gender"  AnsType="6" PrimaryKey="False" Display="false" Prompt="Gender"></Item>

<Item FieldName="FirstName" AnsName="" AnsType="1" PrimaryKey="False" Display="true" Prompt="Firstname(s)"></Item>

<Item FieldName="Surname" AnsName="" AnsType="1" PrimaryKey="False" Display="true" Prompt="Surname"></Item>

</Mapping>

</Command>

    

</DataSource>

</MappingData>