At 2009-10-14 21:24 +0100, Jürgen Jakobitsch wrote:
that the application i'm working on requires
an xml:lang attribute for labels like skos:altLabel or skos:prefLabel.
You'll have to be more specific when adapting my example below.
is there a way (for a complete xsl newbie) to add such an xml:lang
attribute to labels that don't have one and leave the rest of
the thesaurus as it is with xsl?
Yes, base a solution on the identity template, shown below.
I hope this helps.
. . . . . . . . Ken
t:\ftemp>type jurgen.xml
<skos:Concept rdf:nodeID="R0386"
xmlns:skos="urn:X-skos" xmlns:rdf="urn:X-rdf">
<skos:altLabel>Economic recession</skos:altLabel>
<skos:altLabel>Depression, Economic</skos:altLabel>
<skos:related rdf:nodeID="R0392" />
<skos:related rdf:nodeID="R0174" />
<skos:inScheme rdf:nodeID="apais" />
<skos:related rdf:nodeID="R1419" />
<skos:altLabel>Recession, Economic</skos:altLabel>
<skos:prefLabel>Economic depression</skos:prefLabel>
<skos:subjectIndicator
rdf:resource="http://www.nla.gov.au/apais/thesaurus/h
tml/R0386.html" />
</skos:Concept>
t:\ftemp>xslt jurgen.xml jurgen.xsl
<?xml version="1.0"
encoding="utf-8"?><skos:Concept xmlns:skos="urn:X-skos" xmln
s:rdf="urn:X-rdf" xml:lang="en" rdf:nodeID="R0386">
<skos:altLabel xml:lang="en">Economic recession</skos:altLabel>
<skos:altLabel xml:lang="en">Depression, Economic</skos:altLabel>
<skos:related xml:lang="en" rdf:nodeID="R0392"/>
<skos:related xml:lang="en" rdf:nodeID="R0174"/>
<skos:inScheme xml:lang="en" rdf:nodeID="apais"/>
<skos:related xml:lang="en" rdf:nodeID="R1419"/>
<skos:altLabel xml:lang="en">Recession, Economic</skos:altLabel>
<skos:prefLabel xml:lang="en">Economic depression</skos:prefLabel>
<skos:subjectIndicator xml:lang="en"
rdf:resource="http://www.nla.gov.au/apa
is/thesaurus/html/R0386.html"/>
</skos:Concept>
t:\ftemp>type jurgen.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="*[not(@xml:lang)]">
<xsl:copy>
<xsl:attribute name="xml:lang">en</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()"><!--identity for all other nodes-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
t:\ftemp>
--
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>
--~--