我有下面的带有内部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- 520 A- A: XYZ装置-去除 参考数据模块代码标题 数据模块代码标题的先决条件 支持设备名称制造商代码编号无辅助设备 消耗品名称制造商编号:无耗材 备件名称制造商代码编号无备件 安全程序1.断开与另一件东西的连接。2.拆卸螺母(u)、锁紧垫圈(v)及四个平垫圈(w)。3.松开紧固件。4.提起并移除重物。 近距离需求数据模块要求没有特写要求
不像我期望的那样出现的项目是支持设备("supequi“元素)、警告(”警告“元素)、引用("refdm”元素)和所需条件("reqcondm“元素)。
发布于 2017-05-22 16:57:30
我怀疑在像<xsl:template match = "dmodule/content/proced/prelreqs/supequip">这样的地方,您不想使用<xsl:apply-templates select = "dmodule/content/proced/prelreqs/supequip/supeqli/supequi"/>,而是使用相对于匹配元素的路径,比如<xsl:apply-templates select = "supeqli/supequi"/>。
https://stackoverflow.com/questions/44118048
复制相似问题