Print

Print


> Ralph Cleminson wrote: 
> 
> > How about this?
> > 
> > <titlePage>
> >   <docAuthor>
> >     <persName>PEHR KALMS</persName> 
> >     <phr>Mag. Doc. in Hist. Nat. &amp; Oecon. vid *bo <lb/> 
> > Academie, samt Ledamots af Kongl. <lb/>   Svenska Wetenskaps 
> > Academien</phr>
> >   </docAuthor>
> >   <docTitle>
> >     <titlePart type="main">W*STG*THA <lb/> Och <lb/> 
> > BAHUSL*ND-<lb/>SKA RESA <lb/> F*rr*ttad <lb/> *r 1742.</titlePart>
> >     <titlePart type="sub">Med Anm*rkningar uti Historia 
> > Na-<lb/>turali, Physique, Medicine, Oeconomie,<lb/> 
> > Antiquiteter etc.<lb/> Jemte n*dige Figurer.</titlePart>
> >   </docTitle>
> >   <docImprint>
> >     <pubPlace>STOCKHOLM.</pubPlace>
> >     Trykt hos <name>Lars Salvius</name><lb/>
> >     P* des egen kostnad <date>1746</date>.
> >   </docImprint>
> > </titlePage>

Patrick Nyman wrote:

> It would be fine, if only I knew how to code in xslt that 
> the text after the first <lb/> should be treated differently
> than the text after the second <lb/>.

It depends what kind of treatment you want, of course. Personally I
usually just transform <tei:lb/> into <xhtml:br/>, but to actually treat
each line of text independently is something else; perhaps this (HTML)
template might give you a clue:

<xsl:template match="titlePage//*[lb]/text()">

	<xsl:variable 
		name="current-title-page-id" 
		select="generate-id(ancestor::titlePage)"/>

	<xsl:variable 
		name="preceding-line-breaks" 
		select="preceding::lb[
	
generate-id(ancestor::titlePage)=$current-title-page-id
		]"/>

	<xsl:element name="span">
		<xsl:attribute name="class">
			<xsl:value-of select="concat('line-',
1+count(preceding-line-breaks)"/>
		</xsl:attribute>
		<xsl:value-of select="."/>
	</xsl:element>

</xsl:template>

This template wraps each text node with a <span class="line-1"> or <span
class="line-2"> etc, depending on what line the text falls. Maybe it's
not the most useful but it does show a general approach to dealing with
this in XSLT, which is to have templates which match the text nodes
(rather than the line break elements), and then process the text nodes
differently depending on the line breaks around them.

Cheers

Con