<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"
>

<channel>
	<title>LiquidFoot &#187; xslt</title>
	<atom:link href="http://www.liquidfoot.com/tag/xslt/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.liquidfoot.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 17 Apr 2010 16:36:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</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[]]></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;">

&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>
		<item>
		<title>Real Life XSLT 2.0 transformations</title>
		<link>http://www.liquidfoot.com/2006/08/23/real-life-xslt-20-transformations/</link>
		<comments>http://www.liquidfoot.com/2006/08/23/real-life-xslt-20-transformations/#comments</comments>
		<pubDate>Wed, 23 Aug 2006 18:56:31 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://www.liquidfoot.com/?p=208</guid>
		<description><![CDATA[I ran into a bit of a situation that was really blowing my mind. I have a rather large XML file (around 20,000+ lines) marked up in TEI that I wanted to do some transformations on (a day book and ledger from the 1850s). Essentially the code follows the format &#8230; &#60;figure&#62; &#60;head&#62;Page 12&#60;/head&#62; &#60;graphic [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>I ran into a bit of a situation that was really blowing my mind. I have a rather large XML file (around 20,000+ lines) marked up in TEI that I wanted to do some transformations on (a day book and ledger from the 1850s). Essentially the code follows the format</p>
<div class="code">&#8230;<br />
<span style="color: #ff8000;">&lt;figure&gt;</span><br />
<span style="color: #000080;">&lt;head&gt;</span>Page 12<span style="color: #000080;">&lt;/head&gt;</span><br />
&lt;graphic url=<span style="color: #0000ff;">&#8220;0023_p12&#8243;</span>/&gt;<br />
<span style="color: #ff8000;">&lt;/figure&gt;</span></p>
<p>&lt;fw type=<span style="color: #0000ff;">&#8220;header&#8221;</span> place=<span style="color: #0000ff;">&#8220;top-center&#8221;</span>&gt;<br />
<span style="color: #000080;">&lt;name type=<span style="color: #0000ff;">&#8220;place&#8221;</span> key=<span style="color: #0000ff;">&#8220;7022220&#8243;</span>&gt;</span>Williamsburg<span style="color: #000080;">&lt;/name&gt;</span>,<br />
<span style="color: #000080;">&lt;date value=<span style="color: #0000ff;">&#8220;1850&#8243;</span>&gt;</span>1850<span style="color: #000080;">&lt;/date&gt;</span>,<br />
&lt;/fw&gt;</p>
<p><span style="color: #008080;">&lt;table&gt;</span><br />
<span style="color: #000080;">&lt;row&gt;</span><br />
<span style="color: #000080;">&lt;cell&gt;</span><br />
<span style="color: #000080;">&lt;date value=<span style="color: #0000ff;">&#8220;1850-10-03&#8243;</span>&gt;</span>&lt;choice&gt;<span style="color: #008000;">&lt;abbr&gt;</span>Oct<span style="color: #000080;">&lt;hi rend=<span style="color: #0000ff;">&#8220;sup;underline&#8221;</span>&gt;</span>r<span style="color: #000080;">&lt;/hi&gt;</span><span style="color: #008000;">&lt;/abbr&gt;</span><span style="color: #000080;">&lt;expan&gt;</span>October<span style="color: #000080;">&lt;/expan&gt;</span>&lt;/choice&gt; 3<span style="color: #000080;">&lt;hi rend=<span style="color: #0000ff;">&#8220;sup&#8221;</span>&gt;</span>th<span style="color: #000080;">&lt;/hi&gt;</span> 1850<span style="color: #000080;">&lt;/date&gt;</span><br />
<span style="color: #000080;">&lt;/cell&gt;</span><br />
<span style="color: #000080;">&lt;cell&gt;</span><br />
<span style="color: #000080;">&lt;name type=<span style="color: #0000ff;">&#8220;person&#8221;</span> key=<span style="color: #0000ff;">&#8220;griffss01&#8243;</span>&gt;</span>Doct<span style="color: #000080;">&lt;hi rend=<span style="color: #0000ff;">&#8220;sup;underline&#8221;</span>&gt;</span>r<span style="color: #000080;">&lt;/hi&gt;</span> S S Griffin<span style="color: #000080;">&lt;/name&gt;</span><br />
<span style="color: #000080;">&lt;/cell&gt;</span><br />
<span style="color: #000080;">&lt;cell&gt;</span><strong><em>&amp;nbsp;</em></strong><span style="color: #000080;">&lt;/cell&gt;</span><br />
<span style="color: #000080;">&lt;/row&gt;</span><br />
&#8230;<br />
<span style="color: #008080;">&lt;/table&gt;</span><br />
<span style="color: #000080;">&lt;pb/&gt;</span><br />
&#8230;</div>
<p>What I wanted to accomplish was group all this together in separate divs for HTML output (ok, I actually need to write each page to its own file, but this is pretty much just one more step).</p>
<p>I just could not find a way to group this info this way using XSLT 1 without wrapping each page within its own div structure. I didn&#8217;t really want to go back and do this, so I asked the TEI-L list. David Sewell pinged me back with some XQuery code that recursively recalls the document structure for a given node.</p>
<p>He also mentioned that it would be pretty easy to write an XSLT 2 transformation that groups these nodes together. I did a little bit of digging and came up with</p>
<div class="code"><span style="color: #000080;">&lt;xsl:template match=<span style="color: #0000ff;">&#8220;tei:div&#8221;</span>&gt;</span><br />
<span style="color: #000080;">&lt;xsl:for-each-group select=<span style="color: #0000ff;">&#8220;*&#8221;</span> group-ending-with<span style="color: #0000ff;">&#8220;tei:pb&#8221;</span>&gt;</span><br />
<span style="color: #000080;">&lt;div class=<span style="color: #0000ff;">&#8220;page&#8221;</span>&gt;</span><br />
<span style="color: #000080;">&lt;xsl:apply-templates select=<span style="color: #0000ff;">&#8220;current-group()&#8221;</span> /&gt;</span><br />
<span style="color: #000080;">&lt;/div&gt;</span><br />
<span style="color: #000080;">&lt;/xsl:for-each-group&gt;</span><br />
<span style="color: #000080;">&lt;/xsl:template&gt;</span></div>
<p>This transformed the pages to what I was wanting</p>
<div class="code"><span style="color: #000080;">&lt;div class=<span style="color: #0000ff;">&#8220;page&#8221;</span>&gt;</span><br />
<span style="color: #000080;"><span style="color: #800080;">&lt;img src=<span style="color: #0000ff;">&#8220;0023_12.png&#8221;</span> alt=<span style="color: #0000ff;">&#8220;Page 12&#8243;</span> /&gt;</span></span></p>
<p><span style="color: #000080;">&lt;h1 class=<span style="color: #0000ff;">&#8220;fw&#8221;</span>&gt;</span>Williamsburg,<span style="color: #0000ff;"> 1850</span>,<span style="color: #000080;">&lt;/h1&gt;</span></p>
<p><span style="color: #008080;">&lt;table&gt;</span><br />
<span style="color: #008080;">&lt;tr&gt;</span><br />
<span style="color: #008080;">&lt;td&gt;</span><br />
<span style="color: #000080;">&lt;span class=<span style="color: #0000ff;">&#8220;abbr&#8221;</span>&gt;</span>Oct<span style="color: #000080;">&lt;sup&gt;</span><span style="color: #000080;">&lt;u&gt;</span>r<span style="color: #000080;">&lt;/u&gt;</span><span style="color: #000080;">&lt;/sup&gt;</span><span style="color: #000080;">&lt;/span&gt;</span><span style="color: #000080;">&lt;span class=<span style="color: #0000ff;">&#8220;expan&#8221;</span>&gt;</span>October<span style="color: #000080;">&lt;/span&gt;</span> 3<span style="color: #000080;">&lt;sup&gt;</span>th<span style="color: #000080;">&lt;/sup&gt;</span> 1850<span style="color: #000080;">&lt;/date&gt;</span><br />
<span style="color: #008080;">&lt;/td&gt;</span><br />
<span style="color: #008080;">&lt;td&gt;</span><br />
<span style="color: #008000;">&lt;a href=<span style="color: #0000ff;">&#8220;javascript:getName(&#8216;griffss01&#8242;);&gt;</span>Doct<span style="color: #000080;">&lt;sup&gt;</span><span style="color: #000080;">&lt;u&gt;</span>r<span style="color: #000080;">&lt;/u&gt;</span><span style="color: #000080;">&lt;/sup&gt;</span> S S Griffin<span style="color: #008000;">&lt;/a&gt;</span><br />
<span style="color: #008080;">&lt;/td&gt;</span><br />
<span style="color: #008080;">&lt;td&gt;</span><strong><em>&amp;nbsp;</em></strong><span style="color: #008080;">&lt;/td&gt;</span><br />
<span style="color: #000080;">&lt;/row&gt;</span><br />
&#8230;<br />
<span style="color: #008080;">&lt;/table&gt;</span><br />
<span style="color: #000080;">&lt;/div&gt;</span></p>
<p><span style="color: #000080;">&lt;div class=&#8221;</span>page&#8221;&gt;</span><br />
&#8230;<br />
<span style="color: #000080;">&lt;/div&gt;</span></div>
<p>The XSLT processor for ColdFusion doesn&#8217;t support XSLT 2.0 (it&#8217;s still a draft spec). However, Saxon does (specifically Saxon 8). For more on doing XSLT transformations, see <a href="http://swem.wm.edu/blogs/waynegraham/index.cfm/2005/11/21/XSLT-20-in-ColdFusion">XSLT 2.0 in ColdFusion</a>.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2006/08/23/real-life-xslt-20-transformations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
