Skip to content

Commit

Permalink
improved DDI XSL
Browse files Browse the repository at this point in the history
  • Loading branch information
axfelix committed Mar 31, 2015
1 parent df0afc6 commit 7add90a
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 92 deletions.
68 changes: 68 additions & 0 deletions xml/DDI_to_DC.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:codeBook="ddi:codebook:2_5" version="1.0" xsi:schemaLocation="ddi:codebook:2_5 http://wwww.ddialliance.org/Specification/DDI-Codebook/2.5/XMLSchema/codebook.xsd" exclude-result-prefixes="codeBook">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<oai_dc:dc>
<xsl:for-each select="//codeBook:citation/codeBook:titlStmt/codeBook:titl">
<dc:title>
<xsl:value-of select="."/>
</dc:title>
</xsl:for-each>
<xsl:for-each select="//codeBook:citation/codeBook:titlStmt/codeBook:IDNo">
<dc:identifier>
<xsl:value-of select="."/>
</dc:identifier>
</xsl:for-each>
<xsl:for-each select="//codeBook:citation/codeBook:rspStmt/codeBook:AuthEnty">
<dc:creator>
<xsl:value-of select="."/>
</dc:creator>
</xsl:for-each>
<xsl:for-each select="//codeBook:citation/codeBook:rspStmt/codeBook:othId">
<dc:contributor>
<xsl:value-of select="."/>
</dc:contributor>
</xsl:for-each>
<xsl:for-each select="//codeBook:citation/codeBook:prodStmt/codeBook:prodDate">
<dc:date>
<xsl:value-of select="."/>
</dc:date>
</xsl:for-each>
<xsl:for-each select="//codeBook:stdyInfo/codeBook:subject/codeBook:keyword">
<dc:subject>
<xsl:value-of select="."/>
</dc:subject>
</xsl:for-each>
<xsl:for-each select="//codeBook:stdyInfo/codeBook:abstract">
<dc:description>
<xsl:value-of select="."/>
</dc:description>
</xsl:for-each>
<xsl:for-each select="//codeBook:stdyInfo/codeBook:sumDscr/codeBook:geogCover">
<dc:coverage>
<xsl:value-of select="."/>
</dc:coverage>
</xsl:for-each>
<xsl:for-each select="//codeBook:stdyInfo/codeBook:sumDscr/codeBook:dataKind">
<dc:type>
<xsl:value-of select="."/>
</dc:type>
</xsl:for-each>
<xsl:for-each select="//codeBook:method/codeBook:dataColl/codeBook:sources/codeBook:dataSrc">
<dc:source>
<xsl:value-of select="."/>
</dc:source>
</xsl:for-each>
<xsl:for-each select="//codeBook:dataAccs/codeBook:useStmt/codeBook:restrctn">
<dc:rights>
<xsl:value-of select="."/>
</dc:rights>
</xsl:for-each>
<xsl:for-each select="//codeBook:otherMat/codeBook:notes">
<dc:isPartOf>
<xsl:value-of select="."/>
</dc:isPartOf>
</xsl:for-each>
</oai_dc:dc>
</xsl:template>
</xsl:stylesheet>
129 changes: 119 additions & 10 deletions xml/DDI_to_solr.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,125 @@
<xsl:template match="codeBook">
<xsl:param name="prefix">ddi.</xsl:param>
<xsl:param name="suffix"></xsl:param>
<!-- Create fields for the set of selected elements, named according to the 'local-name' and containing the 'text' -->
<xsl:for-each select="./*">

<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<!-- SFUdora DDI subset -->

<xsl:for-each select="//codeBook:citation/codeBook:titlStmt/codeBook:titl[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:citation/codeBook:titlStmt/codeBook:IDNo[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:citation/codeBook:rspStmt/codeBook:AuthEnty[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:citation/codeBook:rspStmt/codeBook:othId[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:citation/codeBook:prodStmt/codeBook:prodDate[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:stdyInfo/codeBook:subject/codeBook:keyword[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:stdyInfo/codeBook:abstract[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:stdyInfo/codeBook:sumDscr/codeBook:geogCover[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:stdyInfo/codeBook:sumDscr/codeBook:timePrd[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:stdyInfo/codeBook:sumDscr/codeBook:dataKind[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:method/codeBook:dataColl/codeBook:sources/codeBook:dataSrc[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:dataAccs/codeBook:useStmt/codeBook:restrctn[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

<xsl:for-each select="//codeBook:otherMat/codeBook:notes[normalize-space(text())]">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, local-name(), $suffix)"/>
</xsl:attribute>
<xsl:value-of select="text()"/>
</field>
</xsl:for-each>

</xsl:template>

Expand Down
82 changes: 0 additions & 82 deletions xml/ddi_to_dc.xsl

This file was deleted.

0 comments on commit 7add90a

Please sign in to comment.