在XSLT流程(使用saxon9he)的html输出文件中,已经出现155次xmlns:fn =“ http://www.w3.org/2005/xpath-functions”插入到各种tr元素中
xsl使用xpath-functions的部分是
<xsl:if test="(string(@hideIfHardwareIs)='') or (not(fn:matches(string($input_doc//inf[@id='5'), string(@hideIfHardwareIs), 'i')))">
除非我读错了,否则matchs接受3个参数,一个字符串,另一个字符串以及一个标志,在这种情况下,这不区分大小写。
我不难理解的是,tr元素与xmlns arent一起显示在接近matchs()函数完成的部分或xsl处。
我正在使用的XSL文件是2100行,而它解析的XML文件是12800行。所以我认为我不能轻易分享它。我已经继承了它,并且需要(目前)对其进行维护。
我可以在XSL中寻找什么,将xmlns插入html输出中?
最佳答案
这些功能不需要前缀。
从xmlns:fn="http://www.w3.org/2005/xpath-functions"
中删除xsl:stylesheet
,并从xpath函数中删除fn:
前缀。
例子:
XML输入
<foo>test</foo>
XSLT 2.0#1
<xsl:stylesheet version="2.0" xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/*">
<xsl:if test="fn:matches(.,'^t')">
<bar><xsl:value-of select="."/></bar>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
输出量
<bar xmlns:fn="http://www.w3.org/2005/xpath-functions">test</bar>
XSLT 2.0#2
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/*">
<xsl:if test="matches(.,'^t')">
<bar><xsl:value-of select="."/></bar>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
输出量
<bar>test</bar>
关于html - 为什么我的HTML输出中有xmlns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19802095/