Chapter 4ext:xinclude in XSLT

SInclude ships with a Saxon extension function to perform XInclude processing from XSLT: ext:xinclude.

To use it, bind the ext prefix (or any prefix you prefer) to the http://nwalsh.com/xslt1.

To make the function available within Saxon, make sure that the SInclude jar file is on your class path and then use the Saxon -init option to register the function: -init:com.nwalsh.xslt.Register. (This step allows the extension function to work in Saxon-HE.)

Call the function, for example in xsl:sequence:

  |<xsl:sequence select="ext:xinclude(., map { 'fixup-xml-base': false(),
  |                                            'trim-text': true() })"/>

Three boolean options are supported:

fixup-xml-base

To enable xml:base fixup.

fixup-xml-lang

To enable xml:lang fixup.

trim-text

If the trim-text option is true, when a text inclusion is performed, leading and trailing whitespace will be trimmed off of each line.

The amount of leading whitespace trimmed will be adjusted so that the least-indented line is flush left. All trailing whitespace is removed.