Proposal for @selector attribute on rendition

From TEIWiki
Jump to navigation Jump to search

NOTE: THIS PROPOSAL WAS IMPLEMENTED IN revision 13264 and 13266.

This proposal arises out of FR 520, which presents a number of ideas for enhancements to the <rendition> element. This proposal is the simplest and most straightforward, consisting of a single new attribute, which I believe will be the least controversial and easiest to implement.

Rationale

The combination of <rendition> and @rendition currently allows us to link specific elements with blocks of style code (almost always CSS) in the manner of the HTML @class attribute, and @style allows the direct application of CSS to a specific element. What we cannot currently do is specify a default rendition for an element or a set of elements, except through the use of <tagUsage>/@render; this is crude in allowing only the linking of style blocks with unqualified elements, and it also brings in the requirement that every element used be provided with a matching <tagUsage> element.

I would argue that a better approach would be a new attribute called @selector available on the <rendition> element, through the att.styleDef class. Its definition would be:

A selector or series of selectors specifying the elements to which the contained style description applies, expressed in the language specified in the @scheme attribute.

This would allow simple definitions like the following:

  <rendition 
     scheme="css" 
     selector="text, front, back, body, div, p, ab">
     display: block;
  </rendition>

making this a straighforward way in which to express a basic mapping between TEI elements and their default styles. It would of course allow much more sophisticated mapping, including for instance the use of @rend:

  <rendition 
     scheme="css" 
     selector="*[rend*=italic]">
     font-style: italic;
  </rendition>

and would make it easy to express different default rules for the same element in different contexts:

  <rendition 
     scheme="css" 
     selector="front p, back p">
     margin-top: 0.5em;
  </rendition>
  <rendition 
     scheme="css" 
     selector="body p">
     margin-top: 0;
  </rendition>

Details

ODD

This is the proposed ODD fragment, to be added to rendition.xml<ref>I originally proposed adding this to att.styleDef, but the <styleDefDecl> element is a member of this class, so that makes no sense; instead, it should be added directly to the <rendition> element.</ref>:

  <attDef ident="selector">
     <desc versionDate="2015-05-25" xml:lang="en">
        A selector or series of selectors specifying the elements to which the contained style 
        description applies, expressed in the language specified in the <att>scheme</att> attribute.
     </desc>
     <datatype maxOccurs="1">
       <ref xmlns="http://relaxng.org/ns/structure/1.0" name="data.text"/>
     </datatype>
     <exemplum xml:lang="en">
        <egXML xmlns="http://www.tei-c.org/ns/Examples">
           <rendition 
              scheme="css" 
              selector="text, front, back, body, div, p, ab">
              display: block;
           </rendition>
        </egXML>
     </exemplum>
     <exemplum xml:lang="en">
        <egXML xmlns="http://www.tei-c.org/ns/Examples">
           <rendition 
              scheme="css" 
              selector="*[rend*=italic]">
              font-style: italic;
           </rendition>
        </egXML>
     </exemplum>
     <remarks versionDate="2015-05-25" xml:lang="en">
        Since the default value of the <att>scheme</att> attribute is assumed to be CSS, the default 
        expectation for this attribute, in the absence of <att>scheme</att>, is that CSS selector
        syntax will be used.
     </remarks>
     <remarks versionDate="2015-05-25" xml:lang="en">
        While <att>rendition</att> is used to point from an element in the transcribed source to a 
        <gi>rendition</gi> element in the header which describes how it appears, the <att>selector</att>
        attribute allows the encoder to point in the other direction: from a <gi>rendition</gi> in the
        header to a collection of elements which all share the same renditional features. In both cases,
        the intention is to record the appearance of the source text, not to prescribe any particular 
        output rendering.
     </remarks>
  </attDef>

Chapter prose

These are proposed changes to the prose of Chapter 2:

The attribute will be added to 2.3.4's specDesc for att.styleDef:


  <specDesc key="att.styleDef" atts="scheme schemeVersion selector"/>



The following changes would be made to 2.3.4.1 Rendition:


One or more such specifications may be associated with elements of a document in two three ways:

  • the @render attribute of the appropriate tagUsage element may be used to indicate a default rendition for all occurrences of the named element
  • the @selector attribute on any <rendition> element may be used to select a collection of elements to which it applies
  • the global @rendition attribute may be used on any element to indicate its rendition, overriding or complementing any supplied default value


Following the first example and before the second, the following prose and example would be inserted:


In the above example, all <p> are styled in the same way, as are all <hi> elements, except where @rendition is used to override the default at the element level. However, suppose that all paragraphs in the <front> of a text appear in a large font, with significant top and bottom margins, while paragraphs in the main <body> are in regular font size and have no top and bottom margins. This would be difficult to express using <tagUsage>; and it would be inefficient to have to provide repeated @rendition attributes on every paragraph in one or the other context. Instead, we can use the @selector attribute on <rendition> for a more elegant solution:

  <egXML xmlns="http://www.tei-c.org/ns/Examples">
     <rendition 
        scheme="css" 
        selector="front p">
             font-size: 110%;
             margin-top: 0.5em;
             margin-bottom: 0.5em;
     </rendition>
  </egXML>
  <egXML xmlns="http://www.tei-c.org/ns/Examples">
     <rendition 
        scheme="css" 
        selector="body p">
             font-size: 100%;
             margin-top: 0;
             margin-bottom: 0;
     </rendition>
  </egXML>


It is recommended that in a single text, either <rendition>/@selector or <tagUsage>/@render be used; the combination of both is potentially confusing and harder to process.




2.3.5 The Default Style Definition Language Declaration would be amended as follows:



The content of the rendition element, the value of the @selector attribute, and the value of the style attribute are expressed using one of a small number of formally defined style definition languages. For ease of processing, it is strongly recommended to use a single such language throughout an encoding project, although the TEI system permits a mixture.



Notes

<references/>