Topic
  • 11 replies
  • Latest Post - ‏2014-04-20T09:31:30Z by HermannSW
HermannSW
HermannSW
4645 Posts

Pinned topic webDataPower

‏2011-04-08T17:05:15Z |
This topic was on my toPost list.

Because of some threads of Dinesh on how to use stylesheets stored in a DataPower context
for transformation I added a sample to webDataPower and post it here now.

In last year's WSTE Webcast I showed a slide on "Processing embedded stylesheets":
http://www-01.ibm.com/support/docview.wss?uid=swg27019118&aid=1#page=17
There I used a transform action taking the stylesheet for the transform from a context for the first time.

A month ago I made use of that technique again for my coproc2 posting:
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/coproc210
There a stylesheet and a XML file are sent to DataPower and DataPower executes the stylesheet
on the XML file and returned the result.
There were two clients, a bash shell script (coproc2) and a Java client (coproc2.java).

Now webDataPower is similar to coproc2, it allows to pass a stylesheet and XML data
to DataPower for execution and return of the result.
But this time all happens in a Web browser's HTTP form (no extra client).

The only installation necessary is to import the attached backup of application domain webDataPower
onto one of your DataPower boxes -- that's it (for verification I imported it successfully on boxes with
firmware 3.7.3.8, 3.8.0.11, 3.8.1.10, 3.8.2.2 and 4.0.1.0).
Finally open URL "http://yourbox:2401/demo" in your Web browser and start working.
 
