[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: embed Base64 content into xml element

Subject: Re: embed Base64 content into xml element
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Mon, 12 Apr 2010 00:55:48 +0200
Re:  embed Base64 content into xml element
Suresh,

from your posting I assume that you are trying to copy a file onto a
DataPower box using the XML Management interface.

In order to do so you have to use "dp:set-file" in the request and provide
the filename on the box in its attribute "name".
(you may want to have a look into this redpaper:
http://www.redbooks.ibm.com/abstracts/redp4446.html)
If your file is really already base64 encoded replace "base64" in below
script by "cat", otherwise "base64" will do the encoding.

Doing the task you want in XSLT is not possible since opening the file with
document() function will result in an error if it is not an XML file (as
your file containing base64 data).
I would use the shell script below for doing what you want.

$ cat set-file
#!/bin/bash
echo '<?xml version="1.0" encoding="UTF-8"?>'
echo '<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">'
echo '<soapenv:Body>'
echo '<dp:request xmlns:dp="http://www.datapower.com/schemas/management">'
echo '<dp:set-file name="'$1'">'
base64 $2
echo '</dp:set-file>'
echo '</dp:request>'
echo '</soapenv:Body>'
echo '</soapenv:Envelope>'
$ cat testfile
test
$ ./set-file local:///testfile testfile >set-file1.xml
$ cat set-file1.xml
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<dp:request xmlns:dp="http://www.datapower.com/schemas/management">
<dp:set-file name="local:///testfile">
dGVzdAo=
</dp:set-file>
</dp:request>
</soapenv:Body>
</soapenv:Envelope>
$ curl -k -s -u user:password --data-binary @set-file1.xml
https://dp1-l3.boeblingen.de.ibm.com:5550/service/mgmt/current ; echo
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><dp:response

xmlns:dp="http://www.datapower.com/schemas/management"><dp:timestamp>2010-04-12T00:38:03
+02:00</dp:timestamp><dp:result>OK</dp:result></dp:response></env:Body></env:Envelope>
$


You may want to have a look into the DataPower forum (for DP specific
questions):
http://www.ibm.com/developerworks/forums/forum.jspa?forumID=1198


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


                                                                           
             Suresh                                                        
             <suresh.chinta@gm                                             
             ail.com>                                                   To 
                                       xsl-list@xxxxxxxxxxxxxxxxxxxxxx     
             04/09/2010 08:50                                           cc 
             PM                                                            
                                                                   Subject 
                                        embed Base64 content into xml 
             Please respond to         element                             
             xsl-list@xxxxxxxx                                             
              lberrytech.com                                               
                                                                           
                                                                           
                                                                           
                                                                           




I have some content in base64 format in a text file. How can I embed
the base64 content into xml file.

For example :

base64 text file:
------------------------
RGVwbG95bWVudFx0ZW1wXE1vZGlmaW

Required output in XML File:
-----------------------------------------

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
            <env:Body>
                <dp:request
xmlns:dp="http://www.datapower.com/schemas/management">
                    <dp:file> CONTENT FROM BASE64 TEXT FILE </dp:file>
                </dp:request>
            </env:Body>
</env:Envelope>

How can I write XSLT?

Thanks.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.