开发者

XSLT: Creating an Image from base64 content AND linking to it from an img tag in a jtextpane

Im useing this aproach to create an image while in an xsl transformer: XSLT: Convert base64 data into image files

My issue is that now i what to create an IMG tag that references the created image. Here is what I've done:

<!-- CREATE TEMP IMAGE -->
<xsl:variable name="b64" select="b64:new(string(./swe:Text/swe:value))"/>
<xsl:variable name="fos" select="fos:new(string('./temp.jpeg'))"/>
<xsl:value-of select="fos:write($fos, b64:getBinaryValue($b64))"/>
<xsl:value-of select="fos:close($fos)"/>
<a>
    <xsl:attribute name="href">
        <xsl:value-of select="concat('./temp', '.jpeg')"/>
    </xsl:attribute>
    <img>
        <xsl:attribute name="src">
            <xsl:value-of select="concat('./temp', '.jpeg')"/>
        </xsl:attribute>
        <xsl:attribute name="align">TOP</xsl:attribute>
        <xsl:attribute name="width">100</xsl:attribute>
        <xsl:attribute name="height">75</xsl:attribute>
    </img>
</a>

Im taking the output from above and displaying it in a JTextPane, but the image is always broken.

I imagine it's an issue with relative pathing, but i dont know how to get the absolute path from within the xsl.

EDIT: Ok, turns out that i cant reference images relative in the img tag because JTextPanes cant handle that. I was able to get this working using the following:

<xsl:variable name="b64" select="b64:new(string(./swe:Text/swe:value))"/>
<xsl:variable na开发者_Python百科me="fos" select="fos:new(string(concat('/temp/', @name, '.jpeg')))"/>
<xsl:value-of select="fos:write($fos, b64:getBinaryValue($b64))"/>
<xsl:value-of select="fos:close($fos)"/>
<img>
    <xsl:attribute name="src">
        <xsl:value-of select="concat('file:///C:/temp/', @name, '.jpeg')"/>
    </xsl:attribute>
    <xsl:attribute name="align">MIDDLE</xsl:attribute>
    <xsl:attribute name="width">200</xsl:attribute>
    <xsl:attribute name="height">150</xsl:attribute>
</img>

but i really need it to either be relative or

i need to get access to the system defined temp directory.

Anybody know how to this?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