Help

Python Scripting examples for Transformation Rules

For single source path transformations, (i.e. transformation rules like below)

transform column "$..'PDBx:struct'.'PDBx:title'.'_$'" to "dataItem.title";
The matching source paths value in the current document is provided to the Python script in the APPLY section of the transformation rule as the predefined variable value. Each APPLY Python code block needs to assign the new transformed value to the Python variable result and return it.
result = 'doi:' + value 

For multiple source path transformations, for each source path the matching values are provided as value1,value2 etc for the first, second and so on source path.

arr=re.split("\s*,\s*",value1,)
arr.extend(re.split("\s*,\s*",value2))
result=arr