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

【已解决】docbook中用xsltproc处理xsl文件时用xsl:import引用本地css,js等文件时,必须加上file:///或file://的前缀才可以

Docbook crifan 3824浏览 0评论

【问题】

之前折腾docbook时,就遇到这个问题了。

现在又遇到了:

docbook中用xsltproc处理xsl文件,在xsl文件中,去xinclude或import一些文件时,对于本地文件

比如加上file://或file:///,比如:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\docbook\ant\webhelp\xsl\webhelp_crl.xsl

中的:

<!--
<xsl:import href="file:///E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.1/webhelp/xsl/webhelp.xsl"/>
-->
<xsl:import href="webhelp.xsl"/>
<xsl:import href="file:///&config_path;/common_all.xsl"/>
<!--<xsl:import href="file:///E:/Dev_Root/docbook/dev/config/docbook-xsl-ns-1.77.1/html/multi/chunk_crl.xsl"/>-->

就是之前加上的。

【折腾过程】

1.后来,也折腾了:

【记录】docbook的docbook-xsl-ns-1.78.1中的webhelp:优化使得共用之前的chunk等公共的xsl配置

和:

【未解决】cygwin中的docbook中使用xsltproc时命令行中通过–stringparam传入的参数无效

了解了更多。

2.现在再去确认:

在cygwin中

用现在的最新的cygwin中自带的xsltproc:

CLi@PC-CLI-1 ~/develop/docbook/tools/xsltproc_libxml2-2.8.0/bin
$ which xsltproc
/bin/xsltproc
 
CLi@PC-CLI-1 ~/develop/docbook/tools/xsltproc_libxml2-2.8.0/bin
$ xsltproc --version
Using libxml 20901, libxslt 10127 and libexslt 816
xsltproc was compiled against libxml 20900, libxslt 10127 and libexslt 816
libxslt 10127 was compiled against libxml 20900
libexslt 816 was compiled against libxml 20900

去处理包含file:///前缀的xsl:

XSLTPROC=xsltproc
#XSLTPROC=/cygdrive/d/tmp/dev_tools/docbook/docbook_libxml/xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0/bin/xsltproc

webhelp_chunk:
	$(XSLTPROC) \
        --xinclude --output xincluded-profiled.xml  \
          --stringparam  profile.arch ${PROFILE.ARCH} \
          --stringparam  profile.audience ${PROFILE.AUDIENCE} \
          --stringparam  profile.condition ${PROFILE.CONDITION} \
          --stringparam  profile.conformance ${PROFILE.CONFORMANCE} \
          --stringparam  profile.lang ${PROFILE.LANG} \
          --stringparam  profile.os ${PROFILE.OS} \
          --stringparam  profile.revision ${PROFILE.REVISION} \
          --stringparam  profile.revisionflag ${PROFILE.REVISIONFLAG} \
          --stringparam  profile.role ${PROFILE.ROLE} \
          --stringparam  profile.security ${PROFILE.SECURITY} \
          --stringparam  profile.status ${PROFILE.STATUS} \
          --stringparam  profile.userlevel ${PROFILE.USERLEVEL} \
          --stringparam  profile.vendor ${PROFILE.VENDOR} \
          --stringparam  profile.wordsize ${PROFILE.WORDSIZE} \
          --stringparam  profile.attribute ${PROFILE.ATTRIBUTE} \
          --stringparam  profile.value ${PROFILE.VALUE} \
          $(TOOLS_XSL_NS_PROFILING)/profile.xsl  \
          $(MAIN_SRC_FILE)
	@#$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} $(TOOLS_XSL_NS_WEBHELP)/xsl/webhelp.xsl xincluded-profiled.xml
	$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} /home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
	@#$(XSLTPROC) $(TOOLS_XSL_NS_WEBHELP)/xsl/webhelp.xsl ${WEBHELP_OTHER_XSLTPROC_ARGS} xincluded-profiled.xml
	rm xincluded-profiled.xml

的确也是不支持file:///前缀的,会出错:

