У меня ниже xml и xslt.
Все данные в XML-файле печатаются на одной странице.
С каждым офисом связан персонал и факсы.
Я хочу, чтобы каждый офис (Office One, Office Two и Office Three) вместе со связанным с ним персоналом и факсами отправлял каждый отпечаток на отдельных страницах.
Заранее спасибо за любую помощь.
personnel_roster.xml
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href = "personnel_roster.xslt"?>
<rows appMode="{appmode}" dateGenerated="11/05/2018">
<row OfficeID="32" OfficeOutputOrder="1" Office="O1" OfficeTitle="Office One" RoomFaxID="88" RoomFaxNumber="(555) 555-1212" RoomNumberID="120">
<personnel>
<person PersonnelID="360" Name="Employee Supervisor" PositionRoomNumberID="120" phone="(555) 637-5770" PAETitle="Dir, Head Office" PositionEmployeeTypeID="C" PositionOutputOrder="1" />
<person PersonnelID="850" Name="Employee One" PositionRoomNumberID="120" phone="(555) 694-7191" PAETitle="Principal Deputy Director" PositionEmployeeTypeID="C" PositionOutputOrder="2" />
<person PersonnelID="669" Name="Employee Two" PositionRoomNumberID="120" phone="(555) 554-0199" PAETitle="Senior Assistant" PositionEmployeeTypeID="M" PositionOutputOrder="11" />
<person PersonnelID="417" Name="Employee Three" PositionRoomNumberID="125" phone="(555) 336-4242" PAETitle="Special Assistant" PositionEmployeeTypeID="C" PositionOutputOrder="21" />
<person PersonnelID="470" Name="Employee Four" PositionRoomNumberID="125" phone="(555) 587-9046" PositionEmployeeTypeID="C" PositionOutputOrder="21" />
<person PersonnelID="474" Name="Employee Five" PositionRoomNumberID="125" phone="(555) 2270-8654" PAETitle="Special Assistant to the Director" PositionEmployeeTypeID="C" PositionOutputOrder="22" />
</personnel>
<officeFaxes>
<fax RoomNumberID="120" RoomFaxNumber="(555) 614-8413" OfficeID="32" />
</officeFaxes>
</row>
<row OfficeID="82" OfficeOutputOrder="5" Office="O2" OfficeTitle="Office Two" RoomFaxID="94" RoomFaxNumber="(555) 555-1213" RoomNumberID="121">
<personnel>
<person PersonnelID="582" Name="Employee Supervisor" PositionRoomNumberID="121" phone="(555) 693-7828" PAETitle="Director (O2)" PositionEmployeeTypeID="C" PositionOutputOrder="4" />
<person PersonnelID="398" Name="Employee One" PositionRoomNumberID="126" phone="(555) 372-4329" PAETitle="T Specialist" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="338" Name="Employee Two" PositionRoomNumberID="121" phone="(555) 693-7825" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="368" Name="Employee Three" PositionRoomNumberID="121" phone="(555) 693-2086" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="365" Name="Employee Four" PositionRoomNumberID="121" phone="(555) 697-0223" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="375" Name="Employee Five" PositionRoomNumberID="121" phone="(555) 693-4141" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="797" Name="Employee Six" PositionRoomNumberID="121" phone="(555) 614-9271" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="356" Name="Employee Seven" PositionRoomNumberID="121" phone="(555) 697-0361" PAETitle="Operations Research Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="404" Name="Employee Eight" PositionRoomNumberID="126" phone="(555) 372-4331" PAETitle="manager" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
</personnel>
<officeFaxes>
<fax RoomNumberID="121" RoomFaxNumber="(555) 372-4342" OfficeID="82" />
<fax RoomNumberID="121" RoomFaxNumber="(555) 372-4370" OfficeID="82" />
<fax RoomNumberID="126" RoomFaxNumber="(555) 614-8413" OfficeID="82" />
</officeFaxes>
</row>
<row OfficeID="76" OfficeOutputOrder="9" Office="O3" OfficeTitle="Office Three" RoomFaxID="95" RoomFaxNumber="(555) 555-1214" RoomNumberID="122">
<personnel>
<person PersonnelID="763" Name="Employee Supervisor" PositionRoomNumberID="122" phone="(555) 697-9189" PAETitle="Director (O3)" PositionEmployeeTypeID="C" PositionOutputOrder="4" />
<person PersonnelID="471" Name="Employee One" PositionRoomNumberID="122" phone="(555) 695-7935" PAETitle="Management and Program Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="439" Name="Employee Two" PositionRoomNumberID="122" phone="(555) 614-3951" PAETitle="administrative Program Specialist" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="446" Name="Employee Three" PositionRoomNumberID="122" phone="(555) 256-0636" PAETitle="Security Specialist" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="456" Name="Employee Four" PositionRoomNumberID="122" phone="(555) 256-0603" PAETitle="Management and Program Analyst" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="436" Name="Employee Five" PositionRoomNumberID="122" phone="(555) 695-8225" PAETitle="Talent Management Specialist" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
<person PersonnelID="729" Name="Employee Six" PositionRoomNumberID="122" phone="(555) 693-3038" PAETitle="Administrative Program Specialist (Facilities)" PositionEmployeeTypeID="C" PositionOutputOrder="20" />
</personnel>
<officeFaxes>
<fax RoomNumberID="122" RoomFaxNumber="(555) 256-1412" OfficeID="76" />
</officeFaxes>
</row>
</rows>
personnel_roster.xslt
<?xml version="1.0" encoding="utf-8"?>
<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">
<xsl:output method="html" version="1.0" indent="no" omit-xml-declaration="yes" media-type="text/html"/>
<xsl:template match="/rows">
<div class="previewPrintReport">
<table id="art_report_output" class="tablesorter-blue execTable" cellpadding="1" cellspacing="0" width="100%" border="0">
<caption style="text-align:center;vertical-align:middle"><b>REPORT TITLE </b>
<xsl:choose>
<xsl:when test="@appMode='prod'"></xsl:when>
<xsl:otherwise> (<xsl:value-of select="@appMode"/>)</xsl:otherwise>
</xsl:choose>
generated on <xsl:value-of select="@dateGenerated"/>
</caption>
<thead>
<tr>
<th colspan="4" style="text-decoration: underline; text-align: center;">TELEPHONE ROSTER</th>
</tr>
<tr>
<th colspan="4" style="text-decoration: underline; text-align: center;">OFFICE OF THE DIRECTOR, COST ASSESSMENT PROGRAM EVALUATION</th>
</tr>
<tr>
<th width="25%"> </th>
<th width="30%"> </th>
<th width="15%">ROOM NO.</th>
<th width="30%">EXTENSION</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="row">
<xsl:variable name="officeName" select="@Office"/>
<xsl:variable name="officeTitle" select="@OfficeTitle"/>
<xsl:variable name="officeFaxRoom" select="@RoomNumberID"/>
<xsl:variable name="officeFax" select="@RoomFaxNumber"/>
<xsl:variable name ="officeFirst" select="/rows/row[1]/@Office"/>
<xsl:variable name ="officeLast" select="/rows/row[last()]/@Office"/>
<xsl:if test="personnel">
<page>
<xsl:element name="tr">
<td colspan="4"><hr style="background-color: #000000;" /></td>
</xsl:element>
<xsl:for-each select="personnel/person">
<xsl:choose>
<xsl:when test="position()=1">
<!-- Office Manager -->
<xsl:element name="tr">
<td>Director (<xsl:value-of select="$officeName"/>)<br/><xsl:value-of select="$officeTitle"/></td>
<td><xsl:value-of select="@Name"/></td>
<td><xsl:value-of select="@PositionRoomNumberID"/></td>
<td><xsl:value-of select="@phone"/></td>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="tr">
<td> </td>
<td><xsl:value-of select="@Name"/></td>
<td><xsl:value-of select="@PositionRoomNumberID"/></td>
<td><xsl:value-of select="@phone"/></td>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:if test="officeFaxes">
<xsl:element name="tr">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</xsl:element>
<xsl:for-each select="officeFaxes/fax">
<xsl:choose>
<xsl:when test="position()=1 and $officeFax">
<xsl:element name="tr">
<td> </td>
<td>Fax Line:</td>
<td><xsl:value-of select="$officeFaxRoom"/></td>
<td><xsl:value-of select="$officeFax"/></td>
</xsl:element>
<xsl:element name="tr">
<td> </td>
<td> </td>
<td><xsl:value-of select="@RoomNumberID"/></td>
<td><xsl:value-of select="@RoomFaxNumber"/></td>
</xsl:element>
</xsl:when>
<xsl:when test="position()=1">
<xsl:element name="tr">
<td> </td>
<td>Fax Line:</td>
<td><xsl:value-of select="@RoomNumberID"/></td>
<td><xsl:value-of select="@RoomFaxNumber"/></td>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="tr">
<td> </td>
<td> </td>
<td><xsl:value-of select="@RoomNumberID"/></td>
<td><xsl:value-of select="@RoomFaxNumber"/></td>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:if>
</page>
<xsl:if test="$officeName=$officeFirst or $officeName=$officeLast">
<xsl:element name="tr">
<td colspan="4" style="text-align: center; padding-top: 10px;"><span class="importantContactNumber">*** Call Center Support 555-555-1316 ***</span></td>
</xsl:element>
</xsl:if>
<xsl:if test="$officeName=$officeLast">
<xsl:element name="tr">
<td colspan="4" style="text-align: center;">FOOTER FOR LAST OFFICE</td>
</xsl:element>
</xsl:if>
</xsl:if>
</xsl:for-each>
</tbody>
</table>
</div>
</xsl:template>
</xsl:stylesheet>