Dost.jar and fo.jar


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Dost.jar and fo.jar

  1. 1. Overview of Dost.jar and FO.jar<br />Aryeh Sanders, Suite Solutions<br />
  2. 2. Who Are We?<br />Our Mission<br />To increase our customers’ profitability by significantly improving the efficiency of their information development and delivery processes.<br />Qualitative Advantage<br />Content Lifecycle Implementation (CLI) is Suite Solutions’ comprehensive approach – from concept to publication – to maximizing the value of your information assets.<br />Our professionals are with you at every phase, determining, recommending and implementing the most cost-effective, flexible and long term solution for your business.<br />
  3. 3. Clients and Partners<br />3<br />Private and Confidential<br />Suite Solutions©2009<br />
  4. 4. Introduction<br />We will discuss what exactly are dost.jar and fo.jar and the role they play in the DITA-OT<br />Quick answers:<br />dost.jar holds the Java code for the DITA-OT as a whole<br />fo.jar holds the Java code for the FO plugin (otherwise known as PDF output)<br />In both cases, the JAR files are simply a place to store Java code. As such, they each have a collection of different functions.<br />We will discuss why you usually will NOT want to customize them, and some exceptions<br />
  5. 5. Overview<br />How to Build a New dost.jar<br />Overview of Functions of dost.jar<br />Changing dost.jar to Detect New Image Types<br />Overview of Functions of fo.jar<br />How to Build a New fo.jar<br />
  6. 6. Dost.jar Source Code<br />Not available in the default DITA-OT download<br />Available via CVS (the source control system) from SourceForge<br />Available as a separate download from SourceForge<br />Current stable version available here:<br />You may have to hunt for it; the name isn’t consistent between versions<br />
  7. 7. Building dost.jar<br />Unzip the source code over an existing copy of the DITA-OT<br />You may prefer to download a clean copy of the DITA-OT for this<br />Not all of the tools needed are included in the source code package, but they are in the full DITA-OT download<br />Some files will overwrite each other, but this will create a copy of the DITA-OT with the source code<br />Run startcmd.bat<br />This sets up various environment variables so that, for instance, you can run Ant<br />Build dost.jar<br />ant -f buildPackage.xml package-java<br />You’ll get some warnings, but if you get a successful build, that’s it<br />
  8. 8. Overview of Functions of dost.jar <br />
  9. 9. Layout of dost.jar Source Code<br />
  10. 10. Layout of dost.jar Source Code<br />Although we can broadly define three different functions in dost.jar, they’re not organized that way in the source code.<br />Instead it’s organized by specific function – the code is invoked through one of the files in the invoker folder; logging is done by code in the log folder, and so on<br />
  11. 11. Dost.jar Functions (1)<br />Java Invoker<br />Implemented in the invoker folder in<br />Not related to the other files in that folder<br />(ExtensibleAntInvoker doesn’t seem to be used?)<br />Does rely on other Java code for logging and so on<br />If you use the Java command line, and needed to add a command line parameter to the DITA-OT, then this is where to do it<br />If you wanted to add a new parameter /myparam:value, so you could use it like so:java -jar libdost.jar /i:inputfile /transtype:xhtml /myparam:special<br />Just add:paramMap.put("/myparam", “my.ant.parameter");in the section with the rest of the parameters<br />
  12. 12. Downside to Modifying dost.jar<br />dost.jar is not designed to be modified or extended. You have no easy way to upgrade dost.jar and retain your changes.<br />Unlike most other parts of the toolkit, which support plugins<br />There’s an easier way to achieve the same goal as the previous example:<br />set ANT_OPTS="%ANT_OPTS% -Dmy.ant.parameter=value"<br />This is usually true for most other changes you would want<br />The DITA-OT still has known bugs, so even if you are satisfied with the current functionality, you may want to preserve your ability to upgrade to get bug fixes<br />DITA itself gets updated, and you may want to benefit from new DITA 1.2 or eventually DITA 1.3 features when they come along<br />
  13. 13. Basic Flow of CommandLineInvoker<br />First, validate the parameters<br />Modify certain parameters to have a full path instead of a relative path<br />Write the parameters to a temporary properties file<br />Call integrator<br />Call Ant via the command line, with a custom logger and the properties file as parameters<br />
  14. 14. Dost.jar Functions (2)<br />Integrator<br />Java implementation for supporting plugins<br />Searches demo and plugins subfolders for folders that contain a file called plugin.xml<br />If it has one, then it’s a plugin<br />Each plugin.xml file has a list of plugin points it modifies<br />Example: demodita11plugin.xml:<feature extension="dita.specialization.catalog.relative”value="catalog.xml" type="file"/>This will take the contents of demodita11catalog.xml and put it into the dita.specialization.catalog.relative extension point.<br />Plugin points are defined in many different files, all including _template in their names<br />Example: dita.specialization.catalog.relative is defined in catalog-dita_template.xml<br />Integrator will take catalog-dita_template.xml, and generate catalog-dita.xml, inserting the appropriate data from the dita11 plugin<br />
  15. 15. More About Integrator<br />We’re not going into much more detail now – in short, Integrator reads plugin.xml from each plugin, and rewrites each _template file to create the “real” version of the file.<br />catalog-dita_template.xml -> catalog-dita.xml<br />build_template.xml -> build.xml<br />build_general_template.xml -> build_general.xml<br />build_dita2eclipsehelp_template.xml -> build_dita2eclipsehelp.xml<br />build_preprocess_template.xml -> build_preprocess.xml<br />resource/messages_template.xml -> resource/messages.xml<br />xsl/common/allstrings_template.xml -> xsl/common/allstrings.xml<br />xsl/dita2xhtml_template.xsl -> xsl/dita2xhtml.xsl<br />xsl/dita2rtf_template.xsl -> xsl/dita2rtf.xsl<br />xsl/dita2odt_template.xsl -> xsl/dita2odt.xsl<br />xsl/dita2dynamicdita_template.xsl -> xsl/dita2dynamicdita.xsl<br />xsl/dita2fo-shell_template.xsl -> xsl/dita2fo-shell.xsl<br />xsl/dita2docbook_template.xsl -> xsl/dita2docbook.xsl<br />xsl/preprocess/maplink_template.xsl -> xsl/preprocess/maplink.xsl<br />xsl/preprocess/mapref_template.xsl -> xsl/preprocess/mapref.xsl<br />xsl/preprocess/mappull_template.xsl -> xsl/preprocess/mappull.xsl<br />xsl/map2plugin_template.xsl -> xsl/map2plugin.xsl<br />xsl/preprocess/conref_template.xsl -> xsl/preprocess/conref.xsl<br />xsl/preprocess/topicpull_template.xsl -> xsl/preprocess/topicpull.xsl<br />
  16. 16. More About Integrator<br />We will point out, though, that there are a bunch of different ways that Integrator inserts data into the template:<br />All defined in the platform folder, new ones added from time to time<br /><br /><br /><br /><br /><br />…<br />Selected by the _template files themselves:<br />E.g. catalog-dita_template.xml contains:<dita:extensionid="dita.specialization.catalog“ behavior="org.dita.dost.platform.InsertAction“xmlns:dita="" /><dita:extension id="dita.specialization.catalog.relative“ behavior="org.dita.dost.platform.InsertCatalogActionRelative“xmlns:dita="" /><br />
  17. 17. Dost.jar Functions (3)<br />Pipeline Functions<br />You can run the DITA-OT without the other functions. As long as you have created all those files that integrator will create, and as long as you invoke the toolkit directly via Ant, you can publish your DITA output just fine.<br />And it should be slightly faster! (Maybe a second or two)<br />These are also an assortment of unrelated functions<br />They are tied together by the DITA-OT pipeline – the DITA-OT runs the DITA files through a series of steps. The steps are coordinated by Ant, but some of the steps are implemented in Java<br />The are called by the <pipeline> task in Ant<br />Example:<pipeline message="Generate list." module="GenMapAndTopicList”basedir="${basedir}" inputmap="${args.input}”tempdir="${dita.temp.dir}“ extparam="ditadir=${dita.dir};validate=${validate};generatecopyouter=${generate.copy.outer};outercontrol=${outer.control};onlytopicinmap=${};outputdir=${output.dir};transtype=${transtype}" /><br />
  18. 18. Pipeline Functions<br />Current modules in use:<br />Chunk<br />Coderef<br />ConrefPush<br />DebugAndFilter<br />EscapeUnicode<br />GenMapAndTopicList<br />IndexTermExtract<br />Keyref<br />MoveLinks<br />MoveMeta<br />TopicMerge<br /><ul><li>Each one does something different
  19. 19. Most of the names are pretty clear
  20. 20. They are only chained together through Ant, so there’s no direct relationship between them
  21. 21. There’s some infrastructure within the Java code that passes the call from Ant to a specific module
  22. 22. invokerAntInvoker calls pipelinePipelineFacade which calls modulesModuleFactory which gets the actual module
  23. 23. The actual modules are defined in the modules folder</li></li></ul><li>Some Specific Pipeline Functions<br />gen-list, otherwise known as GenMapAndTopicList<br />Runs through the whole ditamap and all the referenced files, and generates a list of files that will be needed by Ant for each future step. This is how Ant knows which files need to be copied.<br />This is where conreflistand imagelist are generated<br />Although the files conref.list and image.list are generated later<br />DebugAndFilter<br /><ul><li>Adds debug attributes to each file in a new copy in the temp directory and filters out elements that are supposed to be removed as per the instructions in the ditaval file</li></ul>xtrc, xtrf attributes<br />Not all modules are always used<br />TopicMerge is used by PDF, but not by XHTML<br />TopicMerge creates one big file<br />It can take a stylesheet as a parameter, so the TopicMerge processing in PDF is actually partially Java (the merge) and partially a stylesheet (the actual form of the output from this step) <br />
  24. 24. Adding a New Image Type to the DITA-OT<br />The current implementation of the DITA-OT decides what’s an image based on a hard coded list<br />Which module would have this code?<br />It uses a utility function in<br />isSupportedImageFile<br />Supported images also appear in the function isValidTarget<br />Both require a one line modification:<br />|| lcasefn.endsWith(Constants.FILE_EXTENSION_GIF)<br />The constants are defined in<br />/**.gif extension.*/<br /> public static final String FILE_EXTENSION_GIF = ".gif";<br />Just add the appropriate lines, and rebuild, and you’ve added support for a new image type<br />
  25. 25. FO.jar<br />Like dost.jar, it’s a catch-all<br />
  26. 26. fo.jar Folder Structure<br />The sourceis in src:<br />
  27. 27. fo.jar Components (1)<br />In comidiomincwsopentopicxslextension:<br /> reports back to Ant what version of DITA is being processed<br />Ant uses it to decide which version of the stylesheets to use; the regular version for older versions of DITA, and the versions with _1.0 in the name for newer versions<br />In comsuitesolditaot<br />DetectLang.javareports the first xml:lang attribute in your files, which is used if you didn’t set the document.locale parameter to let the system know what language settings to use<br />
  28. 28. fo.jar Components (2)<br />In comidiomincwsopentopicfo:<br />In xep: there are Java classes that call RenderX XEP. This is used if you use XEP for your FO processor.<br />In i18n: there is code that is used together with your i18n configuration file and your font-mappings file to set fonts on a character-by-character basis. The Java code simply searches for each character listed in the i18n configuration files and marks it. The actual font is selected with the i18n-postprocess.xsl stylesheet.<br />In index2: this code is the code that constructs the index. The actual display is left to the stylesheets, but it searches for all the indexterms, constructs, groups, and sorts the list, and inserts it into one of the intermediate files, namely stage1.xml. That file is the input to the main stylesheets.<br />
  29. 29. More About fo.jar Index Sorting<br />Several known bugs<br />We’re working on them – if you have new ones, please report them on SourceForge<br />fo.jar does grouping and sorting<br />Grouping is deciding which words go in the “A” section, which in the “B” section, which in the “Special Characters” section, and so on<br />Sorting is putting them in the right order within that section<br />The index configuration files are used for grouping, not sorting<br />Sorting is handed off to the icu4j.jar library when it’s present. Otherwise, it uses built-in Java sorting, which is fine for English, but not for many languages<br />
  30. 30. Questions?<br />Any questions?<br />Be in touch!Aryeh<br />