xsl-list
[Top] [All Lists]

RE: Transformation problem tei > xhtml

2005-04-11 23:22:35
Hi,

In TEI, this might be encoded as follows (2):

<p>Text text text:
   <quote>
     <p>Quotation quotation quotation.</p>
   </quote>
  More comment on this quotation.
   <quote>
      <p>Another long quotation.</p>
   </quote>
</p>

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>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns="http://www.w3.org/1999/xhtml";
                version="1.0">
  
  <xsl:template match="/p">
    <xsl:apply-templates select="node()[1]" mode="group"/>
  </xsl:template>
  
  <xsl:template match="quote">
    <blockquote>
      <xsl:apply-templates/>
    </blockquote>
  </xsl:template>
  
  <xsl:template match="p">
    <p>
      <xsl:apply-templates/>
    </p>
  </xsl:template>
  
  <xsl:template match="text()" mode="group">
    <xsl:if test="normalize-space()">
    <p>
      <xsl:apply-templates select="."/>
    </p>
      </xsl:if>
    <xsl:apply-templates select="following-sibling::node()[1]" mode="group"/>
  </xsl:template>
  <xsl:template match="*" mode="group">
    <xsl:apply-templates select="."/>
    <xsl:apply-templates select="following-sibling::node()[1]" mode="group"/>
  </xsl:template>
  
</xsl:stylesheet>

I.e. Tree Walker grouping aka Levitation.

Cheers,

Jarno - Mark Tyler: July 2002 Mix <www.hardnrg.com>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>