xsl-list
[Top] [All Lists]

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

2009-10-15 07:54:49
thanks, ken!

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

wkr www.turnguard.com


----- Original Message -----
From: "G. Ken Holman" <gkholman(_at_)CraneSoftwrights(_dot_)com>
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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, Jürgen Jakobitsch wrote:
based on the first answer from ken, i'm doing the following
which does exactly what i want
...
<xsl:template 
match="skos:prefLabel|skos:altLabel|skos:hiddenLabel|skos:definition|skos:scopeNote[not(@xml:lang)]">

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

   match="skos:prefLabel[not(@xml:lang)]|
          skos:altLabel[not(@xml:lang)]|
          skos:hiddenLabel[not(@xml:lang)]|
          skos:definition[not(@xml:lang)]|
          skos:scopeNote[not(@xml:lang)]"

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

   match="skos:prefLabel|
          skos:altLabel|
          skos:hiddenLabel|
          skos:definition|
          skos:scopeNote"

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?  http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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>
--~--


--~------------------------------------------------------------------
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>
--~--