One of the DIG's objectives is to generate staff client help files from The
Book of Evergreen.  On the Evergreen wiki Jason Etheridge described how
future releases are expected to load help files for the active staff client
tab (see http://www.open-ils.org/dokuwiki/doku.php?id=scratchpad:custom_help).
Using this as starting point I've adapted some stylesheets to make
selections from The Book of Evergreen available via future help menus.
Here's a draft workflow:

1) All parts of The Book of Evergreen relevant to the staff client are
flagged with the attribute audience="staff-client".  This is a recursive
attribute: if a part is flagged, all chapters and sections within that part
are also flagged.  This is optional but makes it possible to publish a
subset of The Book of Evergreen excluding sections that do not apply to the
GUI.

2) Elements in the DocBook files (chapters, sections, etc) are flagged for
use as help files with two attributes: role="help" and
annotations="path-and-name-of-help-file" (e.g.
server/circ/checkin.xul.help.html).  The path and name of help file
determines the staff client screen(s) it is associated with.

3) Publish a streamlined html version of The Book of Evergreen
(audience="staff-client") with no images.  This is the help file content and
could be stored on the Evergreen server or in any web-accessible location.
Headers, footers, and navigation buttons could be customized.

4) Generate help files following the naming convention Jason described on
the wiki.  These are small html files stored on the server that load the
content generated in step 3.

Attached are a script and stylesheets for steps 3 and 4.  They work in tests
with Sitka's DocBook files but aren't very pretty (remote content loads with
iframes, no header/footer customization, might only work with xsltproc,
etc).  But before doing any further work, some questions for the community:

-Overall does this seem like a reasonable approach?  Is anyone else already
working to link sections of The Book of Evergreen to staff client help
menus?

-How should help files display in the client?  Will they open in new tab, a
column in the active tab, as a pop-up window, or?

-Is there a list of staff client screens with associated help file names, or
do we need to copy them from the console as Jason describes on the wiki?

Any questions, suggestions, and comments are welcome.

Thanks,
Jeremy

-- 
Jeremy Buhler
Trainer/Help Desk Specialist
Sitka Evergreen Implementation
[email protected]

Attachment: help_draft.sh
Description: Bourne shell script

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:lxslt="http://xml.apache.org/xslt"; xmlns:exsl="http://exslt.org/common";
    xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"; xmlns="http://www.w3.org/1999/xhtml";
    version="1.0" extension-element-prefixes="lxslt exsl">

<!-- create a file for each element with attribute role="help", with an iframe pointing to 
help content (html) at another location -->


