【发布时间】:2018-03-13 08:05:31
【问题描述】:
我是新手,刚刚接触到 XSLT。我正在研究一份手稿,我想获得其中的专有名称(@name type ="proper")。通过样式表我只知道如何获取名称(@name)的值我如何添加类型? 以下是我创建的样式表 XSLT 和 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="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>
【问题讨论】:
-
当你使用@name 意味着这是名称属性。