Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
10 replies Latest Post - ‏2013-07-11T10:46:58Z by HermannSW
Daviiid
Daviiid
282 Posts
ACCEPTED ANSWER

Pinned topic extract Value in post Form

‏2011-11-24T09:57:51Z |
Hello

Here are a form (testUpLoad.html)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
</head>
<body>
<form enctype="multipart/form-data" action="http://url:port/service/ServiceFichier/Upload" method="post">
<!-- MAX_FILE_SIZE doit précéder le champ input de type file -->
<input type="hidden" name="USER" value="A10250" />
<input type="hidden" name="PROVENANCE" value="FLOTTE" />
<!-- Le nom de l'élément input détermine le nom dans le tableau $_FILES -->
Envoyez ce fichier : <input name="FICHIER" type="file" value="toto"/>
<input type="submit" value="Envoyer le fichier" />
</form>
</body>
</html>

Here is the file to upload (file.csv, for exemple)

société;n°assuré/sociétaire;n°client externe;n°contrat;n°contrat externe;libellé du produit;raison sociale assuré;adr;CP;VILLe;POUET;USER;ADRESSE3

Here is the input context of datapower

0x000000 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d
0x000010 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 37 64 62 -------------7db
0x000020 31 66 66 31 38 31 36 30 39 66 36 0d 0a 43 6f 6e 1ff181609f6..Con
0x000030 74 65 6e 74 2d 44 69 73 70 6f 73 69 74 69 6f 6e tent-Disposition
0x000040 3a 20 66 6f 72 6d 2d 64 61 74 61 3b 20 6e 61 6d : form-data; nam
0x000050 65 3d 22 55 53 45 52 22 0d 0a 0d 0a 41 31 30 32 e="USER"....A102
0x000060 35 30 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 50..------------
0x000070 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d
0x00008 2d 37 64 62 31 66 66 31 38 31 36 30 39 66 36 0d -7db1ff181609f6.
0x00009 0a 43 6f 6e 74 65 6e 74 2d 44 69 73 70 6f 73 69 .Content-Disposi
0x0000a 74 69 6f 6e 3a 20 66 6f 72 6d 2d 64 61 74 61 3b tion: form-data;
0x0000b 20 6e 61 6d 65 3d 22 50 52 4f 56 45 4e 41 4e 43 name="PROVENANC
0x0000c 45 22 0d 0a 0d 0a 46 4c 4f 54 54 45 0d 0a 2d 2d E"....FLOTTE..--
0x0000d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d
0x0000e 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 37 64 62 31 66 -----------7db1f
0x0000f 66 31 38 31 36 30 39 66 36 0d 0a 43 6f 6e 74 65 f181609f6..Conte
0x00010 6e 74 2d 44 69 73 70 6f 73 69 74 69 6f 6e 3a 2 nt-Disposition:
0x00011 66 6f 72 6d 2d 64 61 74 61 3b 20 6e 61 6d 65 3d form-data; name=
0x00012 22 46 49 43 48 49 45 52 22 3b 20 66 69 6c 65 6e "FICHIER"; filen
0x00013 61 6d 65 3d 22 43 3a 5c 55 73 65 72 73 5c 61 31 ame="C:\Users\a1
0x00014 30 32 35 30 5c 44 65 73 6b 74 6f 70 5c 46 49 43 0250\Desktop\FIC
0x00015 48 49 45 52 20 43 53 56 2e 43 53 56 22 0d 0a 43 HIER CSV.CSV"..C
0x00016 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70 7 ontent-Type: app
0x00017 6c 69 63 61 74 69 6f 6e 2f 6f 63 74 65 74 2d 73 lication/octet-s
0x00018 74 72 65 61 6d 0d 0a 0d 0a 73 6f 63 69 e9 74 e9 tream....soci.t.
0x00019 3b 6e b0 61 73 73 75 72 e9 2f 73 6f 63 69 e9 74 ;n.assur./soci*.*t
0x0001a 61 69 72 65 3b 6e b0 63 6c 69 65 6e 74 20 65 78 aire;n.client ex
0x0001b 74 65 72 6e 65 3b 6e b0 63 6f 6e 74 72 61 74 3b terne;n.contrat;
0x0001c 6e b0 63 6f 6e 74 72 61 74 20 65 78 74 65 72 6e n.contrat extern
0x0001d 65 3b 6c 69 62 65 6c 6c e9 20 64 75 20 70 72 6f e;libell. du pro
0x0001e 64 75 69 74 3b 72 61 69 73 6f 6e 20 73 6f 63 69 duit;raison soci
0x0001f 61 6c 65 20 61 73 73 75 72 e9 3b 61 64 72 3b 43 ale assur.;adr;C
0x00020 50 3b 56 49 4c 4c 65 3b 50 4f 55 45 54 3b 55 53 P;VILLe;POUET;US
0x00021 45 52 3b 41 44 52 45 53 53 45 33 0d 0a 32 3b 31 ER;ADRESSE3
Here is the result file after this node "Convert Query Params to XML"