<!-- the directory containing the help content files -->
    <xsl:variable name="base-url"
        >http://coconut.pines.bclibrary.ca:21080/docbook/Help/</xsl:variable>

    <!-- where to store the generated files (directory must already exist) -->
    <xsl:variable name="output-directory">~/help/</xsl:variable>


    <xsl:template match="/">
        <!-- find elements where role="help"  -->
        <xsl:for-each select="descendant::node()[...@role='help']">

            <!-- for each element write an html file, with filename pulled from the annotations attribute -->
            <xsl:variable name="filename" select="concat($output-directory,@annotations,'.html')"/>
            <exsl:document method="xml" indent="yes" href="{$filename}">

                <!-- file content -->
                <xsl:text disable-output-escaping="yes"><![CDATA[<html>
            <title>]]></xsl:text>
                <xsl:text>Evergreen help file</xsl:text>
                <xsl:text disable-output-escaping="yes"><![CDATA[</title> 
            <body>
                <iframe width="100%" height="100%" frameborder="0" src="]]></xsl:text>

                <!-- set iframe src (location of help content files) -->
                <xsl:copy-of select="concat($base-url,@xml:id,'.html')"/>
                <xsl:text disable-output-escaping="yes"><![CDATA["/> 
            </body>                
            </html>]]></xsl:text>

            </exsl:document>

        </xsl:for-each>

    </xsl:template>

</xsl:stylesheet>
<?xml version='1.0'?>
<xsl:stylesheet  
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

<xsl:import href="docbook-xsl/xhtml/chunk.xsl"/>
<xsl:import href="evergreen_help_graphics.xsl"/> <!-- override default graphics stylesheet with one that strips all images -->

<!-- <xsl:param name="html.stylesheet" select="'../??????.css'"/>  -->
<xsl:param name="glossary.sort" select="1"/> <!-- sort glossterms aphabetically regardless of order in xml docs -->
<xsl:param name="glossterm.separation" select="'0.1in'"/> <!-- vertical space between term and definition paragraph -->
<xsl:param name="use.id.as.filename" select="1"/> <!-- to avoid changes to urls as new chapters/sections are added -->
<xsl:param name="chunker.output.indent" select="'yes'"/> <!-- for tidier formatting of html output -->    

<!-- allow for linebreaks in html output using the <?linebreak?> PI -->
<xsl:template match="processing-instruction('linebreak')">
<br/>
</xsl:template>


<!-- customized header, to add home link -->
    
    <xsl:template name="header.navigation">
        <xsl:param name="prev" select="/d:foo"/>
        <xsl:param name="next" select="/d:foo"/>
        <xsl:param name="nav.context"/>
        
        <xsl:variable name="home" select="/*[1]"/>
        <xsl:variable name="up" select="parent::*"/>
        
        <xsl:variable name="row1" select="$navig.showtitles != 0"/>
        <xsl:variable name="row2" select="count($prev) &gt; 0                                     or (count($up) &gt; 0                                          and generate-id($up) != generate-id($home)                                         and $navig.showtitles != 0)                                     or count($next) &gt; 0"/>
        
        <xsl:if test="$suppress.navigation = '0' and $suppress.header.navigation = '0'">
            <div class="navheader">
                <xsl:if test="$row1 or $row2">
                    <table width="100%" summary="Navigation header">
                        <xsl:if test="$row1">
                            <tr>
                                <th colspan="3" align="center">
                                    <xsl:apply-templates select="." mode="object.title.markup"/>
                                </th>
                            </tr>
                        </xsl:if>
                        
                        <xsl:if test="$row2">
                            <tr>
                                <td width="20%" align="{$direction.align.start}">
                                    <xsl:if test="count($prev)&gt;0">
                                        
                               <!-- the next line is custom, adds TOC link to HTML pages -->         
                                        
                                        <a style="margin-right: 10px;" href="index.html">Home</a>
                                        <a accesskey="p">
                                            <xsl:attribute name="href">
                                                <xsl:call-template name="href.target">
                                                    <xsl:with-param name="object" select="$prev"/>
                                                </xsl:call-template>
                                            </xsl:attribute>
                                            <xsl:call-template name="navig.content">
                                                <xsl:with-param name="direction" select="'prev'"/>
                                            </xsl:call-template>
                                        </a>
                                    </xsl:if>
                                    <xsl:text>&#160;</xsl:text>
                                </td>
                                <th width="60%" align="center">
                                    <xsl:choose>
                                        <xsl:when test="count($up) &gt; 0                                   and generate-id($up) != generate-id($home)                                   and $navig.showtitles != 0">
                                            <xsl:apply-templates select="$up" mode="object.title.markup"/>
                                        </xsl:when>
                                        <xsl:otherwise>&#160;</xsl:otherwise>
                                    </xsl:choose>
                                </th>
                                <td width="20%" align="{$direction.align.end}">
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:if test="count($next)&gt;0">
                                        <a accesskey="n">
                                            <xsl:attribute name="href">
                                                <xsl:call-template name="href.target">
                                                    <xsl:with-param name="object" select="$next"/>
                                                </xsl:call-template>
                                            </xsl:attribute>
                                            <xsl:call-template name="navig.content">
                                                <xsl:with-param name="direction" select="'next'"/>
                                            </xsl:call-template>
                                        </a>
                                    </xsl:if>
                                </td>
                            </tr>
                        </xsl:if>
                    </table>
                </xsl:if>
                <xsl:if test="$header.rule != 0">
                    <hr/>
                </xsl:if>
            </div>
        </xsl:if>
    </xsl:template>
   
  <!-- custom footer for Sitka copyright --> 
   
    <xsl:template name="user.footer.navigation">
        
       <div style="float: left;"> <p style="font-style: italic; font-size: .8em;">Copyright © 2010, BC Libraries Cooperative
        </p><p><a href="http://creativecommons.org/licenses/by-sa/3.0/"; title="Creative Commons license">
            <img src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png"/></a></p></div>
               
    </xsl:template>
    


</xsl:stylesheet>

<?xml version="1.0" encoding="ASCII"?>
<!--This file was created automatically by html2xhtml-->
<!--from the HTML stylesheets.-->
<!--edited to exclude all images from html output (lines 54-60) -->
  
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:d="http://docbook.org/ns/docbook";
xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory"; xmlns:simg="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.ImageIntrinsics"; xmlns:ximg="xalan://com.nwalsh.xalan.ImageIntrinsics" xmlns:xtext="xalan://com.nwalsh.xalan.Text" xmlns:lxslt="http://xml.apache.org/xslt"; xmlns="http://www.w3.org/1999/xhtml"; exclude-result-prefixes="xlink stext xtext lxslt simg ximg d" extension-element-prefixes="stext xtext" version="1.0">

<!-- ********************************************************************
     $Id: graphics.xsl 8421 2009-05-04 07:49:49Z bobstayton $
     ********************************************************************

     This file is part of the XSL DocBook Stylesheet distribution.
     See ../README or http://docbook.sf.net/release/xsl/current/ for
     copyright and other information.

     Contributors:
     Colin Paul Adams, <[email protected]>

******************************************************************** -->  


<lxslt:component prefix="xtext" elements="d:insertfile"/>
<lxslt:component prefix="ximg" functions="new getWidth getDepth"/>

<!-- ==================================================================== -->
<!-- Graphic format tests for the HTML backend -->

<xsl:template name="is.graphic.format">
  <xsl:param name="format"/>
  <xsl:if test="$format = 'SVG'                 or $format = 'PNG'                 or $format = 'JPG'                 or $format = 'JPEG'                 or $format = 'linespecific'                 or $format = 'GIF'                 or $format = 'GIF87a'                 or $format = 'GIF89a'                 or $format = 'BMP'					or $format = 'SWF'">1</xsl:if>
</xsl:template>

<xsl:template name="is.graphic.extension">
  <xsl:param name="ext"/>
  <xsl:variable name="lcext" select="translate($ext,                                        'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                        'abcdefghijklmnopqrstuvwxyz')"/>
  <xsl:if test="$lcext = 'svg'              or $lcext = 'png'              or $lcext = 'jpeg'              or $lcext = 'jpg'              or $lcext = 'avi'              or $lcext = 'mpg'              or $lcext = 'mpeg'              or $lcext = 'qt'              or $lcext = 'gif'              or $lcext = 'bmp'">1</xsl:if>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template match="d:screenshot">
  <div>
    <xsl:apply-templates select="." mode="common.html.attributes"/>
    <xsl:apply-templates/>
  </div>
</xsl:template>

<xsl:template match="d:screeninfo">
</xsl:template>

<!-- ==================================================================== -->

<xsl:template name="process.image">
    <!-- deleted all template content to strip output of images.  To restore, copy from evergreen_xhtml_graphics.xsl -->
</xsl:template>

<xsl:template name="process.image.attributes">
  <!-- deleted all template content to strip output of images.  To restore, copy from evergreen_xhtml_graphics.xsl -->
</xsl:template>

<!-- ==================================================================== -->

<xsl:template match="d:graphic">
  <xsl:choose>
    <xsl:when test="parent::d:inlineequation">
      <xsl:call-template name="anchor"/>
      <xsl:call-template name="process.image"/>
    </xsl:when>
    <xsl:otherwise>
      <div>
        <xsl:if test="@align">
          <xsl:attribute name="align">
            <xsl:value-of select="@align"/>
          </xsl:attribute>
        </xsl:if>
        <xsl:call-template name="anchor"/>
        <xsl:call-template name="process.image"/>
      </div>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="d:inlinegraphic">
  <xsl:variable name="filename">
    <xsl:choose>
      <xsl:when test="@entityref">
        <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="@fileref"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:call-template name="anchor"/>

  <xsl:choose>
    <xsl:when test="@format='linespecific'">
      <xsl:choose>
        <xsl:when test="$use.extensions != '0'                         and $textinsert.extension != '0'">
          <xsl:choose>
            <xsl:when test="element-available('stext:insertfile')">
              <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
            </xsl:when>
            <xsl:when test="element-available('xtext:insertfile')">
              <xtext:insertfile href="{$filename}"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:message terminate="yes">
                <xsl:text>No insertfile extension available.</xsl:text>
              </xsl:message>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
	  <xsl:message terminate="yes">
	    <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
	    <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text> 
	  </xsl:message>
	</xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="process.image"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template match="d:mediaobject|d:mediaobjectco">

  <xsl:variable name="olist" select="d:imageobject|d:imageobjectco                      |d:videoobject|d:audioobject                      |d:textobject"/>

  <xsl:variable name="object.index">
    <xsl:call-template name="select.mediaobject.index">
      <xsl:with-param name="olist" select="$olist"/>
      <xsl:with-param name="count" select="1"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="object" select="$olist[position() = $object.index]"/>

  <xsl:variable name="align">
    <xsl:value-of select="$object/descendant::d:imageda...@align][1]/@align"/>
  </xsl:variable>

  <div>
    <xsl:apply-templates select="." mode="common.html.attributes"/>
    <xsl:if test="$align != '' ">
      <xsl:attribute name="align">
        <xsl:value-of select="$align"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:call-template name="anchor"/>

    <xsl:apply-templates select="$object"/>
    <xsl:apply-templates select="d:caption"/>
  </div>
</xsl:template>

<xsl:template match="d:inlinemediaobject">
  <span>
    <xsl:apply-templates select="." mode="common.html.attributes"/>
    <xsl:call-template name="anchor"/>
    <xsl:call-template name="select.mediaobject"/>
  </span>
</xsl:template>

<xsl:template match="d:programlisting/d:inlinemediaobject                      |d:screen/d:inlinemediaobject" priority="2">
  <!-- the additional span causes problems in some cases -->
  <xsl:call-template name="select.mediaobject"/>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template match="d:imageobjectco">
  <xsl:call-template name="anchor"/>
  <xsl:apply-templates select="d:imageobject"/>
  <xsl:apply-templates select="d:calloutlist"/>
</xsl:template>

<xsl:template match="d:imageobject">
  <xsl:apply-templates select="d:imagedata"/>
</xsl:template>

<xsl:template match="d:imagedata">
  <xsl:variable name="filename">
    <xsl:call-template name="mediaobject.filename">
      <xsl:with-param name="object" select=".."/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:choose>
    <!-- Handle MathML and SVG markup in imagedata -->
    <xsl:when xmlns:mml="http://www.w3.org/1998/Math/MathML"; test="mml:*">
      <xsl:apply-templates/>
    </xsl:when>
    
    <xsl:when xmlns:svg="http://www.w3.org/2000/svg"; test="svg:*">
      <xsl:apply-templates/>
    </xsl:when>

    <xsl:when test="@format='linespecific'">
      <xsl:choose>
        <xsl:when test="$use.extensions != '0'                         and $textinsert.extension != '0'">
          <xsl:choose>
            <xsl:when test="element-available('stext:insertfile')">
              <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
            </xsl:when>
            <xsl:when test="element-available('xtext:insertfile')">
              <xtext:insertfile href="{$filename}"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:message terminate="yes">
                <xsl:text>No insertfile extension available.</xsl:text>
              </xsl:message>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
          <a xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" href="{$filename}"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="longdesc.uri">
        <xsl:call-template name="longdesc.uri">
          <xsl:with-param name="mediaobject" select="ancestor::d:imageobject/parent::*"/>
        </xsl:call-template>
      </xsl:variable>

      <xsl:variable name="phrases" select="ancestor::d:mediaobject/d:textobject[d:phrase]                             |ancestor::d:inlinemediaobject/d:textobject[d:phrase]                             |ancestor::d:mediaobjectco/d:textobject[d:phrase]"/>

      <xsl:call-template name="process.image">
        <xsl:with-param name="alt">
          <xsl:apply-templates select="$phrases[not(@role) or @role!='tex'][1]"/>
        </xsl:with-param>
        <xsl:with-param name="longdesc">
          <xsl:call-template name="write.longdesc">
            <xsl:with-param name="mediaobject" select="ancestor::d:imageobject/parent::*"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0                     and ancestor::d:imageobject/parent::*/d:textobject[not(d:phrase)]">
        <xsl:call-template name="longdesc.link">
          <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/>
        </xsl:call-template>
      </xsl:if>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template name="longdesc.uri">
  <xsl:param name="mediaobject" select="."/>
  <xsl:if test="$html.longdesc">
    <xsl:if test="$mediaobject/d:textobject[not(d:phrase)]">
      <xsl:variable name="dbhtml.dir">
        <xsl:call-template name="dbhtml-dir"/>
      </xsl:variable>
      <xsl:variable name="filename">
        <xsl:call-template name="make-relative-filename">
          <xsl:with-param name="base.dir">
            <xsl:choose>
              <xsl:when test="$dbhtml.dir != ''">
                <xsl:value-of select="$dbhtml.dir"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$base.dir"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:with-param>
          <xsl:with-param name="base.name">
            <xsl:choose>
              <xsl:when test="                 $mediaobject/@*[local-name() = 'id']                 and not($use.id.as.filename = 0)">
                <!-- * if this mediaobject has an ID, then we use the -->
                <!-- * value of that ID as basename for the "longdesc" -->
                <!-- * file (that is, without prepending an "ld-" too it) -->
                <xsl:value-of select="$mediaobject/@*[local-name() = 'id']"/>
                <xsl:value-of select="$html.ext"/>
              </xsl:when>
              <xsl:otherwise>
                <!-- * otherwise, if this mediaobject does not have an -->
                <!-- * ID, then we generate an ID... -->
                <xsl:variable name="image-id">
                  <xsl:call-template name="object.id">
                    <xsl:with-param name="object" select="$mediaobject"/>
                  </xsl:call-template>
                </xsl:variable>
                <!-- * ...and then we take that generated ID, prepend an -->
                <!-- * "ld-" to it, and use that as the basename for the file -->
                <xsl:value-of select="concat('ld-',$image-id,$html.ext)"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:variable>

      <xsl:value-of select="$filename"/>
    </xsl:if>
  </xsl:if>
</xsl:template>

<xsl:template name="write.longdesc">
  <xsl:param name="mediaobject" select="."/>
  <xsl:if test="$html.longdesc != 0 and $mediaobject/d:textobject[not(d:phrase)]">
    <xsl:variable name="filename">
      <xsl:call-template name="longdesc.uri">
        <xsl:with-param name="mediaobject" select="$mediaobject"/>
      </xsl:call-template>
    </xsl:variable>

    <xsl:value-of select="$filename"/>

    <xsl:call-template name="write.chunk">
      <xsl:with-param name="filename" select="$filename"/>
      <xsl:with-param name="quiet" select="$chunk.quietly"/>
      <xsl:with-param name="content">
      <xsl:call-template name="user.preroot"/>
        <html>
          <head>
            <xsl:call-template name="system.head.content"/>
            <xsl:call-template name="head.content">
              <xsl:with-param name="title" select="'Long Description'"/>
            </xsl:call-template>
            <xsl:call-template name="user.head.content"/>
          </head>
          <body>
            <xsl:call-template name="body.attributes"/>
            <xsl:for-each select="$mediaobject/d:textobject[not(d:phrase)]">
              <xsl:apply-templates select="./*"/>
            </xsl:for-each>
          </body>
        </html>
        <xsl:value-of select="$chunk.append"/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

<xsl:template name="longdesc.link">
  <xsl:param name="longdesc.uri" select="''"/>

  <xsl:variable name="this.uri">
    <xsl:call-template name="make-relative-filename">
      <xsl:with-param name="base.dir" select="$base.dir"/>
      <xsl:with-param name="base.name">
        <xsl:call-template name="href.target.uri"/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="href.to">
    <xsl:call-template name="trim.common.uri.paths">
      <xsl:with-param name="uriA" select="$longdesc.uri"/>
      <xsl:with-param name="uriB" select="$this.uri"/>
      <xsl:with-param name="return" select="'A'"/>
    </xsl:call-template>
  </xsl:variable>

  <div class="longdesc-link" align="{$direction.align.end}">
    <br clear="all"/>
    <span class="longdesc-link">
      <xsl:text>[</xsl:text>
      <a href="{$href.to}" target="longdesc">D</a>
      <xsl:text>]</xsl:text>
    </span>
  </div>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template match="d:videoobject">
  <xsl:apply-templates select="d:videodata"/>
</xsl:template>

<xsl:template match="d:videodata">
  <xsl:call-template name="process.image">
    <xsl:with-param name="tag" select="'embed'"/>
    <xsl:with-param name="alt">
      <xsl:apply-templates select="(../../d:textobject/d:phrase)[1]"/>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template match="d:audioobject">
  <xsl:apply-templates select="d:audiodata"/>
</xsl:template>

<xsl:template match="d:audiodata">
  <xsl:call-template name="process.image">
    <xsl:with-param name="tag" select="'embed'"/>
    <xsl:with-param name="alt">
      <xsl:apply-templates select="(../../d:textobject/d:phrase)[1]"/>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template match="d:textobject">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="d:textdata">
  <xsl:variable name="filename">
    <xsl:choose>
      <xsl:when test="@entityref">
        <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="@fileref"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="encoding">
    <xsl:choose>
      <xsl:when test="@encoding">
        <xsl:value-of select="@encoding"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$textdata.default.encoding"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="$use.extensions != '0'                     and $textinsert.extension != '0'">
      <xsl:choose>
        <xsl:when test="element-available('stext:insertfile')">
          <stext:insertfile href="{$filename}" encoding="{$encoding}"/>
        </xsl:when>
        <xsl:when test="element-available('xtext:insertfile')">
          <xtext:insertfile href="{$filename}"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:message terminate="yes">
            <xsl:text>No insertfile extension available.</xsl:text>
          </xsl:message>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:message terminate="yes">
	<xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
	<xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text> 
      </xsl:message>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template match="d:caption">
  <div>
    <xsl:apply-templates select="." mode="common.html.attributes"/>
    <xsl:if test="@align = 'right' or @align = 'left' or @align='center'">
      <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
    </xsl:if>
    <xsl:apply-templates/>
  </div>
</xsl:template>

<!-- ==================================================================== -->
<!-- "Support" for SVG -->

<xsl:template xmlns:svg="http://www.w3.org/2000/svg"; match="svg:*">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>


<!-- The following works sometimes, but needs to take into account
             1. When there is no /*/@xml:base
             2. When the chunks are going somewhere else
<xsl:variable name="relpath">
  <xsl:call-template name="relative-uri">
    <xsl:with-param name="filename" select="@fileref"/>
  </xsl:call-template>
</xsl:variable>

<xsl:choose>
  <xsl:when test="/*/@xml:base
                  and starts-with($relpath,/*/@xml:base)">
    <xsl:value-of select="substring-after($relpath,/*/@xml:base)"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="@fileref"/>
  </xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@fileref"/>
      </xsl:when>
-->
<!-- Resolve xml:base attributes -->
<xsl:template match="@fileref">
  <!-- need a check for absolute urls -->
  <xsl:choose>
    <xsl:when test="contains(., ':')">
      <!-- it has a uri scheme so it is an absolute uri -->
      <xsl:value-of select="."/>
    </xsl:when>
    <xsl:when test="$keep.relative.image.uris != 0">
      <!-- leave it alone -->
      <xsl:value-of select="."/>
    </xsl:when>
    <xsl:otherwise>
      <!-- its a relative uri that needs xml:base processing -->
      <xsl:call-template name="relative-uri">
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>
_______________________________________________
OPEN-ILS-DOCUMENTATION mailing list
[email protected]
http://list.georgialibraries.org/mailman/listinfo/open-ils-documentation

Reply via email to