1

In the html output file from an XSLT process (using saxon9he), there have been 155 occurrences of xmlns:fn="http://www.w3.org/2005/xpath-functions" inserted into a variety of tr elements

The part of xsl that uses xpath-functions is

<xsl:if test="(string(@hideIfHardwareIs)='') or (not(fn:matches(string($input_doc//inf[@id='5'), string(@hideIfHardwareIs), 'i')))">

unless I am reading it wrong, matches takes 3 arguments, a string, another string and then a flag in which case this is case-insensitive.

What I don't undestand is that the tr elements that are showing up with the xmlns arent close to the portion or xsl that the matches() function is done at.

The XSL file I am working with is 2100 lines and the XML file it parses is 12800 lines. So I don't think I can share it easily. I've inherited this and need to (at this time) maintain it.

What are somethings i can look for within the XSL that would insert the xmlns into the html output?

4

1 回答 1

3

这些函数不需要前缀。

xmlns:fn="http://www.w3.org/2005/xpath-functions"从xpath 函数中删除xsl:stylesheet并删除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>
于 2013-11-06T01:51:28.223 回答