<request>
<url>/service/ServiceFichier/Upload</url>
<base-url>/service/ServiceFichier/Upload</base-url>
<args src="url"/>
<args src="body">
<arg name="USER">A10250</arg>
<arg name="PROVENANCE">FLOTTE</arg>
<arg name="FICHIER">société;n°assuré/sociétaire;n°client externe;n°contrat;n°contrat externe;libellé du produit;raison sociale assuré;adr;CP;VILLe;POUET;USER;ADRESSE3
</arg>
</args>
</request>
When this path //arg is cast as BLOB and insert into table DB2, the hexa character E9 (é) (input context) is transform in 8274(é) (in database)

Here is my insert database command.

<xsl:variable name="query">INSERT INTO FLOTTE_DOC (DOC) VALUES (?)</xsl:variable>

<dp:sql-execute source="'USA'" statement="$query">
<arguments>
<argument type="SQL_BLOB">
<xsl:value-of select="dp:radix-convert(dp:encode(//arg,'base-64'),64,16)"/>
</argument>
</arguments>
</dp:sql-execute>

Have you got any idea?

Other question : Why the param fileName does no apper in the xml file?
Updated on 2011-11-30T07:25:57Z at 2011-11-30T07:25:57Z by Daviiid
  • HermannSW
    HermannSW
    4488 Posts
    ACCEPTED ANSWER

    Re: extract Value in post Form

    ‏2011-11-24T20:04:09Z  in response to Daviiid
    You must know that DataPower internal encoding is UTF-8:
    http://www-01.ibm.com/support/docview.wss?uid=swg27022977&aid=3#page=11

    Therefore your é character (E9 in windows-1250 encoding) becomes C3A9 UTF-8 encoded, see below demonstration.
    So if you would log the output of "dp:radix-convert(dp:encode(//arg,'base-64'),64,16)"by <xsl:message> you should see ...C3A9...

    Currently I have no idea why you see 8274(é) (in database).

    File Daviiid.xml contains character é in windows-1250 encoded XML file:
    (dp5-l3 has "normal" coproc2 service, coproc2 service on dp3-l3 is with minimal output escaping)
    
    $ cat Daviiid.xml <?xml version=
    "1.0" encoding=
    "windows-1250"?> <char>�</char> $ $ od -Ax -tcx1 Daviiid.xml 000000   <   ?   x   m   l       v   e   r   s   i   o   n   =   
    "   1 3c  3f  78  6d  6c  20  76  65  72  73  69  6f  6e  3d  22  31 000010   .   0   
    "       e   n   c   o   d   i   n   g   =   "   w   i 2e  30  22  20  65  6e  63  6f  64  69  6e  67  3d  22  77  69 000020   n   d   o   w   s   -   1   2   5   0   
    "   ?   >  \n   <   c 6e  64  6f  77  73  2d  31  32  35  30  22  3f  3e  0a  3c  63 000030   h   a   r   > 351   <   / c   h   a   r   >  \n 68  61  72  3e  e9  3c  2f  63  68  61  72  3e  0a 00003d $ $ coproc2 identity.xsl Daviiid.xml http:
    //dp5-l3:2223; echo <?xml version=
    "1.0" encoding=
    "UTF-8"?> <char>&​#233;</char> $ $ coproc2 identity.xsl Daviiid.xml http:
    //dp3-l3:2223; echo <?xml version=
    "1.0" encoding=
    "UTF-8"?> <char>é</char> $ $ coproc2 identity.xsl Daviiid.xml http:
    //dp3-l3:2223 | od -Ax -tcx1 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current Dload  Upload   Total   Spent    Left  Speed 0    54    0    54    0    61    440    497 --:--:-- --:--:-- --:--:--     0 000000   <   ?   x   m   l       v   e   r   s   i   o   n   =   
    "   1 3c  3f  78  6d  6c  20  76  65  72  73  69  6f  6e  3d  22  31 000010   .   0   
    "       e   n   c   o   d   i   n   g   =   "   U   T 2e  30  22  20  65  6e  63  6f  64  69  6e  67  3d 22  55  54 000020   F   -   8   
    "   ?   >  \n   <   c   h   a   r   > 303 251   < 46  2d  38  22  3f  3e  0a  3c  63  68  61  72  3e  c3  a9  3c 000030   /   c   h   a   r   > 2f  63  68  61  72  3e 000036 $
    


     
    Hermann<myXsltBlog/>
    • Daviiid
      Daviiid
      282 Posts
      ACCEPTED ANSWER

      Re: extract Value in post Form

      ‏2011-11-25T08:53:20Z  in response to HermannSW
      Thanks Hermann.

      First, i was wrong and you were right. é character (E9) becomes C3A9 UTF-8 encoded and not 8274. Sorry

      So, is it possible to re convert UTF-8 to windows encoding?

      And my other question is why i didn't retrieve the namefile in datapower when this file is send with a form with post method?
      • HermannSW
        HermannSW
        4488 Posts
        ACCEPTED ANSWER

        Re: extract Value in post Form

        ‏2011-11-26T11:07:50Z  in response to Daviiid
        > Thanks Hermann.
        >
        > First, i was wrong and you were right. é character (E9) becomes C3A9 UTF-8 encoded and not 8274. Sorry
        >
        Thanks for confirming.

        > So, is it possible to re convert UTF-8 to windows encoding?
        >
        I just answered an equivalent question in another thread, find the answer there:
        https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14729767#14729767

        > And my other question is why i didn't retrieve the namefile in datapower when this file is send with a form with post method?
        >
        Do you mean the filename of the file you uploaded with the HTTP form?

        If yes, there is a simple answer:
        The broswer does not transmit the filename, it transmits the form field name "FICHIER" and the file content only.
        Please take a packet capture and do a "Follow TCP stream" to see what arrives on the wire.

        Last, but not least, if you ever need to upload binary files that will not work with convert-http action.
        See "swaform tool" from last years webcast for a solution:
        http://www-01.ibm.com/support/docview.wss?uid=swg27019118&aid=1#page=16

         
        Hermann<myXsltBlog/>
        • HermannSW
          HermannSW
          4488 Posts
          ACCEPTED ANSWER

          Re: extract Value in post Form

          ‏2011-11-29T08:31:38Z  in response to HermannSW
          Hi Daviiid,

          my previous comment on browser not sending the filename was wrong.
          I just did point your HTTP form (attached) to a passthru loopback XML FW and saved the output.

          The filename (not the path) is transmitted:
          -----------------------------78159923810906365881780933203
          Content-Disposition: form-data; name="USER"
           
          A10250
          -----------------------------78159923810906365881780933203
          Content-Disposition: form-data; name="PROVENANCE"
           
          FLOTTE
          -----------------------------78159923810906365881780933203
          Content-Disposition: form-data; name="FICHIER"; filename="Daviiid.xml"
          Content-Type: text/xml
           
          <?xml version="1.0" encoding="windows-1250"?>
          <char>�</char>
           
          -----------------------------78159923810906365881780933203--
          


           
          Hermann <myXsltBlog/>
          Updated on 2014-03-25T03:06:23Z at 2014-03-25T03:06:23Z by iron-man
          • HermannSW
            HermannSW
            4488 Posts
            ACCEPTED ANSWER

            Re: extract Value in post Form

            ‏2011-11-29T08:32:48Z  in response to HermannSW
            The promised HTTP form as attachment.
            • HermannSW
              HermannSW
              4488 Posts
              ACCEPTED ANSWER

              Re: extract Value in post Form

              ‏2011-11-29T08:34:03Z  in response to HermannSW
              For completeness the sample file I did upload with the form attached
              (the file I talked about in previous comments).
              • HermannSW
                HermannSW
                4488 Posts
                ACCEPTED ANSWER

                Re: extract Value in post Form

                ‏2011-11-29T08:46:18Z  in response to HermannSW
                OK, so what we have on DataPower side is that convert-http action
                • does not provide the (transmitted) filename information
                • does convert uploaded file to UTF-8 encoding
                • cannot process "binary" file uploads (use swaform tool for that).

                Please try stylesheet fileupload.xsl below.
                You provide
                • base64 encoded HTTP form data received at DataPower
                • the field name of the file upload field you are interested in.

                Point you HTTP form against a Non-XML XML loopback FW service with just a "Transform Binary" action referencing this stylesheet.

                If you select a file for upload and then submit you will see the base64 encoded file content you uploaded in your browser display
                ("as is", not converted in any form).
                
                $ echo 
                "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0id2luZG93cy0xMjUwIj8+CjxjaGFyPuk8L2NoYXI+Cg==" | base64 -id <?xml version=
                "1.0" encoding=
                "windows-1250"?> <char>�</char> $
                


                But if you will do "View Page Source" on the result you will see the magic -- your filename is extracted and available:
                
                <file name=
                "Daviiid.xml">PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0id2luZG93cy0xMjUwIj8+CjxjaGFyPuk8L2NoYXI+Cg==</file>
                


                Stylesheet fileupload.xsl:
                
                <!-- fileupload.xsl: ===============   Use as 
                "Transform Binary" action in Non-XML policy. Point HTTP form (with file upload field) POST to 
                
                this service.   Provide HTTP form file upload field name and get - uploaded file content base64 encoded (even binary file content) - filename of uploaded file   Result of func:fileName(_,_): <file name=
                "....">***base64 encoded file data***</file>   You can send the file content then by <dp:url-open target=
                "..." data-type=
                "base64" ...> --> <xsl:stylesheet version=
                "1.0" xmlns:xsl=
                "http://www.w3.org/1999/XSL/Transform" xmlns:func=
                "http://exslt.org/functions" xmlns:dp=
                "http://www.datapower.com/extensions" extension-element-prefixes=
                "dp" > <dp:input-mapping  href=
                "store:///pkcs7-convert-input.ffd" type=
                "ffd"/>   <xsl:output omit-xml-declaration=
                "yes" /> <!-- quot --> <xsl:variable name=
                "quot" select=
                "'22'" />   <!-- CRLF --> <xsl:variable name=
                "CRLF" select=
                "'0D0A'" />   <!-- two CRLFs --> <xsl:variable name=
                "CRLFCRLF" select=
                "'0D0A0D0A'" />   <!-- Content-Disposition: form-data; --> <xsl:variable name=
                "contDisp" select=
                "'436F6E74656E742D446973706F736974696F6E3A20666F726D2D646174613B'" />   <!-- name=
                " --> <xsl:variable name=
                "pname" select=
                "'6E616D653D22'" />   <!-- filename=
                " --> <xsl:variable name=
                "fname" select=
                "'66696C656E616D653D22'" />   <!-- two dashes --> <xsl:variable name=
                "ddash" select=
                "'2D2D'" />     <func:function name=
                "func:fileName"> <xsl:param name=
                "file"/> <xsl:param name=
                "field"/> <xsl:param name=
                "delimiter"/>   <xsl:choose>   <!-- end of file, not found, 
                
                return empty string --> <xsl:when test=
                "not($file)"/>     <!-- initially $delimiter is empty --> <xsl:when test=
                "not($delimiter)">   <!-- convert base64 input to hex --> <xsl:variable name=
                "inputHex" select=
                "dp:radix-convert($file,64,16)" />   <!-- convert clear text name to hex --> <xsl:variable name=
                "nameHex" select=
                "dp:radix-convert(dp:encode($field,'base-64'),64,16)"/>   <!-- MIME boundary in hex --> <xsl:variable name=
                "boundaryHex" select=
                "dp:radix-convert( dp:encode( substring-after( dp:http_request-header(
                'Content-Type'), 
                'boundary=' ), 
                'base-64' ), 64, 16 )
                " />   <!-- recursive call, start at first MIME section --> <func:result select=
                "func:fileName( substring-after($inputHex,concat($ddash,$boundaryHex)), $nameHex, concat($ddash,$boundaryHex) )
                " /> </xsl:when>     <!-- 
                "normal" case, search 
                
                for matching MIME section --> <xsl:otherwise>   <!-- determine MIME section header --> <xsl:variable name=
                "hdr" select=
                "substring-before($file,$CRLFCRLF)"/>   <xsl:variable name=
                "rest" select=
                "substring-after($hdr,$contDisp)"/>   <xsl:choose>   <!-- MIME section matches HTTP form field name? --> <xsl:when test=
                "contains( $rest, concat($pname,$field,$quot) )
                " > <!-- 
                
                return filename and base64 encoded file content --> <func:result> <file name=
                "{dp:decode( dp:radix-convert( substring-before( substring-after($rest,$fname), $quot ), 16, 64 ), 
                'base-64' )
                }
                " > <xsl:value-of select=
                "dp:radix-convert( substring-before( substring-after( $file, $CRLFCRLF ), concat($CRLF,$delimiter) ), 16, 64 )
                " /> </file> </func:result> </xsl:when>   <!-- recursive call at next MIME section --> <xsl:otherwise> <func:result select=
                "func:fileName( substring-after($file,$delimiter), $field, $delimiter )
                " /> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </func:function>     <xsl:template match=
                "/"> <!-- call initially without $delimiter; file base64 encoded (not hex); HTTP form field name in clear --> <xsl:copy-of select=
                "func:fileName( dp:binary-encode(/object/message/node()), 
                'FICHIER' )
                " /> </xsl:template> </xsl:stylesheet>
                


                 
                Hermann<myXsltBlog/>
                • HermannSW
                  HermannSW
                  4488 Posts
                  ACCEPTED ANSWER

                  Re: extract Value in post Form

                  ‏2011-11-29T09:30:25Z  in response to HermannSW
                  I forgot to mention the most important point:
                  • you can use stylesheet fileupload.xsl in a first "Transform Binary" action from INPUT to NULL
                  • and send the file content via <dp:url-open target="..." data-type="base64" ...> unmodified

                  • you can have after that action a convert-http action reading from INPUT in addition
                  • for processing the other HTTP form fields.

                   
                  Hermann<myXsltBlog/>
                  • Daviiid
                    Daviiid
                    282 Posts
                    ACCEPTED ANSWER

                    Re: extract Value in post Form

                    ‏2011-11-30T07:25:57Z  in response to HermannSW
                    Hi Hermann.

                    You are the best. :)

                    I adapt your script for my needs and it works well :)

                    thanks
                • HermannSW
                  HermannSW
                  4488 Posts
                  ACCEPTED ANSWER

                  Re: extract Value in post Form

                  ‏2013-07-11T10:46:58Z  in response to HermannSW

                  above posting got broken by forum software migration, trying to recover by reply (edit is impossible).

                   

                  OK, so what we have on DataPower side is that convert-http action

                  • does not provide the (transmitted) filename information
                  • does convert uploaded file to UTF-8 encoding
                  • cannot process "binary" file uploads (use swaform tool for that).


                  Please try stylesheet fileupload.xsl below.
                  You provide

                   

                  • base64 encoded HTTP form data received at DataPower
                  • the field name of the file upload field you are interested in.


                  Point you HTTP form against a Non-XML XML loopback FW service with just a "Transform Binary" action referencing this stylesheet.

                  If you select a file for upload and then submit you will see the base64 encoded file content you uploaded in your browser display
                  ("as is", not converted in any form).

                  $ echo "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0id2luZG93cy0xMjUwIj8+CjxjaGFyPuk8L2NoYXI+Cg==" | base64 -id
                  <?xml version="1.0" encoding="windows-1250"?>
                  <char>�</char>
                  $


                  But if you will do "View Page Source" on the result you will see the magic -- your filename is extracted and available:

                  
                  
                  <file name=
                  "Daviiid.xml">PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0id2luZG93cy0xMjUwIj8+CjxjaGFyPuk8L2NoYXI+Cg==</file>
                  



                  Stylesheet fileupload.xsl:

                  <!--
                       fileupload.xsl:
                       ===============

                       Use as "Transform Binary" action in Non-XML policy.
                       Point HTTP form (with file upload field) POST to this service.

                       Provide HTTP form file upload field name and get
                       - uploaded file content base64 encoded (even binary file content)
                       - filename of uploaded file

                       Result of func:fileName(_,_):
                       <file name="....">***base64 encoded file data***</file>

                       You can send the file content then by
                       <dp:url-open target="..." data-type="base64" ...>
                  -->
                  <xsl:stylesheet version="1.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:func="http://exslt.org/functions"
                    xmlns:dp="http://www.datapower.com/extensions"
                    extension-element-prefixes="dp"
                  >
                    <dp:input-mapping  href="store:///pkcs7-convert-input.ffd" type="ffd"/>

                    <xsl:output omit-xml-declaration="yes" />
                     
                    <!-- quot -->
                    <xsl:variable name="quot" select="'22'" />

                    <!-- CRLF -->
                    <xsl:variable name="CRLF" select="'0D0A'" />

                    <!-- two CRLFs -->
                    <xsl:variable name="CRLFCRLF" select="'0D0A0D0A'" />

                    <!-- Content-Disposition: form-data; -->
                    <xsl:variable name="contDisp"
                      select="'436F6E74656E742D446973706F736974696F6E3A20666F726D2D646174613B'"
                    />

                    <!-- name=" -->
                    <xsl:variable name="pname" select="'6E616D653D22'" />

                    <!-- filename=" -->
                    <xsl:variable name="fname" select="'66696C656E616D653D22'" />

                    <!-- two dashes -->
                    <xsl:variable name="ddash" select="'2D2D'" />


                    <func:function name="func:fileName">
                      <xsl:param name="file"/>
                      <xsl:param name="field"/>
                      <xsl:param name="delimiter"/>

                      <xsl:choose>

                        <!-- end of file, not found, return empty string -->
                        <xsl:when test="not($file)"/>


                        <!-- initially $delimiter is empty -->
                        <xsl:when test="not($delimiter)">

                          <!-- convert base64 input to hex -->
                          <xsl:variable name="inputHex"
                             select="dp:radix-convert($file,64,16)" />

                          <!-- convert clear text name to hex -->
                          <xsl:variable name="nameHex"
                            select="dp:radix-convert(dp:encode($field,'base-64'),64,16)"/>

                          <!-- MIME boundary in hex -->
                          <xsl:variable name="boundaryHex"
                            select="dp:radix-convert(
                                      dp:encode(
                                        substring-after(
                                          dp:http_request-header('Content-Type'),
                                          'boundary='
                                        ),
                                        'base-64'
                                      ),
                                      64,
                                      16
                                    )"
                          />

                         <!-- recursive call, start at first MIME section -->
                         <func:result
                           select="func:fileName(
                                     substring-after($inputHex,concat($ddash,$boundaryHex)),
                                     $nameHex,
                                     concat($ddash,$boundaryHex)
                                   )"
                          />
                        </xsl:when>


                        <!-- "normal" case, search for matching MIME section -->
                        <xsl:otherwise>

                          <!-- determine MIME section header -->
                          <xsl:variable name="hdr" select="substring-before($file,$CRLFCRLF)"/>

                          <xsl:variable name="rest" select="substring-after($hdr,$contDisp)"/>

                          <xsl:choose>

                            <!-- MIME section matches HTTP form field name? -->
                            <xsl:when test="contains(
                                              $rest,
                                              concat($pname,$field,$quot)
                                            )"
                            >
                              <!-- return filename and base64 encoded file content -->
                              <func:result>
                                <file
                                  name="{dp:decode(
                                           dp:radix-convert(
                                             substring-before(
                                               substring-after($rest,$fname),
                                               $quot
                                             ),
                                             16,
                                             64
                                           ),
                                           'base-64'
                                         )}"
                                >
                                  <xsl:value-of
                                    select="dp:radix-convert(
                                              substring-before(
                                                substring-after(
                                                  $file,
                                                  $CRLFCRLF
                                                ),
                                                concat($CRLF,$delimiter)
                                              ),
                                              16,
                                              64
                                            )"
                                  />
                                </file>
                              </func:result>    
                            </xsl:when>

                            <!-- recursive call at next MIME section -->
                            <xsl:otherwise>
                              <func:result
                                select="func:fileName(
                                          substring-after($file,$delimiter),
                                          $field,
                                          $delimiter
                                        )"
                              />
                            </xsl:otherwise>
                          </xsl:choose>
                        </xsl:otherwise>
                      </xsl:choose>
                    </func:function>


                    <xsl:template match="/">
                      <!--
                           call initially without $delimiter;
                           file base64 encoded (not hex);
                           HTTP form field name in clear
                      -->
                      <xsl:copy-of
                        select="func:fileName(
                                  dp:binary-encode(/object/message/node()),
                                  'FICHIER'
                                )"
                      />
                    </xsl:template>
                   
                  </xsl:stylesheet>

                   

                  Hermann<myXsltBlog/>

                   

                  Attachments

                  Updated on 2013-07-11T10:53:10Z at 2013-07-11T10:53:10Z by HermannSW