[XSLT2.0] PSVI, XPath, and optimization

I have a question about the interaction between the PSVI and XPath 2.0.
If I understand things correctly, a schema-aware XSLT processor is supposed
to respect the PSVI annotations on the original XML tree.  Leaving aside
questions as to how those annotations are to be transmitted, I think this
will prevent a serious performance hurdle to XSLT transformers, especially
highly optimizing transformers.

Let's use an example stylesheet with only one template:

	<xsl:template match="top">
		<xsl:value-of select="a+b"/>
	</xsl:template>


Now, assume that it is fed this input doc.  I'm using xsi:type attributes
to indicate the PSVI typing information, though of course it could have
come from a schema or some other source:

	<top>
		<a xsi:type="xs:integer">22</a>
		<b xsi:type="xs:integer">44</b>
	</top>

I would assume the output of this execution is '66'.  On the other hand,
if we fed it this input document:


	<top>
		<!-- Note: I can't remember the syntax for schema dates
		and durations off the top of my head, so forgive my informal
		notation here -->
		<a xsi:type="xs:gDate">Mar 20, 2003</a>
		<b xsi:type="xs:duration">1 month</b>
	</top>

Am I correct that we would expect the output to be "Apr 20, 2003" (or
something similar, I forget the details of duration+date addition)?

If so, that's a real drag.  It used to be possible to determine statically
the types of almost every expression in a stylesheet.  The only exception
were parameters, where it was possible to pass parameters of two different
types to a single template.

For a highly optimizing XSLT engine, that allowed you to avoid the overhead
of dynamic typing in places where it wasn't needed.  In my experience, this
can be a very big deal.

I understand that the committee is committed to schema typing in XSLT 2.0.
I would suggest, however, that it not be the default behavior, but that the
user specifically request that PSVI annotations be respected.  At a minimum,
you could have an attribute that specifically stated that PSVI annotations
be disregarded, which would allow the engine to optimize more aggressively.

I know that the working group has gone to great pains to ensure that all
expressions behave naturally when no typing information is available, but
I'm not sure that you've considered the ramifications to performance of
making schema annotations enabled by default.



Thanks,

Niko Matsakis
DataPower Technology

Received on Thursday, 13 November 2003 09:01:52 UTC