xsl-list
[Top] [All Lists]

Re: [xsl] embed Base64 content into xml element

2010-04-11 22:13:20
Thank you Hermann for an answer in the exact context.

Because I was planning to run this transformation out of the DataPower
box, just wondering if there is some function available in XSLT 2.0
which can do this.

Now that it is known, I will look for a scripted approach.

Best Regards,
Suresh

On Sun, Apr 11, 2010 at 6:55 PM, Hermann Stamm-Wilbrandt
<STAMMW(_at_)de(_dot_)ibm(_dot_)com> wrote:
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(_dot_)chinta(_at_)gm
            ail.com>                                                   To
                                      
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
            04/09/2010 08:50                                           cc
            PM
                                                                  Subject
                                      [xsl] embed Base64 content into xml
            Please respond to         element
            xsl-list(_at_)lists(_dot_)mu
             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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





-- 
Suresh

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>