Part Automating ENTITY LIST Management

Are you missing a feature? Request it's implementation here.
Guest

Part Automating ENTITY LIST Management

Mon Aug 25, 2003 10:18 pm

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"

Next:

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:template match="file">
<xsl:variable name="Path" select="@Path"/>
<xsl:variable name="Name" select="@name"/>
<xsl:text disable-output-escaping="yes">&lt;</xsl:text>!ENTITY <xsl:value-of
select="substring-before($Name, '.')"/> SYSTEM '<xsl:value-of select="$Path"/>'<xsl:text disable-output-escaping="yes">&gt;</xsl:text>
</xsl:template>
</xsl:stylesheet>

---------------
Save.

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'>
%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.

Sean Wheller

Return to “Feature Request”

Who is online

Users browsing this forum: No registered users and 1 guest