For people who use modular DocBook the management of entity references can become very time consuming, especially when the number of XML files is high and even more so when they are managed in a folder structure.
To part automate the procedure of creating and maintaining such entity lists, I have hacked the following solution. If anyone has improvements or suggestions, please let me know.
To the Oxygen Development Team, perhaps you could find a way to include this solution as a plug-in, or develop the equal functionality in Oxy.
I have used DIRTOXML from http://www.bayes.co.uk to create the input for the XSLâ€™s that will write the entity list. DIRTOXML is a command line tool that writes a directory listing as an XML file, recursively.
For Windows Users
The script dirTOxml2.js needs no modification. Just run the script. Depending on how you have scripting set up one of the following 3 methods will produce an XML file containing a directory listing.
cscript dirTOxml2.js folder xmlfile
wscript dirTOxml2.js folder xmlfile
dirTOxml2.js folder xmlfile
Example: dirTOxml2.js "c:\temp" "xmlfile.xml"
Open an XSL in Oxygen and copy paste the following script:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml"/>
<xsl:variable name="Path" select="@Path"/>
<xsl:variable name="Name" select="@name"/>
<xsl:text disable-output-escaping="yes"><</xsl:text>!ENTITY <xsl:value-of
select="substring-before($Name, '.')"/> SYSTEM '<xsl:value-of select="$Path"/>'<xsl:text disable-output-escaping="yes">></xsl:text>
Input the output file from obtained from dirTOxml2.js and your.xsl to your processor. Direct the output to a filename of your choice. Transform and the entity list is written.
In the prolog of your main (root) file, point to the file containing the entity list, something like this:
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"./docbook/dtd/docbookx.dtd" [<!ENTITY % global_ent SYSTEM 'global.ent'>
For Linux Users (or users that wish to use perl), if anyone is interested I also have an xsl that will output an entity list from the output of the perl version. The perl version of DIRTOXML works a little differently. The XML format is not the same as the dirTOxml2.js and it does not require output to a file by default. If anyone is interested I can send the XSL, just let me know.
I hope this gives the general idea. I think this functionality is basic, but if enhanced and placed in a jar plugin to Oxygen it will be a very useful tool.
Enjoy and more ideas later.
Are you missing a feature? Request it's implementation here.
1 post • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests