forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clay Leeds <webmaes...@mac.com>
Subject Re: ODT: adding title element to pages
Date Tue, 25 Apr 2006 04:15:29 GMT
Updated Subject line. Sorry.

I meant to add, that OOo grabs the file name via an xsl:param, which  
is passed through via a Cocoon pipeline. Will we want to do a similar  
thing with this odt plugin?

Clay

On Apr 24, 2006, at 9:12 PM, Web Maestro Clay wrote:
> ODT uses a similar structure to OOo. I want to grab the document  
> title element (stored in 'odt_file.odt/meta.xml' as / 
> office:document-meta/office:meta/dc:title). But the ODT transformer  
> currently only looks at /content.xml.
>
> Here's what I've got so far:
>
> <xsl:stylesheet ..>
> <!-- FIXME Grab the file name -->
> <xsl:variable name="filename">Insert Client Name</xsl:variable>
>
> <xsl:output
> 	method="xml"
> 	indent="yes"
> 	omit-xml-declaration="yes"
> 	doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
> 	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1- 
> transitional.dtd"
> 	encoding="UTF-8"
> />
>
> <..>
>
> <!--
>        Following hanged to match="/" from match="/office:document- 
> content"
>        with optimistic hope I could grab the dc:title element from / 
> meta.xml
> -->
> <xsl:template match="/">
> <!-- At this point, we are inside /content.xml, but we need to grab  
> the 'title' element from /meta.xml (a sibling of /content.xml),  
> but /meta.xml is a sibling inside the ODT ZIP file. How do we get  
> to that? I don't think xsl:import would work, since we're in a ZIP  
> file. -->
>
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <title>
>   <xsl:choose>
>     <!-- if no title element or h1 elements, display $filename -->
>     <xsl:when test="(/office:document-meta/office:meta/dc:title =  
> '' or
>         not(office:document-meta/office:meta/dc:title)) and
>         office:document-content/office:body/text:h[1] = ''">
>       <xsl:value-of select="$filename"/>
>     </xsl:when>
>     <!-- if no title element, display 1st h1 -->
>     <xsl:when test="not(/office:document-meta/office:meta/dc:title)  
> and
>         office:document-content/office:body/text:h[1] != ''">
>       <xsl:value-of select="office:document-content/office:body/ 
> text:h[1]"/>
>     </xsl:when>
>     <!-- display title element from ODT File:Properties -->
>     <xsl:otherwise>
>       <xsl:value-of select="/office:document-meta/office:meta/ 
> dc:title"/>
>     </xsl:otherwise>
>   </xsl:choose>
> </title>
> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
> <xsl:apply-templates select="office:document-content/ 
> office:automatic-styles"/>
> </head>
> <body>
> <xsl:apply-templates select="office:document-content/office:body/ 
> office:text"/>
> </body>
> </html>
> </xsl:template>


Clay Leeds
webmaestro@mac.com

My religion is simple. My religion is kindness.
-- HH Dalai Lama of Tibet




Mime
View raw message