Byron Ellacott
bje at apnic.net
Fri Aug 20 11:18:19 EDT 2004
(combined responses, this thread is probably getting too offtopic...) Scott Sanders wrote: Nic Ferrier wrote: [I believe you both told me it's possible to stream data through an XSLT processor; please correct me if this is not what you meant!] My basic problem here is that there are trivial XSLT fragments that may not be determinable until the entire source document has been read. Consider <xsl:if test="/foo/bar">There is a bar element</xsl:if>. In this example, a source document may have no bar elements at all, or it may have a bar element as the very last element before closing the root foo element. An XSLT processor cannot distinguish these cases until the root element has been closed. If the bar element appeared earlier in the document, a sufficiently clever XSLT processor could continue processing as soon as that element was encountered, but this falls down when you consider: <xsl:for-each select="/foo/bar">Another bar found</xsl:for-each> In this case, processing must be halted until the root element has been closed, since another bar element may be encountered at any time. Once again, a clever processor could continue processing, storing tree fragments for later use, but it could not output any further elements until it was satisfied that the xsl:for-each had completed. So, I can see how a sufficiently clever XSLT processor could stream output where possible, but this requires the stylesheet author to carefully avoid any construct that would cause output to block. Most notably, any XPath expression used to control transformation that cannot be sufficiently evaluated until the document is fully parsed must be avoided, and for any non-trivial use of XSLT, this is, to say the least, a hard task. If I'm missing something here, please fill me in, because I am in the process of recommending an XML/XSLT approach to web development here at work, and I'd love to strike out the cost to perceived response times associated with a document transformation. -- bje
|