Altova Mailing List Archives


RE: [xml-dev] Streaming Transformations for XML

From: Michael Brennan <Michael_Brennan@-------.--->
To: "'Paul Prescod'" <paul@-------.--->, xml-dev@-----.---.---
Date: 2/14/2002 10:00:00 PM
> From: Paul Prescod [mailto:paul@p...]

<snip/>

> I did something like this once but I don't quit understand how you
> expect the rule to know when all of the variables are "fully 
> collected".
> In my model you had actions on the start event and end event. If you
> didn't have enough data by the end event then you were kind of out of
> luck. I'm curious about your model.

The model I was thinking of was similar. If the variables use XPath
expressions that only select along the child, descendant, or attribute axes,
then you can be assured that they are "fully collected" when the end event
for the node matching the template pattern is received.

For instance, something like:

 <template match="PersonInfo">
    <variable name="firstName" select="firstName"/>
    <variable name="id" select="@objectId"/>
    <variable name="zipCode" select="homeAddress/zipCode"/>
   ...
 </template>

This is a silly example, but I think it illustrates what I'm thinking
(though I have not pursued this line of thought in great depth). When you
get the end event for a "PersonInfo" element, you know that the variables
have collected all of the data relevant to this particular element. This
only works, of course, if you restrict the axes that can be used for
selecting the variables values (or at least have analyzed the expression and
know what axes are used). If you know what axes are used in the XPath
expressions, then it seems like it shouldn't be necessary to explicitly
define whether you want something to happen in the start event or end event.
For instance, if the variables only select along the attribute axis, then
you could fire off the action in the start event and you don't need to wait
for the end event. 

Two other key constraints, here. There are restrictions as to what axes can
be referenced in the "match" expression for the template. The idea is that a
stack is maintained keeping track of the ancestor nodes of each element for
matching purposes, but children are not automatically remembered (and
template matching is done in the start event for the element); so you can't
do something like include a predicate that selects along the child axis
(since it hasn't parsed that, yet, when an element is matched). You could
include a predicate, though, that filters based on attribute values. Also,
any action that gets fired only has access to data that has been collected
into a variable. There is no tree of nodes to traverse. 

As I mention above, I haven't pursued this line of thought in great depth.
This is just something I've been thinking about relatively recently, and
I've toyed with the idea of trying to use SAXPath[1] to implement something
like this. But I haven't seriously pursued it, at this point.

[1] http://www.saxpath.org

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.