Hermann<myXsltBlog/>
Updated on 2011-10-10T17:18:23Z at 2011-10-10T17:18:23Z by HermannSW
  • HermannSW
    HermannSW
    4645 Posts

    Re: webDataPower

    ‏2011-04-08T17:06:49Z  
    Without installation you can see the start screen of webDataPower in attached HTML file.
  • HermannSW
    HermannSW
    4645 Posts

    Re: webDataPower

    ‏2011-04-08T17:09:40Z  
    • HermannSW
    • ‏2011-04-08T17:06:49Z
    Without installation you can see the start screen of webDataPower in attached HTML file.
    The HTML file attached here shos the result of the execution on DataPower.
    As you can see the XSL and XML sections are generated again.
    This way you can modify XSL or XML, execute, modify again, execute again ...
  • HermannSW
    HermannSW
    4645 Posts

    Re: webDataPower

    ‏2011-04-08T17:12:51Z  
    • HermannSW
    • ‏2011-04-08T17:09:40Z
    The HTML file attached here shos the result of the execution on DataPower.
    As you can see the XSL and XML sections are generated again.
    This way you can modify XSL or XML, execute, modify again, execute again ...
    The HTML file attached here shows what happens if the XSL textarea has a problem.
    In case of a transformation error webDataPower error rule returns dp:parse()ed XSL and XML output.
    The empty textarea shows you where the problem is.
    And the Output table allows you to inspect what DataPower received from the browser.
  • HermannSW
    HermannSW
    4645 Posts

    Re: webDataPower

    ‏2011-04-08T17:25:52Z  
    • HermannSW
    • ‏2011-04-08T17:12:51Z
    The HTML file attached here shows what happens if the XSL textarea has a problem.
    In case of a transformation error webDataPower error rule returns dp:parse()ed XSL and XML output.
    The empty textarea shows you where the problem is.
    And the Output table allows you to inspect what DataPower received from the browser.
    Stylesheet webDataPowerPre.xsl gets invoked on the output of convert-http action.
    It selects the contexts of the XSL and XML HTTP form fields and stores them into DataPower contexts "XSL" and "XML".
    The documented use of a context variable for dp:set-variable is a little bit different (see Appendix. Working with variables).
    There context variables of the form "var://context/ctxname/varname" are described.
    Storing into "var://context/ctxname" stores into the context itself (and in this case always the complete document of a node gets stored).
    
    <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" xmlns:dp=
    "http://www.datapower.com/extensions" extension-element-prefixes=
    "dp" > <xsl:template match=
    "/"> <dp:set-variable name=
    "'var://context/XSL'" value=
    "dp:parse(/request/args[@src='body']/arg[@name='XSL'])" /> <dp:set-variable name=
    "'var://context/XML'" value=
    "dp:parse(/request/args[@src='body']/arg[@name='XML'])" /> </xsl:template> </xsl:stylesheet>
    


    Hermann<myXsltBlog/>
  • HermannSW
    HermannSW
    4645 Posts

    Re: webDataPower

    ‏2011-04-08T17:33:44Z  
    • HermannSW
    • ‏2011-04-08T17:25:52Z
    Stylesheet webDataPowerPre.xsl gets invoked on the output of convert-http action.
    It selects the contexts of the XSL and XML HTTP form fields and stores them into DataPower contexts "XSL" and "XML".
    The documented use of a context variable for dp:set-variable is a little bit different (see Appendix. Working with variables).
    There context variables of the form "var://context/ctxname/varname" are described.
    Storing into "var://context/ctxname" stores into the context itself (and in this case always the complete document of a node gets stored).
    <pre class="jive-pre"> <xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" xmlns:dp= "http://www.datapower.com/extensions" extension-element-prefixes= "dp" > <xsl:template match= "/"> <dp:set-variable name= "'var://context/XSL'" value= "dp:parse(/request/args[@src='body']/arg[@name='XSL'])" /> <dp:set-variable name= "'var://context/XML'" value= "dp:parse(/request/args[@src='body']/arg[@name='XML'])" /> </xsl:template> </xsl:stylesheet> </pre>

    Hermann<myXsltBlog/>
    Stylesheet webDataPowerPost.xsl is a little bit tricky.
    It gets invoked for the (demo) GET rule, the HTTP form post rule as well as the error rule.
    It does Non-XML data processing by the dp:input-mapping "String.ffd".
    String.ffd (see below) just wraps Non-XML data (sample) into XML
    (<Conversion><string>sample</string></Conversion>) for further processing.

    <?xml version="1.0" encoding="UTF-8" ?>
    <File version="2.1" name="Conversion">
        <Field name="string" type="String" />
    </File>
    


    Hermann <myXsltBlog/>
    Updated on 2014-03-25T03:32:30Z at 2014-03-25T03:32:30Z by iron-man
  • dpdeveloper
    dpdeveloper
    111 Posts

    Re: webDataPower

    ‏2011-08-18T20:56:50Z  
    • HermannSW
    • ‏2011-04-08T17:33:44Z
    Stylesheet webDataPowerPost.xsl is a little bit tricky.
    It gets invoked for the (demo) GET rule, the HTTP form post rule as well as the error rule.
    It does Non-XML data processing by the dp:input-mapping "String.ffd".
    String.ffd (see below) just wraps Non-XML data (sample) into XML
    (<Conversion><string>sample</string></Conversion>) for further processing.

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><?xml version="1.0" encoding="UTF-8" ?> <File version="2.1" name="Conversion"> <Field name="string" type="String" /> </File> </pre>

    Hermann <myXsltBlog/>
    Thanks for the providing this config.... This really helps in developing fastly....

    I also tried using Eclipse plugin, but this is more helpful because we can even use the dp extension functions here..
  • dp_developer
    dp_developer
    31 Posts

    Re: webDataPower

    ‏2011-10-09T13:10:08Z  
    • HermannSW
    • ‏2011-04-08T17:33:44Z
    Stylesheet webDataPowerPost.xsl is a little bit tricky.
    It gets invoked for the (demo) GET rule, the HTTP form post rule as well as the error rule.
    It does Non-XML data processing by the dp:input-mapping "String.ffd".
    String.ffd (see below) just wraps Non-XML data (sample) into XML
    (<Conversion><string>sample</string></Conversion>) for further processing.

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><?xml version="1.0" encoding="UTF-8" ?> <File version="2.1" name="Conversion"> <Field name="string" type="String" /> </File> </pre>

    Hermann <myXsltBlog/>
    Hi Hermann,

    For some reason i do not have the privileges to import the WebDataPower conifguration into my DP box . So i was trying to manually create the integration myself. I have successfully created your Xpath++ and the CoProc integrations without importing anything into my DP box . Would like to do the same with some help from yours.

    Request rule (Sequence of Actions)
    1) Match
    2) Advanced action(Convert HTTP)
    3) Transform Action with the webDataPowerPre.xsl
    4) Transform Action with input context XML . And having "XSL" as the actual transformation.
    5) Advanced Action(Transform Binary) webDataPowerPost.xsl
    6) Results Action

    I followed the above sequence and the happy path scenario seems to work .

    Now i wanted to know how the error-rule should be ? Also will webDatapower point out the error in the XSL passed (say Line number and Error like the way the Oxygen Editor does? ) or display the service/error-code and error-message variables.

    Also i wanted to know how the "reset to demo XML/XSL" button in the HTML page works. Have you created a new rule for this?.

    Thanks in Advance .
  • HermannSW
    HermannSW
    4645 Posts

    Re: webDataPower

    ‏2011-10-10T17:18:23Z  
    Hi Hermann,

    For some reason i do not have the privileges to import the WebDataPower conifguration into my DP box . So i was trying to manually create the integration myself. I have successfully created your Xpath++ and the CoProc integrations without importing anything into my DP box . Would like to do the same with some help from yours.

    Request rule (Sequence of Actions)
    1) Match
    2) Advanced action(Convert HTTP)
    3) Transform Action with the webDataPowerPre.xsl
    4) Transform Action with input context XML . And having "XSL" as the actual transformation.
    5) Advanced Action(Transform Binary) webDataPowerPost.xsl
    6) Results Action

    I followed the above sequence and the happy path scenario seems to work .

    Now i wanted to know how the error-rule should be ? Also will webDatapower point out the error in the XSL passed (say Line number and Error like the way the Oxygen Editor does? ) or display the service/error-code and error-message variables.

    Also i wanted to know how the "reset to demo XML/XSL" button in the HTML page works. Have you created a new rule for this?.

    Thanks in Advance .
    Hi Rahul,
    >
    > For some reason i do not have the privileges to import the WebDataPower conifguration into my DP box .
    > So i was trying to manually create the integration myself. I have successfully created your Xpath++ and the CoProc
    > integrations without importing anything into my DP box . Would like to do the same with some help from yours.
    >
    > Request rule (Sequence of Actions)
    > 1) Match
    > 2) Advanced action(Convert HTTP)
    > 3) Transform Action with the webDataPowerPre.xsl
    > 4) Transform Action with input context XML . And having "XSL" as the actual transformation.
    > 5) Advanced Action(Transform Binary) webDataPowerPost.xsl
    > 6) Results Action
    >
    > I followed the above sequence and the happy path scenario seems to work .
    >
    good.

    > Now i wanted to know how the error-rule should be ?
    See attached screenshots collection -- I did 10 "Aquire->Screen Shot"s with Gimp ... ;-)

    > Also will webDatapower point out the error in the XSL passed (say Line number and Error like the way the Oxygen Editor does? )
    sorry, not possible in webDataPower ...

    > or display the service/error-code and error-message variables.
    >
    That would be possible, but is not currently.

    > Also i wanted to know how the "reset to demo XML/XSL" button in the HTML page works. Have you created a new rule for this?.
    >
    Yes, see "/demo" rule (the first 3 screenshots in attached screenshot collection).

     
    Just some days ago I thought on a nice extension for webDataPower.
    Currently webDataPower is implemented browser neutral -- runs on all (big5) browsers (Chrome, FF, IE, Opera, Safari).

    I found interesting Mozilla FileReader API which allows upload of local files(!) for Webkit based browsers (= big5 - IE).
    Here you can find documentation and a sample application:
    https://developer.mozilla.org/en/DOM/FileReader#section_12

    Instead of "oFReader.readAsDataURL(oFile);" for loading images "readAsText()"
    https://developer.mozilla.org/en/DOM/FileReader#readAsText%28%29
    would be nice to have -- one file upload for XSL and one for XML text areas of webDataPower ...

    If you want to try it out (with images), I stored the sample cited above here:
    http://stamm-wilbrandt.de/en/mozilla-demo/FileReader.html

     
    Hermann<myXsltBlog/>
  • HermannSW
    HermannSW
    4645 Posts

    webDataPower-xformbin edition

    ‏2013-10-02T15:18:22Z  

    Just revisited webDataPower, changed "XML" to "DATA" and replaced  XML-xform(XSL)-PIPE
    by  DATA-xformbin(XSL)-PIPE -- only few changes were needed.


    The initial display, or when clicked on "Reset":

     

    Clicking on "Execute" results in this (as the stylesheet says, just the base64 encoded DATA string:

     

    And this is display after entering "test" in DATA and pressing "Execute" again:

     

    Just import attached MPGW export and try yourself ...


    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

    Attachments

  • FrankX.Ning
    FrankX.Ning
    39 Posts

    Re: webDataPower-xformbin edition

    ‏2014-04-19T07:20:08Z  
    • HermannSW
    • ‏2013-10-02T15:18:22Z

    Just revisited webDataPower, changed "XML" to "DATA" and replaced  XML-xform(XSL)-PIPE
    by  DATA-xformbin(XSL)-PIPE -- only few changes were needed.


    The initial display, or when clicked on "Reset":

     

    Clicking on "Execute" results in this (as the stylesheet says, just the base64 encoded DATA string:

     

    And this is display after entering "test" in DATA and pressing "Execute" again:

     

    Just import attached MPGW export and try yourself ...


    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

    This is great, Hermann!

     

    Just curious, I changed "yes" to "no" for

                 <xsl:output omit-xml-declaration="no"/>

    However, the Output still does not have the XML declaration.

    Regards

    Frank

  • HermannSW
    HermannSW
    4645 Posts

    Re: webDataPower-xformbin edition

    ‏2014-04-20T09:31:30Z  

    This is great, Hermann!

     

    Just curious, I changed "yes" to "no" for

                 <xsl:output omit-xml-declaration="no"/>

    However, the Output still does not have the XML declaration.

    Regards

    Frank

    Hi,

    reason is that output is just text and not XML.

    If output real XML like this

    <x><xsl:copy-of select="dp:binary-encode(/object/message/node())"/></x>
    


    you will see the difference between "yes" and "no".


    Hermann<myBlog/> <myTweets/> | <GraphvizFiddle/> | <xqib/> | <myCE/> <myFrameless/>