XSL 浏览器问题
XSL Browser Issue
我可以 运行 在 firefox 中,但不能在 Chrome 或 Safari 中执行。我希望它在所有三个浏览器中 运行
Chrome 版本 - 79.0.3945.130(正式版)(64 位)
运行 open -n -a "Google Chrome" --args --disable-web-security --user-data-dir=$HOME/fakeChromeDir
到 运行 xsl
野生动物园版本 - 13.0.4 (14608.4.9.1.4)
选中禁用本地文件限制和跨源限制
Firefox 版本 - 68.4.2esr(64 位)
设置为 privacy.file_unique_origin;false 和 security.fileuri.strict_origin_policy;false
如果我在 XSL 中替换下面的代码
<xsl:for-each select="*">
<xsl:apply-templates select=".[*/*]"/>
<xsl:apply-templates
select=".[* and not(*/*)][generate-id() = generate-id(key('table-group', concat(generate-id(..), '|', local-name()))[1])]" mode="merge-groups"/>
</xsl:for-each>
和
<xsl:apply-templates select="*[*/*]"/>
<xsl:apply-templates
select="*[* and not(*/*)][generate-id() = generate-id(key('table-group', concat(generate-id(..), '|', local-name()))[1])]" mode="merge-groups"/>
它适用于所有浏览器,但我想保持表格的顺序,如 xml 中那样。所以,我正在使用 for 循环。
我的 XML 文件
<?xml version = '1.0' encoding = 'utf-8'?>
<?xml-stylesheet type="text/xsl" href="transformer.xsl" ?>
<group1>
<item1>val1</item1>
<item2>val2</item2>
<group2>
<item3>val3</item3>
<item4>val4</item4>
<group3>
<item5>val5</item5>
</group3>
</group2>
<group2>
<item3>val6</item3>
<item4>val7</item4>
<group3>
<item5>val8</item5>
</group3>
</group2>
<group4>
<item6>val9</item6>
<item7>val10</item7>
</group4>
<group4>
<item6>val11</item6>
<item7>val12</item7>
</group4>
</group1>
我的 Xsl 文件
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="exsl msxml"
version="1.0">
<xsl:output method="html" indent="yes" version="5" doctype-system="about:legacy-doctype"/>
<xsl:key name="table-group"
match="*[* and not(*/*)]"
use="concat(generate-id(..), '|', local-name())"/>
<xsl:template match="*[*]">
<div>
<h4><xsl:value-of select="local-name()"/></h4>
<table>
<thead>
<tr>
<xsl:apply-templates select="*[not(*)]" mode="header"/>
</tr>
</thead>
<tbody>
<tr>
<xsl:apply-templates select="*[not(*)]"/>
</tr>
</tbody>
</table>
</div>
<xsl:for-each select="*">
<xsl:apply-templates select=".[*/*]"/>
<xsl:apply-templates
select=".[* and not(*/*)][generate-id() = generate-id(key('table-group', concat(generate-id(..), '|', local-name()))[1])]" mode="merge-groups"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="*[not(*)]" mode="header">
<th>
<xsl:value-of select="local-name()"/>
</th>
</xsl:template>
<xsl:template match="*[not(*)]">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
<xsl:template match="*[*]" mode="merge-groups">
<div>
<h4><xsl:value-of select="local-name()"/></h4>
<table>
<thead>
<tr>
<xsl:apply-templates select="*[not(*)]" mode="header"/>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="key('table-group', concat(generate-id(..), '|', local-name()))" mode="row"/>
</tbody>
</table>
</div>
</xsl:template>
<xsl:template match="*" mode="row">
<tr>
<xsl:apply-templates select="*"/>
</tr>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<title>Diagnostic Report</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我认为 XPath 1 有一个限制,即谓词不能应用于缩写形式 .
,但您应该能够将其替换为 self::node()
,因此请使用例如<xsl:apply-templates select="self::node()[*/*]"/>
。对您尝试使用 .[predicate]
.
的其他地方进行相同的更改
我可以 运行 在 firefox 中,但不能在 Chrome 或 Safari 中执行。我希望它在所有三个浏览器中 运行
Chrome 版本 - 79.0.3945.130(正式版)(64 位)
运行 open -n -a "Google Chrome" --args --disable-web-security --user-data-dir=$HOME/fakeChromeDir
到 运行 xsl
野生动物园版本 - 13.0.4 (14608.4.9.1.4) 选中禁用本地文件限制和跨源限制
Firefox 版本 - 68.4.2esr(64 位) 设置为 privacy.file_unique_origin;false 和 security.fileuri.strict_origin_policy;false
如果我在 XSL 中替换下面的代码
<xsl:for-each select="*">
<xsl:apply-templates select=".[*/*]"/>
<xsl:apply-templates
select=".[* and not(*/*)][generate-id() = generate-id(key('table-group', concat(generate-id(..), '|', local-name()))[1])]" mode="merge-groups"/>
</xsl:for-each>
和
<xsl:apply-templates select="*[*/*]"/>
<xsl:apply-templates
select="*[* and not(*/*)][generate-id() = generate-id(key('table-group', concat(generate-id(..), '|', local-name()))[1])]" mode="merge-groups"/>
它适用于所有浏览器,但我想保持表格的顺序,如 xml 中那样。所以,我正在使用 for 循环。
我的 XML 文件
<?xml version = '1.0' encoding = 'utf-8'?>
<?xml-stylesheet type="text/xsl" href="transformer.xsl" ?>
<group1>
<item1>val1</item1>
<item2>val2</item2>
<group2>
<item3>val3</item3>
<item4>val4</item4>
<group3>
<item5>val5</item5>
</group3>
</group2>
<group2>
<item3>val6</item3>
<item4>val7</item4>
<group3>
<item5>val8</item5>
</group3>
</group2>
<group4>
<item6>val9</item6>
<item7>val10</item7>
</group4>
<group4>
<item6>val11</item6>
<item7>val12</item7>
</group4>
</group1>
我的 Xsl 文件
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="exsl msxml"
version="1.0">
<xsl:output method="html" indent="yes" version="5" doctype-system="about:legacy-doctype"/>
<xsl:key name="table-group"
match="*[* and not(*/*)]"
use="concat(generate-id(..), '|', local-name())"/>
<xsl:template match="*[*]">
<div>
<h4><xsl:value-of select="local-name()"/></h4>
<table>
<thead>
<tr>
<xsl:apply-templates select="*[not(*)]" mode="header"/>
</tr>
</thead>
<tbody>
<tr>
<xsl:apply-templates select="*[not(*)]"/>
</tr>
</tbody>
</table>
</div>
<xsl:for-each select="*">
<xsl:apply-templates select=".[*/*]"/>
<xsl:apply-templates
select=".[* and not(*/*)][generate-id() = generate-id(key('table-group', concat(generate-id(..), '|', local-name()))[1])]" mode="merge-groups"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="*[not(*)]" mode="header">
<th>
<xsl:value-of select="local-name()"/>
</th>
</xsl:template>
<xsl:template match="*[not(*)]">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
<xsl:template match="*[*]" mode="merge-groups">
<div>
<h4><xsl:value-of select="local-name()"/></h4>
<table>
<thead>
<tr>
<xsl:apply-templates select="*[not(*)]" mode="header"/>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="key('table-group', concat(generate-id(..), '|', local-name()))" mode="row"/>
</tbody>
</table>
</div>
</xsl:template>
<xsl:template match="*" mode="row">
<tr>
<xsl:apply-templates select="*"/>
</tr>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<title>Diagnostic Report</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我认为 XPath 1 有一个限制,即谓词不能应用于缩写形式 .
,但您应该能够将其替换为 self::node()
,因此请使用例如<xsl:apply-templates select="self::node()[*/*]"/>
。对您尝试使用 .[predicate]
.