Jump to content

Streaming Transformations for XML

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 203.173.188.111 (talk) at 10:12, 25 December 2005 (Clarifying typical uses of STX -- emphasising that it's not a general purpose transformation language). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Streaming Transformations for XML (STX) is an XML transformation language intended as a high-speed, low memory consumption alternative to XSLT.

Introduction

STX is an XML standard for efficient processing of stream-based XML. As we will discover XSLT is not well suited to stream based processing and STX fills this niche.

Conventional XML processing involves loading the entire XML document into memory for use. This is as opposed to SAX which streams XML events such as "open element" "close element" "text node" (and so on) so that other software that can begin interpreting these immediately -- before the end of the file is reached. Unfortunately some software can't effectively use individual XML segments this way and must stockpile the events to build up the whole document and then begin processing. So is the case with XSLT. Because XSLT's XPath can select any node throughout the document it must have the entire document available in memory. This could be perceived as a bottleneck.

STX only allows queries based on nodes immediately surrounding the current node. This architectural decision means that STX is faster than XSLT and it can start transforming and outputting SAX event nodes as they arrive. Also, as it can discard nodes immediately after processing the memory use is significantly lower than that of XSLT.

These limitations in the query language intentionally marginalise STX as a niche language. Indeed, it would be wrong to say that STX is a general purpose transformation language however if your transformation needs can be met by STX then it's an efficient and smart choice.

Standards

STX's query language is called STXPath.

Implementations of STX are available in Java and Perl.

Similar projects

Unlike STX which is declared using an XML syntax, these two projects associate SAX events with callback functions.