<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>LiquidFoot &#187; sql</title>
	<atom:link href="http://www.liquidfoot.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.liquidfoot.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 02 Jan 2012 22:56:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Updated XSL for MODS</title>
		<link>http://www.liquidfoot.com/2008/11/21/updated-xsl-for-mods/</link>
		<comments>http://www.liquidfoot.com/2008/11/21/updated-xsl-for-mods/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 20:57:09 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[xslt]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=141</guid>
		<description><![CDATA[David noticed that not all the authors were being inserted into the database. I looked at it and it turns out that an author can have an arbitrary number of given names to handle the inclusion of middle names. I had thought I was only pulling the first node, but it turns out I wasn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>David noticed that not all the authors were being inserted into the database. I looked at it and it turns out that an author can have an arbitrary number of given names to handle the inclusion of middle names. I had thought I was only pulling the first node, but it turns out I wasn&#8217;t and the SQL to insert the authors with was erroring out so there were a lot of citations without authors.</p>
<p>I went back in and modified the XSLT that was processing the given names to now read:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;xsl:variable name=&quot;ref_id&quot;&gt;
    &lt;xsl:value-of select=&quot;@ID&quot; /&gt;
&lt;/xsl:variable&gt;
...
&lt;xsl:for-each select=&quot;name&quot;&gt;
INSERT INTO authors (id, ref_id, given, family, role)
VALUES(
    UUID(),
    &lt;!--(SELECT id FROM citations ORDER BY added desc limit 1),--&gt;
    '&lt;xsl:value-of select=&quot;$ref_id&quot;/&gt;',
    &lt;xsl:for-each select=&quot;.&quot;&gt;
        '&lt;xsl:for-each select=&quot;namePart[@type='given']&quot;&gt;
            &lt;xsl:value-of select=&quot;.&quot;/&gt;
            &lt;xsl:text&gt; &lt;/xsl:text&gt;
        &lt;/xsl:for-each&gt;',
        '&lt;xsl:value-of select=&quot;namePart[@type='family']&quot;/&gt;',
        '&lt;xsl:value-of select=&quot;role/roleTerm&quot;/&gt;'
    &lt;/xsl:for-each&gt;
    );
&lt;/xsl:for-each&gt;
</pre>
<p>It looked like the SQL to grab the last item didn&#8217;t always return a record for whatever reason (a locking issue?). Since there was already a key in the field, I just switched over to use that in the inserts. Still need to go through and regularize the fields so MySQL isn&#8217;t attempting to pull a foreign key index on a variable width field, but this is an update to yesterday&#8217;s code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2008/11/21/updated-xsl-for-mods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

