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
- IBM Certified - eBusiness Solution Technologist
- IBM Certified Developer - XML
- Microsoft Certified Application Developer
- Tibco Certified Professional
- Sun Certified Java Professional
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?
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.