XSLTExternalMappingIU
Group |
|
Class Name |
com.ebd.hub.datawizard.iu.XSLTExternalMappingIU |
Function |
The Integration Unit can be used to execute an XSLT transformation on an XML file. |
Description
Introduction: Integration Units.
The class XSLTExternalMappingIU can be used to execute an XSLT transformation on an XML file. The Integration Unit expects files with UTF-8 encoding. You have to use document type Custom Class. As a result, a received XML file is transferred directly to the Integration Unit for the XSLT transformation.
Parameter Description
Parameter Name |
Allowed Values |
Default Value |
Description |
xslt factory |
net.sf.saxon.TransformerFactoryImpl |
Specification of XSLT factory. |
|
xslt file |
Path of XSLT file. |
By default, the Saxon library is used for the transformation, which has to be installed first. You could, for example, go to page https://sourceforge.net and search for saxon. Download the ZIP file and move the contained .jar files to the folder ./extlib. The path to the specified factory in the Integration Unit (parameter xslt factory) has to be defined in the classpath of Lobster_data (which it is if you put the .jar files in the folder ./extlib). Note: You have to restart the Integration Server to make the new classes 'visible' (to load them).
The parameter xslt file specifies the XSLT file that is used for the transformation.
If you do not provide the correct Saxon library, you will get the following error message when executing a profile using this Integration Unit.
Example
Create a new profile, choose input agent Man. Upload, select document type Custom Class and set checkbox No mapping. You can use the settings in the screenshot above for the Integration Unit in phase 5. The specified XSLT file will be provided below. Create a response route of type File and use the settings shown in the following screenshot.
This is the XSLT file specified in the Integration Unit.
<?
xml
version
=
"1.0"
?>
<
xsl
:stylesheet
version
=
"1.0"
xmlns:xsl
=
"http://www.w3.org/1999/XSL/Transform"
>
<
xsl
:template
match
=
"teacher"
>
<
p
><
u
><
xsl
:value-of
select
=
"."
/></
u
></
p
>
</
xsl
:template>
<
xsl
:template
match
=
"student"
>
<
p
><
b
><
xsl
:value-of
select
=
"."
/></
b
></
p
>
</
xsl
:template>
<
xsl
:template
match
=
"/"
>
<
html
>
<
body
>
<
xsl
:apply-templates/>
</
body
>
</
html
>
</
xsl
:template>
</
xsl
:stylesheet>
Use the following XML file as the input file for the profile.
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<?
xml
-stylesheet
type
=
"text/xsl"
href
=
"class.xsl"
?>
<
class
>
<
student
>Jack</
student
>
<
student
>Harry</
student
>
<
student
>Rebecca</
student
>
<
teacher
>Mr. Bean</
teacher
>
</
class
>
Your profile should produce the following output file.
<
html
>
<
body
>
<
p
><
b
>Jack</
b
></
p
>
<
p
><
b
>Harry</
b
></
p
>
<
p
><
b
>Rebecca</
b
></
p
>
<
p
><
u
>Mr. Bean</
u
></
p
>
</
body
>
</
html
>