具有名称空间的实体在 Edge 和 IE 上不起作用
Entities with namespace not working on Edge and IE
我有一个 XML 文件及其 XSL 转换文件:
simple.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>
<!DOCTYPE simple [
<!ENTITY ie "<expan>id est</expan>">
]>
<text xmlns="http://www.tei-c.org/ns/1.0">
I am happy &ie; I am not upset.
</text>
simple.xsl
:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:n="http://www.tei-c.org/ns/1.0"
>
<xsl:template match="/">
<xsl:apply-templates select="//n:text" />
</xsl:template>
<xsl:template match="n:text">
<html>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="n:expan">
<span style="color: red;"><xsl:apply-templates /></span>
</xsl:template>
</xsl:stylesheet>
当我在 Firefox 上打开 XML 文件时,正确生成了跨度:
但是在 Edge 和 Internet Explorer 上,n:expan
模板没有应用,所以 id est
不在一个跨度内,也没有写成红色:
当我删除命名空间和所有 n:
前缀时,它在 Edge 和 IE 上运行良好。此外,当我删除 ie
实体并直接写入 I am happy <expan>id est</expan> I am not upset.
时,它适用于两种浏览器。
我应该怎么做才能使其同时适用于实体和命名空间?
感谢您的帮助。
显然不同的处理器对 expan
元素属于哪个命名空间有不同的想法。我在自己的测试中看到 Saxon 和 Xalan 将它放在其父 text
的命名空间中,而 libxslt 认为它在无命名空间中。
How should I do to make it work with both entities and namespace?
怎么样:
<xsl:template match="expan | n:expan">
我有一个 XML 文件及其 XSL 转换文件:
simple.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>
<!DOCTYPE simple [
<!ENTITY ie "<expan>id est</expan>">
]>
<text xmlns="http://www.tei-c.org/ns/1.0">
I am happy &ie; I am not upset.
</text>
simple.xsl
:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:n="http://www.tei-c.org/ns/1.0"
>
<xsl:template match="/">
<xsl:apply-templates select="//n:text" />
</xsl:template>
<xsl:template match="n:text">
<html>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="n:expan">
<span style="color: red;"><xsl:apply-templates /></span>
</xsl:template>
</xsl:stylesheet>
当我在 Firefox 上打开 XML 文件时,正确生成了跨度:
但是在 Edge 和 Internet Explorer 上,n:expan
模板没有应用,所以 id est
不在一个跨度内,也没有写成红色:
当我删除命名空间和所有 n:
前缀时,它在 Edge 和 IE 上运行良好。此外,当我删除 ie
实体并直接写入 I am happy <expan>id est</expan> I am not upset.
时,它适用于两种浏览器。
我应该怎么做才能使其同时适用于实体和命名空间?
感谢您的帮助。
显然不同的处理器对 expan
元素属于哪个命名空间有不同的想法。我在自己的测试中看到 Saxon 和 Xalan 将它放在其父 text
的命名空间中,而 libxslt 认为它在无命名空间中。
How should I do to make it work with both entities and namespace?
怎么样:
<xsl:template match="expan | n:expan">