view visualise.xpl @ 26:d2ca3ea1f5ae

plumb in and use inverted ref table (via key)
author Henry S. Thompson <ht@markup.co.uk>
date Fri, 07 Apr 2017 18:42:47 +0100
parents a5125a2e77ea
children 8309dcfce613
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" name="vis">
 
 <p:documentation xmlns="http://www.w3.org/1999/xhtml">
  <div>Run this e.g. as follows:
       xproc --input source=sample2/xl/worksheets/sheet1.xml visualise.xpl elabDir=file:/d/MT/sonra/OOXML</div>
 </p:documentation>
 
 <p:option name="elabDir" required="true">
  <p:documentation xmlns="http://www.w3.org/1999/xhtml">
   <div>Directory where stylesheets, other info for stylesheet elaboration are found</div>
  </p:documentation>
 </p:option>
 
 <p:option name="format">
  <p:documentation xmlns="http://www.w3.org/1999/xhtml">
   <div>If supplied, then use as stylesheet (located relative to elabDir), to
produce pretty output (e.g. ascii, html)</div>
  </p:documentation>
 </p:option>
 
 <p:load name="ss1">
  <p:with-option name="href" select="concat($elabDir,'/format.xsl')"/>
  <p:documentation>
   <div>Use cell format and other cues in order to assign classes to cells</div>
  </p:documentation>
 </p:load>

 <p:xslt name="format">
   <p:input port="source">
    <p:pipe step="vis" port="source"/>
   </p:input>
  <p:input port="stylesheet">
   <p:pipe step="ss1" port="result"/>
  </p:input>
  <p:with-param name="elabDir" select="$elabDir"/>
 </p:xslt> 
 
 <p:load name="ssr">
  <p:with-option name="href" select="concat($elabDir,'/refs.xsl')"/>
  <p:documentation>
   <div>Tokenise cell formulae and extract local, range and external references</div>
  </p:documentation>
 </p:load>

 <p:xslt name="refs">
  <p:input port="source">
   <p:pipe step="vis" port="source"/>
  </p:input>
  <p:input port="stylesheet">
     <p:pipe step="ssr" port="result"/>
    </p:input>
 </p:xslt>
 
 <p:load name="ssr2">
  <p:with-option name="href" select="concat($elabDir,'/refs2.xsl')"/>
  <p:documentation>
   <div>Invert refs data into a map from cell to cells which point to it</div>
  </p:documentation>
 </p:load>
 
 <p:xslt name="refs2">
  <p:input port="source">
   <p:pipe step="refs" port="result"/>
  </p:input>
  <p:input port="stylesheet">
     <p:pipe step="ssr2" port="result"/>
    </p:input>
 </p:xslt>

 <p:load name="ss2">
  <p:with-option name="href" select="concat($elabDir,'/rect.xsl')"/>
 </p:load>
 
 <p:xslt name="rect">
   <p:input port="source">
    <p:pipe step="format" port="result"/>
    <p:pipe step="refs2" port="result"/>
   </p:input>
  <p:input port="stylesheet">
   <p:pipe step="ss2" port="result"/>
  </p:input>
 </p:xslt>
 
 <p:choose> 
  <p:when test="p:value-available('format')">
   <p:load name="ss3">
    <p:with-option name="href" select="concat($elabDir,'/',$format)"/>
   </p:load>
   <p:xslt name="fmt">
    <p:input port="source">
     <p:pipe step="rect" port="result"/>
    </p:input>
    <p:input port="stylesheet">
     <p:pipe step="ss3" port="result"/>
    </p:input>
   </p:xslt>
  </p:when>
  <p:otherwise>
   <p:identity/>
  </p:otherwise>
 </p:choose>
</p:pipeline>