<xsl:template match="skos:altLabel|skos:prefLabel">
<xsl:copy>
<xsl:attribute name="xml:lang">en</xsl:attribute>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
This relies on the fact that if you add the same attribute to an element
twice, the last one wins.
1) Is that true for both XSLT 1 and 2 ?
2) No disrespect intended, but something looks amiss here to me. I
notice there is a separate <copy-of> for the attributes, but then
templates are applied for the attributes, too. And what does a <copy-of>
that's a child of <copy> do, anyway?
Ah. To answer my own question, I just ran a tiny stylesheet with
the above identity template on itself, and got the following result.
--------- output of this stylesheet on itself ---------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">1.0
<xsl:template match="/">/
<xsl:apply-templates select="node()">node()</xsl:apply-templates>
</xsl:template>
<xsl:template match="*">*
<xsl:copy>
<xsl:copy-of select="@*">@*</xsl:copy-of>
<xsl:apply-templates select="@*|node()">@*|node()</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--------- end output ---------
So I think that's not what M. Kay meant -- I suspect the <copy-of>
is a holdover from a previous version or a copy-and-paste error or
some such.
Either that or I've missed something, in which case I'm hoping
someone explains it!
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--