doTranslateToNative Function Translator XPath Functions

Native Format Builder Wizard 6-57 ■ Root-Element is a root element in the NXSD schema. ■ return_csv_data is the string variable that contains the translated CSV data. Example 6–6 Configuring XPath Function to Translate an Incoming XML DOM into an Attachment Representing the Target File-Path for the Translated CSV 1. Define attachmentElement in the schema of the BPEL process, as follows: schema targerNamespace=… element name=attachmentElement complexType attribute name=href type=string complexType element schema 2. Create an input variable of type attachmentElement in the schema of the BPEL process, as follows: variables variable… variable name=inputDOM type=ns1:Root-Element variable name=attachmentVariable type=client:attachmentElement variables 3. Assign the target file path where you want the translated CSV to be written, as follows: assign name=AssignAttachmentReference copy from expression=tmpxpathoutaddress.csv to variable=attachmentVariable query=client:attachmentElementhref copy assign 4. Call the XPath function, as follows: assign name=xlateToNative copy from expression=ora:doTranslateToNativebpws:getVariableDatainputDOM,xsdaddre ss-csv.xsd, Root-Element, ATTACHMENT, bpws:getVariableData attachmentVariable to variable=attachmentVariable copy assign In this example: ■ inputDOM is a BPEL DOM variable containing XML data to be translated into a CSV output file represented by tmpxpathoutaddress.csv. ■ xsdaddress-csv.xsd is the relative path to the NXSD schema in the project. ■ Root-Element is a root element in the NXSD schema. ■ AttachmentElement points to the target output file path represented by tmpxpathoutaddress.csv. 6-58 Oracle Fusion Middleware Users Guide for Technology Adapters Note: In this example, targetType is set to ATTACHMENT, and AttachmentVariable points to the file path where the translated CSV file is to be written. However, the fifth parameter bpws:getVariableDataattachmentVariable is optional. If this parameter is missing, then the XPath function creates a database-backed attachment and returns it. In such a case, the XPath function is configured as follows: 1. Define attachmentElement in the schema of the BPEL process, as follows: schema targerNamespace=… element name=attachmentElement complexType attribute name=href type=string complexType element schema 2. Create an input variable of type attachmentElement in the schema of the BPEL process, as follows: variables variable… variable name=inputDOM type=ns1:Root-Element variable name=attachmentVariable type=client:attachmentElement variables 3. Call the XPath function, as follows: assign name=xlateToNative copy from expression=ora:doTranslateToNativebpws:getVariableDatainputDOM,xsdaddre ss-csv.xsd, Root-Element, ATTACHMENT to variable=attachmentVariable copy assign After the XPath call returns, attachmentVariable is populated with the href attribute pointing to the GUID representing the database-backed attachment.

6.3.2.3 doStreamingTranslate Function

XPath functions implement the batching transformation approach. With this approach, files that are of the order of a few gigabytes GB can be processed without running into memory issues. Arbitrarily large payloads can be handled because the transformation engine does not store the result of the transformation in its memory. The transformation engine flushes its memory after a batch of elements of the large file is processed. The default batch size is 10000, which is the number of elements after which the transformation engine flushes its memory. This parameter is used internally and is optional. Syntax: ora:doStreamingTranslateinput,streamingXpathContext,target Type ,attachmentElement? Note: Batching transformation approach is supported for XML documents that have repeating structures only. Native Format Builder Wizard 6-59 The following table describes the parameters used in the syntax for using this function: The streamingXPathContext parameter specifies the context for the streaming transformation and, it must conform to the following schema element: schema targetNamespace=… element name=streamingcontext complexType sequence element name=sourceSchema type=string element name=sourceRootElement type=string element name=sourceType type=string element name=xsl type=string element name=targetSchema type=string element name=targetRootElement type=string element name=targetType type=string element name=batchSize type=string sequence complexType element schema In context:

6.3.2.4 Batching Transformation Features

This section discusses the following features of batching transformation: Parameter Description input Input data for the XPath function; the data can either be SDOM or an Attachment element. streamingXpathContext DOM representing the XPath context. targetType This parameter decides how the XPath function translates the input data into an attachment. This must be set to either SDOM or ATTACHMENT. attachmentElement This parameter is optional. This is the attachment to which the data is streamed. Schema Element Description sourceSchema Source NXSD schema used to translate a native data to XML. sourceRootElement Name of root element in source NXSD schema. sourceType Set this to either xml or native depending on the input data. xsl Relative path of the XSL file. targetSchema Target NXSD schema used to translate an XML into native data. targetRootElement Name of root element in target NXSD schema. targetType Set this to either xml or native depending on the output data. batchSize The number of elements after which the transformation engine flushes its memory.