我使用apache和php7生成xml文件并使用xslt文件传递给浏览器以呈现视图。
我注意到浏览器正在两次加载头部的css和javascript文件。
以下是我需要在所有视图中包含的头文件。
header.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- header.xsl -->
<xsl:template match="header">
<!-- content of header -->
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="NOINDEX, NOFOLLOW" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="-1" />
<!-- Bootstrap -->
<link href="/assets/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="/assets/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet" />
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="/assets/jquery/dist/jquery.js"></script>
<script src="/assets/jquery-ui/jquery-ui.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/assets/bootstrap/dist/js/bootstrap.min.js"></script>
<link href="/assets/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
<link href="/assets/datatables/css/dataTables.bootstrap.min.css" rel="stylesheet" />
<script src="/assets/datatables/js/jquery.dataTables.min.js"></script>
<script src="/assets/datatables/js/dataTables.bootstrap.js"></script>
<script src="/assets/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
<script src="/assets/datatables.net-select/js/dataTables.select.min.js"></script>
<xsl:element name="link">
<xsl:attribute name="rel">
stylesheet
</xsl:attribute>
<xsl:attribute name="type">
text/css
</xsl:attribute>
<xsl:attribute name="href">/stylesheets/simple-sidebar.css?<xsl:value-of select="/response/header/timestamp" /></xsl:attribute>
</xsl:element>
<xsl:element name="link">
<xsl:attribute name="rel">
stylesheet
</xsl:attribute>
<xsl:attribute name="type">
text/css
</xsl:attribute>
<xsl:attribute name="href">/stylesheets/ccp.css?<xsl:value-of select="/response/header/timestamp" /></xsl:attribute>
</xsl:element>
<link href="/assets/fancytree/dist/skin-lion/ui.fancytree.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="/images/ccp.ico" />
<!--[if IE]><link rel="shortcut icon" href="images/ccp.ico"/><![endif] --><!-- Internet Explorer -->
<!-- flot -->
<script src="/assets/flot/jquery.flot.js"></script>
<script src="/assets/flot/jquery.flot.time.js"></script>
<script src="/assets/moment/moment.js"></script>
<script type="text/javascript" src="/assets/jquery-depends-on/dependsOn.min.js"></script>
<!-- Include Fancytree skin and library -->
<link href="/assets/fancytree/dist/skin-bootstrap/ui.fancytree.min.css" rel="stylesheet" />
<script src="/assets/fancytree/dist/src/jquery.fancytree.js"></script>
<script src="/assets/fancytree/dist/src/jquery.fancytree.dnd.js"></script>
<script src="/assets/fancytree/dist/src/jquery.fancytree.edit.js"></script>
<xsl:element name="script">
<xsl:attribute name="language">
javascript
</xsl:attribute>
<xsl:attribute name="type">
text/javascript
</xsl:attribute>
<xsl:attribute name="src">/javascripts/api.js?<xsl:value-of select="/response/header/timestamp" /></xsl:attribute>
</xsl:element>
<xsl:element name="script">
<xsl:attribute name="language">
javascript
</xsl:attribute>
<xsl:attribute name="type">
text/javascript
</xsl:attribute>
<xsl:attribute name="src">/javascripts/ccp.js?<xsl:value-of select="/response/header/timestamp" /></xsl:attribute>
</xsl:element>
<xsl:element name="link">
<xsl:attribute name="rel">
stylesheet
</xsl:attribute>
<xsl:attribute name="type">
text/css
</xsl:attribute>
<xsl:attribute name="media">
print
</xsl:attribute>
<xsl:attribute name="href">/stylesheets/print.css?<xsl:value-of select="/response/header/timestamp" /></xsl:attribute>
</xsl:element>
<title>
<xsl:value-of select="/response/header/title" />
- Connectivity Compliance Portal (CCP)
</title>
<xsl:if test="/response/header/server">
<xsl:text disable-output-escaping="yes"><!--</xsl:text> <xsl:value-of select="/response/header/server" /> <xsl:text disable-output-escaping="yes">--></xsl:text>
</xsl:if>
</HEAD>
<div class="container-fluid" id="top_section">
</div>
<!-- Sidebar -->
<div id="sidebar-wrapper" class="hidden-print">
</div>
<!-- /#sidebar-wrapper -->
<!-- Modal -->
<div id="myModalError" class="modal fade" role="dialog">
</div>
</xsl:template>
<xsl:template name="footer">
<FOOTER>
</FOOTER>
</xsl:template>
</xsl:stylesheet>
以下是我正在使用的xsl主文件的示例
user_dcsn.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="header.xsl" />
<xsl:output method="html" encoding="UTF-8"
omit-xml-declaration="yes" doctype-system="about:legacy-compat" indent="no"
media-type="text/html" />
<xsl:template match="/">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="body">
<!-- Page Content -->
<div id="page-content-wrapper">
</div>
<!-- content of other element -->
<xsl:apply-templates select="footer" />
</xsl:template>
</xsl:stylesheet>
XML
这是回应浏览器
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/xslt/user_dcsn.xsl"?>
<response>
<header>
<api_status>1</api_status>
<api_response>success</api_response>
<http_status>200</http_status>
<http_response>ok</http_response>
<format>xml</format>
<csrf>c982afaddd89be70147e788e9f216915</csrf>
<error>false</error>
<quiet>false</quiet>
<token>c982afaddd89be70147e788e9f216915</token>
<user>UddinS2</user>
<title>DC Standard Networks</title>
<description>Displays standard networks which are available for use</description>
<nav>
<container>
<title>Users</title>
<link>#</link>
<theme>#007c92</theme>
<sub_modules>
<title>Getting Started</title>
<link>#</link>
<theme>#007c92</theme>
<menuitem>
<title>File - CM Template v6.3</title>
<link>/library/templates/FW-LB-CommsMatrix-Template-v6.3.xls</link>
</menuitem>
</sub_modules>
</container>
</nav>
<version>7.0</version>
<server>1</server>
<timestamp>1502353988</timestamp>
</header>
<body>
<recordset>
<record>
<id>17218037</id>
<network>x.x.x.x</network>
<routing_domain>x.x.x.x</routing_domain>
<zone_name>Database (D1)</zone_name>
<zone>x.x.x.x</zone>
<seczone>x.x.x.x</seczone>
<netzone>x.x.x.x</netzone>
<loczone>x.x.x.x</loczone>
<location>x.x.x.x</location>
<vlan>x.x.x.x</vlan>
<vrf>x.x.x.x</vrf>
<sw>x.x.x.x</sw>
<dsw>x.x.x.x</dsw>
<lbmode>Not assigned</lbmode>
<utilization>23%</utilization>
<free_ips>47</free_ips>
<source>x.x.x.x</source>
</record>
</recordset>
</body>
</response>
下面的是丝网印刷,您可以在其中看到两次加载的重复来源。它不会一直发生
以下是ccp.js文件的响应/请求标头图片