Mask XML in a Database Using CONCAT

As a Test Data Engineer, you want to mask XML data stored in a database column. These example procedures use the mask type CONCAT to concatenate values to mask an XML element.
tdm49
As a Test Data Engineer, you want to mask XML data stored in a database column. These example procedures use the mask type CONCAT to concatenate values to mask an XML element.
CONCAT Syntax
When you define
Values or Columns
, there are four options for each parameter used in the concatenation. Options within the CONCAT parameter are separated by two tilde characters (
~~
).
CONCAT Syntax:
COLUMN_NAME~~
XPATH
~~
substring_start
,
substring_length
  • COLUMN_NAME
    Defines the column from where to get values to mask.
  • XPATH
    (Optional) Defines the XPATH value that identifies the XML element inside the column that you want to mask.
  • substring_start
    (Optional) Specifies the start position of the substring.
    • ,
      substring_length
      Specifies the length of the substring. If you specify a value greater than the length of the string,
      substring_length
      defaults to the length of the string.
Syntax example 1:
NAME
We mask just the column NAME or a fixed value. Default.
Syntax example 2:
NAME~~1,2
We want to mask any XML element in the
NAME
column. We mask the substring from character position 1 to 2. If the length of the string is 1, then we mask only position 1.
Syntax example 3:
XML_DATA~~/Entry/entity-Person/LicenseNumber
The XPATH value
/Entry/entity-Person/LicenseNumber
specifies the XML element that we want to mask in the
XML_DATA
column. We mask the whole string.
Syntax example 4:
XML_DATA~~/Entry/entity-Person/LicenseNumber~~2,20
The XPATH value
/Entry/entity-Person/LicenseNumber
specifies the XML element that we want to mask in the
XML_DATA
column. We mask the substring from character position 2 to 20. If the length of the string is less than 20, then we mask from position 2 to the end of the string.
Example Masks
Fixed value
The string literal MYFIXEDVALUE is concatenated with the masked value for the NAME column, in this example, "Kiela".
Add column to mask:
XML_DATA
  • Data Type:
    Character
  • Mask Type:
    CONCAT
  • Enable
    Use Masked Values
    .
  • Value or Column:
    • MYFIXEDVALUE
    • NAME
  • XML/JSON Data XPATH:
    /Entry/entity-Person/LicenseNumber
Add column to mask:
NAME
  • Data Type:
    Character
  • Mask Type:
    HASHLOV
  • Get Seed data:
    from File
  • Data Category:
    English Last Names
Data before:
<Entry>
  <entity-person>
    <FirstName>Amphitryon</FirstName>
    <LastName>Tiryns</LastName>
    <LicenseNumber>
X123456
</LicenseNumber>
  </entity-person>
Data after:
<Entry>
  <entity-person>
    <FirstName>Amphitryon</FirstName>
    <LastName>Tiryns</LastName>
    <LicenseNumber>
MYFIXEDVALUEKiela
</LicenseNumber>
  </entity-person>
Example: Substrings 1
In this example, we replace the first letter of the value of the XML element
/Entry/entity-Person/LicenseNumber
(X) by the first letter of the masked value of the XML element
/Entry/entity-Person/LastName
(K). The masked value in NAME is Keila.
Add column to mask:
XML_DATA
  • Data Type:
    Character
  • Mask Type:
    CONCAT
  • Enable
    Use Masked Values
    .
  • Value or Column:
    • XML_DATA~~/Entry/entity-Person/LastName~~1,1
    • XML_DATA~~/Entry/entity-Person/LicenseNumber~~2,20
  • XML/JSON Data XPATH:
    /Entry/entity-Person/LicenseNumber
Add column to mask:
XML_DATA
  • Data Type:
    Character
  • Mask Type:
    HASHLOV
  • Get Seed data:
    from File
  • Data Category:
    American Female First Name
Data before:
<Entry>
  <entity-person>
    <FirstName>Amphitryon</FirstName>
    <LastName>Tiryns</LastName>
    <LicenseNumber>
X123456
</LicenseNumber>
  </entity-person>
Data after:
<Entry>
  <entity-person>
    <FirstName>Amphitryon</FirstName>
    <LastName>Tiryns</LastName>
    <LicenseNumber>
K123456
</LicenseNumber>
  </entity-person>
Example: Substrings 2
In this example, we concatenate the substring of the masked value in the NAME column from position 1 with length 3, with the substring from the value in
/Entry/entity-Person/LicenseNumber
from position 2 with length up to 20. The masked value in NAME is Keila.
Add column to mask:
XML_DATA
  • Data Type:
    Character
  • Mask Type:
    CONCAT
  • Enable
    Use Masked Values
    .
  • Value or Column:
    • XML_DATA~~/Entry/entity-Person/LastName~~1,3
    • XML_DATA~~/Entry/entity-Person/LicenseNumber~~2,20
  • XML/JSON Data XPATH:
    /Entry/entity-Person/LicenseNumber
Add column to mask:
NAME
  • Data Type:
    Character
  • Mask Type:
    HASHLOV
  • Get Seed data:
    from File
  • Data Category:
    American Female First Name
Data before:
<Entry>
  <entity-person>
    <FirstName>Amphitryon</FirstName>
    <LastName>Tiryns</LastName>
    <LicenseNumber>
X123456
</LicenseNumber>
  </entity-person>
Data after:
<Entry>
  <entity-person>
    <FirstName>Amphitryon</FirstName>
    <LastName>Tiryns</LastName>
    <LicenseNumber>
Kei123456
</LicenseNumber>
  </entity-person>