File tree 17 files changed +470
-0
lines changed
02.multiple-structured-xml-sources
03.structured-xml-to-json
17 files changed +470
-0
lines changed Original file line number Diff line number Diff line change
1
+ target /
2
+ ! .mvn /wrapper /maven-wrapper.jar
3
+ ! ** /src /main /** /target /
4
+ ! ** /src /test /** /target /
5
+ ** /.camel-jbang
6
+
7
+ # ## IntelliJ IDEA ###
8
+ .idea
9
+ .idea /modules.xml
10
+ .idea /jarRepositories.xml
11
+ .idea /compiler.xml
12
+ .idea /libraries /
13
+ * .iws
14
+ * .iml
15
+ * .ipr
16
+
17
+ # ## Eclipse ###
18
+ .apt_generated
19
+ .classpath
20
+ .factorypath
21
+ .project
22
+ .settings
23
+ .springBeans
24
+ .sts4-cache
25
+
26
+ # ## NetBeans ###
27
+ /nbproject /private /
28
+ /nbbuild /
29
+ /dist /
30
+ /nbdist /
31
+ /.nb-gradle /
32
+ build /
33
+ ! ** /src /main /** /build /
34
+ ! ** /src /test /** /build /
35
+
36
+ # ## VS Code ###
37
+ .vscode /
38
+
39
+ # ## Mac OS ###
40
+ .DS_Store
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <xsl : stylesheet version =" 3.0" xmlns : xsl =" http://www.w3.org/1999/XSL/Transform" >
3
+
4
+ <xsl : output method =" xml" indent =" yes" />
5
+ <xsl : param name =" datamapper-step1-header-step1-header1" />
6
+ <xsl : param name =" datamapper-step1-header-global-header1" />
7
+ <xsl : param name =" datamapper-step2-header-step2-header1" />
8
+ <xsl : param name =" datamapper-step2-header-global-header1" />
9
+ <xsl : param name =" datamapper-step3-header-global-header1" />
10
+
11
+ <xsl : template match =" /" >
12
+ <Headers >
13
+ <Global >
14
+ <Step1 ><xsl : value-of select =" $datamapper-step1-header-global-header1" /></Step1 >
15
+ <Step2 ><xsl : value-of select =" $datamapper-step2-header-global-header1" /></Step2 >
16
+ <Step3 ><xsl : value-of select =" $datamapper-step3-header-global-header1" /></Step3 >
17
+ </Global >
18
+ <Local >
19
+ <Step1 ><xsl : value-of select =" $datamapper-step1-header-step1-header1" /></Step1 >
20
+ <Step2 ><xsl : value-of select =" $datamapper-step2-header-step2-header1" /></Step2 >
21
+ </Local >
22
+ </Headers >
23
+ </xsl : template >
24
+
25
+ </xsl : stylesheet >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <modelVersion >4.0.0</modelVersion >
6
+ <parent >
7
+ <groupId >io.kaoto.research.datamapper.examples</groupId >
8
+ <artifactId >examples</artifactId >
9
+ <version >1.0-SNAPSHOT</version >
10
+ <relativePath >../pom.xml</relativePath >
11
+ </parent >
12
+ <artifactId >01.headers</artifactId >
13
+ <packaging >jar</packaging >
14
+
15
+ </project >
Original file line number Diff line number Diff line change
1
+ # camel-k: language=yaml
2
+
3
+ # Service sub routes
4
+ - from :
5
+ uri : " direct:step1"
6
+ steps :
7
+ - set-header :
8
+ name : " step1-header1"
9
+ simple : " Header 1 from step1 service"
10
+ - set-header :
11
+ name : " global-header1"
12
+ simple : " Global header 1 from step1 service"
13
+ - log :
14
+ message : " step1(source):\n ${headers}"
15
+ - from :
16
+ uri : " direct:step2"
17
+ steps :
18
+ - set-header :
19
+ name : " step2-header1"
20
+ simple : " Header 1 from step2 service"
21
+ - set-header :
22
+ name : " global-header1"
23
+ simple : " Global header 1 from step2 service"
24
+ - log :
25
+ message : " step2(source):\n ${headers}"
26
+ - from :
27
+ uri : " direct:step3"
28
+ steps :
29
+ - log :
30
+ message : " endStep(target):\n ${headers}"
31
+
32
+ # Main route
33
+ - from :
34
+ uri : " timer:yaml"
35
+ parameters :
36
+ period : " 3000"
37
+ steps :
38
+ - step :
39
+ id : " step1-wrapped-for-datamapper"
40
+ steps :
41
+ - to :
42
+ uri : " direct:step1"
43
+ # Capture headers from step1 and save into exchange properties
44
+ - set-property :
45
+ name : " datamapper-step1-header-step1-header1"
46
+ simple : " ${header[step1-header1]}"
47
+ - set-property :
48
+ name : " datamapper-step1-header-global-header1"
49
+ simple : " ${header[global-header1]}"
50
+ - step :
51
+ id : " step2-wrapped-for-datamapper"
52
+ steps :
53
+ - to :
54
+ uri : " direct:step2"
55
+ # Capture headers from step2 and save into exchange properties
56
+ - set-property :
57
+ name : " datamapper-step2-header-step2-header1"
58
+ simple : " ${header[step2-header1]}"
59
+ - set-property :
60
+ name : " datamapper-step2-header-global-header1"
61
+ simple : " ${header[global-header1]}"
62
+ - step :
63
+ id : " datamapper-1"
64
+ steps :
65
+ - set-property :
66
+ name : " datamapper-step3-header-global-header1"
67
+ simple : " ${header[global-header1]}"
68
+ - to :
69
+ uri : " xslt-saxon:mapping.xsl"
70
+ parameters :
71
+ failOnNullBody : " false"
72
+ - to :
73
+ uri : " direct:step3"
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <First >
3
+ <Items >
4
+ <Item >Apple</Item >
5
+ <Item >Orange</Item >
6
+ <Item >Apple</Item >
7
+ </Items >
8
+ </First >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <xsl : stylesheet version =" 3.0" xmlns : xsl =" http://www.w3.org/1999/XSL/Transform" >
3
+
4
+ <xsl : output method =" xml" indent =" yes" />
5
+ <xsl : param name =" datamapper-step1-body" />
6
+ <xsl : param name =" datamapper-step2-body" />
7
+
8
+ <xsl : template match =" /" >
9
+ <Third >
10
+ <xsl : for-each select =" $datamapper-step1-body/First/Items/Item" >
11
+ <Item >
12
+ <Name >
13
+ <xsl : value-of select =" ." />
14
+ </Name >
15
+ <Price >
16
+ <xsl : choose >
17
+ <xsl : when test =" . = 'Apple'" >
18
+ <xsl : value-of select =" $datamapper-step2-body/Second/Apple/UnitPrice" />
19
+ </xsl : when >
20
+ <xsl : when test =" . = 'Orange'" >
21
+ <xsl : value-of select =" $datamapper-step2-body/Second/Orange/UnitPrice" />
22
+ </xsl : when >
23
+ </xsl : choose >
24
+ </Price >
25
+ </Item >
26
+ </xsl : for-each >
27
+
28
+ <xsl : variable name =" total-price" >
29
+ <xsl : for-each select =" $datamapper-step1-body/First/Items/Item" >
30
+ <xsl : choose >
31
+ <xsl : when test =" . = 'Apple'" >
32
+ <xsl : copy-of select =" $datamapper-step2-body/Second/Apple/UnitPrice" />
33
+ </xsl : when >
34
+ <xsl : when test =" . = 'Orange'" >
35
+ <xsl : copy-of select =" $datamapper-step2-body/Second/Orange/UnitPrice" />
36
+ </xsl : when >
37
+ </xsl : choose >
38
+ </xsl : for-each >
39
+ </xsl : variable >
40
+ <TotalPrice >
41
+ <xsl : value-of select =' format-number(sum($total-price/UnitPrice), "#.00")' />
42
+ </TotalPrice >
43
+ </Third >
44
+ </xsl : template >
45
+
46
+ </xsl : stylesheet >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <modelVersion >4.0.0</modelVersion >
6
+ <parent >
7
+ <groupId >io.kaoto.research.datamapper.examples</groupId >
8
+ <artifactId >examples</artifactId >
9
+ <version >1.0-SNAPSHOT</version >
10
+ <relativePath >../pom.xml</relativePath >
11
+ </parent >
12
+ <artifactId >02.multiple-structured-xml-body</artifactId >
13
+ <packaging >jar</packaging >
14
+
15
+ </project >
Original file line number Diff line number Diff line change
1
+ # camel-k: language=yaml
2
+
3
+ # Service sub routes
4
+ - from :
5
+ uri : " direct:step1"
6
+ steps :
7
+ - set-body :
8
+ simple : " resource:classpath:first.xml"
9
+ - convert-body-to :
10
+ type : " org.w3c.dom.Document"
11
+ - log :
12
+ message : " step1(source):\n ${body}"
13
+ - from :
14
+ uri : " direct:step2"
15
+ steps :
16
+ - set-body :
17
+ simple : " resource:classpath:second.xml"
18
+ - convert-body-to :
19
+ type : " org.w3c.dom.Document"
20
+ - log :
21
+ message : " step2(source):\n ${body}"
22
+ - from :
23
+ uri : " direct:step3"
24
+ steps :
25
+ - log :
26
+ message : " endStep(target):\n ${body}"
27
+
28
+ # Main route
29
+ - from :
30
+ uri : " timer:yaml"
31
+ parameters :
32
+ period : " 3000"
33
+ steps :
34
+ - step :
35
+ id : " step1-wrapped-for-datamapper"
36
+ steps :
37
+ - to :
38
+ uri : " direct:step1"
39
+ # Capture body from step1 and save into exchange properties
40
+ - set-property :
41
+ name : " datamapper-step1-body"
42
+ simple : " ${body}"
43
+ - step :
44
+ id : " step2-wrapped-for-datamapper"
45
+ steps :
46
+ - to :
47
+ uri : " direct:step2"
48
+ # Capture body from step1 and save into exchange properties
49
+ - set-property :
50
+ name : " datamapper-step2-body"
51
+ simple : " ${body}"
52
+ - step :
53
+ id : " datamapper-1"
54
+ steps :
55
+ - to :
56
+ uri : " xslt-saxon:mapping.xsl"
57
+ parameters :
58
+ failOnNullBody : " false"
59
+ - to :
60
+ uri : " direct:step3"
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <Second >
3
+ <Apple >
4
+ <UnitPrice >3.00</UnitPrice >
5
+ </Apple >
6
+ <Orange >
7
+ <UnitPrice >2.00</UnitPrice >
8
+ </Orange >
9
+ </Second >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <Account >
3
+ <FirstName >John</FirstName >
4
+ <LastName >Smith</LastName >
5
+ <Contact >
6
+
7
+ <Address >
8
+ <Street >1st Street</Street >
9
+ <City >New York</City >
10
+ <State >NY</State >
11
+ <Zip >10021</Zip >
12
+ </Address >
13
+ </Contact >
14
+ </Account >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <xsl : stylesheet version =" 3.0" xmlns : xsl =" http://www.w3.org/1999/XSL/Transform"
3
+ xmlns : xj =" http://camel.apache.org/component/xj"
4
+ exclude-result-prefixes =" xj" >
5
+
6
+ <xsl : output omit-xml-declaration =" no" method =" xml" indent =" yes" />
7
+ <xsl : param name =" datamapper-step1-body" />
8
+
9
+ <xsl : template match =" /" >
10
+ <Person >
11
+ <firstName ><xsl : value-of select =" $datamapper-step1-body/Account/FirstName" /></firstName >
12
+ <lastName ><xsl : value-of select =" $datamapper-step1-body/Account/LastName" /></lastName >
13
+ <email ><xsl : value-of select =" $datamapper-step1-body/Account/Contact/Email" /></email >
14
+ <address >
15
+ <streetAddress ><xsl : value-of select =" $datamapper-step1-body/Account/Contact/Address/Street" /></streetAddress >
16
+ <city ><xsl : value-of select =" $datamapper-step1-body/Account/Contact/Address/City" /></city >
17
+ <state ><xsl : value-of select =" $datamapper-step1-body/Account/Contact/Address/State" /></state >
18
+ <postalCode xj : type =" int" ><xsl : value-of select =" $datamapper-step1-body/Account/Contact/Address/Zip" /></postalCode >
19
+ </address >
20
+ </Person >
21
+ </xsl : template >
22
+
23
+ </xsl : stylesheet >
Original file line number Diff line number Diff line change
1
+ {
2
+ "firstName" : " John" ,
3
+ "lastName" : " Smith" ,
4
+
5
+ "address" :
6
+ {
7
+ "streetAddress" : " 21 2nd Street" ,
8
+ "city" : " New York" ,
9
+ "state" : " NY" ,
10
+ "postalCode" : " 10021"
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <modelVersion >4.0.0</modelVersion >
6
+ <parent >
7
+ <groupId >io.kaoto.research.datamapper.examples</groupId >
8
+ <artifactId >examples</artifactId >
9
+ <version >1.0-SNAPSHOT</version >
10
+ <relativePath >../pom.xml</relativePath >
11
+ </parent >
12
+ <artifactId >03.structured-xml-to-json</artifactId >
13
+ <packaging >jar</packaging >
14
+
15
+ </project >
You can’t perform that action at this time.
0 commit comments