This article will look at scripting languages that are not covered in the Xalan documentation, in particular, Python, VBScript, and PerlScript. In addition, we will show how Java Object instances, created in XSLT as part of the Java language extensions mechanism, are passed to these scripts and utilized by them. These samples will provide a solid foundation on which to build more complicated script-based extensions.
Note that for the in-line Python script, the def statement must start in column 0, otherwise a fault occurs during the Python script compilation.
Function with JavaBean Processing
def calculate_bonus( quota, actual, bonusplan, bonus_table ) : """ find base bonus from lookup table """ bonus_base = long ( bonus_table.lookUp(bonusplan,1), 10 )
""" calculate multiple, bonus multiple is zero if they underperform """ if actual > quota : multiple = actual / quota return multiple * bonus_base else : return 0.0