At
http://www.w3.org/2000/06/dc-extract/form.html
there is an XSLT-based tool by Dan Connolly for transforming DC meta
tags in XHTML to DC/RDF/XML. Unfortunately, for most source HTML files,
incorrect DC property names are generated (because of uppercase first
letters appearing in XHTML meta tag names).
Attached to this message is a modified XSL file which improves the
transformation by converting DCMES property names to lowercase and
dumbing-down element refinements correctly.
My XSLT is now available at the above page (as Version 2). It works fine
for me locally (using Xalan), but the XSLT processor at W3C generates an
empty xmlns="" attribute for each DC property :-( I don't understand why
it does this. Can any XSLT experts out there suggest a correction to my
XSL file?
Andy
--
Distributed Systems, UKOLN, University of Bath, Bath, BA2 7AY, UK
http://www.ukoln.ac.uk/ukoln/staff/a.powell +44 1225 383933
Resource Discovery Network http://www.rdn.ac.uk/
<xsl:stylesheet
xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:h ="http://www.w3.org/1999/xhtml"
xmlns ="http://www.w3.org/1999/xhtml"
xmlns:dc ="http://purl.org/dc/elements/1.1/"
xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<h:p>$Id: dc-extract.xsl,v 1.2 2002/11/15 13:58:09 lisap Exp lisap $</h:p>
<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="h:html">
<rdf:RDF>
<rdf:Description about="">
<xsl:apply-templates/>
</rdf:Description>
</rdf:RDF>
</xsl:template>
<xsl:template match="h:meta[starts-with(@name, 'DC.')]">
<xsl:variable name="n" select="translate(substring-after(@name, '.'), $ucletters, $lcletters)" />
<xsl:choose>
<xsl:when test="contains($n, '.')">
<xsl:element name="ddc:{substring-before($n, '.')}" >
<xsl:value-of select='@content'/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="dc:{$n}" >
<xsl:value-of select='@content'/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- don't pass text thru -->
<xsl:template match="text()|@*">
</xsl:template>
</xsl:stylesheet>
|