This chapter provides an overview of eXtensible Stylesheet Language Transformation (XSLT) and how it is used in Service Bus services to map XML input to XML output. It also describes how to create XSLT maps in Service Bus projects.
This chapter includes the following sections:
For more in-depth information about the XSLT mapper in JDeveloper, see "Creating Transformations with the XSLT Map Editor" in Developing SOA Applications with Oracle SOA Suite.
Transformation maps describe the mapping between two data types. eXtensible Stylesheet Language Transformation (XSLT) maps describe mappings between XML documents with different schemas. Using XSLT, Service Bus can process XML documents and transform document data from one XML schema to another, enabling data interchange among applications that use different schemas. You can perform complex data manipulation and transformation using XSLT. For example, you can map an incoming purchase order schema to an outgoing invoice schema.
JDeveloper provides both an Expression Builder, where you can script transformations using XQuery, and an XSLT Mapper, where you can create complex mappings. The Oracle Service Bus Console provides an editor for scripting transformations using XQuery. These editors provide options to define an XQuery expression, to specify an XSLT resource to execute, or to define an expression that evaluates at runtime to the name of an existing XSLT resource. For both JDeveloper and the console, you access the editors from an action in either a pipeline or split-join.
The XSLT mapper in JDeveloper is a graphical tool that lets you define mappings between schema root elements, WSDL message parts, or WSDL messages. Schema root elements can come from XSD schema files or WSDL files, but only those WSDL messages that contain a single message part can be mapped directly. Once you create an XSLT mapping in JDeveloper, you can upload the
.xsl file generated by the mapper to an XSLT resource in the Oracle Service Bus Console.
JDeveloper also includes a variety of Expression Builders, where you can create expressions that specify an existing XSLT resource to use. For more information about the mapper and editors in JDeveloper, see the following topics:
"Creating Transformation with the XSLT Map Editor" in Developing SOA Applications with Oracle SOA Suite
"Building XPath Expressions in the Expression Builder in Oracle JDeveloper" in Developing SOA Applications with Oracle SOA Suite
In the Oracle Service Bus Console, the XQuery/XSLT Expression Editor lets you create expressions that specify an existing XSLT resource to use. Before you can reference an XSLT resource, you need to create the resource in the console and upload an existing XSL transformation to the resource. This feature allows you to create complex mappings in JDeveloper that you can then import and use in the console. You can reuse an XSL transformation in multiple pipelines and split-joins.
For information about the XQuery/XSLT Editor in the Oracle Service Bus Console, see Working With Expression Editors in Oracle Service Bus Console.
You can create XSLT mappings in a Service Bus project in JDeveloper, and then use them in XQuery expressions in pipelines and split-joins to map objects between external systems.
When you create an XSLT mapping, you need to select the source XML schema elements or XML files to use for the source and target mappings.
To create an XSLT mapping in JDeveloper:
In the Application Navigator in JDeveloper, right-click the Service Bus project or folder in which you want to create the mapping.
In the menu that appears, point to New and select XSL Map.
The Create XSL Map File dialog appears.
In the File Name field, enter a unique name for the XSLT map file.
Optionally enter a new directory location and a brief description for the cross reference.
The location must be within the directory structure of the current application.
To define the source schema, do the following:
Select Use Source Schema.
Click Browse next to the Primary Source field.
On the Select Schema dialog, select whether to use an XML schema or to generate the source directly from an XML file.
Click Browse in the section you chose above to navigate to and select the XML schema element or file to use.
You can select an XML schema element from the current application. You can select an XML file from the file system.
When you have selected the schema element or file, click OK on the Select Schema dialog.
To select additional sources to use as parameters, click Add Schema above the Additional Sources table.
To define the target schema, select Use target schema, and repeat the above steps on the Select Schema dialog to select the XML components to use.
Click OK on the Create XSL Map File dialog.
The XSLT Mapper appears with the source and target structures displayed.
To define the mapping logic, see "Editing an XSLT Map in Map Mode" in Developing SOA Applications with Oracle SOA Suite.
In the Oracle Service Bus Console, XSLT maps are stored in XSLT resources, which can be reused in any pipelines and split-joins in the current session. You can upload existing XSLT maps into the XSLT resources, and use a text editor to edit them.
If you are using the Oracle Service Bus Console, you can add XSL transformations that you first create in JDeveloper and that you then import into a Service Bus project or upload into an XSL transformation resource. For information on importing, see Importing and Exporting Resources and Configurations . Use the procedure below to upload a mapping file into an XSL transformation resource.
Before you Begin
Create the XSL transformation mapping file as described in Creating XSLT Mappings in JDeveloper.
To create an XSLT resource in the console:
In the Project Navigator, right-click the project or folder to contain the new XSL transformation, point to Create, and select XSLT.
The Create Schema dialog appears.
Do one of the following:
To create the resource from an existing XSL mapping file, click Browse next to the File Upload field and then navigate to and select the file you created in JDeveloper.
The Resource Name field is automatically populated with the file name minus the file extension. You can change this name.
To create a new XSL transformation, enter a unique name for the transformation resource.
Optionally, enter a brief description of the resource.
The XSLT parameters, if defined, appear in the XSLT Definition Editor.
To modify the schema, do the following:
Click Edit Source in the toolbar.
The Edit Source dialog appears.
To browse to and select a new mapping file to upload, click Browse.
To modify the contents of the file, update the code directly in the Contents section of the dialog.
In the XSLT Definition Editor toolbar, click Save.
To end the session and deploy the configuration to the runtime, click Activate.
The Oracle Service Bus Console lets you edit an XSLT resource directly or update the contents by uploading a new or updated file.
To edit an XSL transformation in the console:
The Edit Source dialog appears.
If any resources reference the XSLT resource you want to delete, remove those references before deleting the resource. In the Oracle Service Bus Console, open the XSLT resource in the XSLT Definition Editor and click the References icon in the upper right to find out whether it has any references. In JDeveloper, right-click the XSLT resource and select Explore Dependencies.
You can delete the transformation even if it is referenced by other resources, though this might result in conflicts due to unresolved references to the deleted resource.
To delete an XSLT resource: