Configuring this project takes approximately 5 minutes.
Before you begin
Before you can work with the sample, you must first import
it into your workspace:
- Click the following link: Import sample
- In the Import Project dialog box, accept the defaults and click Finish.
The following projects are imported into your workspace:
- BookCatalogWebService
- BookCatalogWebServiceEAR
About this task
Using the imported sample code, you see how you can use
XSL style sheet to transform XML code in the following ways:
- You can use the XSL style sheet to transform an XML file into
a new XML file that contains contents that are defined by the XSL
file.
- Using a Web Service, you can transform XML input content into
XML content that is defined by the XSL file that is called by the
Web Service.
To use an XSL style sheet to transform an XML file
into a new XML file:- In the Enterprise Explorer view, open .
- Open the Catalog.xml file and inspect its
contents. The file contains Book (<tns: Book>) and Magazine (<tns:
Magazine>) elements. There is no order to the elements in the file.
- Press the Ctrl key and click the following
files:
Both files are selected.
- Right-click either selected file and click .
The Console view opens and shows the names of the transformation input
files and the result file.
- The result file _Catalog_transform.xml is located in the WebContent
folder. Open the result file and inspect the contents. You should
see that it contains only Book elements that are ordered first by
country and then by publishing date.
What to do next
You can also run a similar transformation using a Web
service.
To use a Web Service that calls an XSL transformation
to transform input XML content:- Ensure that you have a WebSphere Application Server V8.5.5.5 server
defined:
By default a server is created for you when you install
WebSphere Application Server. This server can be seen in the Servers
view. However, if you want to create a new server, complete the following
steps:
- Click .
- Select WebSphere V8.5.5 Server as the server type, and click Next.
- If you do not have a runtime environment attached to your workspace,
you are prompted to enter the installation directory of WebSphere
Application Server.
- On the server settings page, click Finish.
- To see the server you have created in the workspace, click .
- Add the EAR project to the server:
- In the Servers view, right-click the WebSphere Application Server
V8.5.5 server and click Add and Remove Projects.
- In the list of available projects, click BookCatalogWebServiceEAR,
click Add > and then click Finish.
- Check the HTTP port used by WebSphere Application Server V8.5.5
server:
- In the Servers view, right-click the WebSphere Application Server
V8.5.5 server and click Properties.
- In the left-hand side of the properties window that opens, click WebSphere
Application Server.
- Check the value of HTTP port. If the value
is not 9080, make a note of it; you will use this value in
a later step.
- In the Servers view, right-click the WebSphere Application Server
V8.5.5 server and click Start
- In the Enterprise Explorer view, navigate to the WebContent\WEB-INF\wsdl\Catalog.wsdl
file.
- If the HTTP port for WebSphere Application Server V8.5.5 that
you checked in step 3 is not 9080, then you must modify the WSDL file:
- Right-click Catalog.wsdl and then click .
- Find the following text near the end of the file:
<soap:address
location="http://localhost:9080/BookCatalogWebService/BookCatalogService" />
- Change the value of localhost to the HTTP port
that you noted in Step 3. For example, if the HTTP port is 9082, then
change the text to:
<soap:address
location="http://localhost:9082/BookCatalogWebService/BookCatalogService" />
- Save your changes.
- In the Enterprise Explorer view, right-click Catalog.wsdl and
then click . The Web Services
Explorer opens.
- In the Actions window of the Web Services Explorer, under Operations,
click generateReport.
- In the top-right corner of the Actions window, click Source.
- In the input window under <soapenv:Body>, delete the current
content.
- Copy of the following content into the input window under <soapenv:Body>
(this content is the same as the source of the Catalog.xml file, except
the first line in Catalog.xml has been deleted):
<tns:Catalog xmlns:tns="http://www.eclipse.org/webtools/Catalog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.eclipse.org/webtools/Catalog Catalog.xsd">
<tns:Book>
<Title>Professional XML Schema</Title>
<PublishDate>2001-01-01</PublishDate>
<ISBN>1-861005-47-4</ISBN>
<Publisher>Wrox Press</Publisher>
<Country>USA</Country>
</tns:Book>
<tns:Magazine>
<Title>WebSphere Developer's Journal</Title>
<PublishDate>2001-02-01</PublishDate>
</tns:Magazine>
<tns:Book>
<Title>Java and XSLT</Title>
<PublishDate>2001-03-01</PublishDate>
<ISBN>0-596-00143-6</ISBN>
<Publisher>O'Reilly</Publisher>
<Country>Canada</Country>
</tns:Book>
<tns:Book>
<Title>XSLT 2.0</Title>
<PublishDate>2006-04-05</PublishDate>
<ISBN>0-596-125407</ISBN>
<Publisher>Hello World</Publisher>
<Country>Canada</Country>
</tns:Book>
<tns:Book>
<Title>Rational handbook</Title>
<PublishDate>2005-06-07</PublishDate>
<ISBN>2-345005-47-4</ISBN>
<Publisher>IBM</Publisher>
<Country>USA</Country>
</tns:Book>
<tns:Book>
<Title>XPath and XML 2.0</Title>
<PublishDate>2006-02-03</PublishDate>
<ISBN>2-536-897767</ISBN>
<Publisher>IBM</Publisher>
<Country>Canada</Country>
</tns:Book>
</tns:Catalog>
- Click Go.
- Inspect the Status window of the Web Services Explorer. You should
see that it contains only Book elements that are ordered first by
country and then by publishing date.
- When you are finished, you can stop the server.