[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Streaming XSL Stylesheets - Was: XML::Writer 0.1 available

  • From: "Eric Prud'hommeaux" <eric@w...>
  • To: Perl-XML Mailing List <perl-xml@l...>, xml-dev <xml-dev@i...>
  • Date: Tue, 20 Apr 1999 07:47:04 -0400

xsl writer
On Mon, Apr 19, 1999 at 10:02:56PM -0400, David Megginson wrote:
> XSL provides one good and very powerful model for doing XML
> transformations, but that model itself requires that an entire
> document be held in random-access storage of some sort (say, memory,
> or a database) during processing, and that's inappropriate for the
> very large subset of XML work that is both speed- and memory-critical.

I'd love to differ with you here. In practice, I can't, but in
theory... I have this itch to work out and implemnt an XSL parser that
works as as a SAX stream. Given an XslStream that reads the parsed
stylesheet from an XslDB and has an output SAX stream $this->{OUTPUT},
the notion is something like this:

parser reads "<someTag attr1='value1'>"

calls W3C::SAX::XslStream::startElement

XslStream checks is XslDB for a list of all rules that could apply to
'someTag' and finds only a single template:
  <xsl:template match="someTag[@attr1=value1]">
    <innerTag>
      <xsl::apply-templates>
    </innerTag>
  </xsl:template>
This tells it that there is no ambiguity or ordering so it can call
$this->{OUTPUT}->startElement('innerTag', new AttributeList)

That's the ideal case, but XSL accomodates many situations where it's
not that easy.  Since XSL defines sorting and sequencing, it is
possible to arrive in at a rule that cannot be immediately sent to the
output stream, like:

  <xsl:template match="someTag[@attr1=value1]">
    <tagA>
      <xsl::apply-templates match="As">
    </tagA>
    <tagB>
      <xsl::apply-templates match="Bs">
    </tagB>
  </xsl:template>

In this case, the stream can dump output the tagA immediately, and
stick the tagB in an event queue (or maybe just a grove) to be flushed
when W3C::SAX::XslStream::endElement('someTag') is called.

If the XML document contains long series of atoms that the stylesheet
says do not need to be ordered, the transformed document can be
generated as the document is parsed. For instance:

DOCUMENT:
<molecule>
  <atom>
    <symbol>Ne</symbol>
    <positions>
      <orbital>s</orbital>
      <shell>1</shell>
      <count>2</count>
    </positions>
    <positions>
      <orbital>s</orbital>
      <shell>2</shell>
      <count>2</count>
    </positions>
    <positions>
      <orbital>p</orbital>
      <shell>2</shell>
      <count>6</count>
    </positions>
  </atom>
  <atom>...</atom>
  <!-- and a zillion more atoms -->
</molecule>

XSL STYLESHEET:
<xsl:template match="atom">
  <xhtml:h1>The Atoms...</xhtml:h1>
  <xhtml:ul>
    <xsl:apply-templates select="positions">
      <xsl:sort select="orbital"/>
      <xsl:sort select="shell"/>
    </xsl:apply-templates>
  </xhtml:ul>
</xsl:template>
<!-- some more templates for specifying how the positions are rendered -->

The sort on the positions causes the XslStream to buffer the output
for each position until the /position is hit, but it still gets to
flush the atoms basicly as fast as they come in.

I see lots of folks talking about using XML for moving vast streams of
business process data. I beleive this sort of mechanism will make all
that pheasible without have to write custom translation engines for
this data. I have sketched out the players in perl (XslParser, XslDB,
XslStream) but haven't started the real work of coding the
transformations and when it can flush and when it can't. Anybody out
there interested in taking this over?
-- 
-eric

(eric@w...)

PS. If the chemistry-looking stuff above is wrong, it's because I'm
    not now, nor ever intended to be, a physical chemist.

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.