[
Lists Home |
Date Index |
Thread Index
]
Karl Waclawek wrote:
>
> Jeff Rafter wrote:
>
>> Karl Waclawek has done some work in this area in both Delphi and C#
>> in his toolkit XPEA. But I am sure he will take some ideas from this
>> thread as well... it is all very interesting.
>
>
> Well, XPEA really is a very low level way of building
> some pattern matching on top of SAX (or other push APIs).
> Predicate processing as well as attribute matching is done
> through call-backs.
Pleased to meet someone as intent on bending their brain as I am.
> I am not a big believer in inventing
> new languages - my ambitions are a lot more modest.
Just to be sure there's no misunderstanding, no one on this thread has
aid anything about inventing a new language, right? As I clarified,
"XPattern" is merely the older name for XSLT patterns, defined in XSLT 1.0.
> Example (C# 2.0 syntax):
>
> IXmlReader reader;
> ...
> SaxPathDispatcher<EventStatus> disp = new
> SaxPathDispatcher<EventStatus>();
> disp.AttachTo(reader);
> /* Path related set-up */
> Div1Handler div1 = new Div1Handler(...);
> Div2Handler div2 = new Div2Handler(...);
> BasicPathFactory pathFactory = new BasicPathFactory(...);
> // Add path with call-back arguments: "/spec/*//div1[div1]/div2[div2]"
> BasicPath path = pathFactory.Create("/spec/*//div1[0]/div2[1]",
> div1, div2);
> path.AddTo(disp.Paths);
> ...
> reader.Parse(input);
>
> Div1Handler and Div2Handler are implementations of the IElementHandler
> interface and their events are called when they match the path above.
I suspect you mean "match the XSLT pattern" as well, and just don't know
it :-)
It's not all that meaningful to "match" an "XPath".
> Really just one step more than SAX. I use it for writing SAX-based
> transformations.
Seems very similar to amara.saxtools.xpattern_sax_state_machine, but
rather than call-backs to the handler, the state machine object just
maintains a list of patterns matched in the current node. The SAX
handler can check this list at its leisure. I find this is a bit more
flexible.
--
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
|