WebSphere DataPower SOA Appliances and XSLT Part 1
WebSphere DataPower SOA Appliances and XSLT Part 1
Agenda
DataPower tools
built-in
others
Appendix
2 of 23
3 of 23
4 of 23
5 of 23
Stylesheet tracing
Configure tracing of a stylesheet by
a compile option policy (for its XML Manager)
and a matching Debug Rule there.
6 of 23
Streaming model
Hybrid technique, the application starts processing in SAX model manner.
If needed the application program builds trees for that part of the data as the DOM.
After processing of this tree completes it is immediately removed.
Flexibility of the DOM model with some of the storage advantages of the SAX model.
Source: OptimizingThroughStreaming-v1.pdf
7 of 23
Streaming (2/4)
This stylesheet is streamable.
The commenting out was
necessary (double use of .).
Source: Find stylesheet and script for generating large input data in appendix
8 of 23
Source: Find stylesheet and script for generating large input data in appendix
9 of 23
10 of 23
XPath Tool
In WebGUI's left navbar
click on "Objects->XML
Processing->XPath
Routing Map"
Click on "Add" and select
the "Rules" tab
Click "Add" again, a popup
opens
Click "XPath Tool" in the
popup, "Xpath Tool" popup
opens.
Or use bookmark
Upload XML file
Click somewhere (eg. Log)
Inspect generated Xpath
and take it as a start
11 of 23
Agenda
DataPower tools
built-in
others
Appendix
12 of 23
$ xpath "count(//*[name()='xsl:for-each']//*[name()='xsl:for-each']//*[name()='xsl:foreach']//*[name()='xsl:for-each']//*[name()='xsl:for-each']//*[name()='xsl:for
each']//*[name()='xsl:for-each']//*[name()='xsl:for-each']//*[name()='xsl:foreach']//*[name()='xsl:for-each']//*[name()='xsl:for-each']//*[name()='xsl:for-each'])"
HugeXslFor-each.xsl
4
$
uncovering (structural) performance issues in stylesheets
xpath "/*/*/*[name()='dp:response']/*[name()='dp:status']/StylesheetStatus/Log[text()]"
returns all warnings/errors retrieved by get-status SOMA call for compiled stylesheets
Source: xpath tool posting on developerWorks DataPow er Forum
13 of 23
Scripting DataPower
DataPower Scripting is preferably done over the XML Management Interface
This is a really good RedPaper on this topic:
WebSphere DataPower SOA Appliance: The XML Management Interface
Rolf Wittich
http://www.redbooks.ibm.com/abstracts/redp4446.html
External CLI scripting can be done eg. with netcat command (nc, Linux/Cygwin)
have Telnet service enabled (on intranet interface)
store sequence of entries of a CLI session into eg. cli.txt
execute nc yourbox telnetport < cli.txt
Executing CLI commands from within a stylesheet is possible (posting link below)
While DataPower currently has no raw TCP support on the front side it HAS
support for raw TCP on the back side, the protocol "tcp:" ( Telnet service)
Source: Executing CLI commands f rom w ithin a stylesheet posting on developerWorks DataPow er Forum
14 of 23
DataPower provides lots of Extension functions/elements, you may want to have a look into
the Extension Functions Catalog ...
Source: Processing UTF-8 URL-encoded URIs w ith WebSphere DataPow er technote
15 of 23
sa
Strip
Strip
Attachments
Attachmen
ts
pl e
ap
pli
ca
tio
n
swaform tool
Non-XML request type policy
replaces "Content-Type" multipart/form-data by multipart/related
replaces 'Content-Disposition ... name="xyz" ...' by 'Content-Id: <xyz>'
prepends root section with "dummy" SOAP message
Source: sw aform -- using HTTP f orms as generator f or "Soap With Attachments" posting on developerWorks DataPow er Forum
16 of 23
Use an "Extract Using XPath" action to extract the stylesheet into a context "ctx".
The XPATH to use is
//*[attribute::*[local-name()='id']=substring-before(substring-after(/processing
instruction()[local-name()='xml-stylesheet'],'href="#'),'"')]
Be careful with the single and double quotes.
It extracts the stylesheet by the id referenced by href in xml-stylesheet processing
instruction into context "ctx".
Next use a xform action reading from INPUT with processing control file "ctx".
It is not possible to create this in WebGUI directly.
After having selected any xform action (eg. store://identity.xsl) you have to
edit the action in CLI and execute "transform ctx" to make the xform action take
the stylesheet from context "ctx"
or via WebGUI using Objects menu, select ObjectsXML ProcessingProcessing
Action, the Transform is a text field in this page and you input ctx there.
17 of 23
Agenda
DataPower tools
built-in
others
Appendix
18 of 23
dbsql.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/
Transform"
>
<xsl:template match="table">
<document>
<xsl:apply-templates select="row"/>
</document>
</xsl:template>
<xsl:template match="row">
<xsl:apply-templates select="id"/>
<xsl:apply-templates select="firstname"/>
<xsl:apply-templates select="lastname"/>
<xsl:apply-templates select="street"/>
<xsl:apply-templates select="city"/>
<xsl:apply-templates select="state"/>
<xsl:apply-templates select="zip"/>
<xsl:text>
</xsl:text>
</xsl:template>
"
"
"
"
"
<row>\n";
<id>%04d</id>\n", $i;
<firstname>$first</firstname>\n", $i;
<lastname>$last</lastname>\n", $i;
<street>%d Any St.</street>\n", ($i %
<xsl:template match="id|firstname|lastname|
street|city|state|zip">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>
"
"
"
"
<city>Anytown</city>\n";
<state>$state</state>\n";
<zip>%d</zip>\n", $zip;
</row>\n";
</xsl:stylesheet>
print "</table>\n";
dbsql1.pl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="table">
<document>
<xsl:apply-templates select="row"/>
</document>
</xsl:template>
<xsl:template match="row">
<xsl:choose>
<xsl:when test="contains('CA,NY,WY',state)">
<xsl:apply-templates select="id"/>
<xsl:apply-templates select="firstname"/>
<xsl:apply-templates select="lastname"/>
<xsl:apply-templates select="state"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="id"/>
<xsl:apply-templates select="firstname"/>
<xsl:apply-templates select="lastname"/>
<xsl:apply-templates select="street"/>
<xsl:apply-templates select="city"/>
<xsl:apply-templates select="state"/>
<xsl:apply-templates select="zip"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="id|firstname|lastname|street|
city|state|zip">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
19 of 23
Summary
Built-in DataPower tools (Stylesheet profiling and
tracing, XPath tool)
DataPower XML Data Processing (streaming,
partial streaming)
Other DataPower tools (xpath tool, scripting,
processing UTF-8 URL-encoded URIs, Enhancing
near SOAP With Attachment data, processing
embedded stylesheets)
20 of 23
Learn about upcoming WebSphere Support Technical Exchange webcasts, and access
previously recorded presentations at:
http://www.ibm.com/software/websphere/support/supp_tech.html
Access key product show-me demos and tutorials by visiting IBM Education Assistant:
http://www.ibm.com/software/info/education/assistant
View a webcast replay with step-by-step instructions for using the Service Request (SR)
tool for submitting problems electronically:
http://www.ibm.com/software/websphere/support/d2w.html
21 of 23
22 of 23
23 of 23