2015-07-21 48 views
0

的聲明如下理解XSL import語句:需要幫助從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代碼如何解析這些路徑?

+1

我認爲'plugin:'是一個已知的並由您使用的軟件支持的自定義URI方案,它將實現一個知道如何使用方案'plugin:'處理這些URI的URI解析器。 –

+0

@MartinHonnen你的意思是這樣的[鏈接](http://stackoverflow.com/questions/11864564/xslcompiledtransform-and-custom-xmlurlresolver-an-entry-with-the-same-key-alre)? –

+0

該鏈接是關於.NET的,但我知道Dita工具包是基於Java的。我不熟悉該工具包的細節,也許別人可以告訴你更多。 –

回答

2

如果您查看DITA-OT的根安裝文件夾,您會發現一個名爲catalog-dita.xml的文件。這個XML catalog旨在爲XML實體提供解決方案。摘自XML目錄規範摘要:

此OASIS Standard定義了一個實體目錄,它將外部標識符和任意URI引用都映射到URI引用。

打開目錄,dita.xml文件,並搜索plugin:org.dita.xhtml。你會發現這個條目:

<rewriteURI uriStartString='plugin:org.dita.xhtml:' rewritePrefix='plugins/org.dita.xhtml/'/> 

因此,任何<xsl:import href="...">(以及<xsl:include href="...">document()功能)有與plugin:org.dita.xhtml:開始參考URI將「重定向」的文件夾plugins/org.dita.xhtml/,使你的情況,文件plugins/org.dita.xhtml/xsl/dita2html-base.xsl ,相對於DITA-OT安裝文件夾,將被搜索。

但是這個目錄是如何使用的?

例如在$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>這裏是任務),該目錄將爲轉換過程中所需的所有資源提供適當的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目錄。