On Thu, 3 May 2007 09:03:56 -0700
"ccbranham" <[EMAIL PROTECTED]> wrote:

> Hello. I'm in the process of learning XSLT on my own and trying to 
> transition from working with the simple examples in books and documentation 
> to working with exported XML from OO Writer. It's a giant leap!
> 
> I'd like to create a transformation that works with OO Writer to export a 
> document to a simple XML format (stripping out all the style information and 
> metadata and retaining just the structure of the document). I can't seem 
> even to get it started, so was wondering if someone had a simple XSLT 
> example that I could study or knew where I could find one.

Hi Craig,

See attached example.xsl. Note that I stripped this down heavily so I
may have broken it in the process. Also, beware that ODT is a flag XML
format (I'd be curious to know why they did that) so all of the usual
child and decendent Xpath expressions are less useful with ODT. You'll
find yourself doing a lot of preceding-sibling / following-sibling stuff
which can get quite hairy.

Mike

-- 
Michael B Allen
PHP Active Directory Kerberos SSO
http://www.ioplex.com/
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
	xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
	xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
	xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
	xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
	xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
	xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
	xmlns:xlink="http://www.w3.org/1999/xlink";
	xmlns:dc="http://purl.org/dc/elements/1.1/";
	xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
	xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
	xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
	xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
	xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
	xmlns:math="http://www.w3.org/1998/Math/MathML";
	xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
	xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
	xmlns:ooo="http://openoffice.org/2004/office";
	xmlns:ooow="http://openoffice.org/2004/writer";
	xmlns:oooc="http://openoffice.org/2004/calc";
	xmlns:dom="http://www.w3.org/2001/xml-events";
	xmlns:xforms="http://www.w3.org/2002/xforms";
	xmlns:xsd="http://www.w3.org/2001/XMLSchema";
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
	exclude-result-prefixes="office style text table draw fo xlink dc meta number svg chart dr3d math form script ooo ooow oooc dom xforms xsd xsi">

<xsl:output method="html"
	encoding="ISO-8859-1"
	doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>

<xsl:template match="office:body">
	<xsl:apply-templates/>
</xsl:template>

<xsl:template match="text:[EMAIL PROTECTED]:style-name='p_5f_heading_5f_5']">
	<h5><xsl:apply-templates/></h5>
</xsl:template>

<xsl:template match="text:[EMAIL PROTECTED]:style-name='p_5f_text_5f_body']">
	<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="text:[EMAIL PROTECTED]:style-name='p_5f_italic']">
	<i><xsl:apply-templates/></i>
</xsl:template>

<xsl:template match="table:table">
	<table class="sdata" width="100%">
		<xsl:apply-templates/>
	</table>
</xsl:template>

<xsl:template match="table:table-row[position() = 1]">
	<tr>
		<xsl:apply-templates mode="th"/>
	</tr>
</xsl:template>
<xsl:template match="table:table-row">
	<tr>
		<xsl:apply-templates/>
	</tr>
</xsl:template>

<xsl:template mode="th" match="table:table-cell">
	<th>
		<xsl:apply-templates/>
	</th>
</xsl:template>

<xsl:template match="table:table-cell">
	<td>
		<xsl:apply-templates/>
	</td>
</xsl:template>

<xsl:template match="text()|@*">
    <xsl:value-of select="."/><xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="text:p">
	<xsl:apply-templates/>
</xsl:template>

<xsl:template match="text:h|text:index-title-template|text:table-of-content|text:user-index|office:automatic-styles|office:font-face-decls">
</xsl:template>

</xsl:stylesheet>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to