需要帮助理解来自 DITA-OT xsl 的 xsl 导入语句
Need help in understanding xsl import statement from DITA-OT xsl
声明如下:
<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 catalog 旨在为 XML 实体提供解决方案。摘自 XML 目录规范的摘要:
this OASIS Standard defines an entity catalog that maps both external identifiers and arbitrary URI references to URI references.
打开 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()
函数)将是 "redirected" 文件夹plugins/org.dita.xhtml/
这样在您的情况下,将搜索相对于 DITA-OT 安装文件夹的文件 plugins/org.dita.xhtml/xsl/dita2html-base.xsl
。
但是这个目录怎么用呢?
例如在 $DITAOT_DIR$\plugins\org.dita.xhtml\build_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$\plugins\org.dita.basebuild_init.xml
,你会发现:
<xmlcatalog id="dita.catalog">
<catalogpath path="${dita.plugin.org.dita.base.dir}/catalog-dita.xml"/>
</xmlcatalog>
指向最开始打开的XML目录。
声明如下:
<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 catalog 旨在为 XML 实体提供解决方案。摘自 XML 目录规范的摘要:
this OASIS Standard defines an entity catalog that maps both external identifiers and arbitrary URI references to URI references.
打开 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()
函数)将是 "redirected" 文件夹plugins/org.dita.xhtml/
这样在您的情况下,将搜索相对于 DITA-OT 安装文件夹的文件 plugins/org.dita.xhtml/xsl/dita2html-base.xsl
。
但是这个目录怎么用呢?
例如在 $DITAOT_DIR$\plugins\org.dita.xhtml\build_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$\plugins\org.dita.basebuild_init.xml
,你会发现:
<xmlcatalog id="dita.catalog">
<catalogpath path="${dita.plugin.org.dita.base.dir}/catalog-dita.xml"/>
</xmlcatalog>
指向最开始打开的XML目录。