最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】Docbook中用xsltproc生成HTML过程中出错:runtime error xxx/chunker.xsl line 226 element document, invalid value for indent,xsltRunStylesheet : run failed + 【顺带解决】docbook的xsltproc生成的HTML中Charset的值是空的,不是所设置的UTF-8

Docbook crifan 4824浏览 0评论

【问题】

docbook中,用xsltproc去生成HMTL。之前一切都正常的,没有任何error。

但是默认输出的HTML的源码,是没有缩进indent的,很是乱,所以后来看到这里:Indenting HTML elements,就想要给HTML源码添加缩进indent,然后就去在xsl中添加了设置:

<xsl:param name="chunker.output.indent" select="yes"/>

结果运行出错:

Administrator@K470 /cygdrive/e/Dev_Root/docbook/dev/books/VBR/src
$ make htmls
=============================== generating htmls ==============================
export XML_CATALOG_FILES="/home/develop/docbook/config_root/catalog/catalog.xml" && \
export XML_DEBUG_CATALOG=1 && \
xsltproc --xinclude   -o ../output/html/multi/MPEG_VBR.html chunk_html_crl.xsl MPEG_VBR.xml
Resolve: sysID chunk_html_crl.xsl
536870968 Parsing catalog /home/develop/docbook/config_root/catalog/catalog.xml
/home/develop/docbook/config_root/catalog/catalog.xml added to file hash
Resolve URI chunk_html_crl.xsl
Found URI match chunk_html_crl.xsl
Resolve: pubID crl.ent sysID null
Found public match crl.ent
Writing pr01s02.html for section
runtime error: file /home/develop/docbook/tools_root/docbook-xsl-ns-1.76.1/html/chunker.xsl line 226 element document
invalid value for indent:
...
Writing index.html for book
runtime error: file /home/develop/docbook/tools_root/docbook-xsl-ns-1.76.1/html/chunker.xsl line 226 element document
invalid value for indent:
Writing MPEG_VBR.html.manifest
error: file MPEG_VBR.xml
xsltRunStylesheet : run failed
Catalogs cleanup
...
Makefile:139: recipe for target `../output/html/multi/MPEG_VBR.html' failed
make: *** [../output/html/multi/MPEG_VBR.html] Error 11

【解决过程】

1.先去找到了对应的chunker.xsl文件,找到相关部分的源码:

<xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
  <exsl:document href="{$filename}"
                 method="{$method}"
                 encoding="{$encoding}"
                 indent="{$indent}"
                 omit-xml-declaration="{$omit-xml-declaration}"
                 cdata-section-elements="{$cdata-section-elements}"
                 standalone="{$standalone}">
    <xsl:copy-of select="$content"/>
  </exsl:document>
</xsl:otherwise>

但是还是看不太懂。

2.看了官网的对于此参数的解释:chunker.output.indent,也还是没有任何头绪。

3.怀疑是不是自己的xsl配置文件chunk_crl.xsl中:

<xsl:output method="html"
            encoding="UTF-8"
            indent="no"/>

indent设置为no而导致后面的错误的,所以去试着改为:

<xsl:output method="html"
            encoding="UTF-8"
            indent="yes"/>

结果错误依旧。

4.后来也找到了,上述chunker.xsl相关源码部分的语法:

Element Syntax

<exsl:document

   href = { uri-reference }

   method = { "xml" | "html" | "text" | qname-but-not-ncname }

   version = { nmtoken }

   encoding = { string }

   omit-xml-declaration = { "yes" | "no" }

   standalone = { "yes" | "no" }

   doctype-public = { string }

   doctype-system = { string }

   cdata-section-elements = { qnames }

   indent = { "yes" | "no" }

   media-type = { string }>

   <– Content: template –>

</exsl:document>

但是还是没啥帮助,还是不知道错在哪里。

5.最后,还是无意间,看到chunker.xsl中最开始的部分,有一些相关的配置:

<xsl:param name="chunker.output.method" select="'html'"/>
<xsl:param name="chunker.output.encoding" select="'ISO-8859-1'"/>
<xsl:param name="chunker.output.indent" select="'no'"/>
<xsl:param name="chunker.output.omit-xml-declaration" select="'no'"/>
<xsl:param name="chunker.output.standalone" select="'no'"/>
<xsl:param name="chunker.output.doctype-public" select="''"/>
<xsl:param name="chunker.output.doctype-system" select="''"/>
<xsl:param name="chunker.output.media-type" select="''"/>
<xsl:param name="chunker.output.cdata-section-elements" select="''"/>
<xsl:param name="chunker.output.quiet" select="0"/>

<xsl:param name="saxon.character.representation" select="'entity;decimal'"/>

然后突然间发现,原来其chunker.output.indent的值为’no’,即是用两个单引号引起来的no,而不是单独的no或yes。

所以就去自己的chunk_crl.xsl中试试:

<xsl:param name="chunker.output.indent" select="yes"/>

结果就没了上述错误,可以正常生成html了:

Administrator@K470 /cygdrive/e/Dev_Root/docbook/dev/books/VBR/src
$ make htmls
=============================== generating htmls ==============================
export XML_CATALOG_FILES="/home/develop/docbook/config_root/catalog/catalog.xml" && \
export XML_DEBUG_CATALOG=1 && \
xsltproc --xinclude   -o ../output/html/multi/MPEG_VBR.html chunk_html_crl.xsl MPEG_VBR.xml
Resolve: sysID chunk_html_crl.xsl
536870968 Parsing catalog /home/develop/docbook/config_root/catalog/catalog.xml
/home/develop/docbook/config_root/catalog/catalog.xml added to file hash
Resolve URI chunk_html_crl.xsl
Found URI match chunk_html_crl.xsl
Resolve: pubID crl.ent sysID null
Found public match crl.ent
Writing pr01s02.html for section
Writing preface.html for preface(preface)
Writing ch01s02.html for sect1
Writing ch01s03.html for sect1
Writing ch01s04.html for sect1
Writing ch01s05.html for sect1
Writing ch01_mpeg_related.html for chapter(ch01_mpeg_related)
Writing ch02s02.html for sect1
Writing ch02s03.html for sect1
Writing ch02s04.html for sect1
Writing ch02s05.html for sect1
Writing ch02s06.html for sect1
Writing ch02s07.html for sect1
Writing ch02s08.html for sect1
Writing ch02_mp3_term.xml.html for chapter(ch02_mp3_term.xml)
Writing ch03s02.html for sect1
Writing ch03s03.html for sect1
Writing ch03_mpeg_frame.xml.html for chapter(ch03_mpeg_frame.xml)
Writing ch04s02.html for sect1
Writing ch04_xing_vbri.xml.html for chapter(ch04_xing_vbri.xml)
Writing ch05s02.html for sect1
Writing ch05s03.html for sect1
Writing ch05_calc_duration.xml.html for chapter(ch05_calc_duration.xml)
Writing ch06s02.html for sect1
Writing ch06s03.html for sect1
Writing ch06s04.html for sect1
Writing ch06_mp3_related.xml.html for chapter(ch06_mp3_related.xml)
Writing ch07_after_content.xml.html for chapter(ch07_after_content.xml)
Writing reference.html for bibliography(reference)
Writing index.html for book
Writing MPEG_VBR.html.manifest
Catalogs cleanup
Free catalog entry crl.ent
Free catalog entry /home/develop/docbook/tools_root/docbook-xsl-ns-1.76.1/
Free catalog entry docbook_html.xsl
Free catalog entry docbook_fo.xsl
Free catalog entry /home/develop/docbook/config_root/docbook-xsl-ns-1.76.1/
Free catalog entry docbook_html_crl.xsl
Free catalog entry chunk_html_crl.xsl
Free catalog entry docbook_htmlhelp_crl.xsl
Free catalog entry docbook_fo_crl.xsl
Free catalog entry /home/develop/docbook/config_root/catalog/catalog.xml
Free catalog entry

【总结】

不知道为何此处只有chunker.xsl中的参数配置,都这么变态,参数值的设置,还要用额外的单引号引起来。

即普通参数设置:

<xsl:param name="chunker.output.indent" select="yes"/>

是错误的,而正确的写法是:

<xsl:param name="chunker.output.indent" select="yes"/>

【另外】

顺带解决了之前的就看到的一个问题,即,默认用配置:

<xsl:param name="chunker.output.encoding" select="UTF-8"/>

生成的HTML中,关于charset部分的设置,是不正常的,是空的值:

<meta http-equiv="Content-Type" content="text/html; charset=">

而后来顺带参考了chunker.xsl中的设置:

<xsl:param name="chunker.output.encoding" select="'ISO-8859-1'"/>

去给UTF-8添加两个单引号,变成:

<xsl:param name="chunker.output.encoding" select="'UTF-8'"/>

然后用此配置生成的HTML源码中的编码的值,就是正常的所设置的UTF-8的了:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

转载请注明:在路上 » 【已解决】Docbook中用xsltproc生成HTML过程中出错:runtime error xxx/chunker.xsl line 226 element document, invalid value for indent,xsltRunStylesheet : run failed + 【顺带解决】docbook的xsltproc生成的HTML中Charset的值是空的,不是所设置的UTF-8

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
56 queries in 0.210 seconds, using 18.78MB memory