<?xml version="1.0" encoding="UTF-8"?>

<!-- wvWiki.xsl

an XSLT stylesheet to go from WV's XML output to the TWiki.org dialect
of WikiText.  To use this you need to first run WV to convert doc to
xml and then run the xml through an XSLT transformer using this
stylesheet to generate WikiText.  For example (on a Debian unstable
machine):

$ wvWare -x /usr/share/wv/wvXml.xml foo.doc > foo.xml
$ xsltproc wvWiki.xsl foo.xml > foo.txt

This sheet is pretty crude, and it will err on the side of stripping
unrecognized formatting (I find it's easier to add formatting back in
than to cut it out by hand).  If you're converting a lot of docs then
you probably want to add your custom Word styles to this sheet.

Also, WV seems to have some bugs that can cause it to generate
badly-formed XML in some cases.  The ones I've seen include botched
encoding declarations for docs that have european characters in them.
Hacking the encoding to encoding="ISO-8859-1" worked around the
problem for me, but if anyone knows the correct encoding I'd
appreciate them letting me know.  WV does a good job with embedded
images but adds some malformed XML (unmatched img element, IIRC) so
you need to fix those up by hand.

Toby Cabot
toby@caboteria.org

-->


<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">

<output method="text" />

<strip-space elements="doc table tr" />

<template match="/doc">
<apply-templates />
</template>

<template match="p[@class='Body Text']">
<apply-templates />
</template>

<template match="p[@class='Title Block']"><text>

---+ </text><value-of select="normalize-space(.)" /><text>
</text>
</template>


<template match="p[@class='Heading 1']"><text>

---+ </text><value-of select="normalize-space(.)" /><text>
</text>
</template>


<template match="p[@class='Heading 1,1']"><text>

---+ </text><value-of select="normalize-space(.)" /><text>
</text>
</template>


<template match="p[@class='Heading 2,2']"><text>

---++ </text><value-of select="normalize-space(.)" /><text>
</text>
</template>


<template match="p[@class='Normal,UC Heading']"><text>

---++ </text><value-of select="normalize-space(.)" /><text>
</text>
</template>

<template match="p[@class='Normal,BR Heading']"><text>

---++ </text><value-of select="normalize-space(.)" /><text>
</text>
</template>


<template match="p[@class='Heading 2']"><text>

---++ </text><value-of select="normalize-space(.)" /><text>
</text>
</template>


<template match="p[@class='Heading 3,3']"><text>

---+++ </text><value-of select="normalize-space(.)" /><text>
</text>
</template>


<template match="p[@class='Heading 4']"><text>

---+++ </text><value-of select="normalize-space(.)" /><text>
</text>
</template>


<template match="p[@class='UC Step Title']"><text>

---+++ </text><value-of select="normalize-space(.)" /><text>
</text> 
</template>


<template match="p[@class='Normal']">
  <value-of select="." />
</template>

<template match="p[@class='Body Text Indent']">
  <value-of select="." />
</template>

<template match="p">
<apply-templates />
</template>

<template match="table">
  <apply-templates />
</template>

<template match="tr">
| <apply-templates /></template>

<template match="th">
*<value-of select="normalize-space(.)" />* | </template>

<template match="td"><value-of select="normalize-space(.)" /> | </template>

<template match="b/i">__<value-of select="normalize-space(.)" />__ </template>
 
<template match="b">*<value-of select="normalize-space(.)" />* </template>
</stylesheet>
 
