<?xml version="1.0" encoding="UTF-8"?>
<data>
<employees>
<employee>
<id>100</id>
<name>John Smith</name>
</employee>
<employee>
<id>101</id>
<name>Jane Doe</name>
</employee>
</employees>
<departments>
<department>
<id>10</id>
<name>HR</name>
</department>
<department>
<id>20</id>
<name>IT</name>
</department>
</departments>
</data>
<?template:subtemplate?>
List of Employees:
------------------
<?for-each:/data/employees/employee?><?xdofx:$_XDOCTX->set_variable('emp_id',id)?><?xdofx:$_XDOCTX->set_variable('emp_name',name)?>
Employee ID: <?$emp_id?>
Employee Name: <?$emp_name?>
<?end for-each?>
Title Page:
-----------
Welcome to the Employee and Department Report
<?xdoxslt:set_variable($_XDOCTX,'subtemplateURL','http://yourserver/subtemplate.rtf')?>
<?xdoxslt:import($_XDOCTX,$subtemplateURL)?>
<?xml-stylesheet type="text/xsl" href="../../xdocore/Templates/TEST_PYF_REP_FORMAT.xsl"?>
<?xdoxslt:set_variable($_XDOCTX,'sheet_num',1)?>
<?xdoxslt:set_variable($_XDOCTX,'sheet_name','Employees')?>
<?xdosheet:<?$sheet_num?>;name=<?$sheet_name?>?>
<?xdoxslt:call-template($_XDOCTX,'subtemplate')?>
<?xdoxslt:set_variable($_XDOCTX,'sheet_num',2)?>
<?xdoxslt:set_variable($_XDOCTX,'sheet_name','Departments')?>
<?xdosheet:<?$sheet_num?>;name=<?$sheet_name?>?>
List of Departments:
---------------------
<?for-each:/data/departments/department?><?xdofx:$_XDOCTX->set_variable('dept_id',id)?><?xdofx:$_XDOCTX->set_variable('dept_name',name)?>
Department ID: <?$dept_id?>
Department Name: <?$dept_name?>
<?end for-each?>
With the above XML data document, subtemplate RTF file, and main template RTF file, the output will have two sheets (Employees and Departments) with the respective information from the XML data.