Use Case 5.14 Pipeline

This one actually works!  Tides from the NOAA

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
   xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0"
   xmlns:xhtml="http://www.w3.org/1999/xhtml">
   <p:output port="result"/>
   <p:http-request>
      <p:input port="source">
         <p:inline>
            <c:request method="GET"
href="http://tidesonline.nos.noaa.gov/data_read.shtml?station_info=9414290"/>
         </p:inline>
      </p:input>
   </p:http-request>
   <p:unescape-markup content-type="text/html"/>
   <p:filter select="/c:body/xhtml:html/xhtml:body/xhtml:pre/xhtml:pre"/>
   <p:unwrap match="xhtml:font"/>
   <p:xslt>
      <p:input port="stylesheet">
         <p:inline>
            <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
               <xsl:template match="xhtml:pre">
                  <xsl:copy>
                     <xsl:analyze-string select="." regex="\n">
                        <xsl:non-matching-substring>
                           <line><xsl:value-of select="."/></line>
                        </xsl:non-matching-substring>
                     </xsl:analyze-string>
                  </xsl:copy>
               </xsl:template>
            </xsl:stylesheet>
         </p:inline>
      </p:input>
      <p:input port="parameters">
         <p:inline><c:param-set/></p:inline>
      </p:input>
   </p:xslt>
   <p:xslt>
      <p:input port="stylesheet">
         <p:inline>
            <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
               <xsl:template match="line">
                  <xsl:analyze-string select="."
regex="^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)">
                     <xsl:matching-substring
xmlns="http://www.w3.org/1999/xhtml" xml:space='preserve'>
                        <tr>
                           <td><xsl:value-of select="regex-group(1)"/></td>
                           <td><xsl:value-of select="regex-group(2)"/></td>
                           <td><xsl:value-of select="regex-group(3)"/></td>
                           <td><xsl:value-of select="regex-group(4)"/></td>
                           <td><xsl:value-of select="regex-group(5)"/></td>
                           <td><xsl:value-of select="regex-group(6)"/></td>
                           <td><xsl:value-of select="regex-group(7)"/></td>
                           <td><xsl:value-of select="regex-group(8)"/></td>
                           <td><xsl:value-of select="regex-group(9)"/></td>
                           <td><xsl:value-of select="regex-group(10)"/></td>
                           <td><xsl:value-of select="regex-group(11)"/></td>
                           <td><xsl:value-of select="regex-group(12)"/></td>
                           <td><xsl:value-of select="regex-group(13)"/></td>
                        </tr>
                     </xsl:matching-substring>
                  </xsl:analyze-string>
               </xsl:template>
               <xsl:template match="xhtml:pre">
                  <table
xmlns="http://www.w3.org/1999/xhtml"><xsl:apply-templates
select="@*|node()"/></table>
               </xsl:template>
            </xsl:stylesheet>
         </p:inline>
      </p:input>
      <p:input port="parameters">
         <p:inline><c:param-set/></p:inline>
      </p:input>
   </p:xslt>
   <p:xquery>
      <p:input port="query">
         <p:inline>
            <c:data>
            declare namespace xhtml="http://www.w3.org/1999/xhtml";
            element tides {
              attribute high { string((for $r in /xhtml:table/xhtml:tr
                                         order by
string($r/xhtml:td[4]) descending
                                         return $r)[1]/xhtml:td[2]) },
              attribute low { string((for $r in /xhtml:table/xhtml:tr
                                         order by
string($r/xhtml:td[4]) ascending
                                         return $r)[1]/xhtml:td[2]) },
              /xhtml:table
            }
            </c:data>
         </p:inline>
      </p:input>
      <p:input port="parameters">
         <p:inline><c:param-set/></p:inline>
      </p:input>
   </p:xquery>
</p:declare-step>

-- 
--Alex Milowski
"The excellence of grammar as a guide is proportional to the paucity of the
inflexions, i.e. to the degree of analysis effected by the language
considered."

Bertrand Russell in a footnote of Principles of Mathematics

Received on Tuesday, 8 May 2012 20:09:21 UTC