xsl:function を使用してカスタム文字列操作を追加する必要がある XSL スタイル シートがあります。しかし、関数をドキュメントのどこに配置するかを考え出すのに苦労しています。
私の XSL 簡略化は次のようになります。
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:my="myFunctions" xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="Master.xslt"/>
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!-- starts actual layout -->
<fo:page-sequence master-reference="first">
<fo:flow flow-name="xsl-region-body">
<!-- this defines a title level 1-->
<fo:block xsl:use-attribute-sets="heading">
HelloWorld
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
そして、単純な関数を入れたいのですが、たとえば、
<xsl:function name="my:helloWorld">
<xsl:text>Hello World!</xsl:text>
</xsl:function>
しかし、関数を配置する場所がわかりません。ノードの下に配置すると、「xsl:function」は「xsl:stylesheet」要素の子にできないというエラーが表示されます。、ノードの下に置くと、同様のエラーが発生します。
関数はどこに配置すればよいですか?理想的には、関数を外部ファイルに入れて xsl ファイルにインポートしたいと考えています。