Re: [xsl] Change xml:lang of a skos:prefLabel [ skos, rdf, xml:lang ]

Subject: Re: [xsl] Change xml:lang of a skos:prefLabel [ skos, rdf, xml:lang ]
From: Jürgen Jakobitsch <jakobitschj@xxxxxxxx>
Date: Thu, 15 Oct 2009 12:53:30 +0100 (GMT+01:00)
thanks, ken!

again this helped and helps me VERY much - i learned a lot from only two
and i promise you get an honorable mention
in final xlst :)


----- Original Message -----
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Thursday, October 15, 2009 1:40:58 PM GMT +01:00 Amsterdam / Berlin /
Bern / Rome / Stockholm / Vienna
Subject: Re: [xsl] Change xml:lang of a skos:prefLabel [ skos, rdf, xml:lang

You need a slight modification, Jurgen, because
predicates are not distributive across the union
"|" operator as you have written.

But there is an explanation as to why your code works for you.

At 2009-10-15 08:11 +0100, JCB<rgen Jakobitsch wrote:
>based on the first answer from ken, i'm doing the following
>which does exactly what i want

The way you've written the above implies a
distributive property that does not exist ... to
get what you are expressing you would need:


But, in fact, because of the way I wrote the template, you really only need:


Because of the order of the content of the copy:

>    <xsl:copy>
>      <xsl:attribute name="xml:lang">en</xsl:attribute>
>      <xsl:apply-templates select="@*|node()"/>

In XSLT/XQuery, when you construct the result
tree, you can continuously replace a given
attribute as many times as you need up until you
begin that attribute's element's content ... at which point you are stuck.

So, in my template rule, I am adding the
xml:lang="en" and then adding all of the input
element's attributes.  If the input element also
has xml:lang= then that will replace the one I
put into the result tree, and you end up getting it preserved.

My use of "*[not(@xml:lang)]" in the original
could have simply been "*", but that would not
have conveyed to the reader that the match is
qualifying only particular elements, not all
elements (in fact it could have been written as
all elements, but then there would be no
catch-all for all elements in the identity template).

I hope this helps.

. . . . . . . . . . . Ken

Upcoming: hands-on code list, UBL, XSLT, XQuery and XSL-FO classes
in Copenhagen Denmark and Washington DC USA, October/November 2009
Interested in other classes?
Crane Softwrights Ltd.
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:
Video overview:
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07
Legal business disclaimers:

Current Thread