Re: [xsl] How do I display an SVG file using XSLT?

Subject: Re: [xsl] How do I display an SVG file using XSLT?
From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Nov 2002 12:15:49 -0700
  Forgetting for the moment the SVG issues, you're basically asking:
How do I convert the element

<image NAME="images/svg_test.svg" WIDTH="219" HEIGHT="174" />

into


<object data="images/svg_test.svg" width="219" height="174"
type="image/svg+xml"></object>

?


Looking at your template...

               <xsl:attribute name="type">
                  <xsl:value-of select="image/svg+xml" />
               </xsl:attribute>

Here's your immediate problem. The value-of above implies that there exists in the xml the following structure:
<image NAME="..." WIDTH="..." HEIGHT="...">
<image>
<svg+xml>...</svg+xml>
</image>
</image>


What you mean to say is <xsl:text>image/svg+xml</xsl:text> since that is the literal string that you wish to appear as the 'type' value.

Your whole template above can be written as
<xsl:template match="image">
<object type="image/svg+xml">
<xsl:attribute name="data"><xsl:value-of select="@NAME"/></xsl:attribute>
<xsl:attribute name="width"><xsl:value-of select="@WIDTH"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="@HEIGHT"/></xsl:attribute>
</object>
</xsl:template>


As for what fills the resultant object in your browser after this conversion, that is up to your browser configuration / object installation / registry settings.


Greg Faron Integre Technical Publishing Co.



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


Current Thread