document.write
is a method of the document
object exposed by browsers in text/html
documents to script. XSLT does not have access to that document object and its method, not even with client-side XSLT done in the browser. The only option you have there is to have XSLT generate a HTML result document that then uses script to document.write
something. And even that is restricted, for instance Mozilla browsers don't support document.write
in the result document of an XSLT transformation, see https://developer.mozilla.org/en/docs/XSL_Transformations_in_Mozilla_FAQ#What_about_document.write.3F.
As for Javascript with Apache FOP, no, I don't think there is any document object available. And I am not sure why you need script to create a fo:block
element, with XSLT it suffices to use literal result element e.g.
<xsl:template match="foo">
<fo:block>some text</fo:block>
</xsl:template>