EPrints Technical Mailing List Archive

Message: #05891


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Atom.xsl Patch Submission


Hello everyone,

I have found the reason why the category id and subjects are not recognized when depositing files in E-Prints using the Atom Publishing Protocol. The XSLT stylesheet 'Atom.xsl' [0]  in the Import directory does not handle those elements when converting Atom to EPrints XML.

Please find attached a version of the file which handles the dcterms:type and dcterms:subject terms and translates them into E-Prints XML. The dcterms vocabulry seems to be widely used in SWORD protocol implementations (i.e. [1]).

Additionally, I corrected a line in the stylesheet which transforms a submitted eprints status. The line checked for the status being equal to 'MailScanner has detected a possible fraud attempt from "yomiko.ecs.soton.ac.uk80" claiming to be http://yomiko.ecs.soton.ac.uk:8080/data/eprint/status/'. It seems to me that this is a concrete EPrints instance, so the line would not work for any other EPrints instance. I changed the line to: 'contains(@scheme,'/eprint/status')'. This should work for all EPrints instances, including my test server.

Please let me know if you will be including my patch into the repository.

Thank you,

Sebastian

[0] perl_lib/EPrints/Plugin/Import/XSLT/Atom.xsl
[1] http://guides.dataverse.org/en/latest/api/sword.html

Semiodesk GmbH | Werner-von-Siemens-Str. 6 Geb. 15k, 86159 Augsburg, Germany Phone: +49 821 8854401 | Fax: +49 821 8854410 | www.semiodesk.com


This e-mail message may contain confidential or legally privileged information and is intended only for the use of the intended recipient(s). Any unauthorized disclosure, dissemination, distribution, copying or the taking of any action in reliance on the information herein is prohibited. E-mails are not secure and cannot be guaranteed to be error free as they can be intercepted, amended, or contain viruses. Anyone who communicates with us by e-mail is deemed to have accepted these risks. Semiodesk GmbH is not responsible for errors or omissions in this message and denies any responsibility for any damage arising from the use of e-mail. Any opinion and other statement contained in this message and any attachment are solely those of the author and do not necessarily represent those of the company.

<?xml version="1.0"?> 
<!-- identity transformation -->
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
	ept:name="Atom XML"
	ept:visible="all"
	ept:advertise="1"
	ept:sourceNamespace="http://www.w3.org/2005/Atom";
	ept:targetNamespace="http://eprints.org/ep2/data/2.0";
	ept:produce="dataobj/eprint"
	ept:accept="application/atom+xml; type=entry"
	ept:type="import"
	xmlns:ept="http://eprints.org/ep2/xslt/1.0";
	xmlns:atom="http://www.w3.org/2005/Atom";
	xmlns:dcterms="http://purl.org/dc/terms/";
	xmlns="http://eprints.org/ep2/data/2.0";>
	<xsl:output method="xml" indent="yes" encoding="utf-8"/>
	<xsl:template match="/">
		<eprints>
			<eprint>
				<xsl:if test="atom:entry/atom:author">
					<creators>
						<xsl:for-each select="atom:entry/atom:author">
							<item>
								<name>
									<xsl:call-template name="printname">
										<xsl:with-param name="fullname" select="normalize-space(./atom:name)"/>
										<xsl:with-param name="lastname" select="normalize-space(./atom:name)"/>
									</xsl:call-template>
								</name>
								<id>
									<xsl:value-of select="./atom:email"/>
								</id>
							</item>
						</xsl:for-each>
					</creators>
				</xsl:if>
				<xsl:if test="atom:entry/atom:link">
					<related_url>
						<xsl:for-each select="atom:entry/atom:link">
							<item>
								<url>
									<xsl:value-of select="@href"/>
								</url>
							</item>
						</xsl:for-each>
					</related_url>
				</xsl:if>
				<xsl:if test="atom:entry/atom:contributor or atom:entry/atom:rights">
					<note>
						<xsl:for-each select="atom:entry/atom:contributor">
							<xsl:value-of select="./atom:name"/> &lt;<xsl:value-of select="./atom:email"/>&gt;<br/>
						</xsl:for-each>
						<xsl:if test="atom:entry/atom:rights">
Rights: <xsl:value-of select="atom:entry/atom:rights"/>
						</xsl:if>
					</note>
				</xsl:if>
				<xsl:if test="atom:entry/dcterms:subject">
					<subjects>
						<xsl:for-each select="atom:entry/dcterms:subject">
							<item>
								<xsl:value-of select="." />
							</item>
						</xsl:for-each>
					</subjects>
				</xsl:if>
				<xsl:apply-templates select="atom:entry/*" />
			</eprint>
		</eprints>
	</xsl:template>
	<xsl:template match="atom:category">
		<xsl:if test="contains(@scheme,'/eprint/status')">
			<eprint_status>
				<xsl:value-of select="@term" />
			</eprint_status>
		</xsl:if>
	</xsl:template>
	<xsl:template match="dcterms:type">
		<type>
			<xsl:value-of select="." />
		</type>
	</xsl:template>
	<xsl:template match="atom:title">
		<title>
			<xsl:value-of select="." />
		</title>
	</xsl:template>
	<xsl:template match="atom:summary">
		<abstract>
			<xsl:value-of select="." />
		</abstract>
	</xsl:template>
	<xsl:template name="printname" mode="printname">
		<xsl:param name="fullname" />
		<xsl:param name="lastname" />
		<xsl:choose>
			<xsl:when test="contains($lastname, ' ')">
				<xsl:call-template name="printname">
					<xsl:with-param name="fullname" select="$fullname"/>
					<xsl:with-param name="lastname" select="substring-after($lastname, ' ')"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<given>
					<xsl:value-of select="substring-before($fullname,concat(' ', $lastname))"/>
				</given>
				<family>
					<xsl:value-of select="$lastname"/>
				</family>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!-- Ignored -->
	<xsl:template match="atom:rights|atom:contributor|atom:author|atom:link|atom:updated|atom:published|dcterms:subject" />
</xsl:stylesheet>