Batching Transformation Features Translator XPath Functions

6-60 Oracle Fusion Middleware Users Guide for Technology Adapters Applicability Batching transformation is applicable to: ■ Documents with repeating structure ■ XSLTs not requiring aggregation across entire document Batched Invocation of XSLT Engine The following procedure highlights the batched invocation of the XSLT engine: 1. Splitting the source document into multiple batches of one or more records 2. Performing the XSLT transformation one batch at a time 3. Combining the result of the XSLT invocation to a single target document Splitting or Combining Performed on the Fly The source documents are split and the results are combined into a target document: ■ Without any intermediate memory or disk storage ■ Through pipelining or intercepting SAX events Low In-Memory Footprint Batching transformation method uses low memory for the following tasks: ■ Transforming arbitrarily large XML documents, which are constrained by the target system ■ For standalone tests, 540 MB is transformed in less than 3 minutes Example 6–7 implements the FlatStructure FileAdapter sample using streaming transformation XPath functions. This sample use case translates the inbound native attachment from a CSV format to an XML format, and then applies the user-supplied XSL file to the resulting XML file. The transformed XML file is then translated into a fixed-length content represented by an attachment. Example 6–7 Using Streaming Transformation XPath Function 1. Define attachmentElement, as shown: schema targerNamespace=… element name=attachmentElement complexType attribute name=href type=string complexType element schema 2. Create a variable for the input attachment referring to the inbound csv file and the output attachment referring to the output fixed-length file. Create the variable corresponding to the streaming context. You must populate this variable before making a call to the XPath function. variables variable name=xlationContext element=client:streamingcontext variable name=inputAttachment element=client:attachmentElement variable name=returnAttachment element=client:attachmentElement variables - - Assign the input and output attachments - - assign name=assignValuesForAttachments Native Format Builder Wizard 6-61 copy from expression=tmpxpathinaddress.csv to variable=inputAttachment query=client:attachmentElementhref copy copy from expression=tmpxpathoutaddress_fixedLength.txt to variable=returnAttachment query=client:attachmentElementhref copy assign - - Assign the streaming context - - assign name=AssignStreamingContext copy from expression=xsdaddress-csv.xsd to variable=xlationContext query=client:streamingcontextclient:sourceSchema copy copy from expression=Root-Element to variable=xlationContext query=client:streamingcontextclient:sourceRootElement copy copy from expression=native to variable=xlationContext query=client:streamingcontextclient:sourceType copy copy from expression=xsdaddress-fixedLength.xsd to variable=xlationContext query=client:streamingcontextclient:targetSchema copy copy from expression=Root-Element to variable=xlationContext query=client:streamingcontextclient:targetRootElement copy copy from expression=native to variable=xlationContext query=client:streamingcontextclient:targetType copy copy from expression=xsladdr1Toaddr2.xsl to variable=xlationContext query=client:streamingcontextclient:xsl copy copy from expression=10000 to variable=xlationContext query=client:streamingcontextclient:batchSize copy assign - - call the XPath function - - assign name=executeStreamingXPath copy from expression=ora:doStreamingTranslatebpws:getVariableDatainputAttachment,c lient:attachmentElement, 6-62 Oracle Fusion Middleware Users Guide for Technology Adapters bpws:getVariableDataxlationContext, ATTACHMENT, bpws:getVariableDatareturnAttachment to variable=returnAttachment query=client:attachmentElement copy assign

6.4 Use Cases for the Native Format Builder

This section describes the following use cases: ■ Section 6.4.1, Defining the Schema for a Delimited File Structure ■ Section 6.4.2, Defining the Schema for a Fixed Length File Structure ■ Section 6.4.3, Defining the Schema for a Complex File Structure ■ Section 6.4.4, Removing or Adding Namespaces to XML with No Namespace ■ Section 6.4.5, Defining the Choice Condition Schema for a Complex File Structure ■ Section 6.4.6, Defining Choice Condition With LookAhead for a Complex File Structure ■ Section 6.4.7, Defining Array Type Schema for a Complex File Structure ■ Section 6.4.8, Defining the Schema for a DTD File Structure ■ Section 6.4.9, Defining the Schema for a COBOL Copybook File Structure

6.4.1 Defining the Schema for a Delimited File Structure

A comma-separated value CSV file is a common non-XML file structure. Use the Delimited option in the Native Format Builder wizard, when creating the XML schema for this native file. The nxsd:headerLines=1 schema attribute signifies that the first line must be treated as a header row and skipped in the native data before actually translating the rest of the data. The nxsd:stream=chars schema attribute signifies that the data should be read as characters. If nxsd:stream is set as bytes, nxsd:stream=bytes, then this schema attribute signifies that the native data should be read as bytes. For each of the element declarations, Name, Street, City, State, and Country, which have a corresponding scalar data, the nxsd:style=terminated attribute defines that the corresponding data is stored in terminated style. The actual terminator is then defined by the nxsd:terminatedBy=, attribute specified at that construct. See Section 6.2.2.2, Defining Terminated Data for details on the terminated style. In this use case, the Native Format Builder uses a delimited sample file type that contains the address details, such as name, street, city, state, and country. Every element in this sample native file is delimited by a comma ,. You can generate the corresponding NXSD and also test it. Perform the following steps to run the use case:

1. The data in a sample text file, address-csv.txt, appears as below:

Note: Sampling the data with multi-character delimiter in Native Format Builder is not supported currently. The same can be achieved through hand coding the NXSD with the appropriate Delimited By string. Native Format Builder Wizard 6-63 Name,Street1,Street2,City,State,Country Oracle India Private Limited, Lexington Towers Prestige St. Johns Woods, 2nd Cross Road Chikka Audugodi, Bangalore, Karnataka, India Intel Technology India Private Limited, Survey 23-56 P Devarabeesanahalli Village, Outer Ring Road Varthur Hobli, Bangalore, Karnataka, India 2. Navigate to the Adapter Configuration Wizard Messages page, as displayed in Figure 6–4 , and click the Define Schema for Native Format button. Figure 6–4 Starting the Native Format Builder Wizard The Native Format Builder Welcome page is displayed, as shown in Figure 6–5 . Figure 6–5 Native Format Builder Wizard Welcome Page