xsl-list
[Top] [All Lists]

Re: xsltproc multiple file output

2003-05-15 00:01:59
Am Donnerstag, 15. Mai 2003 05:49 schrieb David Pratt:
I have a file with several figures.  I want to output each as a
separate html file from a single xml file and single xsl file using
xsltproc.   I am wanting to title the name of each file with the
fileref minus the extension  ie. first_figure.jpg page is
first_figure.html.  Is this possible?

     <figure>
       <title>title of first figure</title>
       <mediaobject>
         <imageobject>
           <imagedata fileref="first_figure.jpg"
                      format="JPG" />
         </imageobject>
         <caption>
           <para>This would be the first figure</para>
         </caption>
       </mediaobject>
     </figure>

with xsltproc you can use xsl:document like this:
 
<xsl:template match="figure">
  <xsl:variable name="src" 
       select="mediaobject/imageobject/imagedata/@fileref"/>
  <xsl:variable name="href" value="substring-before($src, '.')"/>
  <xsl:document href="{$href}.html" method="html">
    <html><body><img src="{$src}"/></body></html>
  </xsl:document>
</xsl:template>

just written down. didnt test it. And of course it is not that easy. 
You have to take care about more dots (.) in filenames. More 
imagedata (you might use docbooks mediaselect template) and so on.

kind regards
janning

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list