浏览器上的XSLT处理器不执行转换

我使用Internet上的XSLT处理器将XML文件转换为HTML文件。 它起作用了,但是当我尝试在浏览器上做同样的事情时,将引用myproject添加到XML文件中,这是行不通的。 我尝试使用Firefox,Chrome和Edge,结果是相同的。 这是XML文件:

<?xml-stylesheet type="text/xsl" href="contabilità.xsl"?>

这是XSL文件:

<?xml version="1.0" encoding="UTF-8" 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à>1</quantità>
                <costo>3.3</costo>
                <partecipante>
                    <id>stefano</id>
                </partecipante>
                <partecipante>
                    <id>sergio</id>
                </partecipante>
            </prodotto>
            <prodotto>
                <nome>bresaola</nome>
                <quantità>1</quantità>
                <costo>5.5</costo>
                <partecipante>
                    <id>sergio</id>
                </partecipante>
            </prodotto>
            <prodotto>
                <nome>pasta</nome>
                <quantità>10</quantità>
                <costo>0.5</costo>
                <partecipante>
                    <id>stefano</id>
                </partecipante>
                <partecipante>
                    <id>sergio</id>
                </partecipante>
            </prodotto>
            <prodotto>
                <nome>pane</nome>
                <quantità>3</quantità>
                <costo>1.4</costo>
                <partecipante>
                    <id>stefano</id>
                </partecipante>
                <partecipante>
                    <id>sergio</id>
                </partecipante>
            </prodotto>
            <data>2020-02-10</data>
            <pagato>true</pagato>
        </scontrino>
        <pagamenti>
            <partecipante>
                <id>Stefano</id>
                <quota>-33.0</quota>
            </partecipante>
        </pagamenti>
    </studente>
    <studente>
        <id>stefano</id>
        <nome>stefano</nome>
        <cognome>Silvestri</cognome>
        <scontrino>
            <prodotto>
                <nome>shampoo</nome>
                <quantità>2</quantità>
                <costo>2.3</costo>
                <partecipante>
                    <id>stefano</id>
                </partecipante>
            </prodotto>
            <prodotto>
                <nome>insalata</nome>
                <quantità>4</quantità>
                <costo>0.5</costo>
                <partecipante>
                    <id>stefano</id>
                </partecipante>
                <partecipante>
                    <id>sergio</id>
                </partecipante>
            </prodotto>
            <prodotto>
                <nome>hamburger</nome>
                <quantità>1</quantità>
                <costo>3.6</costo>
                <partecipante>
                    <id>stefano</id>
                </partecipante>
            </prodotto>
            <prodotto>
                <nome>pane</nome>
                <quantità>3</quantità>
                <costo>1.4</costo>
                <partecipante>
                    <id>stefano</id>
                </partecipante>
                <partecipante>
                    <id>sergio</id>
                </partecipante>
            </prodotto>
            <data>2020-03-10</data>
            <pagato>true</pagato>
        </scontrino>
        <pagamenti>
            <partecipante>
                <id>Sergio</id>
                <quota>33.0</quota>
            </partecipante>
        </pagamenti>
    </studente>
</gruppo>

文件位于同一目录中。 我知道如果文件在本地,Chrome会给出错误消息,但对于其他两个文件应该没有任何问题。

hu7405119 回答:浏览器上的XSLT处理器不执行转换

您的XML和XSLT文件都正确。您已经注意到,Chrome无法正常运行。
对于Firefox,此行为已注册as a bug,出于安全方面的考虑,该行为可能无法解决。

但是您可以通过在Firefox中修改[Talk.vue] <template lang="pug"> //display chat list ul li.list(v-for="message in talk" :key="message.id") {{message}} </template> <script lang="ts"> import store from "@/model/vuex/talk.ts" import {getTalk} from "@/domain/talk.ts" @Component export default class Talk extends Vue{ subscription?:Subscription get talks(){ return store.talks } created():void{ this.subscription = getTalk() // <- **here commit talk state implicitly** } destroy():void{ this.subscription.unsubscribe() } } .... 来解决此问题。
设置

about:config

然后,您至少可以在Firefox中将XML与本地XSLT结合使用。
免责声明:我不知道Edge:-(

,

<?xml-stylesheet type="text/xsl" href="contabilità.xsl"?>将通过HTTP(S)运行,而不是通过文件系统运行。这基本上是由于浏览器强加了安全性限制,有些是像很久以前的Chrome一样,有些是像Mozilla一样,只是最近才作为该领域漏洞的修复程序而忽略了文件系统中XSLT的使用,或者如果使用基于Chromium的新版本则忽略了Edge Edge随着浏览器引擎的改变。

本文链接:https://www.f2er.com/2637256.html

大家都在问