Definition

The XMLTemplateReceiver uses an XML template file to replicate a specified subelement within the template multiple times into a new XML file while modifying specific elements and attributes within the replicated subelement.  The XMLTemplateReceiver also uses an XML configuration file that defines the element within the template file to replicate and defines a set of tags that are used within the template file as placeholders where generated test data will be inserted during the replication process. 


Parameters

The XMLTemplateReceiver requires that the following parameters are defined:

  • outputPath - Defines the location to store the newly generated XML output file.
  • outputName - Defines the name of the output file.
  • configPath - Defines the location of the configuration file.
  • configName - Defines the name of the configuration file.
  • templatePath - Defines the location of the template file.
  • templateName - Defines the name of the template file.


Configuration File - Example

The following example XML configuration file defines the required information to replicate the XML template file also defined further below:

  • blockElelement - specifies that the item element is the element to be replicated.
  • templateFileName - this is an optional information attribute to let users know which template this configuration file should use. 
  • tags - three tags, @itemId, @quantity, @price and @productId are defined within the item element; any element or attributes having one of these tags, will have its tag replaced by a generated value from a GenRocket Domain containing Attributes matching the names of each tag. 


<template blockElement="item" templateFileName="Shipper1Template.xml">
  <tags>
    <tag name="@itemId"/>
    <tag name="@quantity"/>
    <tag name="@price"/>
    <tag name="@productId"/>
  </tags>
</template>


Temple File - Example

The following is an example template file containing the item element and using the set of tags as placeholders for generated test data.


<shiporder orderid="100001">
  <shipto>
    <name>Acme Co</name>
    <address>123 Road Runner Dr</address>
    <city>Tuson</city>
    <country>USA</country>
  </shipto>
  <items>
    <item>
      <itemNumber>@itemId</itemNumber>
      <productId>@productId</productId>
      <note>Handle with care</note>
      <quantity>@quantity</quantity>
      <price>@price</price>
    </item>
  </items>
  <billTo>
    <name>Acme Co</name>
    <address>123 Road Runner Dr</address>
    <city>Tuson</city>
    <country>USA</country>
  </billTo>
</shiporder>


GenRocket Domain - Example

The following is an example GenRocket Domain containing the set of Attributes to match the tags defined within the XML configuration file.

 

Domain - ShipOrder

  • Attributes 
    • itemId - RangeGen Generator 
      • startRange = 10000000
    • quantity - RandomGen Generator 
      • startRange = 1
      • endRange = 10  
    • price - RandomMoneyGen Generator 
      • startRange = 10.00
      • endRange = 50.00
    • productId - RandomGen 
      • startRange = 10000
      • endRange = 99999

GenRocket Scenario - Example

If the example Scenario were to specify its loopCount equal to 3, then three item elements would be replicated to a new file.  The resulting file will contain the following set of elements (the data values may be different).


<shiporder orderid="100001">
  <shipto>
    <name>Acme Co</name>
    <address>123 Road Runner Dr</address>
    <city>Tuson</city>
    <country>USA</country>
  </shipto>
  <items>
    <item>
      <itemNumber>10000000</itemNumber>
      <productId>10010</productId>
      <note>Handle with care</note>
      <quantity>3</quantity>
      <price>10.95</price>
    </item>
    <item>
      <itemNumber>10000001</itemNumber>
      <productId>88005</productId>
      <note>Handle with care</note>
      <quantity>9</quantity>
      <price>31.50</price>
    </item>
    <item>
      <itemNumber>10000002</itemNumber>
      <productId>23422</productId>
      <note>Handle with care</note>
      <quantity>5</quantity>
      <price>57.35</price>
    </item>
  </items>
  <billTo>
    <name>Acme Co</name>
    <address>123 Road Runner Dr</address>
    <city>Tuson</city>
    <country>USA</country>
  </billTo>
</shiporder>