浏览器上的XSLT处理器不执行转换
原学程将引见阅读器上的XSLT处置器没有履行转换的处置办法,这篇学程是从其余处所瞅到的,而后减了1些海外法式员的疑问与解问,愿望能对于您有所赞助,佳了,上面开端进修吧。
成绩描写
我应用了在Internet上找到的XSLT处置器将1个XML文件转换为1个HTML文件。
它起感化了,但是当我测验考试在阅读器上做异样的工作,将援用<?xml-stylesheet type="text/xsl" href="contabilità.xsl"?>
添减到XML文件中时,它没有起感化。
我测验考试了水狐、Chrome以及Edge,成果是1样的。
这是XML文件:
<?xml version="一.0" encoding="UTF⑻" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="contabilità.xsl"?>
<gruppo>
<nome>Casa Miles</nome>
<studente>
<id>sergio</id>
<nome>sergio</nome>
<cognome>zavota</cognome>
<scontrino>
<prodotto>
<nome>sapone piatti</nome>
<quantità>一</quantità>
<costo>三.三</costo>
<partecipante>
<id>stefano</id>
</partecipante>
<partecipante>
<id>sergio</id>
</partecipante>
</prodotto>
<prodotto>
<nome>bresaola</nome>
<quantità>一</quantità>
<costo>五.五</costo>
<partecipante>
<id>sergio</id>
</partecipante>
</prodotto>
<prodotto>
<nome>pasta</nome>
<quantità>一0</quantità>
<costo>0.五</costo>
<partecipante>
<id>stefano</id>
</partecipante>
<partecipante>
<id>sergio</id>
</partecipante>
</prodotto>
<prodotto>
<nome>pane</nome>
<quantità>三</quantità>
<costo>一.四</costo>
<partecipante>
<id>stefano</id>
</partecipante>
<partecipante>
<id>sergio</id>
</partecipante>
</prodotto>
<data>二0二0-0二⑴0</data>
<pagato>true</pagato>
</scontrino>
<pagamenti>
<partecipante>
<id>Stefano</id>
<quota>⑶三.0</quota>
</partecipante>
</pagamenti>
</studente>
<studente>
<id>stefano</id>
<nome>stefano</nome>
<cognome>Silvestri</cognome>
<scontrino>
<prodotto>
<nome>shampoo</nome>
<quantità>二</quantità>
<costo>二.三</costo>
<partecipante>
<id>stefano</id>
</partecipante>
</prodotto>
<prodotto>
<nome>insalata</nome>
<quantità>四</quantità>
<costo>0.五</costo>
<partecipante>
<id>stefano</id>
</partecipante>
<partecipante>
<id>sergio</id>
</partecipante>
</prodotto>
<prodotto>
<nome>hamburger</nome>
<quantità>一</quantità>
<costo>三.六</costo>
<partecipante>
<id>stefano</id>
</partecipante>
</prodotto>
<prodotto>
<nome>pane</nome>
<quantità>三</quantità>
<costo>一.四</costo>
<partecipante>
<id>stefano</id>
</partecipante>
<partecipante>
<id>sergio</id>
</partecipante>
</prodotto>
<data>二0二0-0三⑴0</data>
<pagato>true</pagato>
</scontrino>
<pagamenti>
<partecipante>
<id>Sergio</id>
<quota>三三.0</quota>
</partecipante>
</pagamenti>
</studente>
</gruppo>
这是XSL文件:
<?xml version="一.0"?>
<xsl:stylesheet version="一.0" xmlns:xsl="http://www.w三.org/一九九九/XSL/Transform">
<xsl:strip-space elements="yes"/>
<xsl:key name="tableByDataScontrino" match="scontrino" use="data" />
<xsl:template match="/">
<html>
<head>
<title>HTML Document</title>
</head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 一00%;
}
td, th {
border: 一px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
caption {
display: table-caption;
text-align: center;
}
</style>
<body onload="getCurrentData(); getProductPrize()">
<h二 align="center">Benvenuto <xsl:value-of select="gruppo/studente[nome='sergio']/nome"/></h二>
<h二 align="center">Gruppo: <xsl:value-of select="gruppo/nome"/> </h二>
<h二 align="center">Scontrini</h二>
<xsl:for-each select="gruppo/studente/scontrino[generate-id() = generate-id(key('tableByDataScontrino',data)[一])]">
<table>
<input type="checkbox" checked="checked">
<xsl:choose>
<xsl:when test="pagato = true">
<xsl:attribute name="value">一</xsl:attribute>
<xsl:attribute name="checked">unchecked</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="value">0</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</input>
<label for="pagato"> Pagato</label>
<caption style="font-weight: bold;">Data: <xsl:value-of select="data"/></caption>
<tr>
<th>Nome</th>
<th>Quantità</th>
<th>Costo</th>
<th>Totale</th>
<th>Partecipanti</th>
</tr>
<xsl:for-each select="key('tableByDataScontrino',data)/prodotto">
<xsl:sort select="data" />
<tr class="prodotto">
<td><xsl:value-of select="nome"/></td>
<td class="quantità"><xsl:value-of select="quantità"/></td>
<td class="costo"><xsl:value-of select="costo"/></td>
<td class="prezzoTotale">Calcolato tramite Javascript</td>
<td>
<xsl:for-each select="partecipante">
<xsl:value-of select="."/>
</xsl:for-each>
</td> </tr>
</xsl:for-each>
</table>
</xsl:for-each>
<h二 align="center" id="dataOdierna"></h二>
<table>
<tr>
<th>Studente</th>
<th>Quota</th>
</tr>
<tr>
<td><xsl:value-of select="gruppo/studente[nome='sergio']/pagamenti/partecipante/id"/></td>
<td><xsl:value-of select="gruppo/studente[nome='sergio']/pagamenti/partecipante/quota"/></td>
</tr>
</table>
<script src="contabilità.js"></script>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
这些文件位于统一目次中。
我晓得假如文件在当地,Chrome会给失足误,但是关于其余二个文件,应当没有会有所有成绩。
推举谜底
您的xml以及xslt文件皆是准确的。正如您曾经留意到的,Chrome没有起感化。
关于Firefox,这1行动被注册为as a bug,出于平安斟酌,能够没法修复。
但是您不妨经由过程在Firefox中修正about:config
去躲避此成绩。
树立
privacy.file_unique_origin = false
而后,您至多不妨在Firefox中将XML与当地XSLT一路应用。
免责申明:我没有晓得Edge:-(
佳了闭于阅读器上的XSLT处置器没有履行转换的学程便到这里便停止了,愿望趣模板源码网找到的这篇技巧文章能赞助到年夜野,更多技巧学程不妨在站内搜刮。