Project

Profile

Help

Does fn:transform support schema-aware streaming with source-location?

Added by Martin Honnen over 3 years ago

I was looking deeper into using fn:transform with the source-location option and from tests it seems that using source-location and xsl:mode streamable="yes" Saxon (tested with EE 10.3 J) does use streaming but if you throw in the vendor option to do strict validation 'vendor-options': map { QName('http://saxon.sf.net/', 'schema-validation'): 'strict' } the code is run without streaming where the -t option indeed also shows

Warning
  SXWN9000  The unnamed mode is streamable, but the input is not supplied as a stream

Example XSLT run with -it is

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="#all"
    version="3.0">

    <xsl:output indent="yes"/>

    <xsl:template name="xsl:initial-template">
        <xsl:sequence select="
                transform(
                map {
                    'source-location': 'sample1.xml',
                    'stylesheet-location': 'streamable-validation-test1.xsl',
                    'vendor-options': map {
                        QName('http://saxon.sf.net/', 'schema-validation'): 'strict'
                    }
                }
                )?output"/>
    </xsl:template>

</xsl:stylesheet>

I don't know if the EE implementation of fn:transform is the same as the HE but that one indeed seems to build a tree in https://saxonica.plan.io/projects/saxon/repository/he/revisions/master/entry/latest10/hej/net/sf/saxon/functions/TransformFn.java#L749 if validation options are passed in.

Is there no way to use fn:transform with streaming and schema-aware validation?


Replies (1)

RE: Does fn:transform support schema-aware streaming with source-location? - Added by Martin Honnen over 3 years ago

A further tests suggests that using a config file instead does use streaming and validation:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="#all"
    version="3.0">

    <xsl:output indent="yes"/>
    
    <xsl:param name="config">
        <configuration xmlns="http://saxon.sf.net/ns/configuration" edition="EE">
            <global schemaValidation="strict"/>
        </configuration>
    </xsl:param>

    <xsl:template name="xsl:initial-template">
        <xsl:sequence select="
                transform(
                map {
                    'source-location': 'sample1.xml',
                    'stylesheet-location': 'streamable-validation-test1.xsl',
                    'vendor-options': map {
                        QName('http://saxon.sf.net/', 'configuration'): $config
                    }
                }
                )?output"/>
    </xsl:template>

</xsl:stylesheet>

Not quite, however, as I don't get any message about the parsing, neither "streaming" nor "building tree for".

    (1-1/1)

    Please register to reply