为什么我的 XSL 文件不再应用于我的 XML 文件? [英] Why is my XSL file no longer being applied to my XML file?

查看:29
本文介绍了为什么我的 XSL 文件不再应用于我的 XML 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ..\reports 目录中创建 xml 文件它们引用了一个样式表,例如:'.\SurveyRespondentList.xsl'

最新的 Firefox Quantum 68.0(64 位)不接受这一点.
以前的版本已经运行多年
我的报告也适用于 Internet Explorer 11
我的应用程序对所有人开放,多年来我一直使用这种方法来创建和显示数据库查询报告.

所有报告文件都是 file://URL,由我为他们在本地 PC 上使用而创建的程序在本地 PC 上为用户创建.目的是他们可以在大多数网络浏览器中查看他们的报告.这种方法多年来一直很有效(~十年).

我问过 Mozilla/Firefox:

  1. 我多年来使用的简单功能是否一去不复返了?或者将来某个最终的补丁会恢复它吗?

<块引用>

开发人员知道这个补丁给基于 HTML 的帮助文档带来了问题,但他们无法想出一种方法来区分合法的本地链接和潜在的攻击链接.将来,他们可能会提出有一些东西可以让帮助文档再次工作,希望你能从中受益,但它不太可能很快发生."

网络浏览器的趋势是什么?
有人知道另一种方法吗?
例如:是否有一种合理的方法可以将 xslt/css 嵌入到 .xml 数据文件中?

<小时>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fx="#fx-functions" exclude-result-prefixes="msxsl fx"><xsl:output method="html" version="4.0" indent="yes" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/><xsl:template match="//dataroot" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><头><META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8"/><title>MealTimeFoodListReportLIKE</title><style type="text/css">身体{背景颜色:白色;颜色:黑色;字体系列:arial;字体选择策略:自动;字体大小:9pt;字体拉伸:正常;字体大小调整:无;字体样式:正常;字体变体:正常;字体粗细:正常;}</风格><body link="#0000ff" vlink="#800080"><tr><th colspan="2" ><big><big><xsl:value-of select="ReportTitle"/></big></big>&#160;&#160;<小><xsl:value-of select="ReportDate"/></small></th></tr><tr><th>用餐时间</th><th>食物</th></tr><xsl:for-each select="qrMealTimeFoodListReportLIKE"><tr><td align="center"><xsl:value-of select="MealTime"/></td><td align="center"><xsl:value-of select="食物"/></td></tr><!-- 准备组页脚中的任何表达式--></xsl:for-each><!-- 准备组页脚中的任何表达式-->
</html></xsl:模板></xsl:stylesheet>

盒装表:

MealTime 食物清单报告 LIKE 2019-06-14 12:10:19用餐时间食物2018/3/28 下午 2:06:52 巧克力慕斯 - 巧克力慕斯 -2018/5/18 上午 11:45:53 巧克力慕斯 - 巧克力慕斯 -

解决方案

