语句如下:
<xsl:import href="plugin:org.dita.xhtml:xsl/dita2html-base.xsl"/>
我是XSL的新手。我知道href属性需要一个URI,但是href值如何在上述语句中解析为URI。这段代码是DITA-OT中xhtml插件xsl的一部分。有很多这样的语句。这些相对路径来自根目录吗?DITA-OT代码如何解析这些路径?
如果您查看DITA-OT的根安装文件夹,您将发现一个名为catalog-dita.xml的文件。这是一个XML目录,旨在为XML实体提供解析方案。摘自XML编目规范的摘要:
这个OASIS标准定义了一个实体编目,它将外部标识符和任意URI引用映射到URI引用。
打开catalog-dita.xml文件,搜索"plugin:org.dita.xhtml
"。你会发现这个条目:
<rewriteURI uriStartString='plugin:org.dita.xhtml:' rewritePrefix='plugins/org.dita.xhtml/'/>
因此,任何以plugin:org.dita.xhtml:
开头的引用uri的<xsl:import href="...">
(以及<xsl:include href="...">
和document()
函数)将被"重定向"到文件夹plugins/org.dita.xhtml/
,这样在您的情况下,相对于DITA-OT安装文件夹,文件plugins/org.dita.xhtml/xsl/dita2html-base.xsl
将被搜索。
但是这个目录是如何使用的呢?
例如,在$DITAOT_DIR$pluginsorg.dita.xhtmlbuild_general.xml
中(它在DITA-OT中广泛使用,因此几乎在所有build_xxx.xml文件中都可以找到这些指令),您将发现如下内容:
<xslt basedir="${dita.temp.dir}" destdir="${output.dir}" includesfile="${dita.temp.dir}${file.separator}${fullditatopicfile}" reloadstylesheet="${dita.xhtml.reloadstylesheet}" classpathref="dost.class.path" extension="${out.ext}" style="${args.xsl}" filenameparameter="FILENAME" filedirparameter="FILEDIR">
<!-- A huge bunch of parameters comes here ... -->
<param name="[...]" expression="[...]"></param>
<xmlcatalog refid="dita.catalog"></xmlcatalog>
</xslt>
这意味着调用带有目录的XSL-T转换(<xslt>
在这里是一个ant任务),该目录将为转换期间所需的所有资源提供适当的URI映射。显然,dita.catalog
是对其他地方声明的目录的引用。
打开$DITAOT_DIR$pluginsorg.dita.basebuild_init.xml
,你会发现:
<xmlcatalog id="dita.catalog">
<catalogpath path="${dita.plugin.org.dita.base.dir}/catalog-dita.xml"/>
</xmlcatalog>
指向开始时打开的XML编目。