Re: [xsl] Transformation problem tei > xhtml

Subject: Re: [xsl] Transformation problem tei > xhtml
From: James Fuller <jim.fuller@xxxxxxxxxxxxxx>
Date: Tue, 12 Apr 2005 08:57:33 +0200
> In valid XHTML, however, <p> can't contain the equivalent block level
> elements like <blockquote>, <table>, <list>, so the text would need to
> be encoded (3):
>
> <p>Text text text:</p>
>   <blockquote>
>     <p>Quotation quotation quotation.</p>
>   </blockquote>
>  <p>More comment on this quotation.</p>
>   <blockquote>
>      <p>Another long quotation.</p>
>   </blockquote>
>
> The question is, how does one get from the TEI coding (2), where <p>
> can contain 'block level' elements like quote/p, table, and list, to
> the XHTML coding (3), where <p> can't contain block level equivalents
> blockquote/p, table, and ul|ol ?
>

this should do the trick (untested)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >
   
    <xsl:output method="xhtml" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/">
       
        <!-- Transform TEI -->
        <xsl:variable name="result">
            <xsl:apply-templates select="p"/>
        </xsl:variable>
 
        <!-- Display Results -->
        <xsl:copy-of select="$result"/>
       
    </xsl:template>
   
  <xsl:template match="text()">
        <xsl:if test="normalize-space()">
            <p><xsl:value-of select="normalize-space(.)"/></p>
        </xsl:if>
    </xsl:template>
   
    <xsl:template match="p">
        <xsl:apply-templates/>
    </xsl:template>
   
    <xsl:template match="quote">
        <blockquote>
            <xsl:apply-templates/>
        </blockquote>
    </xsl:template>   
   
</xsl:stylesheet>

> Ideally as another constraint, the first html:p in a sequence like (1)
> should be distinguished from the rest so that one can recognise the
> beginning of a rhetorical paragraph--perhaps by the addition of a
> section number.

you can now take the $result variable and do whatever post processing
you would like....which I leave to you.

gl, Jim Fuller

Current Thread