CLi@PC-CLI-1 ~/develop/docbook/books/crifanlib_python/src
$ make webhelp
rm -rf ../output/webhelp
mkdir -p ../output/webhelp
cp -a ./images ../output/webhelp
test ! -d ./images/ || cp -a ./images/ ../output/webhelp
cp D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/webhelp/template/favicon.ico ../output/webhelp/
xsltproc \
        --xinclude --output xincluded-profiled.xml  \
          --stringparam  profile.arch "" \
          --stringparam  profile.audience "" \
          --stringparam  profile.condition "" \
          --stringparam  profile.conformance "" \
          --stringparam  profile.lang "" \
          --stringparam  profile.os "" \
          --stringparam  profile.revision "" \
          --stringparam  profile.revisionflag "" \
          --stringparam  profile.role "" \
          --stringparam  profile.security "" \
          --stringparam  profile.status "" \
          --stringparam  profile.userlevel "" \
          --stringparam  profile.vendor "" \
          --stringparam  profile.wordsize "" \
          --stringparam  profile.attribute "" \
          --stringparam  profile.value "" \
          D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/profiling/profile.xsl  \
          ./crifanlib_python.xml
xsltproc --stringparam webhelp.base.dir ../output/webhelp --stringparam webhelp.indexer.language zh --stringparam webhelp.common.dir file:///D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/webhelp/template/common/ /home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
warning: failed to load external entity "file:///D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.77.1/xhtml/chunk.xsl"
compilation error: file /home/CLi/develop/docbook/ant/webhelp/xsl/webhelp.xsl line 37 element import
xsl:import : unable to load file:///D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.77.1/xhtml/chunk.xsl
warning: failed to load external entity "file:///D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/config/docbook-xsl-ns-1.77.1/common_all.xsl"
compilation error: file /home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl line 32 element import
xsl:import : unable to load file:///D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/config/docbook-xsl-ns-1.77.1/common_all.xsl
make: *** [webhelp_chunk] Error 5

 

3.自己组合出来的win32的xsltproc

用:

libxml2-2.7.8:libxml2-2.7.8.win32.zip

libxslt-1.1.26:libxslt-1.1.26.win32.zip

iconv-1.14:iconv-1.14-win32.7z

zlib-1.2.8:zlib-1.2.8-win32.7z

mingwrt-4.8.0:mingwrt-4.8.0-win32.7z

组合出来的:

D:\tmp\dev_tools\docbook\docbook_libxml\xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0\bin>xsltproc --version
Using libxml 20708, libxslt 10126 and libexslt 815
xsltproc was compiled against libxml 20706, libxslt 10126 and libexslt 815
libxslt 10126 was compiled against libxml 20706
libexslt 815 was compiled against libxml 20706

的xsltproc:

#XSLTPROC=xsltproc
XSLTPROC=/cygdrive/d/tmp/dev_tools/docbook/docbook_libxml/xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0/bin/xsltproc

webhelp_chunk:
	$(XSLTPROC) \
        --xinclude --output xincluded-profiled.xml  \
          --stringparam  profile.arch ${PROFILE.ARCH} \
          --stringparam  profile.audience ${PROFILE.AUDIENCE} \
          --stringparam  profile.condition ${PROFILE.CONDITION} \
          --stringparam  profile.conformance ${PROFILE.CONFORMANCE} \
          --stringparam  profile.lang ${PROFILE.LANG} \
          --stringparam  profile.os ${PROFILE.OS} \
          --stringparam  profile.revision ${PROFILE.REVISION} \
          --stringparam  profile.revisionflag ${PROFILE.REVISIONFLAG} \
          --stringparam  profile.role ${PROFILE.ROLE} \
          --stringparam  profile.security ${PROFILE.SECURITY} \
          --stringparam  profile.status ${PROFILE.STATUS} \
          --stringparam  profile.userlevel ${PROFILE.USERLEVEL} \
          --stringparam  profile.vendor ${PROFILE.VENDOR} \
          --stringparam  profile.wordsize ${PROFILE.WORDSIZE} \
          --stringparam  profile.attribute ${PROFILE.ATTRIBUTE} \
          --stringparam  profile.value ${PROFILE.VALUE} \
          $(TOOLS_XSL_NS_PROFILING)/profile.xsl  \
          $(MAIN_SRC_FILE)
	@#$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} $(TOOLS_XSL_NS_WEBHELP)/xsl/webhelp.xsl xincluded-profiled.xml
	$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} /home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
	@#$(XSLTPROC) $(TOOLS_XSL_NS_WEBHELP)/xsl/webhelp.xsl ${WEBHELP_OTHER_XSLTPROC_ARGS} xincluded-profiled.xml
	rm xincluded-profiled.xml

