Altova Mailing List Archives


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

From: "Michael Kay" <mike@--------.--->
To: <xsl-list@-----.------------.--->
Date: 10/14/2009 10:20:00 PM
> the application i'm working on requires 
> an xml:lang attribute for labels like skos:altLabel or skos:prefLabel.
> 
> 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?

Depending what exactly you mean by "labels like skos:altLabel or
skos:prefLabel", use the modified identity stylesheet pattern:

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

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


--~------------------------------------------------------------------
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@l...>
--~--

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.