XSLT 4.0 Proposal (2) Saxon 10.0が公開されました.

XSLT 4.0のプロポーザルが出たと思ったら、もうSaxon 10.0が出てしまいました.「もう」と書いたのは、10.0は単なるバグフィクッスのためのバージョンアップでなく、XSLT 4.0のプロポーザルに沿って実験的に盛り込んだ各種の機能があることです.

sourceforge.net

Saxon 10.0 includes experimental implementations of a number of powerful new XSLT and XPath features, which Saxonica has put forward for inclusion in a new version 4.0 of the standards.

これらの機能を使用するにはコンフィグレーションファイルに、拡張機能を使う旨指定してやらねばなりません.以下がその例です.

<?xml version="1.0" encoding="UTF-8"?>
<sc:configuration xmlns:sc="http://saxon.sf.net/ns/configuration" edition="PE">
     <sc:global allowSyntaxExtensions="true"/>
     ...
</sc:configuration>

そして、SaxonをJAXPでantから起動している場合は、コンフィグレーションファイルを使う旨、指定してやる必要があります.以下のような感じになるでしょう.

<?xml version="1.0" encoding="UTF-8"?>
...
<target name="build.project.class.path">
	<path id="project.class.path">
		<athelement path="${java.class.path}"/>
		<pathelement path="D:/My_Documents/Java/SaxonPE10-0J/saxon-pe-10.0.jar"/>
	</path>
</target>

<property name="sylesheet.file" value="xsl/conv-pinyin-saxon10.xsl"/>

<target name="transform.template.common.jaxp" depends="build.project.class.path">
	<echo message="Input File=${input.file}"/>
	<echo message="Output File=${output.file}"/>
	<echo message="Stylesheet=${sylesheet.file}"/>
	<property name="classpath" refid="project.class.path"/>
	<xslt processor="trax" in="${dummy.input.file}" out="${output.file}" 
		style="${sylesheet.file}" classpathref="project.class.path" force="true">
		<factory name="net.sf.saxon.TransformerFactoryImpl">
			<attribute name="http://saxon.sf.net/feature/timing" value="true"/>
			<!-- Suppress namespace warning -->
			<attribute name="http://saxon.sf.net/feature/suppressXsltNamespaceCheck" value="true"/>
			<!--Assert-->
			<attribute name="http://saxon.sf.net/feature/enableAssertions" value="true"/>
			<!-- Trace -->
			<attribute name="http://saxon.sf.net/feature/traceListenerClass" value="net.sf.saxon.trace.XSLTTraceListener"/>
			<!-- Configuration File -->
			<attribute name="http://saxon.sf.net/feature/configuration-file" value="${basedir}${file.separator}saxon_config-10.xml"/>
			<!-- Initial Template -->
			<attribute name="http://saxon.sf.net/feature/initialTemplate" value="main"/>
		</factory>
		<param name="PRM_INPUT_FILE_URL" expression="${input.file.url}" if="input.file.url"/>
	</xslt>
</target>

オープンソース版のSaxon-HEを使用している人に朗報なのは、高階関数(High order function)やxsl:evaluate(XPath式の動的評価)も10.0からは使えるようになったことでしょう.

なにはともあれ新しい機能を紹介するのに動いてくれるSaxonがあるのは大変ありがたいものです.ちなみに前回紹介したタプルはさっそく言語仕様が変わっていて、以下のように":"でなくas=でフィールドの型を記述する必要があります.

[Saxon 9.xの書き方]

<xsl:function name="ahf:normalizePinyin" as="tuple(resultPinyin: xs:string, resultTone: xs:string)">

[Saxon 10.0の書き方]

<xsl:function name="ahf:normalizePinyin" as="tuple(resultPinyin as xs:string, resultTone as xs:string)">