最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】在MingW中的MSYS中,运行xsltproc出现catalog方面的错误:warning: failed to load external entity xxx,cannot parse xxx

MSYS crifan 2434浏览 0评论

【问题】

在折腾

【记录】将Cygwin中的Docbook开发环境,整合到MingW中的MSYS中

的过程中,在使用之前的catalog配置,使用xsltproc去编译docbook为html的过程中,出现错误:

Administrator@NYBDHB7EB3XEHP6 /e/Dev_Root/docbook/dev/books/docbook_dev_note/src
$ make html
=============================== cleaning html ==============================
rm -rf ../output/html/single/*
=============================== generating html ==============================
export XML_CATALOG_FILES="/E/Dev_Root/docbook/dev/config/catalog/catalog.xml" && \
        export XML_DEBUG_CATALOG=1 && \
        xsltproc --xinclude --stringparam callout.graphics 1 --stringparam admon.graphics 1  --stringparam callout.graph
ics.number.limit 30 --stringparam callout.graphics.extension .png --stringparam admon.graphics.extension .png --stringpa
ram html.stylesheet.type text/css  --stringparam callout.graphics.path E:/Dev_Root/docbook/dev/config/images/system/call
outs/ --stringparam admon.graphics.path E:/Dev_Root/docbook/dev/config/images/system/ --stringparam html.stylesheet E:/D
ev_Root/docbook/dev/config/docbook-xsl-ns-1.77.1/html/css/common_html.css -o ../output/html/single/docbook_dev_note.html
 docbook_html_crl.xsl docbook_dev_note.xml
Resolve: sysID docbook_html_crl.xsl
8524 Parsing catalog e:/Dev_Root/docbook/dev/config/catalog/catalog.xml
e:/Dev_Root/docbook/dev/config/catalog/catalog.xml added to file hash
Resolve URI docbook_html_crl.xsl
Found URI match docbook_html_crl.xsl
warning: failed to load external entity "docbook_html_crl.xsl"
cannot parse docbook_html_crl.xsl
Catalogs cleanup
Free catalog entry crl.ent
Free catalog entry /home/develop/docbook/tools_root/docbook-xsl-ns-1.77.0/
Free catalog entry docbook_html.xsl
Free catalog entry docbook_fo.xsl
Free catalog entry /home/develop/docbook/config_root/docbook-xsl-ns-1.77.0/
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 e:/Dev_Root/docbook/dev/config/catalog/catalog.xml
Free catalog entry
make: *** [../output/html/single/docbook_dev_note.html] Error 4

【解决过程】

1.发现原因是因为catalog的配置中,也是对应的旧的cygwin中的路径,所以也要改成mingw中的路径。

然后再去修改相关的catalog中的路径的配置,变为:

<!--<!ENTITY docbook_xsl_ns "docbook-xsl-ns-1.76.1">-->
<!ENTITY docbook_xsl_ns "docbook-xsl-ns-1.77.0">

<!-- ============== HOME ============== -->
<!-- <!ENTITY config_dir "/cygdrive/e/Dev_Root/docbook/dev/config"> -->
<!-- <!ENTITY xsl_ns_base_cygwin "/cygdrive/e/Dev_Root/docbook/tools/&docbook_xsl_ns;"> -->

<!-- ============== OFFICE ============== -->
<!-- <!ENTITY config_dir "/home/CLi/develop/docbook/config"> -->
<!-- <!ENTITY xsl_ns_base_cygwin "/home/CLi/develop/docbook/tools/&docbook_xsl_ns;"> -->

<!-- ============== UNIFY ============== -->
<!--<!ENTITY config_dir         "/home/develop/docbook/config_root">-->
<!ENTITY config_dir         "/E/Dev_Root/docbook/dev/config">
<!--<!ENTITY xsl_ns_base_cygwin "/home/develop/docbook/tools_root/&docbook_xsl_ns;">-->
<!ENTITY xsl_ns_base_cygwin "/E/Dev_Root/docbook/tools/&docbook_xsl_ns;">

<!-- ============== COMMON ============== -->
<!ENTITY config_xls_ns_dir "&config_dir;/&docbook_xsl_ns;">

然后还是同样错误

2。所以就重启MingW,然后再去试试,结果错误依旧。

3.然后才发现,原来是上述中的–stringparam参数的值中包含E:的路径,所以错误了。

所以,再去修改之前的docbook.mk,所以再去修改路径的配置为:

# ----------------------- home config -----------------------
#TOOLS_ROOT_CMD = E:/Dev_Root/docbook/tools
TOOLS_ROOT_CMD = /E/Dev_Root/docbook/tools
#CONFIG_ROOT_CMD = E:/Dev_Root/docbook/dev/config
CONFIG_ROOT_CMD = /E/Dev_Root/docbook/dev/config
#LOCAL_RELEASE_PARENT_CMD = E:/Dev_Root/www_crifan_com/files/doc/docbook
LOCAL_RELEASE_PARENT_CMD = /E/Dev_Root/www_crifan_com/files/doc/docbook
#LOCAL_PDF_CMD = E:/tmp/books
LOCAL_PDF_CMD = /E/tmp/books

然后再看看结果。结果是还是有错误:

Resolve: sysID docbook_html_crl.xsl
8276 Parsing catalog e:/Dev_Root/docbook/dev/config/catalog/catalog.xml
e:/Dev_Root/docbook/dev/config/catalog/catalog.xml added to file hash
Resolve URI docbook_html_crl.xsl
Found URI match docbook_html_crl.xsl
warning: failed to load external entity "docbook_html_crl.xsl"
cannot parse docbook_html_crl.xsl

4. 接着继续找原因。

<!ENTITY docbook_xsl_ns "docbook-xsl-ns-1.77.0">

改为

<!ENTITY docbook_xsl_ns "docbook-xsl-ns-1.77.1">

也还是不行。

5.折腾了半天,还是不行。

所以,怀疑是不是由于MSYS中,对于xsltproc这样的程序去执行,结果对于catalog部分支持的不好,而导致的此问题。

6.不过还是继续测试测试。

看了错误的详细信息,看到”Found URI match docbook_html_crl.xsl “即找到了docbook_html_crl.xsl,而其对应的catalog中的配置为:

<!ENTITY docbook_xsl_ns "docbook-xsl-ns-1.77.1">
<!ENTITY config_dir         "/E/Dev_Root/docbook/dev/config">
<!ENTITY config_xls_ns_dir "&config_dir;/&docbook_xsl_ns;">
...

    <group  xml:base="&config_xls_ns_dir;/" >
        <uri name="docbook_html_crl.xsl"
            uri="html/single/docbook_crl.xsl"/>

所以,猜测,也许是路径解析有误,不支持group?

所以就去改为绝对路径:

<!--<group  xml:base="&config_xls_ns_dir;/" >-->
<group  xml:base="/E/Dev_Root/docbook/dev/config/docbook-xsl-ns-1.77.1/" >
	<uri name="docbook_html_crl.xsl"
		uri="html/single/docbook_crl.xsl"/>

然后看看效果如何,结果错误依旧。

对应的,此处确保是可以该路径访问到该xml文件的:

Administrator@NYBDHB7EB3XEHP6 /e/Dev_Root/docbook/dev/books/docbook_dev_note/src
$ ls /E/Dev_Root/docbook/dev/config/docbook-xsl-ns-1.77.1/html/single/
docbook_crl.xsl

所以,那就是catalog不支持,或者group等类型的catalog配置不支持了。

7.又试了试,直接输入上面整套命令:

Administrator@NYBDHB7EB3XEHP6 /e/Dev_Root/docbook/dev/books/docbook_dev_note/src
$ export XML_CATALOG_FILES="/E/Dev_Root/docbook/dev/config/catalog/catalog.xml" && \
>         export XML_DEBUG_CATALOG=1 && \
>         xsltproc --xinclude --stringparam callout.graphics 1 --stringparam admon.graphics 1  --stringparam callout.gr
aphics.number.limit 30 --stringparam callout.graphics.extension .png --stringparam admon.graphics.extension .png --stri
ngparam html.stylesheet.type text/css  --stringparam callout.graphics.path /E/Dev_Root/docbook/dev/config/images/system
/callouts/ --stringparam admon.graphics.path /E/Dev_Root/docbook/dev/config/images/system/ --stringparam html.styleshee
t /E/Dev_Root/docbook/dev/config/docbook-xsl-ns-1.77.1/html/css/common_html.css -o ../output/html/single/docbook_dev_no
te.html

很明显,奇怪的是,竟然没有任何输出。

后来的结果更加奇怪,因为直接运行xsltproc,结果竟然也是没有输出:

Administrator@NYBDHB7EB3XEHP6 /e/Dev_Root/docbook/dev/books/docbook_dev_note/src
$ xsltproc --xinclude --stringparam callout.graphics 1 --stringparam admon.graphics 1  --stringparam callout.graphics.n
umber.limit 30 --stringparam callout.graphics.extension .png --stringparam admon.graphics.extension .png --stringparam
html.stylesheet.type text/css  --stringparam callout.graphics.path /E/Dev_Root/docbook/dev/config/images/system/callout
s/ --stringparam admon.graphics.path /E/Dev_Root/docbook/dev/config/images/system/ --stringparam html.stylesheet /E/Dev
_Root/docbook/dev/config/docbook-xsl-ns-1.77.1/html/css/common_html.css -o ../output/html/single/docbook_dev_note.html

所以,此处感觉还是有点问题的。MingW中,能否正常运行xsltproc,都是需要确认一下的了。

把xsltproc换成xsltproc.exe,问题依旧,还是无输出。

9.后来才注意到,原来上面的一堆命令中,本来是对应的是makefile中的

    $(XSLT) $(XSLT_FLAGS_HTML_LOCAL) -o $@ $(XSL_NS_FILE_HTML) $<

的其中$<表示$(MAIN_SRC_FILE) $(SUB_SRC_FILES) $(MAKE_FILE),是一堆的源文件。

但是此处全部没有显示出来。

即,比如此处的$(MAIN_SRC_FILE),最终对应的

./docbook_dev_note.xml

才对,但是此处更别都没有显示出来,所以,看来还是MingW中的make不支持我此处的makefile中的写法。

但是很奇怪的是,我此处的写法,都是标准的makefile写法,不应该不支持的。

10.最后还是手动输入命令,去一点点验证到底哪里出的问题。

Administrator@NYBDHB7EB3XEHP6 /e/Dev_Root/docbook/dev/books/docbook_dev_note/src
$ xsltproc.exe --xinclude -o ../output/html/single/docbook_dev_note.html /E/Dev_Root/docbook/dev/config/docbook-xsl-ns-
1.77.1/html/single/docbook_crl.xsl docbook_dev_note.xml
Resolve: sysID e:///home/develop/docbook/tools_root/docbook-xsl-ns-1.77.0/html/docbook.xsl
7944 Parsing catalog e:/Dev_Root/docbook/dev/config/catalog/catalog.xml
e:/Dev_Root/docbook/dev/config/catalog/catalog.xml added to file hash
Resolve URI e:///home/develop/docbook/tools_root/docbook-xsl-ns-1.77.0/html/docbook.xsl
warning: failed to load external entity "e:///home/develop/docbook/tools_root/docbook-xsl-ns-1.77.0/html/docbook.xsl"
compilation error: file e:/Dev_Root/docbook/dev/config/docbook-xsl-ns-1.77.1/html/single/docbook_crl.xsl line 22 element
 import
xsl:import : unable to load e:///home/develop/docbook/tools_root/docbook-xsl-ns-1.77.0/html/docbook.xsl
Catalogs cleanup
Free catalog entry crl.ent
Free catalog entry /E/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1/
Free catalog entry docbook_html.xsl
Free catalog entry docbook_fo.xsl
Free catalog entry /E/Dev_Root/docbook/dev/config/docbook-xsl-ns-1.77.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 e:/Dev_Root/docbook/dev/config/catalog/catalog.xml
Free catalog entry

显示import错误。

看到是docbook-xsl-ns-1.77.0,而不是期望的docbook-xsl-ns-1.77.1,所以就去找,是哪里导致的。

结果找到了,是由于E:\Dev_Root\docbook\dev\config\docbook-xsl-ns-1.77.1\html\single\docbook_crl.xsl中的是:

<!ENTITY xsl_ns_base_cygwin "/home/develop/docbook/tools_root/docbook-xsl-ns-1.77.0">

所导致的。

所以,修改一下变为:

<!ENTITY xsl_ns_base_cygwin "/E/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1">

然后再试试结果,结果错误为:

xsl:import : unable to load e:///E/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1/html/docbook.xsl

再改为:

<!ENTITY xsl_ns_base_cygwin "E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1">

然后就可以正常执行了。

11.但是又出现了无法解析http中的ent的错误:

Administrator@NYBDHB7EB3XEHP6 /e/Dev_Root/docbook/dev/books/docbook_dev_note/src
$ xsltproc.exe --xinclude -o ../output/html/single/docbook_dev_note.html /E/Dev_Root/docbook/dev/config/docbook-xsl-ns-
1.77.1/html/single/docbook_crl.xsl docbook_dev_note.xml
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
4520 Parsing catalog e:/Dev_Root/docbook/dev/config/catalog/catalog.xml
e:/Dev_Root/docbook/dev/config/catalog/catalog.xml added to file hash
Found public match crl.ent
Resolve URI e:///E/Dev_Root/docbook/dev/config/entity/crl.ent
ch01_build_env.xml:7: warning: failed to load external entity "https://www.crifan.com/files/res/docbook/entity/crl.ent"
%crl_ent;

然后才发现,原来是由于:

Resolve URI e:///E/Dev_Root/docbook/dev/config/entity/crl.ent

本身就是非法的地址,对应的catalog中的配置为:

<!ENTITY config_dir         "/E/Dev_Root/docbook/dev/config">

所以,改为:

<!ENTITY config_dir         "E:/Dev_Root/docbook/dev/config">

就可以解决问题,正常执行了:

Administrator@NYBDHB7EB3XEHP6 /e/Dev_Root/docbook/dev/books/docbook_dev_note/src
$ xsltproc.exe --xinclude -o ../output/html/single/docbook_dev_note.html /E/Dev_Root/docbook/dev/config/docbook-xsl-ns-
1.77.1/html/single/docbook_crl.xsl docbook_dev_note.xml
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
6872 Parsing catalog e:/Dev_Root/docbook/dev/config/catalog/catalog.xml
e:/Dev_Root/docbook/dev/config/catalog/catalog.xml added to file hash
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Catalogs cleanup
Free catalog entry crl.ent
Free catalog entry /E/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1/
Free catalog entry docbook_html.xsl
Free catalog entry docbook_fo.xsl
Free catalog entry /E/Dev_Root/docbook/dev/config/docbook-xsl-ns-1.77.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 e:/Dev_Root/docbook/dev/config/catalog/catalog.xml
Free catalog entry

就可以生成对应的html文件了:

E:\Dev_Root\docbook\dev\books\docbook_dev_note\output\html\single\docbook_dev_note.html

12.然后回去再执行make html,结果还是和之前一样的错误,还是:

warning: failed to load external entity "docbook_html_crl.xsl"

cannot parse docbook_html_crl.xsl

所以很是奇怪。

最后仔细看了看配置,然后发现,把之前的catalog中的:

<group  xml:base="/E/Dev_Root/docbook/dev/config/docbook-xsl-ns-1.77.1/" >

改为:

<group  xml:base="&config_xls_ns_dir;/" >

然后就可以正常执行了:

Administrator@NYBDHB7EB3XEHP6 /e/Dev_Root/docbook/dev/books/docbook_dev_note/src
$ make html
=============================== cleaning html ==============================
rm -rf ../output/html/single/*
=============================== generating html ==============================
export XML_CATALOG_FILES="/E/Dev_Root/docbook/dev/config/catalog/catalog.xml" && \
        export XML_DEBUG_CATALOG=1 && \
        xsltproc --xinclude --stringparam callout.graphics 1 --stringparam admon.graphics 1  --stringparam callout.graph
ics.number.limit 30 --stringparam callout.graphics.extension .png --stringparam admon.graphics.extension .png --stringpa
ram html.stylesheet.type text/css  --stringparam callout.graphics.path /E/Dev_Root/docbook/dev/config/images/system/call
outs/ --stringparam admon.graphics.path /E/Dev_Root/docbook/dev/config/images/system/ --stringparam html.stylesheet /E/D
ev_Root/docbook/dev/config/docbook-xsl-ns-1.77.1/html/css/common_html.css -o ../output/html/single/docbook_dev_note.html
 docbook_html_crl.xsl docbook_dev_note.xml
Resolve: sysID docbook_html_crl.xsl
6028 Parsing catalog e:/Dev_Root/docbook/dev/config/catalog/catalog.xml
e:/Dev_Root/docbook/dev/config/catalog/catalog.xml added to file hash
Resolve URI docbook_html_crl.xsl
Found URI match docbook_html_crl.xsl
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Resolve: pubID crl.ent sysID https://www.crifan.com/files/res/docbook/entity/crl.ent
Found public match crl.ent
Catalogs cleanup
Free catalog entry crl.ent
Free catalog entry E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1/
Free catalog entry docbook_html.xsl
Free catalog entry docbook_fo.xsl
Free catalog entry E:/Dev_Root/docbook/dev/config/docbook-xsl-ns-1.77.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 e:/Dev_Root/docbook/dev/config/catalog/catalog.xml
Free catalog entry
#cp -a  ../output/html/single/
#cp -a
cp -a ./images ../output/html/single/
#rm -rf

 

由此,最终解决了上述的warning: failed to load external entity的问题。

 

【总结】

此处在MingW的MSYS下,运行xsltproc,结果catalog部分出错:

warning: failed to load external entity

解决办法是:

需要修改两处位置:

1. catalog中

把此处之前Cygwin下面的的路径

<!ENTITY config_dir         "/home/develop/docbook/config_root">

改为windows下面的路径:

<!ENTITY config_dir         "E:/Dev_Root/docbook/dev/config">

 

注意:

如果改为了MSYS下面的路径:

<!ENTITY config_dir         "/E/Dev_Root/docbook/dev/config">

也还是会出现同样的错误:

warning: failed to load external entity "docbook_html_crl.xsl"

cannot parse docbook_html_crl.xsl

的。

 

2.相关的xsl配置文件:

E:\Dev_Root\docbook\dev\config\docbook-xsl-ns-1.77.1\html\single\docbook_crl.xsl

中,也要把之前旧的cygwin中的路径

<!ENTITY xsl_ns_base_cygwin "/home/develop/docbook/tools_root/docbook-xsl-ns-1.77.0">

改为windows中的路径

<!ENTITY xsl_ns_base_cygwin "E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1">

就可以正常载入并解析xsl了。

 

注意:

如果改为MSYS的路径:

<!ENTITY xsl_ns_base_cygwin "/E/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1">

则会出错:

xsl:import : unable to load E:///E/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1/html/docbook.xsl

的。

 

所以,总结一下规律:

对于出现warning: failed to load external entity的错误,如果不是本身路径写错了的话,则就是:

  • catalog中的相关配置路径写错了 -> 导致无法载入xsl文件;
  • xsl中的相关引用路径写错了 -> 能载入xsl文件,但是无法解析xsl;

对应的路径写错了,主要就是看你当前所用的环境是什么环境:

  • windows本身的cmd下:就是最常见的windows中的路径,如E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1
  • MingW的MSYS下:此处可能是MSYS的路径,如/E/Dev_Root/docbook/dev/config,也可能是windows本身的路径,如E:/Dev_Root/docbook/dev/config
  • Cygwin环境下:一般都是Unix类路径,比如上面的/home/develop/docbook/config_root;

所以,如果是路径写错了,则是需要你自己去调试,找到出错的路径,改为合适的类型的路径,即可正常,载入,并解析,对应的catalog配置文件和xsl文件了。

转载请注明:在路上 » 【已解决】在MingW中的MSYS中,运行xsltproc出现catalog方面的错误:warning: failed to load external entity xxx,cannot parse xxx

发表我的评论
取消评论

表情

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
85 queries in 0.190 seconds, using 22.47MB memory