以下是 XSLT 代码嵌入 XML 文档并由 xml-stylesheet 处理指令引用的示例:

]><?xml-stylesheet type='text/xsl' href='#my-sheet'?><datarootgenerated='2019-06-14T12:10:19'><ReportTitle>进餐时间食物清单报告 LIKE</ReportTitle><ReportDate>2019-06-14 12:10:19</ReportDate><reportdatetime>2019 年 6 月 14 日 12:10:19</reportdatetime><qrMealTimeFoodListReportLIKE><MealTime>3/28/2018 2:06:52 PM</MealTime><食物>巧克力慕斯 - 巧克力慕斯 - </食物></qrMealTimeFoodListReportLIKE><qrMealTimeFoodListReportLIKE><MealTime>5/18/2018 11:45:53 AM</MealTime><食物>巧克力慕斯 - 巧克力慕斯 - </食物></qrMealTimeFoodListReportLIKE><xsl:stylesheet id="my-sheet" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fx="#fx-functions" exclude-result-prefixes="msxsl fx"><xsl:output method="html" version="4.0" indent="yes"/><xsl:template match="dataroot"><头><title>MealTimeFoodListReportLIKE</title><style type="text/css">身体{背景颜色:白色;颜色:黑色;字体系列:arial;字体选择策略:自动;字体大小:9pt;字体拉伸:正常;字体大小调整:无;字体样式:正常;字体变体:正常;字体粗细:正常;}</风格><body link="#0000ff" vlink="#800080"><tr><th colspan="2" ><big><big><xsl:value-of select="ReportTitle"/></big></big>&#160;&#160;<小><xsl:value-of select="ReportDate"/></small></th></tr><tr><th>用餐时间</th><th>食物</th></tr><xsl:for-each select="qrMealTimeFoodListReportLIKE"><tr><td align="center"><xsl:value-of select="MealTime"/></td><td align="center"><xsl:value-of select="食物"/></td></tr><!-- 准备组页脚中的任何表达式--></xsl:for-each><!-- 准备组页脚中的任何表达式-->
</html></xsl:模板></xsl:stylesheet></dataroot>

我认为适用于 Firefox 68 和 Chrome 75.

I create xml files in a ..\reports directory They reference a stylesheet e.g.: '.\SurveyRespondentList.xsl'

The most recent Firefox Quantum 68.0 (64-bit) does not accept this.
Previous versions have worked over the years
My reports also work on Internet Explorer 11
My applications are open to all and I have been using this approach to create and display database query reports for years.

ALL of the report files are file:// URLs created for the user on their local PC by the programs I created for their use on their local PC. The intent is they can view their reports in most any web browser. This approach has worked very well for years (~decade).

I asked Mozilla/Firefox:

  1. Is the simple functionality I have used for years gone forever? Or will some eventual future patch restore it?

"The developers are aware that this patch created problems with HTML-based help documentation, but they weren't able to come up with a way to distinguish legitimate local links from potential attack links. In the future, they might come up with something to allow help documentation to work again and hopefully you would be able to benefit from that, but it's not likely to happen soon."

What are the trends in web browsers?
Does anyone know of another approach?
e.g.: Is there a reasonable way to embed the xslt/css within the .xml data file?

<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type='text/xsl' href='.\MealTimeFoodListReportLIKE.xsl'?>
<dataroot generated='2019-06-14T12:10:19'>
    <ReportTitle>MealTime Food List Report LIKE</ReportTitle>
    <ReportDate>2019-06-14  12:10:19</ReportDate>

    <reportdatetime>14 Jun 2019 12:10:19</reportdatetime>

    <qrMealTimeFoodListReportLIKE>
        <MealTime>3/28/2018 2:06:52 PM</MealTime>
        <Food>ChocolateMousse - Chocolate Mousse - </Food>
    </qrMealTimeFoodListReportLIKE>

    <qrMealTimeFoodListReportLIKE>
        <MealTime>5/18/2018 11:45:53 AM</MealTime>
        <Food>ChocolateMousse - Chocolate Mousse - </Food>
    </qrMealTimeFoodListReportLIKE>
