• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Insert JPEGs into XML

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah ! I meant to insert an image file(.jpeg,.gif etc) into an existing XML document.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic