Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert JPEGs into XML

 
Rajan Thiyagarajan
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to insert a JPEG file into an XML document. The situation is that, I don't have a stylesheet(XSL or CSS).
I could insert a JPEG or GIF with the help of XSL, like
This is the XML part.
<image>
<image-clear1 src="C:\india.gif" width="155" height="40"/>
</image>
This is the XSL part.
<xsl:template match="image">
<img>
<xsl:attribute name="src"><xsl:value-of select="image-clear1/@src"/></xsl:attribute>
<xsl:attribute name="width"><xsl:value-of select="image-clear1/@width"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="image-clear1/@height"/></xsl:attribute>
</img>
</xsl:template>
Any suggestions.
Rajan
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajan, could you elaborate on what you mean by "inserting JPEG into XML"? Do you mean that you need to add an <img ...> element into an existing org.w3c.dom.Document, you need to insert the raw image file inside an XML element, something else?
 
Rajan Thiyagarajan
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah ! I meant to insert an image file(.jpeg,.gif etc) into an existing XML document.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the add-to-xml-document part is easy. No different from adding a text node. Another question is, how to encode the binary image file in order to preserve the XML document's well-formedness? One simple option could be to Base64 encode the raw data. The Jakarta Commons project has an implementation you could use for that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic