<xsl:stylesheet
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:dcterms="http://purl.org/dc/terms/"
  exclude-result-prefixes="dcterms"
	version="1.0">

	<!-- *****************************************************************************

	<dc:title>DCDD2.xsl, thabing@uiuc.edu</dc:title>
	<dc:creator>Tom Habing</dc:creator>
	<dc:description>Dumb-down Qualified Dublin Core Refinements to their equivalent
	simple elements, leaving the rest of the XML document unchanged.  Uses the
	substitutionGroup attributes from the XML Schema to find the equivalent simple DC
	elements for the refined elements.</dc:description>
	<dc:date>2002-07-08</dc:date>

	********************************************************************************* -->

	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>

	<xsl:variable name="SCHEMA" select="document('http://www.dublincore.org/schemas/xmls/qdc/2003/04/02/dcterms.xsd')"/>

	<xsl:template match="/">
		<xsl:apply-templates select="node() | @*"/>
	</xsl:template>

	<xsl:template match="dcterms:*">
		<xsl:if test="$SCHEMA//xs:element[@name=local-name(current())]">
  		<xsl:element namespace="http://purl.org/dc/elements/1.1/" name="{$SCHEMA//xs:element[@name=local-name(current())]/@substitutionGroup}">
  			<!--<xsl:apply-templates select="@*"/>-->
  			<xsl:value-of select="."/>
  		</xsl:element>
  	</xsl:if>
	</xsl:template>

	<xsl:template match="dc:*">
		<xsl:copy>
			<xsl:value-of select="."/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="node() | @*">
		<xsl:copy>
			<xsl:apply-templates select="node() | @*"/>
		</xsl:copy>
	</xsl:template>

</xsl:stylesheet>