</dataroot>


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fx="#fx-functions" exclude-result-prefixes="msxsl fx">
    <xsl:output method="html" version="4.0" indent="yes" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
    <xsl:template match="//dataroot" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <html>
            <head>
                <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8"/>
                <title>MealTimeFoodListReportLIKE</title>
                <style type="text/css">
                body
                {
                    background-color:white;
                    color:black;
                    font-family:arial;
                    font-selection-strategy:auto;
                    font-size:9pt;
                    font-stretch:normal;
                    font-size-adjust:none;
                    font-style:normal;
                    font-variant:normal;
                    font-weight:normal;
                }
                </style>
            </head>
            <body link="#0000ff" vlink="#800080">
                <table BORDER="1" CELLSPACING="0" width="100%">
                <tr><th colspan=" 2" > <big><big><xsl:value-of select="ReportTitle"/> </big></big> &#160; &#160; <small> <xsl:value-of select="ReportDate"/></small></th> </tr>
                            <tr>
     <th>MealTime</th>
     <th>Food</th>
                            </tr>
                    <xsl:for-each select="qrMealTimeFoodListReportLIKE">
                            <tr>
   <td align="center">  <xsl:value-of select="MealTime"/>  </td>
   <td align="center">  <xsl:value-of select="Food"/>  </td>
                            </tr>
                        <!-- Prepare for any expressions in the group footer -->
                    </xsl:for-each><!-- Prepare for any expressions in the group footer -->
                </table>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

boxed table:

MealTime Food List Report LIKE     2019-06-14 12:10:19
MealTime                 Food

3/28/2018 2:06:52 PM    ChocolateMousse - Chocolate Mousse -  
5/18/2018 11:45:53 AM    ChocolateMousse - Chocolate Mousse -

解决方案

Here is your example with the XSLT code embedded in the XML document and referenced by the xml-stylesheet processing instruction:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE dataroot [
  <!ATTLIST xsl:stylesheet
    id ID #IMPLIED>
]>
<?xml-stylesheet type='text/xsl' href='#my-sheet'?>
<dataroot generated='2019-06-14T12:10:19'>
    <ReportTitle>MealTime Food List Report LIKE</ReportTitle>
    <ReportDate>2019-06-14  12:10:19</ReportDate>

    <reportdatetime>14 Jun 2019 12:10:19</reportdatetime>

    <qrMealTimeFoodListReportLIKE>
        <MealTime>3/28/2018 2:06:52 PM</MealTime>
        <Food>ChocolateMousse - Chocolate Mousse - </Food>
    </qrMealTimeFoodListReportLIKE>

    <qrMealTimeFoodListReportLIKE>
        <MealTime>5/18/2018 11:45:53 AM</MealTime>
        <Food>ChocolateMousse - Chocolate Mousse - </Food>
    </qrMealTimeFoodListReportLIKE>

    <xsl:stylesheet id="my-sheet" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fx="#fx-functions" exclude-result-prefixes="msxsl fx">
        <xsl:output method="html" version="4.0" indent="yes" />
        <xsl:template match="dataroot">
            <html>
                <head>
                    <title>MealTimeFoodListReportLIKE</title>
                    <style type="text/css">
                        body
                        {
                        background-color:white;
                        color:black;
                        font-family:arial;
                        font-selection-strategy:auto;
                        font-size:9pt;
                        font-stretch:normal;
                        font-size-adjust:none;
                        font-style:normal;
                        font-variant:normal;
                        font-weight:normal;
                        }
                    </style>
                </head>
                <body link="#0000ff" vlink="#800080">
                    <table BORDER="1" CELLSPACING="0" width="100%">
                        <tr><th colspan=" 2" > <big><big><xsl:value-of select="ReportTitle"/> </big></big> &#160; &#160; <small> <xsl:value-of select="ReportDate"/></small></th> </tr>
                        <tr>
                            <th>MealTime</th>
                            <th>Food</th>
                        </tr>
                        <xsl:for-each select="qrMealTimeFoodListReportLIKE">
                            <tr>
                                <td align="center">  <xsl:value-of select="MealTime"/>  </td>
                                <td align="center">  <xsl:value-of select="Food"/>  </td>
                            </tr>
                            <!-- Prepare for any expressions in the group footer -->
                        </xsl:for-each><!-- Prepare for any expressions in the group footer -->
                    </table>
                </body>
            </html>
        </xsl:template>
    </xsl:stylesheet>
</dataroot>

Works with Firefox 68 and with Chrome 75 too I think.

这篇关于为什么我的 XSL 文件不再应用于我的 XML 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