From Gentoo Wiki
Jump to:navigation Jump to:search

Project 2 wiki conversion

I am working on a script and XSL translation to convert Gentoo's ProjectXML into MediaWiki style.

Although capturing the details is not possible, we should be able to make this process as painless as manageable.


The script does a two-trap conversion:

  1. it translates the ProjectXML to GuideXML (similar to how Gentoo's Gorg system does). This should have no loss of information (as we use the same stylesheets).
  2. it translates the GuideXML into MediaWiki format

The last translation does lead to a few problems and need additional work for the moment:

  1. mixing ul with ol (listings) does not work properly, the code currently "assumes" that multiple levels are all of the same type


The following script uses the stylesheets available in our CVS repository.


if [ -z "${PROJ2WIKI_BASE}" ]
  echo "PROJ2WIKI_BASE variable is not set.";
  echo "Please set it to the base location of the Gentoo documentation, like so:"
  echo "export PROJ2WIKI_BASE=/home/you/cvs/gentoo/xml/htdocs"
  exit 1;

if [ ! -d "${PROJ2WIKI_BASE}" ]
  echo "PROJ2WIKI_BASE (\"${PROJ2WIKI_BASE}\") is no valid directory."
  exit 2;


if [ ! -f "${PROJ2WIKI_BASE}/${PROJXML}" ]
  echo "There is no \"${PROJ2WIKI_BASE}/${PROJXML}\"."
  exit 3;

if [ -z "${XML_CATALOG_FILES}" ]
  echo "XML_CATALOG_FILES is not set; please set it to the conversion-catalog file."
  exit 4;

#xsltproc --path "${PROJ2WIKI_BASE}" "${PROJ2WIKI_BASE}/xsl/project.xsl" "${PROJ2WIKI_BASE}/${PROJXML}";
xsltproc --path "${PROJ2WIKI_BASE}" "${PROJ2WIKI_BASE}/xsl/project.xsl" "${PROJ2WIKI_BASE}/${PROJXML}" | xsltproc "${PROJ2WIKI_BASE}/xsl/guidexml2wiki.xsl" -;

The XML_CATALOG_FILE that we need to point to should contain the following:

<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <rewriteURI uriStartString="/" rewritePrefix="/home/user/cvs/gentoo-docs/gentoo/xml/htdocs/"/>
  <rewriteURI uriStartString="" rewritePrefix="/home/swift/cvs/gentoo-docs/gentoo/xml/htdocs/"/>

You will need to change the path to the correct location of the check-out.

Then, wiki-code can be attained as follows:

user $export PROJ2WIKI_BASE=/home/swift/cvs/gentoo/xml/htdocs
user $XML_CATALOG_FILES=/home/swift/conversion-catalog proj/en/hardened/index.xml

Test pages

Below are a few outputs of test pages