Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Parsing XSLT:output&;引用;没有被解析_Parsing_Xslt_Quotes - Fatal编程技术网

Parsing XSLT:output&;引用;没有被解析

Parsing XSLT:output&;引用;没有被解析,parsing,xslt,quotes,Parsing,Xslt,Quotes,我正在尝试实现以下XML输出: <Foo bar="&quot;" /> 伊恩·罗伯茨(Ian Roberts)已经提出了一个非常好的观点,那就是它实际上并不重要。但如果您真的非常想这样做,那么在XSLT 2.0(而不是XSLT 1.0)中,您可以使用字符映射,如下所示: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:outp

我正在尝试实现以下XML输出:

<Foo bar="&quot;" />

伊恩·罗伯茨(Ian Roberts)已经提出了一个非常好的观点,那就是它实际上并不重要。但如果您真的非常想这样做,那么在XSLT 2.0(而不是XSLT 1.0)中,您可以使用字符映射,如下所示:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="xml" use-character-maps="quotes" />

    <xsl:character-map name="quotes">
        <xsl:output-character character="&quot;" string="&amp;quot;" />
    </xsl:character-map>

    <xsl:template match="/">
        <xsl:variable name="quote">
            <xsl:text>&quot;</xsl:text>
        </xsl:variable>

        <Foo bar="{$quote}"/>
    </xsl:template>
</xsl:stylesheet>


为什么这很重要?这两者是等价的(还有其他各种等价的方式来表达相同的内容,例如
),XML解析器不会告诉应用程序它是以何种方式在源代码中编写的,应用程序只会看到一个值为双引号字符的属性。你说得很好。我的目标是以一种特定的格式输出XML—以匹配Microsoft Excel似乎想要的格式,但您是对的,Excel正确解析文件,即使";使用。谢谢!
<Foo bar="&#34;"/>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="xml" use-character-maps="quotes" />

    <xsl:character-map name="quotes">
        <xsl:output-character character="&quot;" string="&amp;quot;" />
    </xsl:character-map>

    <xsl:template match="/">
        <xsl:variable name="quote">
            <xsl:text>&quot;</xsl:text>
        </xsl:variable>

        <Foo bar="{$quote}"/>
    </xsl:template>
</xsl:stylesheet>