There are incremental steps to improving speed of these things. Creation of XML elements is somewhat expensive (although .3 ms is not that bad ... but if you do 10k of those it does add up)
Here are some steps when you identify the most frequenly used expressions.
They are suggestions of what to do after you identify performance issues, not before,
because most often the performance impact is minimal and code readability and maintainability is more important. But once you identify a hot spot consider these:
limit function calls - something this simple can be done inline without a function.
Limit binding to variables
Limit for loops
Limit dynamic construction of elements and attributes
Of course you cant do all of these but you can decide where the pain is most and apply the concepts there.
For example the above call could instead be inlined as
<z:b xml:id="{$node/@xml:id}"/>
Try placing this inline where you tried the function and see what the results are.
Also note that the profiler can sometimes give misleading information. Many expressions are lazily evaluated and tend to attribute their time to where they are used instead of where they are declared.