Difference between revisions of "ZoteroToTEI"

From TEIWiki
Jump to navigation Jump to search
(created new page that's not a subpage of Category:Tools)
 
Line 35: Line 35:
 
<pre><nowiki>
 
<pre><nowiki>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+
<xsl:stylesheet version="2.0"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
+
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
xmlns:vcard="http://nwalsh.com/rdf/vCard#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:z="http://www.zotero.org/namespaces/export#"
+
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dcterms="http://purl.org/dc/terms/" xmlns:bib="http://purl.org/net/biblio#" xmlns:link="http://purl.org/rss/1.0/modules/link/"
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  
xmlns:prism="http://prismstandard.org/namespaces/1.2/basic/" exclude-result-prefixes="xs rdf tei dc vcard foaf z dcterms bib link prism"
+
        xmlns:tei="http://www.tei-c.org/ns/1.0"  
version="2.0">
+
        xmlns:dc="http://purl.org/dc/elements/1.1/"
 +
xmlns:vcard="http://nwalsh.com/rdf/vCard#"  
 +
        xmlns:foaf="http://xmlns.com/foaf/0.1/"  
 +
        xmlns:z="http://www.zotero.org/namespaces/export#"
 +
xmlns:dcterms="http://purl.org/dc/terms/"  
 +
        xmlns:bib="http://purl.org/net/biblio#"  
 +
        xmlns:link="http://purl.org/rss/1.0/modules/link/"
 +
xmlns:prism="http://prismstandard.org/namespaces/1.2/basic/"  
 +
        exclude-result-prefixes="xs rdf tei dc vcard foaf z dcterms bib link prism"
 +
>
  
 
<xsl:output method="xml" escape-uri-attributes="yes" indent="yes"/>
 
<xsl:output method="xml" escape-uri-attributes="yes" indent="yes"/>

Revision as of 01:39, 28 February 2010


Synopsis

This is an XSLT stylesheet to transform RDF/XML into TEI bibls


User commentary

Please sign all comments. (please leave the above note about signing comments, and add signed comments here below it)

System requirements

Source code and licensing

Source code is included at the bottom of this article

Language(s)

XSLT

Documentation

None

Tech support

None


Here follows a Zotero to TEI XSLT, a simple one, that takes Zotero exported RDF and turns it into a listBibl with biblStruct.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
        xmlns:tei="http://www.tei-c.org/ns/1.0" 
        xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:vcard="http://nwalsh.com/rdf/vCard#" 
        xmlns:foaf="http://xmlns.com/foaf/0.1/" 
        xmlns:z="http://www.zotero.org/namespaces/export#"
	xmlns:dcterms="http://purl.org/dc/terms/" 
        xmlns:bib="http://purl.org/net/biblio#" 
        xmlns:link="http://purl.org/rss/1.0/modules/link/"
	xmlns:prism="http://prismstandard.org/namespaces/1.2/basic/" 
        exclude-result-prefixes="xs rdf tei dc vcard foaf z dcterms bib link prism"
	>

	<xsl:output method="xml" escape-uri-attributes="yes" indent="yes"/>

	<xsl:template match="/rdf:RDF">
		<listBibl>
			<head>Works Cited</head>
			<xsl:apply-templates/>
		</listBibl>
	</xsl:template>

	<xsl:template match="bib:Memo"/>
	<xsl:template match="z:Attachment"/>

	<xsl:template match="bib:Book">
		<biblStruct>
			<monogr>
				<title>
					<xsl:value-of select="dc:title"/>
				</title>
				<xsl:call-template name="author"/>
				<imprint>
					<publisher>
						<xsl:value-of select="dc:publisher/foaf:Organization/foaf:name"/>
					</publisher>
					<date>
						<xsl:choose>
							<xsl:when test="contains(dc:date, '-')">
								<xsl:value-of select="substring-before(dc:date, '-')"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="dc:date"/>
							</xsl:otherwise>
						</xsl:choose>
					</date>
				</imprint>
			</monogr>
		</biblStruct>
	</xsl:template>

	<xsl:template match="rdf:li">
		<author>
			<persName>
				<forename>
					<xsl:value-of select="foaf:Person/foaf:givenname"/>
				</forename>
				<surname>
					<xsl:value-of select="foaf:Person/foaf:surname"/>
				</surname>
			</persName>
		</author>
	</xsl:template>

	<xsl:template match="bib:Article">
		<biblStruct>
			<analytic>
				<title><xsl:value-of select="dc:title"/></title>
				<xsl:call-template name="author"/>
			</analytic>
			<monogr>
				<title>
					<xsl:value-of select="following-sibling::bib:Journal[1]/dc:title"/>
				</title>
				<imprint>
					<date><xsl:value-of select="dc:date"/></date>
					<biblScope type="vol"><xsl:value-of select="following-sibling::bib:Journal[1]/prism:volume"/></biblScope>
					<biblScope type="issue"><xsl:value-of select="following-sibling::bib:Journal[1]/prism:number"/></biblScope>
					<biblScope type="pp"><xsl:value-of select="bib:pages"/></biblScope>
				</imprint>
			</monogr>
		</biblStruct>
	</xsl:template>

	<xsl:template match="bib:Journal"/>
	
	<xsl:template match="bib:Document"/>

	<xsl:template match="rdf:Description">
		<xsl:choose>
			<xsl:when test="z:itemType = 'conferencePaper'">
				<biblStruct>
					<analytic>
						<title>
							<xsl:value-of select="dc:title"/>
						</title>
						<xsl:call-template name="author"/>
					</analytic>
				</biblStruct>
			</xsl:when>
			<!-- add outputs for other kinds of objects you collect -->
		</xsl:choose>
	</xsl:template>

        <xsl:template match="z:Collection"/>

	<xsl:template name="author">
		<xsl:apply-templates select="bib:authors/rdf:Seq/rdf:li"/>
	</xsl:template>


</xsl:stylesheet>