title: How do I get each office to print on a seperate page using XSLT?
body: <p>I have the below xml and xslt. </p>
  
  <p>All the data in the xml file prints on a single page.</p>
  
  <p>Each office has personnel and fax machines associated with them.</p>
  
  <p>I want each office (Office One, Office Two and Office Three) along with their associated personnel and faxes to each print on separate pages.</p>
  
  <p>Thanks in advance for any help.</p>
  
  <p>personnel_roster.xml</p>
  
  <pre><code>&lt;?xml version = "1.0"?&gt;
  &lt;?xml-stylesheet type = "text/xsl" href = "personnel_roster.xslt"?&gt;
  &lt;rows appMode="{appmode}" dateGenerated="11/05/2018"&gt;
    &lt;row OfficeID="32" OfficeOutputOrder="1" Office="O1" OfficeTitle="Office One" RoomFaxID="88" RoomFaxNumber="(555) 555-1212" RoomNumberID="120"&gt;
      &lt;personnel&gt;
        &lt;person PersonnelID="360" Name="Employee Supervisor" PositionRoomNumberID="120" phone="(555) 637-5770" PAETitle="Dir, Head Office" PositionEmployeeTypeID="C" PositionOutputOrder="1" /&gt;
        &lt;person PersonnelID="850" Name="Employee One" PositionRoomNumberID="120" phone="(555) 694-7191" PAETitle="Principal Deputy Director" PositionEmployeeTypeID="C" PositionOutputOrder="2" /&gt;
        &lt;person PersonnelID="669" Name="Employee Two" PositionRoomNumberID="120" phone="(555) 554-0199" PAETitle="Senior Assistant" PositionEmployeeTypeID="M" PositionOutputOrder="11" /&gt;
        &lt;person PersonnelID="417" Name="Employee Three" PositionRoomNumberID="125" phone="(555) 336-4242" PAETitle="Special Assistant" PositionEmployeeTypeID="C" PositionOutputOrder="21" /&gt;
        &lt;person PersonnelID="470" Name="Employee Four" PositionRoomNumberID="125" phone="(555) 587-9046" PositionEmployeeTypeID="C" PositionOutputOrder="21" /&gt;
        &lt;person PersonnelID="474" Name="Employee Five" PositionRoomNumberID="125" phone="(555) 2270-8654" PAETitle="Special Assistant to the Director" PositionEmployeeTypeID="C" PositionOutputOrder="22" /&gt;
      &lt;/personnel&gt;
      &lt;officeFaxes&gt;
        &lt;fax RoomNumberID="120" RoomFaxNumber="(555) 614-8413" OfficeID="32" /&gt;
      &lt;/officeFaxes&gt;
    &lt;/row&gt;
    &lt;row OfficeID="82" OfficeOutputOrder="5" Office="O2" OfficeTitle="Office Two" RoomFaxID="94" RoomFaxNumber="(555) 555-1213" RoomNumberID="121"&gt;
      &lt;personnel&gt;
        &lt;person PersonnelID="582" Name="Employee Supervisor" PositionRoomNumberID="121" phone="(555) 693-7828" PAETitle="Director (O2)" PositionEmployeeTypeID="C" PositionOutputOrder="4" /&gt;
        &lt;person PersonnelID="398" Name="Employee One" PositionRoomNumberID="126" phone="(555) 372-4329" PAETitle="T  Specialist" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="338" Name="Employee Two" PositionRoomNumberID="121" phone="(555) 693-7825" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="368" Name="Employee Three" PositionRoomNumberID="121" phone="(555) 693-2086" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="365" Name="Employee Four" PositionRoomNumberID="121" phone="(555) 697-0223" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="375" Name="Employee Five" PositionRoomNumberID="121" phone="(555) 693-4141" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="797" Name="Employee Six" PositionRoomNumberID="121" phone="(555) 614-9271" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="356" Name="Employee Seven" PositionRoomNumberID="121" phone="(555) 697-0361" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="404" Name="Employee Eight" PositionRoomNumberID="126" phone="(555) 372-4331" PAETitle="manager" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
      &lt;/personnel&gt;
      &lt;officeFaxes&gt;
        &lt;fax RoomNumberID="121" RoomFaxNumber="(555) 372-4342" OfficeID="82" /&gt;
        &lt;fax RoomNumberID="121" RoomFaxNumber="(555) 372-4370" OfficeID="82" /&gt;
        &lt;fax RoomNumberID="126" RoomFaxNumber="(555) 614-8413" OfficeID="82" /&gt;
      &lt;/officeFaxes&gt;
    &lt;/row&gt;
    &lt;row OfficeID="76" OfficeOutputOrder="9" Office="O3" OfficeTitle="Office Three"  RoomFaxID="95" RoomFaxNumber="(555) 555-1214" RoomNumberID="122"&gt;
      &lt;personnel&gt;
        &lt;person PersonnelID="763" Name="Employee Supervisor" PositionRoomNumberID="122" phone="(555) 697-9189" PAETitle="Director (O3)" PositionEmployeeTypeID="C" PositionOutputOrder="4" /&gt;
        &lt;person PersonnelID="471" Name="Employee One" PositionRoomNumberID="122" phone="(555) 695-7935" PAETitle="Management and Program Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="439" Name="Employee Two" PositionRoomNumberID="122" phone="(555) 614-3951" PAETitle="administrative Program Specialist" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="446" Name="Employee Three" PositionRoomNumberID="122" phone="(555) 256-0636" PAETitle="Security Specialist" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="456" Name="Employee Four" PositionRoomNumberID="122" phone="(555) 256-0603" PAETitle="Management and Program Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="436" Name="Employee Five" PositionRoomNumberID="122" phone="(555) 695-8225" PAETitle="Talent Management Specialist" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
        &lt;person PersonnelID="729" Name="Employee Six" PositionRoomNumberID="122" phone="(555) 693-3038" PAETitle="Administrative Program Specialist (Facilities)" PositionEmployeeTypeID="C" PositionOutputOrder="20" /&gt;
      &lt;/personnel&gt;
      &lt;officeFaxes&gt;
        &lt;fax RoomNumberID="122" RoomFaxNumber="(555) 256-1412" OfficeID="76" /&gt;
      &lt;/officeFaxes&gt;
    &lt;/row&gt;
  &lt;/rows&gt;
  </code></pre>
  
  <p>personnel_roster.xslt</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"&gt;
  
      &lt;xsl:output method="html" version="1.0" indent="no" omit-xml-declaration="yes" media-type="text/html"/&gt;
  
  
      &lt;xsl:template match="/rows"&gt;
  
          &lt;div class="previewPrintReport"&gt;
              &lt;table id="art_report_output" class="tablesorter-blue execTable" cellpadding="1" cellspacing="0" width="100%" border="0"&gt;
                  &lt;caption style="text-align:center;vertical-align:middle"&gt;&lt;b&gt;REPORT TITLE &lt;/b&gt;
                      &lt;xsl:choose&gt;
                          &lt;xsl:when test="@appMode='prod'"&gt;&lt;/xsl:when&gt;
                          &lt;xsl:otherwise&gt;&amp;#160;(&lt;xsl:value-of select="@appMode"/&gt;)&lt;/xsl:otherwise&gt;
                      &lt;/xsl:choose&gt;
                      generated on &lt;xsl:value-of select="@dateGenerated"/&gt;
                  &lt;/caption&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;th colspan="4" style="text-decoration: underline; text-align: center;"&gt;TELEPHONE ROSTER&lt;/th&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;th colspan="4" style="text-decoration: underline; text-align: center;"&gt;OFFICE OF THE DIRECTOR, COST ASSESSMENT PROGRAM EVALUATION&lt;/th&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;th width="25%"&gt;&amp;#160;&lt;/th&gt;
                          &lt;th width="30%"&gt;&amp;#160;&lt;/th&gt;
                          &lt;th width="15%"&gt;ROOM NO.&lt;/th&gt;
                          &lt;th width="30%"&gt;EXTENSION&lt;/th&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                      &lt;xsl:for-each select="row"&gt;
  
                          &lt;xsl:variable name="officeName" select="@Office"/&gt;
                          &lt;xsl:variable name="officeTitle" select="@OfficeTitle"/&gt;
                          &lt;xsl:variable name="officeFaxRoom" select="@RoomNumberID"/&gt;
                          &lt;xsl:variable name="officeFax" select="@RoomFaxNumber"/&gt;
                          &lt;xsl:variable name ="officeFirst" select="/rows/row[1]/@Office"/&gt;
                          &lt;xsl:variable name ="officeLast" select="/rows/row[last()]/@Office"/&gt;
  
                          &lt;xsl:if test="personnel"&gt;
                              &lt;page&gt;
                              &lt;xsl:element name="tr"&gt;
                                  &lt;td colspan="4"&gt;&lt;hr style="background-color: #000000;" /&gt;&lt;/td&gt;
                              &lt;/xsl:element&gt;
  
                              &lt;xsl:for-each select="personnel/person"&gt;
                                  &lt;xsl:choose&gt;
                                      &lt;xsl:when test="position()=1"&gt;
                                          &lt;!-- Office Manager --&gt;
                                          &lt;xsl:element name="tr"&gt;
                                              &lt;td&gt;Director (&lt;xsl:value-of select="$officeName"/&gt;)&lt;br/&gt;&lt;xsl:value-of select="$officeTitle"/&gt;&lt;/td&gt;
                                              &lt;td&gt;&lt;xsl:value-of select="@Name"/&gt;&lt;/td&gt;
                                              &lt;td&gt;&lt;xsl:value-of select="@PositionRoomNumberID"/&gt;&lt;/td&gt;
                                              &lt;td&gt;&lt;xsl:value-of select="@phone"/&gt;&lt;/td&gt;
                                          &lt;/xsl:element&gt;      
                                      &lt;/xsl:when&gt;
                                      &lt;xsl:otherwise&gt;
                                          &lt;xsl:element name="tr"&gt;
                                              &lt;td&gt;&amp;#160;&lt;/td&gt;
                                              &lt;td&gt;&lt;xsl:value-of select="@Name"/&gt;&lt;/td&gt;
                                              &lt;td&gt;&lt;xsl:value-of select="@PositionRoomNumberID"/&gt;&lt;/td&gt;
                                              &lt;td&gt;&lt;xsl:value-of select="@phone"/&gt;&lt;/td&gt;
                                          &lt;/xsl:element&gt;
                                      &lt;/xsl:otherwise&gt;
                                  &lt;/xsl:choose&gt;
                              &lt;/xsl:for-each&gt;
  
                              &lt;xsl:if test="officeFaxes"&gt;
                                  &lt;xsl:element name="tr"&gt;
                                      &lt;td&gt;&amp;#160;&lt;/td&gt;
                                      &lt;td&gt;&amp;#160;&lt;/td&gt;
                                      &lt;td&gt;&amp;#160;&lt;/td&gt;
                                      &lt;td&gt;&amp;#160;&lt;/td&gt;
                                  &lt;/xsl:element&gt;
  
                                  &lt;xsl:for-each select="officeFaxes/fax"&gt;
                                      &lt;xsl:choose&gt;
                                          &lt;xsl:when test="position()=1 and $officeFax"&gt;
                                              &lt;xsl:element name="tr"&gt;
                                                  &lt;td&gt;&amp;#160;&lt;/td&gt;
                                                  &lt;td&gt;Fax Line:&lt;/td&gt;
                                                  &lt;td&gt;&lt;xsl:value-of select="$officeFaxRoom"/&gt;&lt;/td&gt;
                                                  &lt;td&gt;&lt;xsl:value-of select="$officeFax"/&gt;&lt;/td&gt;
                                              &lt;/xsl:element&gt;                                          
                                              &lt;xsl:element name="tr"&gt;
                                                  &lt;td&gt;&amp;#160;&lt;/td&gt;
                                                  &lt;td&gt;&amp;#160;&lt;/td&gt;
                                                  &lt;td&gt;&lt;xsl:value-of select="@RoomNumberID"/&gt;&lt;/td&gt;
                                                  &lt;td&gt;&lt;xsl:value-of select="@RoomFaxNumber"/&gt;&lt;/td&gt;
                                              &lt;/xsl:element&gt;
                                          &lt;/xsl:when&gt;
                                          &lt;xsl:when test="position()=1"&gt;
                                              &lt;xsl:element name="tr"&gt;
                                                  &lt;td&gt;&amp;#160;&lt;/td&gt;
                                                  &lt;td&gt;Fax Line:&lt;/td&gt;
                                                  &lt;td&gt;&lt;xsl:value-of select="@RoomNumberID"/&gt;&lt;/td&gt;
                                                  &lt;td&gt;&lt;xsl:value-of select="@RoomFaxNumber"/&gt;&lt;/td&gt;
                                              &lt;/xsl:element&gt;                                          
                                          &lt;/xsl:when&gt;
                                          &lt;xsl:otherwise&gt;
                                              &lt;xsl:element name="tr"&gt;
                                                  &lt;td&gt;&amp;#160;&lt;/td&gt;
                                                  &lt;td&gt;&amp;#160;&lt;/td&gt;
                                                  &lt;td&gt;&lt;xsl:value-of select="@RoomNumberID"/&gt;&lt;/td&gt;
                                                  &lt;td&gt;&lt;xsl:value-of select="@RoomFaxNumber"/&gt;&lt;/td&gt;
                                              &lt;/xsl:element&gt;
                                          &lt;/xsl:otherwise&gt;
                                      &lt;/xsl:choose&gt;
                                  &lt;/xsl:for-each&gt;
                              &lt;/xsl:if&gt;
                              &lt;/page&gt;
                              &lt;xsl:if test="$officeName=$officeFirst or $officeName=$officeLast"&gt;
                                  &lt;xsl:element name="tr"&gt;
                                      &lt;td colspan="4" style="text-align: center; padding-top: 10px;"&gt;&lt;span class="importantContactNumber"&gt;*** Call Center Support  555-555-1316 ***&lt;/span&gt;&lt;/td&gt;
                                  &lt;/xsl:element&gt;
                              &lt;/xsl:if&gt;
  
                              &lt;xsl:if test="$officeName=$officeLast"&gt;
                                  &lt;xsl:element name="tr"&gt;
                                      &lt;td colspan="4" style="text-align: center;"&gt;FOOTER FOR LAST OFFICE&lt;/td&gt;
                                  &lt;/xsl:element&gt;
                              &lt;/xsl:if&gt;
  
                          &lt;/xsl:if&gt;                       
                      &lt;/xsl:for-each&gt;
                  &lt;/tbody&gt;
  
              &lt;/table&gt;
          &lt;/div&gt;
      &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>