Skip to content

Instantly share code, notes, and snippets.

@exlcodeshare
Last active August 18, 2023 17:12
Show Gist options
  • Save exlcodeshare/405b0730c41ba019a95d4a45199d6fcf to your computer and use it in GitHub Desktop.
Save exlcodeshare/405b0730c41ba019a95d4a45199d6fcf to your computer and use it in GitHub Desktop.
Files for generating dc.xml in Excel.
<xsl:stylesheet version="1.0" 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/1.1/">
<xsl:output omit-xml-declaration="no" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/collection">
<collection xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://purl.org/dc/terms/1.1/ http://dublincore.org/schemas/xmls/qdc/2008/02/11/dcterms.xsd http://purl.org/dc/elements/1.1/ http://dublincore.org/schemas/xmls/qdc/2008/02/11/dc.xsd">
<xsl:apply-templates select="@*|node()"/>
</collection >
</xsl:template>
<xsl:template match="record">
<xsl:element name="{name()}">
<xsl:copy-of select="namespace::*"/>
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
<xsl:template match="title|creator|subject|description|publisher|contributor|date|type|format|identifier|source|language|relation|coverage|rights">
<xsl:element name="dc:{name()}">
<xsl:copy-of select="namespace::*"/>
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
<xsl:template match="*">
<xsl:element name="dcterms:{name()}">
<xsl:copy-of select="namespace::*"/>
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<collection>
<record>
<title />
<creator />
<subject />
<description />
<publisher />
<contributor />
<date />
<type />
<format />
<identifier />
<source />
<language />
<relation />
<coverage />
<rights />
<alternative />
<tableOfContents />
<abstract />
<created />
<valid />
<available />
<issued />
<modified />
<dateAccepted />
<dateCopyrighted />
<dateSubmitted />
<extent />
<medium />
<isVersionOf />
<hasVersion />
<isReplacedBy />
<replaces />
<isRequiredBy />
<requires />
<isPartOf />
<hasPart />
<isReferencedBy />
<references />
<isFormatOf />
<hasFormat />
<conformsTo />
<spatial />
<temporal />
<audience />
<accrualMethod />
<accrualPeriodicity />
<accrualPolicy />
<instructionalMethod />
<provenance />
<rightsHolder />
<mediator />
<educationLevel />
<accessRights />
<license />
<bibliographicCitation />
</record>
<record>
<title />
<creator />
<subject />
<description />
<publisher />
<contributor />
<date />
<type />
<format />
<identifier />
<source />
<language />
<relation />
<coverage />
<rights />
<alternative />
<tableOfContents />
<abstract />
<created />
<valid />
<available />
<issued />
<modified />
<dateAccepted />
<dateCopyrighted />
<dateSubmitted />
<extent />
<medium />
<isVersionOf />
<hasVersion />
<isReplacedBy />
<replaces />
<isRequiredBy />
<requires />
<isPartOf />
<hasPart />
<isReferencedBy />
<references />
<isFormatOf />
<hasFormat />
<conformsTo />
<spatial />
<temporal />
<audience />
<accrualMethod />
<accrualPeriodicity />
<accrualPolicy />
<instructionalMethod />
<provenance />
<rightsHolder />
<mediator />
<educationLevel />
<accessRights />
<license />
<bibliographicCitation />
</record>
</collection>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment