get matched value()
This function is intended for the document types "XML", "EDIFACT" a nd " JSON" (only fields).
It returns the value of the field's or node's match code that matched during the parsing of the input data. For the function to work, the following conditions must be met.
The option "Normal data mapper" has to be used.
The checkbox "Use matchcode values for functions in mapping" must be set.
Parameters
Parameter |
Description |
a |
Node or field name. The parameter type must be "Source field" if the match code of a field is required. If you need the match code of a node, the type must be "Value". Important note: If you are using document type "EDIFACT", only nodes provide a meaningful result. In addition, the entire data line for which the match code matched is returned and not the match code itself, e.g. LIN+1++101556:SA |
Example
Assume the following XML structure.
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
s
:schema
xmlns:s
=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault
=
"qualified"
>
<
s
:element
name
=
"datalines"
minOccurs
=
"0"
maxOccurs
=
"unbounded"
>
<
s
:complexType>
<
s
:sequence>
<
s
:element
name
=
"data"
minOccurs
=
"0"
maxOccurs
=
"unbounded"
>
<
s
:complexType>
<
s
:simpleContent>
<
s
:extension
base
=
"s:string"
>
<
s
:attribute
name
=
"date"
type
=
"s:string"
/>
<
s
:attribute
name
=
"time"
type
=
"s:string"
/>
<
s
:attribute
name
=
"datetime"
type
=
"s:string"
/>
</
s
:extension>
</
s
:simpleContent>
</
s
:complexType>
</
s
:element>
</
s
:sequence>
</
s
:complexType>
</
s
:element>
</
s
:schema>
An XML that conforms to this schema looks like this, for example.
<
datalines
>
<
data
date
=
"2011-12-23"
/>
<
data
time
=
"12:34:56"
/>
<
data
datetime
=
"2011-12-23 12:34:56"
/>
</
datalines
>
This XML is to be converted into a simple CSV file of the following form.
Date:2011-12-23 00:00:00
Date:1970-01-01 12:34:56
Date:2011-12-23 12:34:56
Solving it the regular way, it would be necessary to create one field per attribute and find out the relevant one during the mapping. Using this function, all attribute values can be assigned to a single field.
The match codes being used on source structure field date-2_attr are the following.
Condition |
Value |
Equals |
date |
Equals |
time |
Equals |
datetime |
The following functions are defined on target structure field datefield.
1) get matched value(a)
a field: date-2_attr
2) replace value(a, list b, list c)
a result: 1
b constant: date,time,datetime
c constant: yyyy-MM-dd,HH:mm:ss,yyyy-MM-dd HH:mm:ss
3) create date strict(value a, adjustable template b, default c, [locale d])
a linked field:
b result: 2
c constant: error
d constant:
4) concat( a, b )
a constant: Date:
b result: 3
Example profile
Download the profile used in this example here and import it: Profile-get_matched_value_example.pak
If you perform a mapping test, you will find the XML input file there.