0

The statement is as follows:

<xsl:import href="plugin:org.dita.xhtml:xsl/dita2html-base.xsl"/>

I am new to XSL. I know the href attribute requires a URI but how does the href value resolve to a URI in the above statement. This code is part of the xhtml plugin's xsl in the DITA-OT. There are multiple statements like these. Are these relative paths from a root directory ? How does the DITA-OT code resolve these paths ?

  • 1
    I assume that `plugin:` is a custom URI scheme known and supported by the software you use, it will have some implementation of a URI resolver that knows how to treat those URIs with the scheme `plugin:`. – Martin Honnen Jul 21 '15 at 10:59
  • @MartinHonnen You mean something like this [link](http://stackoverflow.com/questions/11864564/xslcompiledtransform-and-custom-xmlurlresolver-an-entry-with-the-same-key-alre) ? – Ritesh Srivastava Jul 22 '15 at 06:26
  • That link is about .NET while I understand that the Dita toolkit is Java based. I am not familiar with details of the toolkit, maybe someone else can tell you more. – Martin Honnen Jul 22 '15 at 14:33

1 Answers1

2

If you have a look at the root installation folder of your DITA-OT, you will find a file named catalog-dita.xml. This an XML catalog aimed to provide resolution schemes for XML entities. Excerpt from the abstract of the XML catalogs specification:

this OASIS Standard defines an entity catalog that maps both external identifiers and arbitrary URI references to URI references.

Open the catalog-dita.xml file, and search plugin:org.dita.xhtml. You will find this entry:

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

Thus any <xsl:import href="..."> (and also the <xsl:include href="..."> and document() function) with a reference uri that starts with plugin:org.dita.xhtml: will be "redirected" the folder plugins/org.dita.xhtml/ so that in your case, the file plugins/org.dita.xhtml/xsl/dita2html-base.xsl, relatively to the DITA-OT installation folder, will be searched.

But how is this catalog used?

For example in $DITAOT_DIR$\plugins\org.dita.xhtml\build_general.xml (it is broadly used in the DITA-OT so might find these instructions in almost all build_xxx.xml files), you'll find something like:

<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>

This is meant to invoke an XSL-T transformation (<xslt> here is an task) with the catalog that will provide the appropriate URI mappings for all the resources needed during transformation. Obviously, dita.catalog is a reference to a declared catalog elsewhere.

Open the $DITAOT_DIR$\plugins\org.dita.basebuild_init.xml, you will find this:

<xmlcatalog id="dita.catalog">
  <catalogpath path="${dita.plugin.org.dita.base.dir}/catalog-dita.xml"/>
</xmlcatalog>

Which points to the XML catalog that has been opened at the beginning.

potame
  • 7,597
  • 4
  • 26
  • 33