XSLT (Extensible Stylesheet Language Transformations)
XSLT transforms an XML document into another
XML document.
The XSLT Mapper enables you to create data
transformations between source schema elements and target schema elements in
either Oracle BPEL Process Manager or Oracle Mediator.
- Transformation Language
- XML as Input and Output
- Declarative Language
- XPath for Navigation
- Template-Based Transformation
- XSL Stylesheets
- Conditional Logic
- Iteration and Loops
- Built-in Functions
- Widely Used
While in design
view, the following pages from the Component Palette can be used:
·
General: Commonly used XPath functions and XSLT constructs.
·
Advanced: More advanced XPath functions such as database and cross-reference
functions.
·
User-Defined: User-defined functions and templates. This
page is visible only when the user has templates in their XSL or user-defined
external functions defined through the preferences pages.
Note:
The following functions
are available with Oracle Mediator and Oracle BPEL Process Manager,
in the XSLT Mapper.
- getProperty(propertyName as string)
- setCompositeInstanceTitle(titleElement)
- getComponentInstanceID()
- getComponentName()
- getCompositeInstanceID()
- getCompositeName()
- getECID()
How to Set Constant Values
<ProductName>ABC</ProductName>
1.
Select a node in the target tree.
2.
Invoke the context menu by right-clicking the
mouse.
3.
Select the Set Text
menu option.
A menu provides the following selections:
o <Empty>:
Enables you to create an empty node.
o Enter Text: Enables you to enter
text.
4.
Select Enter Text.
The Set Text dialog appears.
5.
In the Set Text dialog, enter text
6.
Click OK to save the
text.
A T icon is
displayed next to the node that has text associated with it. The beginning of
the text that is entered is shown next to the node name.
7.
To modify the text associated with the node,
right-click the node and select Edit Text to invoke
the Set Text dialog again.
8.
Edit the contents and click OK.
9.
To remove the text associated with the node,
right-click the node and select Remove Text.
How to Add Functions
The XSLT Mapper provides many prebuilt
extension functions and can support user-defined functions and named templates.
The extension functions are prefixed with oraext or orcl and mimic XPath 2.0
functions.
To add functions:
- From the
Component Palette, select a category of functions (for example, String
Functions).
- Right-click
an individual function (for example, lower-case).
- Select Help.
A dialog with a description of the function appears.
- Drag a function from the Component Palette to the center panel of the XSLT Mapper. You can then connect the source parameters from the source tree to the function and the output of the function to a node in the target tree.
XSLT Constructs – if,
for-each,choose
Right-click the element in the target tree where you want to insert an XSLT construct. A context menu is displayed
Select Add XSL Node and then the XSLT construct you want to insert.
xsl:if
xsl:if
statement
that tests for the existence of the source node. If
this is not done and the source node does not exist in the input document, an empty
node is created in the target document.Note:
If these fields are optional in the source and target, it is a good practice to insert an xsl:if statement around these mappings to test for the existence of the source node.
If this is not done, and the source node does not exist in the input document, an empty node is created in the target document. For example, if ProductName is optional in both the source and target, map them as follows:
<xsl:if
test="ProductName">
<ProductName>
<xsl:value-of
select="ProductName"/>
</ProductName>
</xsl:if>
xsl:choose
It contain
when & otherwise (like if else)
you
can copy PurchaseOrder/HQAccount/AccountNumber to Invoice/BilledToAccount/AccountNumber,
if it exists. Otherwise, copy PurchaseOrder/BranchAccount to Invoice/BilledToAccount/AccountNumber.
To use conditional processing with
xsl:choose:
- In the
target tree, select Invoice/BilledToAccount/AccountNumber and
right-click to invoke the context sensitive menu.
- Select Add
XSL Node > choose from the menu.
- Connect PurchaseOrder/HQAccount/AccountNumber
to Invoice/BilledToAccount/choose/when to define the condition.
- Connect PurchaseOrder/HQAccount/AccountNumber
to Invoice/BilledToAccount/choose/when/AccountNumber.
- In the
target tree, select XSL Add Node > choose and right-click
to invoke the context sensitive menu.
- Select Add
XSL node > otherwise from the menu.
- Connect PurchaseOrder/BranchAccount/AccountNumber to Invoice/BilledToAccount/choose/otherwise/AccountNumber.
xsl:for-each
<xsl:for-each select=””>
Selecting a
tag itself
<xsl:value-of select=””/>
Selecting the
actual content inside of tag.
How to Search Source and Target Nodes
To search source and target nodes:
1.
Right-click a source or target node and
select Find from the context menu.
2.
Enter a keyword for which to search.
3. Specify additional details, as necessary. For example:
a. Select Search Annotations if you want annotations
text to also be searched.
b. Specify the scope of the search. You can search the entire source or target
tree, search starting from a selected position, or search within a selected
sub-tree.
4. The first match found is highlighted, and the Find dialog closes. If no
matches are found, a message displays on-screen.
5. Select the F3 key to find the next match in the direction specified. To
search in the opposite direction, select the Shift and F3 keys.
Note: You cannot search on
functions or text values set with the Set Text option.
No comments:
Post a Comment