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

Re: More on taming SAX (was Re: ANN: Amara XMLToolki


sax children
Alan Gutierrez wrote:

>* Jeff Rafter <lists@j...> [2004-12-23 13:43]:
>  
>
>>>While on the topic of SAX taming features in Amara, there is also
>>>amara.saxtools.xpattern_sax_state_machine, which I didn't even bother
>>>mentioning in the announcement (too much to cram in).
>>>      
>>>
>>Can you expand on your expansion? As I was reading this I was thinking 
>>that in the Java/C# world an interesting approach would be to keep a 
>>pseudo DOM stack for the event hierarchy. Maybe something where you keep 
>>everything at an ancestral level intact while parsing
>>
>>
>><foo>
>>  <bar1>
>>    <baz1/>
>>    <baz2/>
>>  </bar1>
>>  <bar2>
>>    <baz1>
>>      <sub/>
>>    </baz1>
>>    <baz2>text</baz2>
>>  </bar2>
>></foo>
>>
>>So when the event stream reached /foo/bar2/baz2/text() you would have 
>>the following in a DOM like structure:
>>
>>  foo
>>    \
>>     bar1 (... no children)
>>     bar2
>>       \
>>        baz1 (... no children, just the previous sibling and attrs)
>>        baz2 (only the StartTag)
>>
>>I am not sure that the preceding siblings would be very useful and have 
>>more chances for pathological cases but when I construct mini-trees this 
>>is the subset I find handy. It is useful when working with an editor to
>>understand the immediate context. Unfortunately by requiring the 
>>previous siblings you have to maintain quite a bit more... the whole 
>>preceding branch of the tree.
>>    
>>
>
>    I have a SAX library (in Java) that keeps the stack around, but
>    not the preceeding siblings. It is quite useful.
>
>    It is, actually, very useful to keep a stack around that has a
>    hash table for each level of the stack, it allows for the
>    devleopment of strategies that are themselves stateless.
>
>    Adding the implied stack goes a long way to make SAX event
>    processing a more practical solution for a lot of problems.
>  
>

Yes.  This is a useful technique I covered for Python in my article 
"Location, Location, Location 
<http://www.xml.com/pub/a/2004/11/24/py-xml.html>":

http://www.xml.com/pub/a/2004/11/24/py-xml.html

I think that while useful this technique can still leave a lot of state 
wrangling to the programmer, which is why Amara has several modules that 
go further.

-- 
Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Use CSS to display XML - http://www.ibm.com/developerworks/edu/x-dw-x-xmlcss-i.html
Full XML Indexes with Gnosis - http://www.xml.com/pub/a/2004/12/08/py-xml.html
Be humble, not imperial (in design) - http://www.adtmag.com/article.asp?id=10286
UBL 1.0 - http://www-106.ibm.com/developerworks/xml/library/x-think28.html
Use Universal Feed Parser to tame RSS - http://www.ibm.com/developerworks/xml/library/x-tipufp.html
Default and error handling in XSLT lookup tables - http://www.ibm.com/developerworks/xml/library/x-tiplook.html
A survey of XML standards - http://www-106.ibm.com/developerworks/xml/library/x-stand4/
The State of Python-XML in 2004 - http://www.xml.com/pub/a/2004/10/13/py-xml.html


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.