Tei:p

From DM

Jump to: navigation, search


tei:p (paragraph) "marks paragraphs in prose" (http://www.tei-c.org/P4X/ref-P.html). For a discussion of how to encode paragraphs in a variety of structural languages, see Paragraph (part of the how do I encode... Binder).

Contents

Subclasses and attributes

There are no required attributes or subclasses. @type or @rend may be used to distinguish among different types of paragraphs, e.g.

rend="first"
rend="warning"

See the TEI Guidelines for a discussion of available attributes.

Style

Paragraphs may be formatted in a variety of different ways depending on the conventions of the medium and aesthetic sensibility of the text designer. Some common formattings include:

  • Block style (justified on one or both sides; first line not indented; 1 line space above and below). This is a common display for text on screen)
  • Indented style (justified on one or both sides; first line indented slightly; no leading or trailing space). This is common in print contexts.
  • Hanging first line (justified on one or both sides; first line extended slightly into the left-margin; with or without no leading or trailing space). This is common in bibliographies.

CSS

If you are attempting to display a TEI XML document directly in a commercial browser, the following CSS fragments can be used to style the element:

Block style

p {
  display:block;
  margin-top:1em;
  margin-bottom:1em;
}

Indented style

p {
  display:block;
  margin-top:0;
  margin-bottom:0;
  text-indent:1em;
}

Hanging first line

p {
  display:block;
  margin-top:0;
  margin-bottom:0;
  text-indent:-1em;
}

Justified left and right margins

All three of the above fragments will produce right-justified text (i.e. aligned down the left margin [except for the first line, in the Indented style] with a "ragged" right margin). To justify both margins, you can add the following line to any style:

text-align:justify;

XSLT

Conversion to XHTML

If you are going to convert your TEI paragraph to XHTML, the basic template looks like this

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

As noted in the Paragraph article, however, TEI and (X)HTML have a different model for paragraphs. This becomes an issue with typographically complex paragraphs, particularly those containing internal block quotations, tables, lists, or figures. The specific details of the template used to do this will vary depending on the precise coding of the input XML document. The following example is based on the markup used for articles in the DM journal, where block quotes are encoded as follows (Lorem ipsum from the Lorem ipsum generator):

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Nam id lorem. Nulla velit dolor, pulvinar id, dignissim et, lobortis et, eros.
Quisque pretium turpis luctus dui. Praesent dapibus. Nunc tincidunt orci eu arcu.
<quote>
 <p>Curabitur mollis, magna eu ultricies sagittis, justo mi
 commodo tellus, sit amet aliquam pede dui sed nunc. Aenean at eros. Aenean eu
 quam vel massa laoreet suscipit.</p>
</quote>
Nunc arcu quam, congue ac, congue et, ullamcorper a, leo. Maecenas dapibus,
sapien non semper semper, neque enim dapibus ligula, in cursus quam dolor sed nunc.
Nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>

Converting this to valid XHTML requires the following the XSLT (version 2.0):

<xsl:template match="p">
 <xsl:for-each-group select="node()"
                     group-adjacent="self::quote[p] or self::table or self::list">
  <xsl:choose>
   <xsl:when test="current-grouping-key()">
    <xsl:apply-templates select="current-group()"/>
   </xsl:when>
   <xsl:otherwise>
    <p>
     <xsl:copy-of select="current-group()"/>
    </p>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:for-each-group>
</xsl:template>

(Based on the example Grouping Alternating Sequences of Elements in the XSLT 2.0 Specification).

Resources

The differences between the TEI and XHTML models for paragraph were the subject of an extended discussion on TEI-L, the mailing list of the Text Encoding initiative. To follow the thread, begin with: http://listserv.brown.edu/archives/cgi-bin/wa?A2=ind0501&L=tei-l&F=&S=&P=20212.

The XSLT method proposed here requires XSLT 2.0. A partial solution for XSLT 1.0 was posted by Michael Beddow as part of the tei-l thread: http://listserv.brown.edu/archives/cgi-bin/wa?A2=ind0501&L=tei-l&F=&S=&P=24080.

Related topics

Personal tools