Part Automating ENTITY LIST Management
Are you missing a feature? Request its implementation here.
Part Automating ENTITY LIST Management
Post by Guest »
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"><</xsl:text>!ENTITY <xsl:value-of
select="substring-before($Name, '.')"/> SYSTEM '<xsl:value-of select="$Path"/>'<xsl:text disable-output-escaping="yes">></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
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"><</xsl:text>!ENTITY <xsl:value-of
select="substring-before($Name, '.')"/> SYSTEM '<xsl:value-of select="$Path"/>'<xsl:text disable-output-escaping="yes">></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
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service