Re: layout for entries in one group

Svante Schubert <[email protected]> Mon, 20 Feb 2006 21:12:51 +0100
Newsgroups gmane.comp.openoffice.devel.xml
Organization StarOffice / Sun Microsystems, Inc.
Message-ID <[email protected]>
Hi Michael,

M. Niedermair wrote:
> hi,
> 
> i will create a layout for listings.
> 
> ...
> [listing] public class Test {
> [listing]     // ...
> [listing] }
> ...
> 
> if i export the document, i get
> <text:p text:style-name="Standard">Dies ist ein Text</text:p>
> <text:p text:style-name="Standard"/>
> <text:p text:style-name="listing">public class Test {</text:p>
> <text:p text:style-name="listing">   // ...</text:p>
> <text:p text:style-name="listing">}</text:p>
> <text:p text:style-name="Standard"/>
> 
> How can i transform this (with xslt) to something like that (the 
> 'Standard' is not the problem):
> 
> <p>Dies ist ein Text</p>
> <p></p>
> <listing>
>   <p>public class Test {</p>
>   <p>   // ...</p>
>   <p>}</p>
> </listing>
> <p></p>
> 
you might do the following:

<xsl:template match="text:p" name="text:p">
     <p>
         <xsl:value-of select="text()"/>
     </p>
</xsl:template>

<xsl:template match="text:p[@text:style-name='listing']">
   <xsl:if 
test="not(preceding-sibling::text:p[@text:style-name='listing'])">
         <listing>
             <xsl:call-template name="text:p"/>
             <xsl:apply-templates select="following-sibling::*[1]" 
mode="list" />
         </listing>
     </xsl:if>
</xsl:template>

<xsl:template match="text:p[@text:style-name='listing']" mode="list">
     <xsl:call-template name="text:p"/>
</xsl:template>

<xsl:template match="text()"/>


Regards,
Svante