去处理,结果:

却在处理cywgin路径的webhelp_crl.xsl:

/home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl

就出错了:

CLi@PC-CLI-1 ~/develop/docbook/books/crifanlib_python/src
$ make webhelp
rm -rf ../output/webhelp
mkdir -p ../output/webhelp
cp -a ./images ../output/webhelp
test ! -d ./images/ || cp -a ./images/ ../output/webhelp
cp D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/webhelp/template/favicon.ico ../output/webhelp/
/cygdrive/d/tmp/dev_tools/docbook/docbook_libxml/xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0/bin/xsltproc \
        --xinclude --output xincluded-profiled.xml  \
          --stringparam  profile.arch "" \
          --stringparam  profile.audience "" \
          --stringparam  profile.condition "" \
          --stringparam  profile.conformance "" \
          --stringparam  profile.lang "" \
          --stringparam  profile.os "" \
          --stringparam  profile.revision "" \
          --stringparam  profile.revisionflag "" \
          --stringparam  profile.role "" \
          --stringparam  profile.security "" \
          --stringparam  profile.status "" \
          --stringparam  profile.userlevel "" \
          --stringparam  profile.vendor "" \
          --stringparam  profile.wordsize "" \
          --stringparam  profile.attribute "" \
          --stringparam  profile.value "" \
          D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/profiling/profile.xsl  \
          ./crifanlib_python.xml
/cygdrive/d/tmp/dev_tools/docbook/docbook_libxml/xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0/bin/xsltproc --stringparam webhelp.base.dir ../output/webhelp --stringparam webhelp.indexer.language zh --stringparam webhelp.common.dir file:///D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/webhelp/template/common/ /home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
warning: failed to load external entity "/home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl"
cannot parse /home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl
make: *** [webhelp_chunk] Error 4

4.那就先去改为windows的路径:

	@#$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} $(TOOLS_XSL_NS_WEBHELP)/xsl/webhelp.xsl xincluded-profiled.xml
	@#$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} /home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
	$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
	@#$(XSLTPROC) $(TOOLS_XSL_NS_WEBHELP)/xsl/webhelp.xsl ${WEBHELP_OTHER_XSLTPROC_ARGS} xincluded-profiled.xml

结果是:

可以正常处理,且直接支持,带file:///前缀的那些import的文件,不会出现cygwin中的xsltproc出现的无法识别的问题。

5.而要是故意去掉file:///的前缀:

<!ENTITY config_path "D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/config/docbook-xsl-ns-1.77.1">
<xsl:import href="&config_path;/common_all.xsl"/>

看看win32的xsltproc是否支持:

结果也是支持的:

CLi@PC-CLI-1 ~/develop/docbook/books/crifanlib_python/src
$ make webhelp
rm -rf ../output/webhelp
mkdir -p ../output/webhelp
cp -a ./images ../output/webhelp
test ! -d ./images/ || cp -a ./images/ ../output/webhelp
cp D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/webhelp/template/favicon.ico ../output/webhelp/
/cygdrive/d/tmp/dev_tools/docbook/docbook_libxml/xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0/bin/xsltproc \
        --xinclude --output xincluded-profiled.xml  \
          --stringparam  profile.arch "" \
          --stringparam  profile.audience "" \
          --stringparam  profile.condition "" \
          --stringparam  profile.conformance "" \
          --stringparam  profile.lang "" \
          --stringparam  profile.os "" \
          --stringparam  profile.revision "" \
          --stringparam  profile.revisionflag "" \
          --stringparam  profile.role "" \
          --stringparam  profile.security "" \
          --stringparam  profile.status "" \
          --stringparam  profile.userlevel "" \
          --stringparam  profile.vendor "" \
          --stringparam  profile.wordsize "" \
          --stringparam  profile.attribute "" \
          --stringparam  profile.value "" \
          D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/profiling/profile.xsl  \
          ./crifanlib_python.xml
