<!-- Stylesheet to convert word processing docs to DocBook -->
<!-- This stylesheet processes the output of sections2blocks.xsl -->
- <xsl:output indent="yes" method="xml"
+ <xsl:output indent="yes" method="xml"
cdata-section-elements='dbk:programlisting dbk:literallayout'/>
<!-- ================================================== -->
@rnd:style = "literallayout"'>
<xsl:variable name='stop.node'
- select='following-sibling::*[@rnd:style != current()/@rnd:style][1]'/>
+ select='following-sibling::dbk:para[@rnd:style != current()/@rnd:style][1]'/>
<xsl:element name='{@rnd:style}'
namespace='http://docbook.org/ns/docbook'>
<xsl:choose>
<xsl:when test='$stop.node'>
- <xsl:apply-templates select='following-sibling::*[following-sibling::*[generate-id() = generate-id($stop.node)]]'
+ <xsl:apply-templates select='following-sibling::dbk:para[following-sibling::*[generate-id() = generate-id($stop.node)]]'
mode='rnd:programlisting'/>
</xsl:when>
<xsl:otherwise>
- <xsl:apply-templates select='following-sibling::*'
+ <xsl:apply-templates select='following-sibling::dbk:para'
mode='rnd:programlisting'/>
</xsl:otherwise>
</xsl:choose>
</dbk:info>
<dbk:mediaobject>
<dbk:imageobject>
- <dbk:imagedata fileref='{.}'/>
+ <dbk:imagedata>
+ <xsl:attribute name='fileref'>
+ <xsl:choose>
+ <xsl:when test='dbk:inlinemediaobject/dbk:imageobject/dbk:imagedata/@fileref != ""'>
+ <xsl:value-of select='dbk:inlinemediaobject/dbk:imageobject/dbk:imagedata/@fileref'/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select='.'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </dbk:imagedata>
</dbk:imageobject>
</dbk:mediaobject>
<xsl:call-template name='rnd:figure-text-caption'>
<xsl:call-template name='rnd:attributes'/>
<dbk:mediaobject>
<dbk:imageobject>
- <dbk:imagedata fileref='{.}'/>
+ <dbk:imagedata>
+ <xsl:attribute name='fileref'>
+ <xsl:choose>
+ <xsl:when test='dbk:inlinemediaobject/dbk:imageobject/dbk:imagedata/@fileref != ""'>
+ <xsl:value-of select='dbk:inlinemediaobject/dbk:imageobject/dbk:imagedata/@fileref'/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select='.'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </dbk:imagedata>
</dbk:imageobject>
</dbk:mediaobject>
<xsl:call-template name='rnd:figure-text-caption'>
<xsl:when test='@rnd:style = "author"'>
<dbk:author>
- <dbk:personname>
- <!-- TODO: check style of author; mixed content or structured -->
- <xsl:apply-templates mode='rnd:personname'/>
- </dbk:personname>
+ <xsl:choose>
+ <xsl:when test='dbk:emphasis[@rnd:style = "orgname"]'>
+ <dbk:orgname>
+ <xsl:apply-templates
+ select='dbk:emphasis[@rnd:style = "orgname"]'
+ mode='rnd:orgname'/>
+ </dbk:orgname>
+ <xsl:if test='*[not(@rnd:style = "orgname")]'>
+ <xsl:call-template name='rnd:error'>
+ <xsl:with-param name='code'>bad-author-orgname-combo</xsl:with-param>
+ <xsl:with-param name='message'>character span "<xsl:value-of select='dbk:emphasis[@rnd:style != "orgname"][1]/@rnd:style'/>" not allowed in an author paragraph combined with orgname</xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <dbk:personname>
+ <!-- TODO: check style of author; mixed content or structured -->
+ <xsl:apply-templates mode='rnd:personname'/>
+ </dbk:personname>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:apply-templates mode='rnd:author-personblurb'/>
<xsl:apply-templates select='following-sibling::*[1]'
mode='rnd:author'/>
<xsl:when test='w:rPr/w:rStyle/@w:val = "attributes"'/>
<xsl:when test='w:rPr/w:rStyle/@w:val = "CommentReference"'/>
<xsl:when test='w:pict'>
+ <!-- "filename" is where the image data gets extracted to -->
<xsl:variable name='filename'>
<xsl:call-template name='rnd:image-filename'/>
</xsl:variable>
+ <!-- "target" is the URL that will be the target of the imagedata hyperlink.
+ This may or may not be related to the physical filename.
+ -->
+ <xsl:variable name='target'>
+ <xsl:call-template name='rnd:image-target'>
+ <xsl:with-param name='filename' select='$filename'/>
+ </xsl:call-template>
+ </xsl:variable>
<xsl:call-template name='rnd:handle-image-data'>
<xsl:with-param name='filename' select='$filename'/>
<dbk:inlinemediaobject>
<dbk:imageobject>
- <dbk:imagedata fileref='{$filename}'>
+ <dbk:imagedata fileref='{$target}'>
<xsl:if test='w:pict/v:shape/@style'>
<xsl:attribute name='width'>
<xsl:value-of select='normalize-space(substring-before(substring-after(w:pict/v:shape/@style, "width:"), ";"))'/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
+
<!-- An application may wish to override these templates -->
+
+ <!-- rnd:image-filename determines the filename of the physical file
+ to which the image data should be written.
+ -->
<xsl:template name='rnd:image-filename'>
<xsl:param name='pict' select='w:pict'/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
+
+ <!-- rnd:image-target determines the URL for the image data.
+ This may or may not be related to the physical filename.
+ -->
+ <xsl:template name='rnd:image-target'>
+ <xsl:param name='filename'/>
+ <xsl:param name='pict' select='w:pict'/>
+
+ <xsl:value-of select='$filename'/>
+ </xsl:template>
+
+ <!-- rnd:handle-image-data receives the base64-encoded data and a filename
+ for the physical file to which the data should be written.
+ Since XSLT cannot natively handle binary data, this implementation
+ just writes the undecoded data to the nominated file.
+ A real application would decode the data into a binary representation.
+ -->
<xsl:template name='rnd:handle-image-data'>
<xsl:param name='filename'/>
<xsl:param name='data'/>