print in italics via XSL


Miguel Lay

I'm a linguist and I'm just starting to understand this grammar. I want to restore, name properbut how can I put it in the first column of this table when anything is exprinted 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! !

Martin Horn

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 exchildren

<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 emelement 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>

https://xsltfiddle.liberty-development.net/bFWR5Et

Related


print in italics via XSL

Miguel Lay I'm a linguist and I'm just starting to understand this grammar. I want to restore, name properbut how can I put it in the first column of this table when anything is exprinted in italics? Here is the XML: <?xml version="1.0" encoding="UTF-8"?> <?xm

print in italics via XSL

Miguel Lay I'm a linguist and I'm just starting to understand this grammar. I want to restore, name properbut how can I put it in the first column of this table when anything is exprinted in italics? Here is the XML: <?xml version="1.0" encoding="UTF-8"?> <?xm

print in italics via XSL

Miguel Lay I'm a linguist and I'm just starting to understand this grammar. I want to restore, name properbut how can I put it in the first column of this table when anything is exprinted in italics? Here is the XML: <?xml version="1.0" encoding="UTF-8"?> <?xm

print in italics via XSL

Miguel Lay I'm a linguist and I'm just starting to understand this grammar. I want to restore, name properbut how can I put it in the first column of this table when anything is exprinted in italics? Here is the XML: <?xml version="1.0" encoding="UTF-8"?> <?xm

How to print text in italics in Python?

Mike Delmonaco I'm writing a program that should receive an entry in a specific modified form of APA and return an APA reference. I've realized that I only need to print certain parts of the text in italics. Right now, my program just executes an input, asks y

How to print text in italics in Python?

Mike Delmonaco I'm writing a program that should receive an entry in a specific modified form of APA and return an APA reference. I've realized that I only need to print certain parts of the text in italics. Right now, my program just executes an input, asks y

Is there a way to format the clipboard with italics via python?

Mr C I'm looking to automate the formatting of source code in Microsoft Word documents (.docx). The problem is that some text in the new format must use italics. Is there a way in python to italicize the clipboard as text? If you copy the italics manually (ctr

Is there a way to format the clipboard with italics via python?

Mr C I'm looking to automate the formatting of source code in Microsoft Word documents (.docx). The problem is that some text in the new format must use italics. Is there a way in python to italicize the clipboard as text? If you copy the italics manually (ctr

Is there a way to format the clipboard with italics via python?

Mr C I'm looking to automate the formatting of source code in Microsoft Word documents (.docx). The problem is that some text in the new format must use italics. Is there a way in python to italicize the clipboard as text? If you copy the italics manually (ctr

Add rowpan via XSL

creature freak I have the following xml: <?xml version="1.0" encoding="ISO-8859-1"?> <Loci> <Locus> <Id>MTBC1726</Id> <Alleles> <Allele> <Name>1.0</Name> <Description>No annotation provided</Desc

Print '<xsl:message>' from xsl file in JTextArea

Kraft I have been trying to print xsl messages in JTextArea. Using the code from the last question, I can print the xsl output in my TextArea, but not the message written in the xslt file. Java code: public static void xslTransform(File xmlFile)throws IOExcept

Print '<xsl:message>' from xsl file in JTextArea

Kraft I have been trying to print xsl messages in JTextArea. Using the code from the last question, I can print the xsl output in my TextArea, but not the message written in the xslt file. Java code: public static void xslTransform(File xmlFile)throws IOExcept

XSL: FO inline and pretty print

Gobanit : I am trying to create a pdf using xsl:fo. I'm stuck with a problem with inline elements. I need to write a line with a bold font. E.g: I need this to be bold. I can do this with the following code: <fo:block> <fo:inline>I need </fo:inline><fo:inl

XSL: FO inline and pretty print

Gobanit : I am trying to create a pdf using xsl:fo. I'm stuck with a problem with inline elements. I need to write a line with a bold font. E.g: I need this to be bold. I can do this with the following code: <fo:block> <fo:inline>I need </fo:inline><fo:inl

Seriously print from XSL transformation

Marcel I have the following XML file: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/css" href="university_students.css" ?> <university> <students> <student sid="sckl9999"> <name>Schmitt</name> <firstname

XSL: FO inline and pretty print

Gobanit : I am trying to create a pdf using xsl:fo. I'm stuck with a problem with inline elements. I need to write a line with a bold font. E.g: I need this to be bold. I can do this with the following code: <fo:block> <fo:inline>I need </fo:inline><fo:inl

XSL: FO inline and pretty print

Gobanit : I am trying to create a pdf using xsl:fo. I'm stuck with a problem with inline elements. I need to write a line with a bold font. E.g: I need this to be bold. I can do this with the following code: <fo:block> <fo:inline>I need </fo:inline><fo:inl

Seriously print from XSL transformation

Marcel I have the following XML file: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/css" href="university_students.css" ?> <university> <students> <student sid="sckl9999"> <name>Schmitt</name> <firstname

Add line spans via XSL

creature freak I have the following xml: <?xml version="1.0" encoding="ISO-8859-1"?> <Loci> <Locus> <Id>MTBC1726</Id> <Alleles> <Allele> <Name>1.0</Name> <Description>No annotation provided</Desc

Add line spans via XSL

creature freak I have the following xml: <?xml version="1.0" encoding="ISO-8859-1"?> <Loci> <Locus> <Id>MTBC1726</Id> <Alleles> <Allele> <Name>1.0</Name> <Description>No annotation provided</Desc

italics in emacs

Eastafri I'm a bit new to emacs. I am editing a document in latex and I want to write some words in italics. I want a simple macro where if you put the cursor on a word and press a key combination, the word is surrounded by italics like this \textit{word}. Is

Is italics in bold?

Heykatieben Nowadays, font-style:italic in css only displays my font in bold on Chrome and Firefox (not on Safari). For example, use the following css: em { font-style: italic; } and this HTML: <p><em>Hi, I'm showing up in bold.</em></p> In italics and bold

italics in emacs

Eastafri I'm a bit new to emacs. I am editing a document in latex and I want to write some words in italics. I want a simple macro where if you put the cursor on a word and press a key combination, the word is surrounded by italics like this \textit{word}. Is

Is italics in bold?

Heykatieben Nowadays, font-style:italic in css only displays my font in bold on Chrome and Firefox (not on Safari). For example, use the following css: em { font-style: italic; } and this HTML: <p><em>Hi, I'm showing up in bold.</em></p> In italics and bold