The following sections describe the XSLT statements you can add to your mapping. You can add or edit these statements by clicking the Edit Statement () button or these statements can be added automatically by selecting them from the dialogs that appear when you drag and drop elements from the Scope Variables tree to the function argument tree.
The following sections discuss statement types (available in the Statement Type drop-down list in the Edit Statement dialog).Allows you to specify an attribute, and optionally the namespace for the attribute. You can also specify the type of value for the attribute.When attributes are created, you can optionally specify the kind of value the attribute will have and whether the attribute should be surrounded by an if statement. For example, you can specify the value of the last name attribute to be a constant, like so:Provides a way to select transformation to perform based on an expression. Specify the condition in the when element as an XPath expression. You can optionally specify an otherwise condition for processing all elements that do not meet any of the specified when conditions.The following determines if the node set for FilesTransferred contains any files, and if so, performs an action. If the node set is empty (no files were transferred), a different action is performed.Copies the selected node to the current node in the input tree. Only the node is copied, no children of the node are copied.<ns0:copy xmlns:ns0="http://www.w3.org/1999/XSL/Transform" select="$Query/resultSet"/>Copies the selected node’s contents. This is useful if you wish to copy an element to a new element with a different name.Creates a copy of the selected node, including the node’s children. Both the copied node and the destination node must have the same name and structure.Performs the specified statements once for each item in the selected node. This is useful if you wish to process each item of a repeating element once.The following iterates over the list of files transferred from a ActiveMatrix BusinessWorks FTP Put activity and outputs an element with the name of each file for each file transferred.Groups the items in a list by a specified element. This statement requires a Grouping statement to specify which element to group-by. See Converting a List Into a Grouped List for an example of using the For-Each-Group statement.<ns0:for-each-group xmlns:ns0="http://www.w3.org/1999/XSL/Transform" select=""/>Places a comment element into the XSLT template. This comment will be generated into the function’s output.<ns0:processing-instruction xmlns:ns0="http://www.w3.org/1999/XSL/Transform" name=""/>An if statement is used to surround other statements in an XSLT template to perform conditional processing. If the test attribute evaluates to true, the statements in the if are output, otherwise they are not output.<ns:if xmlns:ns="http://www.w3.org/1999/XSL/Transform" test="not(position()=last())">Specifies a value-of statement. This is normally done implicitly by specifying the formula for an element (field) in the mapping, but you may insert this statement explicitly.Adds a local variable for use in the current mapping. You can specify the name of the variable and whether you wish the variable to have a select attribute.When you add a local variable, it appears in the Function and Scope Variables panels. You can supply any XPath expression to the new variable in the Function panel (either through mapping or through the XPath Formula Builder).Once the variable’s contents have been supplied, the variable (in the Scope Variables area) can be mapped to any item.Adding a variable is useful when you wish to join two repeating elements into a single list, then map the combined list to an item. Adding a variable is also useful if you perform the same computation repeatedly. You can map the results of the computation to several items instead of recreating the computation for each item.Variables can also improve performance of mappings for large data structures. For example, if you have a process variable with 40 sub-elements, and you map each of the sub-elements to a corresponding input item, TIBCO BusinessEvents must retrieve the current process variable for each XPath expression, in this case 40 times. If this mapping appears in a loop, the retrieval of the current process variable occurs 40 times per iteration of the loop. With a variable, the data is retrieved only once and used for all mappings containing the variable. Therefore, to improve performance, create a local variable to hold process variables with a large number of elements and use the local variable in XPath expressions instead of the process variable.<ns0:variable xmlns:ns0="http://www.w3.org/1999/XSL/Transform" name="var" select="$RetrieveResults/resultSet"/>
Copyright © TIBCO Software Inc. All Rights Reserved.