-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-b-full.xsl
More file actions
51 lines (46 loc) · 2.51 KB
/
Copy path01-b-full.xsl
File metadata and controls
51 lines (46 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file is generated by Kaoto DataMapper. Do not edit. -->
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xf="http://www.w3.org/2005/xpath-functions">
<xsl:output method="text" indent="yes" />
<xsl:param name="kaotoDataMapperBody" />
<xsl:param name="orderSequence" />
<xsl:param name="account" />
<!-- Step1: Converts JSON inputs to lossless XML -->
<xsl:variable
name="body-xml" select="json-to-xml($kaotoDataMapperBody)" />
<xsl:variable
name="account-xml" select="json-to-xml($account)" />
<!-- Step2: Pre-process data mappings to lossless XML -->
<!--
Use lossless XML structure for both sources and target
-->
<xsl:variable name="mapped-lossless-xml">
<xf:map>
<xf:string key="OrderId"><xsl:value-of select="upper-case(concat('ORD-', $account-xml/xf:map/xf:string[@key='AccountId'], '-', $orderSequence))"/></xf:string>
<xf:string key="OrderPerson"><xsl:value-of select="$account-xml/xf:map/xf:string[@key='AccountId'], ':', $account-xml/xf:map/xf:string[@key='Name']"/></xf:string>
<xf:map key="ShipTo">
<xf:string key="Name"><xsl:value-of select="$account-xml/xf:map/xf:string[@key='Name']"/></xf:string>
<xf:map key="Address">
<xf:string key="Street"><xsl:value-of select="$account-xml/xf:map/xf:map[@key='Address']/xf:string[@key='Street']"/></xf:string>
<xf:string key="City"><xsl:value-of select="$account-xml/xf:map/xf:map[@key='Address']/xf:string[@key='City']"/></xf:string>
<xf:string key="State"><xsl:value-of select="$account-xml/xf:map/xf:map[@key='Address']/xf:string[@key='State']"/></xf:string>
<xf:string key="Country"><xsl:value-of select="$account-xml/xf:map/xf:map[@key='Address']/xf:string[@key='Country']"/></xf:string>
</xf:map>
</xf:map>
<xf:array key="Item">
<xsl:for-each select="$body-xml/xf:array/xf:map">
<xf:map>
<xf:string key="Title"><xsl:value-of select="xf:string[@key='Title']"/></xf:string>
<xf:number key="Quantity"><xsl:value-of select="xf:number[@key='Quantity']"/></xf:number>
<xf:number key="Price"><xsl:value-of select="xf:number[@key='Price']"/></xf:number>
</xf:map>
</xsl:for-each>
</xf:array>
</xf:map>
</xsl:variable>
<!-- Step4: Converts lossless XML to JSON output -->
<xsl:template match="/">
<xsl:value-of select="xml-to-json($mapped-lossless-xml)" />
</xsl:template>
</xsl:stylesheet>