In response to: Sum of Pascal's triangle reciprocalsApproved additions to these Online Encyclopedia of Integer Sequences (OEIS):
HermannSW 2700006U54 Marcações:  dp:xquery-transform 1.0 datapower xquery gatewayscript firmware 2.0 18.104.22.168 xpath xslt 8.283 Visualizações
DataPower has a XSLT 1.0 processor since day 1 long ago (1999), and that provides XPath 1.0.
With 22.214.171.124 firmware DataPower shipped XQuery 1.0 processor as well, and that provides XPath 2.0.
With 126.96.36.199 firmware released last Friday we got much new exciting stuff (I blogged on GatewayScript before).
This expression just compares false() with an empty nodeset and that is true for XPath 1.0 and false for XPath 2.0.
This XPath expresion is stored here (in order to be accessible by my and your DataPower boxes):
Now below stylesheet isXPath1.xsl does evaluate above XPath expression in a singe concat statement:
As promised this shows that XPath 1.0 and XPath 2.0 happen within a single concat statement!
Here is stylesheet isXPath1.xsl:
In developerWorks DataPower forum thread Date Conversion from Gregorain to Hijri Asif asked on how to convert Date to Hijri. Wikipedia told me that Hijri is the islamic calendar. External links section showed Calendar Converter link (http://www.fourmilab.ch/documents/calendar/) and that site is pretty cool. It converts date entered in one format to many others (Gregorian, Julian day, Julian, Hebrew, Islamic, Persian, Mayan, Bahá'í, Indian Civil, French Republican, ISO-8601, Unix time(), Excel Serial Day Number).
First lets see both in action, against XSLT and GatewayScript coproc2 endpoints:
The 2nd shows a small difference of GatewayScript to previous JSON processing on DataPower. GatewayScript implements RFC7159 which allows any JSON element at top level, while previous RFC4627 required top level element to be either JSON array or JSON object:
OK, here is stylesheet gregorian_to_islamic.xsl more or less straight translated to XSLT (the needed parts only).
Since the complete work is done in the modules, gregorian_to_islamic.js is minimal:
HermannSW 2700006U54 Marcações:  stylesheet status probe debug variable xslt datapower service 9.614 Visualizações
I am responsible for DataPower Probe since I joined DataPower (Compiler) team 7 years ago. Just looked at the 18 Probe related APARs from the last 4 years and saw that I did fix half of them.
DataPower stylesheets are able to access all status providers via "dp:variable('var://service/system/status/___')":
2) on "disable" Probe, flush service's XML Manager's Stylesheet cache
3) In order to not get fooled by another service's Probe enabled with same XML Manager, use a XML Manager specific to each service
HermannSW 2700006U54 Marcações:  swa xslt datapower attachment mimswa rest soap mimetype.java swacurl json 10.204 Visualizações
Customer raised question on developerWorks DataPower forum on how to convert client SOAP With Attachmnt (SWA) request on DataPower to REST. Yesterday's posting specifically raised the question on how to convert SWA to JSON-WSP attachment service request format.
Find the stylesheet doing the transformation, and how (simple) the attachments itself can be processed in my response:
The response attachment .zip contains sample service export, sample files and quite some useful tools for dealing with SWA files and DataPower. Besides the swa2json-wsp.xsl stylesheet these tools are useful for dealing with SWA files:
With these tools sending some attachments to DataPower SWA service is just two commands (see posting above for sample executions):
HermannSW 2700006U54 Marcações:  unicode browser xqib bmp xquery poster xslt 1 Comentário 8.496 Visualizações
End of 2012 I did blog posting BMP.xsl.html (Basic Multilingual Plane) in which I described stylesheet BMP.xsl that created nice 16x16 table with each cell containing a 16x16 table containing a single unicode character, that spans the complete Basic Multilangual Plane (BMP, Unicodes 0-65535).
In this xml-dev posting John Cowan pointed to two BMP videos and an A0 .pdf poster.
I replied to that posting and criticized that the A0 poster does not show any BMP structure.
I wanted to have BMP.xq.html A0 poster, but the biggest paper format our printers do provide is A3.
Since today his A0 = 8 x A3 BMP poster covers the outside wall of my Boeblingen lab office ;-)
HermannSW 2700006U54 Marcações:  xquery xpath2 xslt function arity datapower 5.992 Visualizações
Recently I got a stylesheet with really HUGE number of arguments in a concat() function.
My first approach of determining the arity was not nice and needed handwork, but did give the result I needed.
Later I learned from our XQuery team that XPath 2 has a much simpler solution for that:
Just replace concat(...) by count( (...) ) making the argument list an XPath 2 sequence and applying the count() function.
With v6.0 firmware DataPower has an XQuery 1.0 compiler, so you can evaluate with DataPower.
The result is "12", which you can see live evaluated on try.zorba.io (I do like the "Share" button):
HermannSW 2700006U54 Marcações:  xslt json xml datapower jsonx transform 2 Comentários 21.477 Visualizações
In developerWorks DataPower forum thread Need Help With XML to Json Transformation the question was raised on how to transform XML to JSON.
I did propose a transformation from XML to JSONX and then making use of "store:///jsonx2json.xsl" transformation to get the JSON output:
Pros of that approach:
I created "all-in-one" stylesheet for doing the XML-->JSON transformation rdp87.3.xsl:
Now I created two XML FW on a box with 188.8.131.52 firmware containing the (performance) fix for APAR IC90781 from May 2013 fixpack.
Finally I did:
Yes, the total time taken for rdp87.2.xsl (1961ms) in the templates is by a factor of 2.66 greater than that of rdp87.3.xsl (735ms).
But that does only make an effect if the whole operation of a service is just XML->JSON conversion.
If this is the case, then the (small) runtime overhead added is outweighted by maintainability and ease of stylesheet in my eyes.
This is the really small diff:
HermannSW 2700006U54 Marcações:  debug xslt datapower probe 1 Comentário 10.974 Visualizações
When using DataPower Probe sometimes a context is displayed as empty. although you know it is not.
Reason is that in DataPower Probe
All screenshots below are done for Firefox web broser, with Chrome browser it is similar.
OK, so lets take this very simple Transform stylesheet value.xsl:
So for input document "<a>1<b>2</b>3</a>" it returns just "123", see sample "curl" request and response returned:
With Probe enabled for the service we get this INPUT context ...
And the context information now is available in 0.xml.gz, 1.xml.gz, (2.xml.gz, ... if there are more contexts):
For the sample we have this:
As you can see the "real content" (123) is framed by serialized <wrap> element.
HermannSW 2700006U54 Marcações:  hash datapower attachment non-xml xslt gzip 8.069 Visualizações
I got notice of a customer requirement to do the following with Non-XML input:
While this sounded not difficult at first, gzip(Non-XML) turned out to be not that easy to do with DataPower.
dp:deflate() cannot be used because it cannot deal with Non-XML data.
The solution was to use the Output-Filter of a rule -- that allows to compress the output data by "PKZIP" or "gzip".
So the solution presented here requires a chained service, and I am not aware of a solution to gzip Non-XML data without a chained service.
You can find a 184.108.40.206 service export here:
It provides two service endpoints, "/gz-hash" doing what is described above, and "/gz" just doing gzip(Non-XML).
Here is a short demonstration of the services:
There is a "front" XML-FW listening on port 6001, gziping the Non-XML input and dispatching
to /gz XML-FW on port 6002 or /gz-hash XML-FW on port 6003.
In order to gzip(Non-XML) both rules have to set "gzip" as Output-Filter and Non-XML Processing to "on" (via Objects screen).
The gz-hash service on port 6003 has a Non-XML Transform Action with output context "xwa" generating the hash.
Next is a Results action that attaches Non-XML input to "xwa" context. Because the Non-XML input is the gziped
input from "front" service this does the right thing.
Last a Results action returns the "xwa" context to OUTPUT (inclusive the attachment, as MIME, see above).
Here is a combination of 4 screenshots of the whole gz-hash policy.
And this is stylesheet "hash.xsl" that hashes the Non-XML input data using dp:hash-base64() DataPower extension function:
I got confirmation that the hash computed by DataPower matches the hash computed for same file by Java backend application.
HermannSW 2700006U54 Marcações:  datapower wsrr nonxml query xslt graph coproc2 7.791 Visualizações
DataPower provides quite some integration with WSRR (WebSphere Service Registry and Repository).
You can query WSRR without DataPower, of course.
A WSRR GraphQuery returns a big amount of data when queried to do so.
I was asked on how to extract all the WSDLs and XSDs returned by a WSRR GraphQuery and "zip" them with DataPower.
The files returned by WSRR are stored in @name and @content attributes of <sdo_1:artefacts> elements.
Because arbitrary files can be stored in WSRR, the file contents returned are base64 encoded.
Here you can see stylesheet zipGraphQuery.xsl in action, with coproc2 service against Non-XML endpoint:
I obfuscated the result since I got the sample response and do not have access to WSRR server to do my own Query right now.
Stylesheet zipGraphQuery.xsl is based on the techniques mentioned in 2nd WSTE webcast on Non-XML data processing.
The tricky part is how to create an "empty" .zip archive in DataPower.
In fact, creating a really empty .zip archive does not work.
I use one that contains an empty directory named "dummy" as simple workaround.
You may want to use $emptyZip yourself in your stylesheets.
And while we are here, we can create (nearly) empty .zip archives and add files to them as demonstrated below.
We can also query the list of contents of a .zip archive as demonstrated in unzip-l.xsl posting.
What is not possible with the rich DataPower attachment protocol is deletion of files from a .zip attachment.
If you do really need that functionality, you can create a new empty .zip and copy over all files but the to be deleted ones.
This is nice, Literal Result Element as Stylesheet (see spec) in the big5 browsers by Valery Chernys's href="#" trick!
OK, this is the all-in-one stylesheet you can open directly in your browser, you may click here: http://www.stamm-wilbrandt.de/en/blog/hello.xsl.xml
The concat() is there just to demonstrate that transformation really happens.
I use Valery's href="#" trick quite often, from n-queens.xsl.xml posting:
HermannSW 2700006U54 Marcações:  stylesheet xslt extension function profiling datapower 7.494 Visualizações
I do need a little helper function which converts a "byte" value represented by two hexadecimal digits into a number from 0-255.
Since this function will get called very often, choosing "the right" solution here is key.
This posting describes how DataPower stylesheet profoiling helped to identify the best alternative.
First I did come up with different solutions for solving the given task.
Next I just did put them into a stylesheet that exercises each function once.
Then I made the XML manager of coproc2 service to do stylesheet profiling by selecting a Profiling Rule in its Compile Options policy.
After flushing that XML manager ("profile", resets the counters) and sending 10000 requests I looked up "Status->XML Processing->Stylesheet Profiles".
Exercising the 10000 request was done this way:
Find the screenshots for inputs "00" , "99", "AA" and "FF" here (click to open big view):
This is just the table showing the measured times (on a 9004 XI50, reported in milli seconds , but with sub nano second precision):
The increased values for *func:hexdig2num* are due to the fact that digit comparisons are done sequentially.
The last column gives just the values for doubled number of calls.
The worst case wrt time is input 'FF' which enforces quite some <xsl:when>s tests.
And the winner is "hex2num3 with hexdig2num3":
(4+24)/10000 = 2.8 [microsecond/call]
Here is the testing stylesheet:
HermannSW 2700006U54 Marcações:  exslt xslt saxon rosettacode saxon-6.5.5 datapower 6.862 Visualizações
On the weekend I stumbled over http://rosettacode.org website.
It presents solutions to the same task (currently 638) in as many different programming languages as possible,
These are the "XSLT" related language categories (out of 487 !):
I read somewhere that matrix multiplication is not a problem normally needed to be be computed in a stylesheet.
While this may be true, it was one of the 638 current tasks without a XSLT solution:
So I did give it a try, and posted my pure XSLT 1.0 solution there:
You can try the solution in your browser, just open this XML input file and you get the matrix product displayed:
(do "View Page Source" to see both input matrices)
The solution can be reduced in number of lines of XSLT by using EXSLT functions.
But XSLT 1.0 processors xalan and xsltproc do have problems with <func:function ...>.
Besides DataPower XSLT processor (compiler) there is another XSLT 1.0 processor being able to process XSLT 1.0 + EXSLT.
It is a very old version of SAXON (version 6.5.5, download here), before SAXON became a XSLT 2.0 processor.
While saxon-6.5.5 does not know about DataPower extension functions, it might be useful to process stylesheets without.
With this input file
saxon-6.5.5 and DataPower both produce the matrix product:
This is stylesheet matmul.xsl being referenced by the input <?xml-stylesheet ...?> declaration allowing SAXON "-a" parameter:
HermannSW 2700006U54 Marcações:  xslt soma interface management datapower xml 10 Comentários 24.363 Visualizações
There is the nice IBM Redpaper "The XML Management Interface" by Rolf Wittich:
It describes the basics, how to access the DataPower XML Management interface and provides quite some samples.
In addition there is a section on troubleshooting.
In developerWorks DataPower Forum there are often discussions on how to achieve a certain goal.
And sample requests are either requested or provided as part of the answers.
The complete interface is specified in these appliance files:
Today I want to describe a method for easily creating ALL sample requests against XML management interface
by using SoapUI tool (there are free and Pro editions, the free edition is sufficient here).
First SoapUI does need access to "store:///xml-mgmt.wsdl" and the other files.
In order to not having to download the files I just created a HTTP service on a 220.127.116.11 XI52 box
* listening on port 88
* with Base Directory "store:///"
Now accessing "http://firestar.boeblingen.de.ibm.com:88/xml-mgmt.wsdl" is possible.
Next create a new SoapUI project
* provide a name
* reference "xml-mgmt.wsdl" as Initial WSDL
* keep option "Create Requests" selected
* press "OK"
This creates new project with "Request 1" under "operation":
By right-clicking into the request you can save the generated file.
Last, but not least, the generated sample file from our Böblingen lab XI52 box: