【发布时间】:2017-05-22 16:38:33
【问题描述】:
我有以下带有内部 XSLT 的 XML。有些模板正在应用,有些没有,我想不出押韵或原因。
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="#style1"?>
<!DOCTYPE dmodule [
<!ELEMENT xsl:stylesheet (#PCDATA)>
<!ATTLIST xsl:stylesheet
id ID #IMPLIED>
]>
<dmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://www.purl.org/dc/elements/1.1/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:nsiv="http://www.pbmassoc.com/nsiv" nsiv:spec-issue="3.0.1">
<?MENTORPATH?>
<?xml-stylesheet type="text/xsl" href="#style1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="style1">
<xsl:template match="/">
<html>
<head>
<title>XML Compare</title>
<style>
table, th, td {
border: 1px solid black;
}
.warning {
color: red;
font-size: 16pt;
font-weight: bold;
}
.caution {
font-size: 14pt;
font-weight:bold;}
</style>
</head>
<body>
<h1>
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/modelic"/>-
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/sdc"/>-
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/chapnum"/>-
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/section"/>
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/subsect"/>-
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/subject"/>-
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/discode"/>
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/discodev"/>-
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/incode"/>
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/incodev"/>-
<xsl:value-of select="dmodule/idstatus/dmaddres/dmc/avee/itemloc"/>:
<xsl:value-of select="dmodule/idstatus/dmaddres/dmtitle/techname"/> -
<xsl:value-of select="dmodule/idstatus/dmaddres/dmtitle/infoname"/>
</h1>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match = "dmodule/content/refs">
<br/>
<table>
<caption>References</caption>
<tr>
<th>Data Module Code</th>
<th>Title</th>
</tr>
<xsl:apply-templates select = "dmodule/content/refs/refdm"/>
</table>
</xsl:template>
<xsl:template match = "dmodule/content/refs/refdm">
<tr>
<td>
<xsl:value-of select="avee/modelic"/>-<xsl:value-of select="avee/sdc"/>-<xsl:value-of select="avee/chapnum"/>-
<xsl:value-of select="avee/section"/><xsl:value-of select="avee/subsect"/>
-<xsl:value-of select="avee/subject"/>-<xsl:value-of select="avee/discode"/><xsl:value-of select="avee/discodev"/>-
<xsl:value-of select="avee/incode"/><xsl:value-of select="avee/incodev"/>
-<xsl:value-of select="avee/itemloc"/>
</td>
<td>
<xsl:value-of select="dmtitle/techname"/> - <xsl:value-of select="dmtitle/infoname"/>
</td>
</tr>
</xsl:template>
<xsl:template match = "dmodule/content/proced/prelreqs/reqconds">
<br/>
<table>
<caption>Pre-Requisites</caption>
<tr>
<th>Data Module Code</th>
<th>Title</th>
</tr>
<xsl:apply-templates select = "dmodule/content/proced/prelreqs/reqconds/reqcondm"/>
</table>
</xsl:template>
<xsl:template match = "dmodule/content/proced/prelreqs/reqconds/reqcondm">
<tr>
<td>
<xsl:value-of select="refdm/avee/modelic"/>-<xsl:value-of select="refdm/avee/sdc"/>-
<xsl:value-of select="refdm/avee/chapnum"/>-<xsl:value-of select="refdm/avee/section"/>
<xsl:value-of select="refdm/avee/subsect"/>-<xsl:value-of select="refdm/avee/subject"/>
-<xsl:value-of select="refdm/avee/discode"/><xsl:value-of select="refdm/avee/discodev"/>-
<xsl:value-of select="refdm/avee/incode"/><xsl:value-of select="refdm/avee/incodev"/>
-<xsl:value-of select="refdm/avee/itemloc"/>
</td>
<td>
<xsl:value-of select = "reqcond"/>
</td>
</tr>
</xsl:template>
<xsl:template match = "dmodule/content/proced/prelreqs/supequip">
<br/>
<table>
<caption>Support Equipment</caption>
<tr>
<th>Nomenclature</th>
<th>Manufacturer Code</th>
<th>Part Number</th>
</tr>
<xsl:apply-templates select = "dmodule/content/proced/prelreqs/supequip/supeqli/supequi"/>
<xsl:apply-templates select = "dmodule/content/proced/prelreqs/supequip/nosupeq"/>
<xsl:if test = "not(dmodule/content/proced/prelreqs/supequip)">
<tr>
<td colspan = "3">No Support Equipment</td>
</tr>
</xsl:if>
</table>
</xsl:template>
<xsl:template match = "dmodule/content/proced/prelreqs/supequip/supeqli/supequi">
<tr>
<td><xsl:value-of select = "nomen"/></td>
<td><xsl:value-of select = "identno/mfc"/></td>
<td><xsl:value-of select = "identno/pnr"/></td>
</tr>
</xsl:template>
<xsl:template match = "dmodule/content/proced/prelreqs/supequip/nosupeq">
<tr>
<td colspan = "3">No Support Equipment</td>
</tr>
</xsl:template>
<xsl:template match = "dmodule/content/proced/prelreqs/supplies">
<br/>
<table>
<caption>Consumables</caption>
<tr>
<th>Nomenclature</th>
<th>Manufacturer Code</th>
<th>Part Number</th>
</tr>
<xsl:apply-templates select = "dmodule/content/proced/prelreqs/supplies/supplyli/supply"/>
<xsl:apply-templates select = "dmodule/content/proced/prelreqs/supplies/nosupply"/>
<xsl:if test = "not(dmodule/content/proced/prelreqs/supplies)">
<tr>
<td colspan = "3">No Consumables</td>
</tr>
</xsl:if>
</table>
</xsl:template>
<xsl:template match = "xsl:stylesheet"/>
<xsl:template match = "dmodule/content/proced/prelreqs/supplies/supplyli/supply">
<tr>
<td><xsl:value-of select = "nomen"/></td>
<td><xsl:value-of select = "identno/mfc"/></td>
<td><xsl:value-of select = "identno/pnr"/></td>
</tr>
</xsl:template>
<xsl:template match = "dmodule/content/proced/prelreqs/supplies/nosupply">
<tr>
<td colspan = "3">No Consumables</td>
</tr>
</xsl:template>
<xsl:template match = "dmodule/content/proced/prelreqs/spares">
<br/>
<table>
<caption>Spares</caption>
<tr>
<th>Nomenclature</th>
<th>Manufacturer Code</th>
<th>Part Number</th>
</tr>
<xsl:apply-templates select = "dmodule/content/proced/prelreqs/spares/sparesli/spare"/>
<xsl:apply-templates select = "dmodule/content/proced/prelreqs/spares/nospares"/>
<xsl:if test = "not(dmodule/content/proced/prelreqs/supplies)">
<tr>
<td colspan = "3">No Spares</td>
</tr>
</xsl:if>
</table>
</xsl:template>
<xsl:template match = "dmodule/content/proced/prelreqs/spares/sparesli/spare">
<tr>
<td><xsl:value-of select = "nomen"/></td>
<td><xsl:value-of select = "identno/mfc"/></td>
<td><xsl:value-of select = "identno/pnr"/></td>
</tr>
</xsl:template>
<xsl:template match = "dmodule/content/proced/prelreqs/safety">
<br/>
<h2>Safety</h2>
<xsl:apply-templates select = "warning"/>
<xsl:apply-templates select = "caution"/>
<xsl:apply-templates select = "note"/>
</xsl:template>
<xsl:template match = "warning">
<p class = "warning">WARNING</p>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match = "para">
<p><xsl:value-of select = "."/></p>
</xsl:template>
<xsl:template match = "caution">
<p clas = "caution">Caution</p>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match = "note">
<p class = "note">Note</p>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match = "dmodule/content/proced/mainfunc">
<h2>Procedure</h2>
<ol>
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template match = "dmodule/content/proced/mainfunc/step1">
<li><xsl:value-of select = "para"/></li>
</xsl:template>
<xsl:template match = "idstatus"/>
<xsl:template match = "closereqs">
<br/>
<table>
<caption>Close-Up Requirements</caption>
<tr>
<th>Data Module</th>
<th>Requirement</th>
</tr>
<xsl:apply-templates select = "reqconds"/>
<xsl:choose>
<xsl:when test = "not(dmodule/content/proced/closereqs)">
<tr>
<td colspan = "2">No Close-Up Requirements</td>
</tr>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select = "noconds"/>
</xsl:otherwise>
</xsl:choose>
</table>
</xsl:template>
<xsl:template match = "noconds">
<tr>
<td colspan = "2">No Close-Up Requirements</td>
</tr>
</xsl:template>
<xsl:output method="html"/>
</xsl:stylesheet>
<idstatus>
<dmaddres>
<dmc>
<avee>
<modelic>XYZ</modelic>
<sdc>AA</sdc>
<chapnum>01</chapnum>
<section>3</section>
<subsect>4</subsect>
<subject>11</subject>
<discode>02</discode>
<discodev>A</discodev>
<incode>520</incode>
<incodev>A</incodev>
<itemloc>A</itemloc>
</avee>
</dmc>
<dmtitle>
<techname>XYZ Device</techname>
<infoname>Removal</infoname>
</dmtitle>
<issno inwork="11" issno="000" type="new"/>
<issdate day="05" month="22" year="2009"/>
<language country="US" language="en"/>
</dmaddres>
<status>
<rpc rpcname="Acme">1234</rpc>
<orig>1234</orig>
<applic>
<displaytext>ALL</displaytext>
</applic>
<brexref>
<refdm>
<avee>
<modelic>XYZ</modelic>
<sdc>AA</sdc>
<chapnum>05</chapnum>
<section>0</section>
<subsect>2</subsect>
<subject>20</subject>
<discode>35</discode>
<discodev>A</discodev>
<incode>015</incode>
<incodev>A</incodev>
<itemloc>C</itemloc>
</avee>
</refdm>
</brexref>
<qa>
<firstver type="tabtop"/>
<secver type="tabtop"/>
</qa>
<remarks>
<p>Ref Designator: </p>
</remarks>
</status>
</idstatus>
<content>
<refs>
<refdm>
<avee>
<modelic>XYZ</modelic>
<sdc>AA</sdc>
<chapnum>01</chapnum>
<section>1</section>
<subsect>1</subsect>
<subject>10</subject>
<discode>10</discode>
<discodev>A</discodev>
<incode>100</incode>
<incodev>A</incodev>
<itemloc>C</itemloc>
</avee>
<dmtitle>
<techname>Pre-Maintenance Checklist</techname>
<infoname>Pre-Operation</infoname>
</dmtitle>
</refdm>
<reftp>
<pubcode>XYZ-7</pubcode>
<pubtitle>Installation and Repair Practices </pubtitle>
</reftp>
</refs>
<proced>
<prelreqs>
<reqconds>
<reqcondm>
<reqcond>Pre-Maintenance Checklist</reqcond>
<refdm>
<avee>
<modelic>XYZ</modelic>
<sdc>AA</sdc>
<chapnum>01</chapnum>
<section>1</section>
<subsect>1</subsect>
<subject>10</subject>
<discode>10</discode>
<discodev>A</discodev>
<incode>100</incode>
<incodev>A</incodev>
<itemloc>C</itemloc>
</avee>
<dmtitle>
<techname>Pre-Maintenance Checklist</techname>
<infoname>Pre-Operation</infoname>
</dmtitle>
</refdm>
</reqcondm>
</reqconds>
<reqpers>
<person man="2"/>
</reqpers>
<supequip>
<supeqli>
<supequi>
<nomen>Lift</nomen>
<identno>
<mfc>123</mfc>
<pnr id="d6791e219" nsiv:sfield="pnr pnrsupeq">301–781</pnr>
</identno>
<qty>1</qty>
</supequi>
<supequi>
<nomen>Screwdriver</nomen>
<identno>
<mfc>113</mfc>
<pnr id="d6791e229" nsiv:sfield="pnr pnrsupeq">01534343</pnr>
</identno>
<qty>1</qty>
</supequi>
</supeqli>
</supequip>
<supplies>
<nosupply/>
</supplies>
<spares>
<nospares/>
</spares>
<safety>
<safecond>
<warning><para>Heavy lift involved.</para></warning>
</safecond>
</safety>
</prelreqs>
<mainfunc>
<step1>
<para>Disconnect the thing from the other thing.</para>
</step1>
<step1>
<para>Remove nut (u), lock washer (v), and four flat washers (w).</para>
</step1>
<step1>
<para>Loosen fasteners (x).</para>
</step1>
<step1>
<warning>
<para>Two people shall support component when handling component. Failure to comply
could result in personnel injury and damage to equipment.</para>
</warning>
<para>Lift and remove the heavy thing.</para>
</step1>
</mainfunc>
<closereqs>
<reqconds>
<noconds/>
</reqconds>
</closereqs>
</proced>
</content>
</dmodule>
我在 Chrome 中得到的输出如下所示:
XYZ- AA- 01- 34- 11- 02A- 520A- A:XYZ 设备 - 拆卸
参考资料 数据模块代码标题
先决条件 数据模块代码标题
支持设备 命名法 制造商代码 部件号 没有支持设备
消耗品 命名法 制造商代码 部件号 无消耗品
备件命名法制造商代码部件号 无备件
安全 程序 1. 将事物与其他事物断开。 2. 拆下螺母 (u)、锁紧垫圈 (v) 和四个平垫圈 (w)。 3. 松开紧固件 (x)。 4. 提起并移除重物。
特写要求 数据模块要求 无特写要求
不符合我预期的项目是支持设备(“supequi”元素)、警告(“warning”元素)、引用(“refdm”元素)和所需条件(“ reqcondm”元素)。
【问题讨论】:
-
您确定带有
<xsl:applytemplates select = "dmodule/content/proced/prelreqs/supequip/nosupeq"/>行的样式表完全可以编译吗? -
确实如此,但我还是修复了错误。也许 Chrome 只是忽略了它?