Appendice 20

FOGLIO DI STILE XSLT "copia e aggiungi attributi.xsl" PER AGGIUNGERE UN ATTRIBUTO ID CON VALORE UNIVOCO A TUTTI GLI ELEMENTI NAME

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:strip-space elements="*"/>
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>
	
	<xsl:template match="TEI.2">
		<xsl:copy>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	
	<xsl:template match="teiHeader"/>
	
	<xsl:template match="text">
		<xsl:copy>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	
	<xsl:template match="back"/>
	
	<xsl:template match="front"/>
	
	<xsl:template match="body">
		<xsl:copy>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	<!-- questo modello copia tutti gli elementi di BODY insieme ad i loro attributi -->
		<xsl:template match="body//*">
		<xsl:copy>
			<xsl:copy-of select="@*"/>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	
		<!-- questo modello aggiunge un'attributo ID all'elemento NAME -->
	<xsl:template match="name" priority="1">
	<xsl:copy>
	<xsl:copy-of select="@*"/>
		<xsl:attribute name="id"><xsl:value-of select="./ancestor::div1/@id"/>-<xsl:value-of 
select="generate-id()"/></xsl:attribute>
	<xsl:apply-templates/>	
	</xsl:copy>	
	</xsl:template>
</xsl:stylesheet>