/cygdrive/d/tmp/dev_tools/docbook/docbook_libxml/xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0/bin/xsltproc --stringparam webhelp.base.dir ../output/webhelp --stringparam webhelp.indexer.language zh --stringparam webhelp.common.dir file:///D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/webhelp/template/common/ D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
language: zh
Writing ../output/webhelp/content/what_is_crifanlib_py.html for sect1(what_is_crifanlib_py)
Writing ../output/webhelp/content/where_download_crifanlib_py.html for sect1(where_download_crifanlib_py)
Writing ../output/webhelp/content/ch01_crifanlib_py_intro.html for chapter(ch01_crifanlib_py_intro)
Writing ../output/webhelp/content/getcurtimestamp.html for sect2(getcurtimestamp)
Writing ../output/webhelp/content/timestamptodatetime.html for sect2(timestamptodatetime)
Writing ../output/webhelp/content/calctimestart_calctimeend.html for sect2(calctimestart_calctimeend)
Writing ../output/webhelp/content/convertlocaltogmt.html for sect2(convertlocaltogmt)
Writing ../output/webhelp/content/time_datetime_funcs.html for sect1(time_datetime_funcs)
Writing ../output/webhelp/content/extractfilename.html for sect2(extractfilename)
Writing ../output/webhelp/content/repuninumenttochar.html for sect2(repuninumenttochar)
Writing ../output/webhelp/content/genfullurl.html for sect2(genfullurl)
Writing ../output/webhelp/content/urlissimilar.html for sect2(urlissimilar)
Writing ../output/webhelp/content/findsimilarurl.html for sect2(findsimilarurl)
Writing ../output/webhelp/content/removenonwordchar.html for sect2(removenonwordchar)
Writing ../output/webhelp/content/removectlchr.html for sect2(removectlchr)
Writing ../output/webhelp/content/replacestrenttonument.html for sect2(replacestrenttonument)
Writing ../output/webhelp/content/converttotupleval.html for sect2(converttotupleval)
Writing ../output/webhelp/content/removeemptyinlist.html for sect2(removeemptyinlist)
Writing ../output/webhelp/content/uniquelist.html for sect2(uniquelist)
Writing ../output/webhelp/content/filterlist.html for sect2(filterlist)
Writing ../output/webhelp/content/randdigitsstr.html for sect2(randdigitsstr)
Writing ../output/webhelp/content/tuplelisttodict.html for sect2(tuplelisttodict)
Writing ../output/webhelp/content/string_unicode_funcs.html for sect1(string_unicode_funcs)
Writing ../output/webhelp/content/savebindatatofile.html for sect2(savebindatatofile)
Writing ../output/webhelp/content/file_funcs.html for sect1(file_funcs)
Writing ../output/webhelp/content/isfilevalid.html for sect2(isfilevalid)
Writing ../output/webhelp/content/downloadfile.html for sect2(downloadfile)
Writing ../output/webhelp/content/manuallydownloadfile.html for sect2(manuallydownloadfile)
Writing ../output/webhelp/content/geturlresponse.html for sect2(geturlresponse)
Writing ../output/webhelp/content/geturlresphtml.html for sect2(geturlresphtml)
Writing ../output/webhelp/content/checkallcookiesexist.html for sect2(checkallcookiesexist)
Writing ../output/webhelp/content/network_http_funcs.html for sect1(network_http_funcs)
Writing ../output/webhelp/content/strisascii.html for sect2(strisascii)
Writing ../output/webhelp/content/getstrpossiblecharset.html for sect2(getstrpossiblecharset)
Writing ../output/webhelp/content/str_encoding_funcs.html for sect1(str_encoding_funcs)
Writing ../output/webhelp/content/translatestring.html for sect2(translatestring)
Writing ../output/webhelp/content/transzhcntoen.html for sect2(transzhcntoen)
Writing ../output/webhelp/content/language_translate_funcs.html for sect1(language_translate_funcs)
Writing ../output/webhelp/content/removesoupcontentstagattr.html for sect2(removesoupcontentstagattr)
Writing ../output/webhelp/content/findfirstnavigablestring.html for sect2(findfirstnavigablestring)
Writing ../output/webhelp/content/soupcontentstounicode.html for sect2(soupcontentstounicode)
Writing ../output/webhelp/content/beautifulsoup_funcs.html for sect1(beautifulsoup_funcs)
Writing ../output/webhelp/content/ch02_crifanlib_py_functions.html for chapter(ch02_crifanlib_py_functions)
Writing ../output/webhelp/content/reference.html for bibliography(reference)
Writing ../output/webhelp/content/index.html for book
Writing ../output/webhelp/index.html
Writing ../output/webhelp/content/search/l10n.js
rm xincluded-profiled.xml
java \
        -DhtmlDir=../output/webhelp \
        -DindexerLanguage=zh \
        -DhtmlExtension=html \
        -DdoStem=true \
        -DindexerExcludedFiles=ix01.html \
        -Dorg.xml.sax.driver=org.ccil.cowan.tagsoup.Parser \
        -Djavax.xml.parsers.SAXParserFactory=org.ccil.cowan.tagsoup.jaxp.SAXFactoryImpl \
        -classpath "D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/extensions/webhelpindexer.jar;D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/extensions/tagsoup-1.2.1.jar;D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/extensions/lucene-analyzers-3.0.0.jar;D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/extensions/lucene-core-3.0.0.jar" \
        com.nexwave.nquindexer.IndexerMain
