Reputation: 1
I am finishing the encoding of a novel using a TEI XML file. I'd like to extract using XSLT the characters of each chapter, tagged as:
<name type="character" key="nameofthecharacter">Name</name>
Here is the structure:
</teiHeader>
<text>
<body>
<div n='firstchapter' type='chapter'>
<head>title</head>
<p><name type="character" key="Sam">Sam</name> is a character
</p>
</div>
<div n='secondchapter' type='chapter'>
<head>title</head>
<p><name type="character" key="Elody">Elody</name> is a character
</body>
</text>
</TEI>
I tried basic XSLT like:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/TEI/text/body/div[@type = 'book']"/>
<xsl:apply-templates select="name[@type = "character"/>
</xsl:template>
</xsl:stylesheet>
But seems not the correct syntax to use. Any suggestions?
Upvotes: 0
Views: 282
Reputation: 211
There is a typo in apply-templates syntaxis, and it looks like you need to match div with @type='chapter' and apply templates for descendant element name with @type = 'character'
In this case XSLT code should be changed like so:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/TEI/text/body/div[@type = 'chapter']">
<xsl:apply-templates select="descendant::name[@type = 'character']"/>
</xsl:template>
</xsl:stylesheet>
Upvotes: 0