User:SwifT/proj2wiki

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.

Process

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

Script

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

#!/bin/sh

if [ -z "${PROJ2WIKI_BASE}" ]
then
  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;
fi

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

PROJXML="${1}";

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

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

#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" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <rewriteURI uriStartString="/" rewritePrefix="/home/user/cvs/gentoo-docs/gentoo/xml/htdocs/"/>
  <rewriteURI uriStartString="http://www.gentoo.org/" rewritePrefix="/home/swift/cvs/gentoo-docs/gentoo/xml/htdocs/"/>
</catalog>

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 proj2wiki.sh proj/en/hardened/index.xml

Test pages

Below are a few outputs of test pages