Stemming enabled
The created index files are located in ..\output\webhelp\search
Indexed the contents in 107 milliseconds
mkdir -p ../output/webhelp/search
cp -r D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/webhelp/template/search/* ../output/webhelp/search
=============================== generating crifanlib_python webhelp ==============================

CLi@PC-CLI-1 ~/develop/docbook/books/crifanlib_python/src
$

6.去掉了file:///前缀的话,那就去试试,再用cygwin自带的xsltproc:

XSLTPROC=xsltproc
#XSLTPROC=/cygdrive/d/tmp/dev_tools/docbook/docbook_libxml/xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0/bin/xsltproc

webhelp_chunk:
	$(XSLTPROC) \
        --xinclude --output xincluded-profiled.xml  \
          --stringparam  profile.arch ${PROFILE.ARCH} \
          --stringparam  profile.audience ${PROFILE.AUDIENCE} \
          --stringparam  profile.condition ${PROFILE.CONDITION} \
          --stringparam  profile.conformance ${PROFILE.CONFORMANCE} \
          --stringparam  profile.lang ${PROFILE.LANG} \
          --stringparam  profile.os ${PROFILE.OS} \
          --stringparam  profile.revision ${PROFILE.REVISION} \
          --stringparam  profile.revisionflag ${PROFILE.REVISIONFLAG} \
          --stringparam  profile.role ${PROFILE.ROLE} \
          --stringparam  profile.security ${PROFILE.SECURITY} \
          --stringparam  profile.status ${PROFILE.STATUS} \
          --stringparam  profile.userlevel ${PROFILE.USERLEVEL} \
          --stringparam  profile.vendor ${PROFILE.VENDOR} \
          --stringparam  profile.wordsize ${PROFILE.WORDSIZE} \
          --stringparam  profile.attribute ${PROFILE.ATTRIBUTE} \
          --stringparam  profile.value ${PROFILE.VALUE} \
          $(TOOLS_XSL_NS_PROFILING)/profile.xsl  \
          $(MAIN_SRC_FILE)
	@#$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} $(TOOLS_XSL_NS_WEBHELP)/xsl/webhelp.xsl xincluded-profiled.xml
	@#$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} /home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
	$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
	@#$(XSLTPROC) $(TOOLS_XSL_NS_WEBHELP)/xsl/webhelp.xsl ${WEBHELP_OTHER_XSLTPROC_ARGS} xincluded-profiled.xml
	rm xincluded-profiled.xml

去处理看看,应该也是可以的。

结果的确是可以的:

CLi@PC-CLI-1 ~/develop/docbook/books/crifanlib_python/src
$ make webhelp
rm -rf ../output/webhelp
mkdir -p ../output/webhelp
cp -a ./images ../output/webhelp
test ! -d ./images/ || cp -a ./images/ ../output/webhelp
cp D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/webhelp/template/favicon.ico ../output/webhelp/
xsltproc \
        --xinclude --output xincluded-profiled.xml  \
          --stringparam  profile.arch "" \
          --stringparam  profile.audience "" \
          --stringparam  profile.condition "" \
          --stringparam  profile.conformance "" \
          --stringparam  profile.lang "" \
          --stringparam  profile.os "" \
          --stringparam  profile.revision "" \
          --stringparam  profile.revisionflag "" \
          --stringparam  profile.role "" \
          --stringparam  profile.security "" \
          --stringparam  profile.status "" \
          --stringparam  profile.userlevel "" \
          --stringparam  profile.vendor "" \
          --stringparam  profile.wordsize "" \
          --stringparam  profile.attribute "" \
          --stringparam  profile.value "" \
          D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/profiling/profile.xsl  \
          ./crifanlib_python.xml
xsltproc --stringparam webhelp.base.dir ../output/webhelp --stringparam webhelp.indexer.language zh --stringparam webhelp.common.dir file:///D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.78.1/webhelp/template/common/ D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
warning: failed to load external entity "file:///D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.77.1/xhtml/chunk.xsl"
compilation error: file D:///tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/ant/webhelp/xsl/webhelp.xsl line 37 element import
xsl:import : unable to load file:///D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/tools/docbook-xsl-ns-1.77.1/xhtml/chunk.xsl
make: *** [webhelp_chunk] Error 5

只不过,上面有错误,那是由于:

<xsl:import href="&config_path;/common_all.xsl"/>

所引用到了之前的1.77.1中的xsl,而之前的xsl,都是加了file:///的。

所以,可以忽略。

因为已经验证此处的:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\docbook\ant\webhelp\xsl\webhelp_crl.xsl

中的:

<xsl:import href="&config_path;/common_all.xsl"/>

的确是已经可以正常解析了。

 

【总结】

目前验证的结果是:

1.之前,最早的,好像是根据之前的教程:

下载windos版本的xsltproc

中的:

  1. xsltproc主程序

    libxslt-1.1.26.win32.zip

    其中包含我们所需要的xsltproc可执行文件:xsltproc.exe

  2. 运行xsltproc所需要的一些库

    为了在windows下面运行xsltproc,还需要一些其所依赖的库:libxml2,iconv,zlib

    下面依次贴出下载地址和简单的解释:

    • libxml2-2.7.8.win32.zip

      C语言实现的XML解析器。

      其支持N多规范或协议,比如XML,XML-NS,XPath,XPointer,XInclude,UTF-8/UTF-16,XML Catalog,Canonical XML,Relax NG等。

    • iconv-1.9.2.win32.zip

      字符编码转换。比如从UTF-8转换为GB18030,就可以用iconv。

    • zlib-1.2.5.win32.zip

      压缩工具。

的1.1.26的版本的xsltproc,是win32的,好像对于本地的文件,必须要加上file:///的。

2.而现在最新版本的,

不论是手动从:

libxml2-2.7.8:libxml2-2.7.8.win32.zip

libxslt-1.1.26:libxslt-1.1.26.win32.zip

iconv-1.14:iconv-1.14-win32.7z

zlib-1.2.8:zlib-1.2.8-win32.7z

mingwrt-4.8.0:mingwrt-4.8.0-win32.7z

组合出来的:

D:\tmp\dev_tools\docbook\docbook_libxml\xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0\bin>xsltproc --version
Using libxml 20708, libxslt 10126 and libexslt 815
xsltproc was compiled against libxml 20706, libxslt 10126 and libexslt 815
libxslt 10126 was compiled against libxml 20706
libexslt 815 was compiled against libxml 20706

xsltproc,还是cygwin自带的:

CLi@PC-CLI-1 ~/develop/docbook/tools/xsltproc_libxml2-2.8.0/bin
$ which xsltproc
/bin/xsltproc
 
CLi@PC-CLI-1 ~/develop/docbook/tools/xsltproc_libxml2-2.8.0/bin
$ xsltproc --version
Using libxml 20901, libxslt 10127 and libexslt 816
xsltproc was compiled against libxml 20900, libxslt 10127 and libexslt 816
libxslt 10127 was compiled against libxml 20900
libexslt 816 was compiled against libxml 20900

的xsltproc,都是支持:

import不带file:///前缀的本地文件的

3.而对于import中

  • 为cygwin的路径,加了file://
  • 为window类路径,加了file:///

的本地文件,上述合并出来的win32的xsltproc,也还是支持的。

 

结论:

如果cygwin中,方便的话,还是安装对应的xsltproc->只支持不带file://或file:///前缀的文件地址->对于xsl本来就最好不加file://的前缀比较好

如果cygwin中没有安装xsltproc,那么就去自己组合出来对应的xsltproc->不论是加file:///前缀,还是不加前缀,都支持的->但是给xsltproc传递参数的时候,比如xsl文件的地址,则必须是window的路径(cygwin的路径是无法识别的)

 

推荐:

最好还是cygwin中安装xsltproc,然后写xsl文件的时候,就不用加那个变态的file://或file:///的前缀了。

 

解释:

1.如何组合出来相对比较新的版本的xsltproc

下载:

libxml2-2.7.8:libxml2-2.7.8.win32.zip

libxslt-1.1.26:libxslt-1.1.26.win32.zip

iconv-1.14:iconv-1.14-win32.7z

zlib-1.2.8:zlib-1.2.8-win32.7z

mingwrt-4.8.0:mingwrt-4.8.0-win32.7z

然后分别解压,每个解压后,都有对应的

bin

lib(有的没有)

include(有的没有)

等文件夹,然后统一合并,放到某个目录下,然后把该路径下面的bin路径的地址,

比如我此处的:

D:\tmp\dev_tools\docbook\docbook_libxml\xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0\bin

加到windows的PATH中。

然后重启cmd,就可以使用了。

 

当然,如果想要在cygwin中使用此组合出来的xsltproc的话,可以直接指定对应的路径

比如我之前就是在makefile中用:

XSLTPROC=xsltproc
#XSLTPROC=/cygdrive/d/tmp/dev_tools/docbook/docbook_libxml/xsltproc_libxml2-2.7.8_libxslt-1.1.26_iconv-1.14_zlib-1.2.8_mingwrt-4.8.0/bin/xsltproc

webhelp_chunk:
	$(XSLTPROC) \
        --xinclude --output xincluded-profiled.xml  \
          --stringparam  profile.arch ${PROFILE.ARCH} \
          --stringparam  profile.audience ${PROFILE.AUDIENCE} \
          --stringparam  profile.condition ${PROFILE.CONDITION} \
          --stringparam  profile.conformance ${PROFILE.CONFORMANCE} \
          --stringparam  profile.lang ${PROFILE.LANG} \
          --stringparam  profile.os ${PROFILE.OS} \
          --stringparam  profile.revision ${PROFILE.REVISION} \
          --stringparam  profile.revisionflag ${PROFILE.REVISIONFLAG} \
          --stringparam  profile.role ${PROFILE.ROLE} \
          --stringparam  profile.security ${PROFILE.SECURITY} \
          --stringparam  profile.status ${PROFILE.STATUS} \
          --stringparam  profile.userlevel ${PROFILE.USERLEVEL} \
          --stringparam  profile.vendor ${PROFILE.VENDOR} \
          --stringparam  profile.wordsize ${PROFILE.WORDSIZE} \
          --stringparam  profile.attribute ${PROFILE.ATTRIBUTE} \
          --stringparam  profile.value ${PROFILE.VALUE} \
          $(TOOLS_XSL_NS_PROFILING)/profile.xsl  \
          $(MAIN_SRC_FILE)
	@#$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} $(TOOLS_XSL_NS_WEBHELP)/xsl/webhelp.xsl xincluded-profiled.xml
	@#$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} /home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
	$(XSLTPROC) ${WEBHELP_OTHER_XSLTPROC_ARGS} D:/tmp/tmp_dev_root/cgwin/home/CLi/develop/docbook/ant/webhelp/xsl/webhelp_crl.xsl xincluded-profiled.xml
	@#$(XSLTPROC) $(TOOLS_XSL_NS_WEBHELP)/xsl/webhelp.xsl ${WEBHELP_OTHER_XSLTPROC_ARGS} xincluded-profiled.xml
	rm xincluded-profiled.xml

而实现,不用cygwin自带的xsltproc,而直接用刚才组合出来win32的xsltproc的。

 

附录:

关于相关的一些文件的下载地址,详见之前我的查找记录:

(1)对此问题,去搜:

xsl  local file:///

找到:

https://bugzilla.mozilla.org/show_bug.cgi?id=439721

其是firefox中之前有人遇到此问题的,说是可以通过firefox中的更改设置而解决此问题。

但是对于xsl的处理,此处的xsltproc,却还是有此bug。

(2)这人也遇到类似问题:

[xslt] Problem with xsltproc on Windows

http://www.mail-archive.com/xslt@gnome.org/msg01645.html

(3)我自己之前的教程:

https://www.crifan.com/files/doc/docbook/docbook_dev_note/release/webhelp/download_xsltproc_win.html

中让其去下载的是

libxslt-1.1.26.win32.zip

即是1.1.26的版本的

不知道官网:

http://xmlsoft.org/XSLT/downloads.html

的最新的:

1.1.28

是否已经修复此bug

如果修复,则:

需要自己去下载源码,自己编译一个win32版本的exe的xsltproc

(4)官网中:

http://xmlsoft.org/XSLT/downloads.html

提到的:

he provides binaries

找到的:

ftp://ftp.zlatkovic.com/pub/libxml/

中,也还是只有之前的那个:

libxslt-1.1.26.win32.zip

还是没有最新的,编译好的win32的1.1.28的版本。

不过却在子文件夹下:

ftp://ftp.zlatkovic.com/pub/libxml/64bit/

中发现了:

libxslt-1.1.28-win32-x86_64.7z

libxslt-1.1.28-win32.7z

下载和解压了:

libxslt-1.1.28-win32-x86_64

的确是我所需要的最新版本的1.1.28的win32的二进制的。

剩下的,就是抽空,按照之前说的,

把cygwin中的xsltproc换为此处的1.1.28的,看看是否解决次bug,而在xls文件中引用无需本地css文件加上file:///的

(5)关于libxml2等等二进制文件下载,又找到一些其他的,包含更新的版本的地址:

http://xmlsoft.org/sources/win32/

libxml2-2.7.8.win32.zip

另外也从这个日本网站:

http://leaf.argyr.net/built/libxml2/

下载到:

libxml2-2.8.0-x86-win32nt-mingw.zip

libxml2-2.8.0-x86-win32nt-msvc.zip

的。

转载请注明:在路上 » 【已解决】docbook中用xsltproc处理xsl文件时用xsl:import引用本地css,js等文件时,必须加上file:///或file://的前缀才可以

发表我的评论
取消评论

表情

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.199 seconds, using 22.28MB memory