summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <bfr@qbus.de>2015-02-18 19:08:17 +0100
committerBenjamin Franzke <bfr@qbus.de>2015-02-18 19:08:17 +0100
commitfe9ddf26982c165d7972c8f013e430d80e912dc1 (patch)
tree5a7c07b0533289c2801f5a3409f8c99949febb6f
parentbc8b53bc02edef1425d7e7b8f17166e0f27d67bd (diff)
downloadendnote-import-fe9ddf26982c165d7972c8f013e430d80e912dc1.zip
endnote-import-fe9ddf26982c165d7972c8f013e430d80e912dc1.tar.gz
endnote-import-fe9ddf26982c165d7972c8f013e430d80e912dc1.tar.bz2
Create a table for authors
..and links the publication by id
-rw-r--r--endnote-to-dbxml.xsl58
-rw-r--r--update.sql4
2 files changed, 56 insertions, 6 deletions
diff --git a/endnote-to-dbxml.xsl b/endnote-to-dbxml.xsl
index 24d3be3..f8880db 100644
--- a/endnote-to-dbxml.xsl
+++ b/endnote-to-dbxml.xsl
@@ -1,11 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:exsl="http://exslt.org/common"
+ extension-element-prefixes="exsl">
+
+ <xsl:key name="author" match="author" use="." />
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:include href="util.xsl"/>
+ <xsl:template match="*">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates />
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="authors" mode="references">
+
+ </xsl:template>
+
<xsl:template match="record">
+ <xsl:param name="authors"/>
+
<publication>
<uid>
<xsl:value-of select="rec-number" />
@@ -29,23 +46,52 @@
</year>
<authors>
- <!--<xsl:apply-templates select="authors" mode="references" />-->
<xsl:for-each select="contributors/authors/author">
<xsl:if test="position() &gt; 1">
- <xsl:text>|</xsl:text>
+ <xsl:text>,</xsl:text>
</xsl:if>
- <xsl:value-of select="." />
+ <xsl:value-of select="exsl:node-set($authors)/tx_likat_pubs_domain_model_authors/author[name=current()]/uid" />
</xsl:for-each>
</authors>
</publication>
</xsl:template>
- <xsl:template match="/">
+ <xsl:template match="records">
+ <xsl:param name="authors"/>
<tx_likat_pubs_domain_model_publications>
- <xsl:apply-templates select="xml/records/record" />
+ <xsl:apply-templates select="record">
+ <xsl:with-param name="authors">
+ <xsl:call-template name="authors" />
+ </xsl:with-param>
+ </xsl:apply-templates>
</tx_likat_pubs_domain_model_publications>
</xsl:template>
+ <xsl:template match="author">
+ <author>
+ <xsl:variable name="pos" select="position()"/>
+ <uid><xsl:value-of select="$pos"/></uid>
+ <name><xsl:value-of select="." /></name>
+ </author>
+ </xsl:template>
+
+
+ <xsl:template name="authors">
+ <tx_likat_pubs_domain_model_authors>
+ <xsl:apply-templates select="//author[generate-id() =
+ generate-id(key('author', .)[1])]"/>
+ </tx_likat_pubs_domain_model_authors>
+ </xsl:template>
+
+ <xsl:template match="/">
+ <db>
+ <xsl:apply-templates select="xml/records"/>
+
+ <xsl:call-template name="authors" />
+ </db>
+ </xsl:template>
+
+
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
diff --git a/update.sql b/update.sql
index c745643..239ac67 100644
--- a/update.sql
+++ b/update.sql
@@ -1,6 +1,10 @@
START TRANSACTION;
DELETE FROM tx_likat_pubs_domain_model_publications;
+DELETE FROM tx_likat_pubs_domain_model_authors;
LOAD XML LOCAL INFILE './dbxml.xml'
INTO TABLE tx_likat_pubs_domain_model_publications
ROWS IDENTIFIED BY '<publication>';
+LOAD XML LOCAL INFILE './dbxml.xml'
+ INTO TABLE tx_likat_pubs_domain_model_authors
+ ROWS IDENTIFIED BY '<author>';
COMMIT;