首页 > 解决方案 > 为什么模板没有注册?

问题描述

我正在尝试将模板添加到现有的 docbook 系统中,但我不明白整个事情是如何工作的。我想出了如何添加详细日志记录,所以我的简单添加现在生成了大约 250000 行日志输出。我知道语法是正确的,但模板没有添加到系统的其余部分。

这是包含的代码:

?xml version="1.0" encoding="UTF-8"?>

<!-- **********************************************************************

     ********************************************************************** -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:db="http://docbook.org/ns/docbook"
                version='1.0'>


<xsl:template name="mike2">
 Add this text
</xsl:template>
 
<xsl:template match="mike">
  <xsl:call-template name="mike2">
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

这是我在日志中看到的内容:

[xsltproc] xsltCompilePattern : parsing 'mike'
 [xsltproc] xsltCompilePattern : parsed mike, default priority 0.000000
 [xsltproc] added pattern : 'mike' priority 0.000000
 [xsltproc] parsed 2 templates
 [xsltproc] parsed 0 templates
 [xsltproc] Resolving attribute sets references
 [xsltproc] Creating sub-dictionary from stylesheet for transformation
 [xsltproc] Registered 0 modules
:
:
 [xsltproc] Element mike in namespace 'http://docbook.org/ns/docbook' encountered in chapter, but no template matches.

日志显示模板已解析,因此语法正常,但随后显示“已注册 0 个模块”,当它在 *.xml 文件中看到标记时,它会显示“没有模板匹配”。为什么?

谢谢。编辑:xml来源:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter [
<!ENTITY % local_ents SYSTEM "file:///local/entities.ent">
<!ENTITY % product_ents SYSTEM "file:///product/entities.ent">
<!ENTITY % common_ents SYSTEM "file:///common/entities.ent">
<!ENTITY % global_ents SYSTEM "file:///global/entities.ent">
%local_ents;
%product_ents;
%common_ents;
%global_ents;
]>


<chapter xmlns="http://docbook.org/ns/docbook"
  xmlns:xi="http://www.w3.org/2001/XInclude" version="5.0-extension xes-1.0"
  xml:id="Memory">

  <title>Memory</title>
<mike/>
  <para>  This is the

    <emphasis role="red" >&check; &agr; &aacgr;</emphasis>
  </para>

  <para><emphasis role="green">memory section of the report. &check;</emphasis>
</para>


</chapter>

标签: templatesxslt

解决方案


推荐阅读