| |||||
|
|
Spicing Up Your Web Services with XSLT By: Paul Zikopoulos
In the first thirteen parts of this series, I’ve introduced you to some of the many features available within the IBM Data Studio integrated development environment (IDE) that’s available for use with the IBM data servers. Specifically, I’ve shown you how to set up and use database connection objects, how to generate an overview diagram of your database architecture, how to build OLE DB functions that can be used to easily integrate data from external data sources that have an OLE DB provider, how to create an SQL statement using either the SQL Builder or the SQL Editor in IBM Data Studio, and how to take an SQL statement and quickly turn it into a stored procedure. I’ve also shown you how to wrap both an SQL statement and a stored procedure as a Web service. Most recently, I showed you how to test your Web service using the Web Services Explorer that’s integrated into IBM Data Studio or through a Web browser using the Web Services Explorer.
Here are some excerpts of the XSLT document that you will be using in this example: <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xalan="http://xml.apache.org/xslt"
xmlns:tns="http://www.w3.org/1999/xhtml">
<xsl:output method="html" version="1" encoding="UTF-8" omit-xml-declaration="yes" standalone="yes" indent="yes" />
As you can see, the excerpts of this XSLT document show you that XSLT documents are indeed written in XML. You can also see that this XSLT document will transform the XML into HTML, as indicated by the xsl:output element where the method attribute is set to "html". Perhaps you are transforming an XML document into an RSS feed for which you would define an output clause similar to this: <xsl:output method="xml" encoding="UTF-8" media-type="application/rss+xml"/> <xsl:template match="/"> <html><body> <h2>Employee Record</h2> <xsl:element name="form"> <xsl:attribute name="action">http://localhost:8080/DemoMyWebService/rest/Demo/updateEmp</xsl:attribute> <xsl:attribute name="method">POST</xsl:attribute> <table border="1"> <tr> <th rowspan="12"> <img> <xsl:attribute name="src">data:image/gif;base64,<xsl:value-of select="//row/PICTURE/text()"/></xsl:attribute> </img> </th> As you further inspect the sample XSLT document used in this article, you can see how the previous code shapes the input XML data from our Web service into an HTML output. The following code tells an XSLT processor how to take the <EMPNO> XML element and transform it into HTML. <td>EMPNO:</td>
<td>
<xsl:value-of select="//row/EMPNO/text()"/>
<xsl:element name="input">
<xsl:attribute name="value">
<xsl:value-of select="//row/EMPNO/text()"/></xsl:attribute>
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name">empno</xsl:attribute>
</xsl:element>
</td>
You can see how XML technologies are used with XSLT by noticing the XPath notation of the textual value of the <EMPNO>: //row/EMPNO/text(). Of course, all of the transformed data will be displayed in table format because all of the transformation logic resides within the following tags: <table border="1">...</table> It’s outside the scope of this article to delve into the depths of transformations with XML data; however, the W3 Schools Web site has some terrific resources on this (and many other) XML-related technologies. Check out http://www.w3schools.com/xsl/ for more information.
Other Related Articles Web Services Support in Oracle Enterprise Pack for Eclipse ASP.NET Session State Management Using SQL Server An Introduction to Stored Procedures in MySQL 5 Jumpstart for Oracle Service Bus Development Migrating Access Apps to SQL Server MySQL Tuning: Getting the most out of your database Arrays in SQL that Avoid Repeated Groups Taking an Oracle ADF Application from Design to Reality ... to read more DBA articles, visit http://dba.fyicenter.com/article/ |
| |||
|
Disclaimer: The FYIcenter DBA team maintains this website to provide you general DBA information. Our goal is to keep this information timely and accurate. If errors are brought to our attention, we will try to correct them. However FYIcenter.com accepts no responsibility or liability whatsoever with regard to the information on this site. | |||||