[Home] [By Thread] [By Date] [Recent Entries]
At 2009-10-14 21:24 +0100, JC<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>
|

Cart



