print in italics via XSL
I'm a linguist and I'm just starting to understand this grammar. I want to restore, name proper
but how can I put it in the first column of this table when anything is ex
printed in italics?
Here is the XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml"
schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?xml-stylesheet type="text/xsl" href="1.antroponimoscopia.xsl"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title>Title</title>
</titleStmt>
<publicationStmt>
<p>Publication Information</p>
</publicationStmt>
<sourceDesc>
<p>Information about the source</p>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<body>
<pb n="001r"/>
<div1 type="book" n="01">
<div2 type="chapter" n="000">
<cb n="a"/>
<head> Capítulo 1 </head>
<ab> Este es el texto del capítulo 1 de la columna A del folio 1r y le pongo dos
nombrecitos <name type="proper">Don alfo<ex>ns</ex>so</name> y otro nombrecillo para no perdernos doña
<name type="proper">beatriz</name>
</ab>
</div2>
<div2 type="chapter" n="001">
<cb n="b"/>
<head>Capítulo II </head>
<ab>Este es el texto del capítulo II, que se encuentra en la columba B del folio 1r.
Y vamos a poner unos nombres: don <name type="proper">al<ex>fon</ex>so</name>, doña <name type="proper">Urraca</name>
</ab>
</div2>
<pb n="001v"/>
<div2 type="chapter" n="002">
<head>Capítulo III</head>
<ab> Este es el texto del capítulo 3. Vamos a poner tres nombres:
<name type="proper">Fer<ex>nan</ex>do</name>, <name type="proper">Le<ex>tic</ex>ia</name> e <name type="proper">I<ex>s</ex>a</name>
</ab>
</div2>
</div1>
</body>
</text>
</TEI>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:tei="http://www.tei-c.org/ns/1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<h3 align="center">
<b>Antropónimos</b>
</h3>
<table width="750" border="1" align="center">
<tr>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Nombre</div>
</th>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Libro</div>
</th>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Capítulo</div>
</th>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Folio</div>
</th>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Columna</div>
</th>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Línea</div>
</th>
</tr>
<tr>
<td>
<xsl:for-each select="//tei:name[@type='proper']">
<div align="center">
<xsl:value-of select="."/>
</div>
</xsl:for-each>
</td>
<td>
<xsl:for-each select="//tei:name[@type='proper']">
<div align="center">
<xsl:value-of select="ancestor::tei:div1/@n"/>
</div>
</xsl:for-each>
</td>
<td>
<xsl:for-each select="//tei:name[@type='proper']">
<div align="center">
<xsl:value-of select="ancestor::tei:div2/@n"/>
</div>
</xsl:for-each>
</td>
<td>
<xsl:for-each select="tei:name[@type='proper']">
<div align="center">
<xsl:value-of select="preceding::tei:pb[@n][1]/@n"/>
</div>
</xsl:for-each>
</td>
<td>
<xsl:for-each select="//tei:name[@type='proper']">
<div align="center">
<xsl:value-of select="preceding::tei:cb[@n][1]/@n"/>
</div>
</xsl:for-each>
</td>
<td>
<xsl:for-each select="//tei:name[@type='proper']">
<div align="center">
<xsl:value-of select="preceding::tei:lb[@n][1]/@n"/>
</div>
</xsl:for-each>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Thanks! !
In general, I recommend setting up templates for nodes to transform and elements name type="proper"
to use , e.g.
<xsl:template match="tei:name[@type = 'proper']">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
and its ex
children
<xsl:template match="tei:name[@type = 'proper']/tei:ex">
<em>
<xsl:apply-templates/>
</em>
</xsl:template>
Keep in mind that XSLT is just a programming language for transforming XML into other formats, so it's not up to XSLT to dictate any italics or other rendering, it's just used to produce the desired output, in your case it Seems to be HTML, where the em
element should be highlighted. You can also choose to use CSS. However, if you want to convert to PDF, you need to use XSLT to generate the correct XSL-FO elements and required attributes.
A more complete example is
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:tei="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="tei">
<xsl:output method="html" version="5.0" doctype-system="about:legacy-comapat"/>
<xsl:template match="/">
<html lang="es">
<head>
</head>
<body>
<h3 align="center">
<b>Antropónimos</b>
</h3>
<table width="750" border="1" align="center">
<thead>
<tr>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Nombre</div>
</th>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Libro</div>
</th>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Capítulo</div>
</th>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Folio</div>
</th>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Columna</div>
</th>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Línea</div>
</th>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="//tei:name[@type = 'proper']"/>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="tei:name[@type = 'proper']">
<tr>
<td>
<xsl:apply-templates/>
</td>
<td>
<xsl:value-of select="ancestor::tei:div1/@n"/>
</td>
<td>
<xsl:value-of select="ancestor::tei:div2/@n"/>
</td>
<td>
...
</td>
<td>
...
</td>
<td>
...
</td>
</tr>
</xsl:template>
<xsl:template match="tei:name[@type = 'proper']/tei:ex">
<em>
<xsl:apply-templates/>
</em>
</xsl:template>
</xsl:stylesheet>