view summa/bilingual/merge.xpl @ 91:8578f2a13dcd

more align
author ht
date Sun, 23 Mar 2014 09:02:04 +0000
parents 75219c0115ca
children
line wrap: on
line source

<?xml version='1.0'?>
<!DOCTYPE p:pipeline SYSTEM "../../../../WWW/XML/XProc/docs/schemas/xproc.dtd" >
<p:pipeline xmlns:p="http://www.w3.org/ns/xproc" xmlns:x="http://www.w3.org/1999/xhtml" version="1.0">
 
 <p:documentation xmlns="http://www.w3.org/1999/xhtml">
  <div>Run this e.g. as follows:
       xprocs --input source=../english/FP_ii.html merge.xpl lfs=../latin/sth1002.html\;../latin/sth1003.html\;../latin/sth1015.html rawpart=FP.ii</div>
 </p:documentation>
 
 <p:option name="lfs" required="true">
  <p:documentation xmlns="http://www.w3.org/1999/xhtml">
   <div>list of latin files, use ; as separator</div>
  </p:documentation>
 </p:option>
 
 <p:variable name="rawpart" select="/x:div/@id"/>
 
 <p:delete match="x:a[@href and not(text())]"/>
 <p:viewport match="x:div[@class='div3']" name="vp">
  <p:xslt>
   <p:input port="stylesheet">
    <p:document href="fixup_e.xsl"/>
   </p:input>
  </p:xslt>  
  <p:viewport match="x:div[@class='div4' and not(@id)]">
   <p:documentation xmlns="http://www.w3.org/1999/xhtml">
    <div>Treat tail of prooemium as index</div>
   </p:documentation>
   <p:xslt>
    <p:input port="stylesheet">
     <p:inline xmlns="http://www.w3.org/1999/xhtml">
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:x="http://www.w3.org/1999/xhtml" exclude-result-prefixes="x xsl">
       <xsl:variable name="prefix" select="concat('#',substring-before(/x:div/x:p[1]/@id,'-'),'_A')"/>
       <xsl:template match="x:p[starts-with(.,' (')]">
        <xsl:copy>
         <xsl:apply-templates select="@*"/>
         <a href="{concat($prefix,substring-after(substring-before(.,')'),'('))}">
          <xsl:apply-templates select="node()"/>
         </a>
        </xsl:copy>
       </xsl:template>
       
       <xsl:template match="@*|node()">
        <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
       </xsl:template>
      </xsl:stylesheet>
   </p:inline>
  </p:input>
   </p:xslt>
  </p:viewport>
  <p:xslt>
   <p:input port="stylesheet">
    <p:document href="merge.xsl"/>
   </p:input>
   <p:with-param name="lfs" select="$lfs"/>
  </p:xslt>
  <p:xslt>
   <p:input port="stylesheet">
    <p:document href="bi.xsl"/>
   </p:input>
   <p:with-param name="rawpart" select="$rawpart"/>
  </p:xslt>
 </p:viewport>
 <p:insert match="x:body" position="first-child" name="wrap">
  <p:input port="source">
   <p:inline xmlns="http://www.w3.org/1999/xhtml">
    <html>
   <head>
    <title>Bilingual Aquinas</title>
    <style>
     h2, h3, h4 {margin-bottom: 0px; clear: both}
     .bilingual {clear: both; margin-top: .5em}
     div.eng {width: 45%; float: left}
     div.lat {width: 45%; float: right}
    @page { size: A4 portrait; margin: 1cm;
            orphans: 2; widows: 2;
            } 
     @media print {div.div3 {page-break-before: always}}
    </style>
   </head>
   <body style="font-family: Bitstream Vera Serif">
   </body>
  </html></p:inline>
  </p:input>
  <p:input port="insertion">
   <p:pipe port="result" step="vp"/>
  </p:input>
 </p:insert>
 <p:wrap-sequence wrapper="x:div">
  <p:input port="source" select="/*/*/x:h3">
   <p:pipe port="result" step="vp"/>
  </p:input>
 </p:wrap-sequence>
 <p:xslt name="toc">
  <p:input port="stylesheet">
   <p:inline xmlns="http://www.w3.org/1999/xhtml">
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:x="http://www.w3.org/1999/xhtml" exclude-result-prefixes="x xsl">
     <xsl:template match="/x:div">
      <div class="toc">
       <xsl:for-each select="x:h3">
        <a href="#{substring-before(@id,'-')}">
         <xsl:apply-templates/>
        </a><br/>
       </xsl:for-each>
      </div>
     </xsl:template>
    </xsl:stylesheet>
   </p:inline>
  </p:input>
 </p:xslt>
 <p:insert match="x:h2" position="after">
  <p:input port="source">
   <p:pipe step="wrap" port="result"/>
  </p:input>
  <p:input port="insertion">
   <p:pipe step="toc" port="result"/>
  </p:input>
 </p:insert>
</p:pipeline>