[xep-support] Re: RenderX to embed SVGs without a need for fo:instream-foreign-object?

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Thu Nov 29 2012 - 19:03:43 PST

At 2012-11-29 17:51 -0800, Michaud, Jean-Francois wrote:
>Is there a way to set RenderX to embed SVGs in the XEP output from
>an FO input that references the SVGs as an external graphics
>(fo:external-graphic) without having to embed the SVG ourselves in
>an fo:instream-foreign-object prior to RenderX processing the FO?

What would be the purpose of replacing the referenced SVG to be an
in-stream SVG? Do you have a requirement for late binding? If not,
I cannot think there would be a penalty for referencing the SVG
rather than embedding it.

A very straightforward XSLT would be able to do the replacement ...
something along the lines of what is below would be all you
need. I've limited myself to XSLT 1.0 in case you are so limited.

I hope this helps.

. . . . . . . . Ken

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

<!--only process those external graphics pointing to recognized extension-->
<xsl:template match="fo:external-graphic[contains(@src,'.svg')]">
     <xsl:when test="substring-before(name(.),':')">
       <xsl:element namespace="{namespace-uri(.)}"
         <xsl:call-template name="graphic-common"/>
       <xsl:element namespace="{namespace-uri(.)}"
         <xsl:call-template name="graphic-common"/>

<!--embed the content regardless of how the in-stream element is named-->
<xsl:template name="graphic-common">
   <xsl:copy-of select="@*[name(.)!='src']"/>
   <xsl:variable name="resource">
       <xsl:when test="contains(@src,'&#x22;')">
       <xsl:when test='contains(@src,"&#x27;")'>
       <xsl:when test='contains(@src,"(")'>
   <xsl:copy-of select="document($resource,.)/*"/>

<xsl:template match="@*|node()"><!--identity for all other nodes-->
     <xsl:apply-templates select="@*|node()"/>


Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/f/
G. Ken Holman                   mailto:gkholman@CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal
(*) To unsubscribe, please visit http://lists.renderx.com/mailman/options/xep-support
(*) By using the Service, you expressly agree to these Terms of Service http://w
Received on Thu Nov 29 18:52:08 2012

This archive was generated by hypermail 2.1.8 : Thu Nov 29 2012 - 18:52:13 PST