Reputation: 19
I'm a rookie and I just got into XSLT. I'm doing a study of a manuscript and I want to get the proper names (@name type ="proper") that are in it. Through the style sheet I only know how to get the value of the names (@name) How could I add the type? Here are the stylesheet XSLT and the XML that I created:
<?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="antroponimos2.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>
<div1 type="book" n="01">
<div2 type="chapter" n="000">
<pb n="001r"/>
<cb n="a"/>
<head>
<hi rend="red"><lb n="1"/>Aqui se comiença <lb n="2"/>la general & grand es<lb n="3"
/>toria que el muy noble <w type="majuscule">Rey</w>
<lb n="4"/>don alfonso fijo del noble <w type="majuscule">Rey</w>
<lb n="5"/>don fernando & dela <w type="majuscule">Reyna</w>
<lb n="6"/>donna beatriz mando fazer. <lb n="7"/>Prólogo.</hi>
</head>
<ab>
<lb n="8"/>
Et delos fechos delos malos que
reçibies<lb n="14"/>sen castigo. por se saber guardar delo non fazer.<lb n="15"/>ONde
por todas estas cosas. yo don<lb n="16"/><name type="proper" n="in">Alfonsso</name> por
la gracia de dios <phr type="apposition">Rey <phr function="list"><phr function="list"
n="1">de<lb n="17"/><name type="place" n="in">Castiella</name></phr>. <phr
function="list" n="2">de <name type="place" n="in">Toledo</name></phr>. <phr
function="list" n="3">de <name type="place" n="in">Leon</name></phr>. <phr
function="list" n="4">de <name type="place" n="in">Gal<lb n="18"
/>lizia</name></phr>. <phr function="list" n="5">de <name type="place" n="in"
>Seuilla</name></phr>. <phr function="list" n="6">de <name type="place" n="in"
>Cordoua</name></phr>
</phr></phr>
</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>NOMBRES PROPIOS</b>
</h3>
<table width="750" border="1" align="center">
<tr>
<th scope="col" bgcolor="#00CCFF">
<div align="center">Nombre</div>
</th>
</tr>
<tr>
<td>
<xsl:for-each select="//tei:div1//tei:name">
<div align="center">
<xsl:value-of select="."/>
</div>
</xsl:for-each>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Upvotes: 1
Views: 39
Reputation: 12438
You can use one of the following Xpath
/TEI/text/body/div1/div2/ab/name[@type='proper']
to force the exact level in the DOM tree or
//name[@type='proper']
to access any element in the DOM tree that has as name name
and has an attribute called type
whose value is at proper
.
Also if you need to only access the content of the element (the text), you can just append /text()
to your xpath:
//name[@type='proper']/text()
or
/TEI/text/body/div1/div2/ab/name[@type='proper']/text()
Upvotes: 0
Reputation: 1816
You should use name
element and matching @type
attribute then the value proper
, See below code:
name[@type='proper']
Upvotes: 1