Reputation: 105
Assume I have simple schema that uses xs:sequence (not xs:all).
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="mynamespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="mynamespace" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="RepeatingElement" type="repeatingElementType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="repeatingElementType">
<xs:sequence>
<xs:element name="FirstElement" type="xs:string"/>
<xs:element name="SecondElement" type="xs:string"/>
<xs:element name="ThirdElement" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
I then write a schema-aware transform, that consumes the nodes in sequential order.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:n1="mynamespace" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:mode streamable="yes"/>
<xsl:import-schema namespace="mynamespace" schema-location="sampleSchema.xsd"></xsl:import-schema>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="element(*, n1:repeatingElementType)">
<xsl:value-of select="n1:FirstElement" />
<xsl:value-of select="n1:SecondElement" />
<xsl:value-of select="n1:ThirdElement" />
</xsl:template>
</xsl:stylesheet>
Right now, streaming engines (i.e. SAXON) will throw an error.
Template rule is declared streamable but it does not satisfy the streamability rules. * There is more than one consuming operand: {xsl:value-of} on line 10, and {xsl:value-of} on line 11
Given the engine knows the order the elements can appear, shouldn't it be able to determine during analysis phase that the style-sheet is streamable?
Upvotes: 0
Views: 81
Reputation: 163458
The streamability analysis built in to the XSLT 3.0 spec, and implemented in Saxon, does not take account of any knowledge of sibling order that might come from schema knowledge. It could be done in theory, but the rules would get very complex to handle any but the most simple cases. (Consider, for example, an xsl:choose
in the stylesheet that corresponds structurally to an xs:choice
in the schema...) The WG made an early decision to exclude that from the scope.
Upvotes: 2