\section{Template for parsing a link from Gaussian log files}
\label{appendix:appendix2}
\linespread{0.5}

A template to parse the output from the 601 link output in Gaussian logfiles. (The code
for beta eigenvalues has been omitted for clarity. )

\begin{verbatim}

<!-- the template selects a chunk of text beginning with "pattern" and ending
     with endPattern. -->
     
<template id="l601.alphabetaeigen" pattern="\s*(Alpha|Beta)\s+(occ|virt)\. eigenvalues.*"
  repeat="*"
  endPattern="\s[^A][^B].*">

  <!-- an example of input which also acts as a unit test -->  
  
  <comment class="example.input" id="l601.alphabeta">
 Alpha  occ. eigenvalues --  -10.17514  -0.68437  -0.38581  -0.38581  -0.38581
 Alpha virt. eigenvalues --    0.11292   0.17036   0.17036   0.17036   0.53917
 Alpha virt. eigenvalues --    0.53917   0.53917   0.88316   0.88316   0.88316
 Alpha virt. eigenvalues --    0.91927   1.09380   1.66027   1.66027   2.21731
 Alpha virt. eigenvalues --    2.21731   2.21731   4.16488
  </comment>
  
  <!-- all lines are parsed with a single recordReader. The trailing part of the line
       is captured into an array and names with the leading string -->
       
  <record id="eigen" repeat="*">\s*{X,g:name}\s*eigenvalues \-\-{1_5F,g:eigen}</record>

  <!-- rename the dictRef to conform to dictionary and to CML syntax -->  
  <transform process="addDictRef" xpath=".//cml:array[@cmlx:temp='Alpha  occ.']" value="cc:alphaocc"/>
  <transform process="addDictRef" xpath=".//cml:array[@cmlx:temp='Alpha virt.']" value="cc:alphavirt"/>

  <!-- stitch lines together -->  
  <transform process="joinArrays" xpath=".//cml:array[@dictRef='g:alphaocc']"/>
  <transform process="joinArrays" xpath=".//cml:array[@dictRef='g:alphavirt']"/>

  <!-- expected output (can also be used for unit testing). Note that the result
       is labelled with the chunk number (l601) as well as the -->
  
  <comment class="example.output" id="l601.alphabeta">
    <module cmlx:templateRef="l601.alphabetaeigen" xmlns="http://www.xml-cml.org/schema" xmlns:cmlx="http://www.xml-cml.org/schema/cmlx">
      <array dataType="xsd:double" size="5" dictRef="cc:alphaocc">-10.17514 -0.68437 -0.38581 -0.38581 -0.38581</array>
      <array dataType="xsd:double" size="18" dictRef=cc:alphavirt">
        0.11292 0.17036 0.17036 0.17036 0.53917 0.53917 0.53917 0.88316 0.88316 0.88316
        0.91927 1.0938 1.66027 1.66027 2.21731 2.21731 2.21731 4.16488</array>
    </module>
 </comment>
 

\end{verbatim}