XQuery is a great language that can be used within the OSB for translations and other expressions. Unfortunately the OSB does not support the module construction of XQuery. A module construction can be perfectly reused for code reuse.
This post shows how this omission in the OSB can be solved.
This example shows how a message with a header and a body can be created of which the header code is reused.
1) First the header function is created (without parameters, but these can also be added).
2) Add another XQuery that creates the message with the header and body content as parameters.
3) Within a Stage or where you want to use the construction add an Assign.
4) The expression must be the Header XQuery.
5) Add another Assign for the message XQuery and add the $body and $header as binding variables.
And that's it, so the trick is to use parameters. This may be not always possible but it is a construction you could use.