XSL模板不匹配

时间:2020-05-10 02:33:47

标签: xml xslt

我在目录中有以下XML,并具有所需的实体文件:

<!DOCTYPE refentry [ <!ENTITY % mathent SYSTEM "math.ent"> %mathent; ]>

<!-- Converted by db4-upgrade version 1.1 -->

<refentry xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="glBlendEquation">
    <info>
        <copyright>
            <year>1991-2006</year>
            <holder>Silicon Graphics, Inc.</holder>
        </copyright>
        <copyright>
            <year>2010-2014</year>
            <holder>Khronos Group</holder>
        </copyright>
    </info>
    <refmeta>
        <refentrytitle>glBlendEquation</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glBlendEquation</refname>
        <refpurpose>specify the equation used for both the RGB blend equation and the Alpha blend equation</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glBlendEquation</function></funcdef>
                <paramdef>GLenum <parameter>mode</parameter></paramdef>
            </funcprototype>
            <funcprototype>
                <funcdef>void <function>glBlendEquationi</function></funcdef>
                <paramdef>GLuint <parameter>buf</parameter></paramdef>
                <paramdef>GLenum <parameter>mode</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
</refentry>

我正在应用以下XSL:

<?xml version="1.0"?>

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  xmlns:fns="http://www.w3.org/2002/Math/preference"
  xmlns:mml="http://www.w3.org/1998/Math/MathML"
  extension-element-prefixes="msxsl fns doc"
  xmlns:h="http://www.w3.org/1999/xhtml"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:doc="http://www.dcarlisle.demon.co.uk/xsldoc"
  xmlns:ie5="http://www.w3.org/TR/WD-xsl"
  exclude-result-prefixes="h ie5 fns msxsl fns doc mml"
>

<xsl:template match="refpurpose">
    <xsl:value-of select="." />
</xsl:template>

<xsl:template match="/">
{
<xsl:apply-templates select="refnamediv/refpurpose" />
}
</xsl:template>

</xsl:stylesheet>

我希望输出为:

<?xml version="1.0"?>

{
specify the equation used for both the RGB blend equation and the Alpha blend equation
}

但是我得到的输出是:

<?xml version="1.0"?>

{

}

为什么我的“ refpurpose”模板不匹配?我正在使用xsltproc。

1 个答案:

答案 0 :(得分:0)

您必须考虑默认名称空间。

添加

xmlns:db="http://docbook.org/ns/docbook"

xsl:stylesheet,并在默认名称空间中的所有元素之前使用已定义的名称空间前缀:db:refpurposedb:refnamediv

相关问题