In the XPath data model, attribute nodes and namespace nodes are quite separate animals. They only look the same when the nodes are serialized. You need to create a namespace node, not an attribute node.
For the
js-function namespace, you don't just want to create a namespace node, you also want the InvoiceHeader element to be in this namespace. You should create the element as
<xsl:element name="InvoiceHeader" namespace="//ServerName/DirectoryPath/
js-functions">
or more simply as
<InvoiceHeader xmlns="//ServerName/DirectoryPath/
js-functions">
The namespace node will be created automatically, and you'll therefore get the namespace declaration attribute in the result when it is serialized.
The xmlns:fo namespace is a bit trickier, because you aren't actually using it: creating namespaces that you don't use is a rather unusual requirement. You can do it in 2.0 with
<xsl:namespace name="fo">http://www.w3.org/1999/XSL/Format</xsl:namespace>
In 1.0 the simplest workaround is to create a document dummy.xml:
<dummy xmlns:fo="http://www.w3.org/1999/XSL/Format"/>
and then do
<xsl:copy-of select="document('dummy.xml')/dummy/namespace::fo"/>
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference