Subject: RE: [xsl] Change xml:lang of a skos:prefLabel [ skos, rdf, xml:lang ] From: Syd Bauman <Syd_Bauman@xxxxxxxxx> Date: Wed, 14 Oct 2009 20:39:48 -0400 |
> <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!
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Change xml:lang of a skos, Michael Kay | Thread | Re: [xsl] Change xml:lang of a skos, Jürgen Jakobitsch |
RE: [xsl] Change xml:lang of a skos, Michael Kay | Date | Re: [xsl] XML to both ODF and OOXML, Vyacheslav Sedov |
Month |