There is an updated version of XML Addon at
    http://olegykj.sourceforge.net/

More at extended notes document
    http://olegykj.sourceforge.net/addons/xml.html

 - example with character data
 - added stop parsing feature for found data and application errors
 - uses j601 dll call enhancements



There is an idea of having a visitor pattern 
with context handlers similar to the XSLT template 
XPath match, but with the natural limitations of SAX parsing
(only current stack contents, not full DOM).
Let me know if anybody is interested.

The handlers would look like this (see protoype below):

'one/two' match 'do stuff...'

'one[../@a="qq"]/[EMAIL PROTECTED]"zz"]/three' match 0
  do stuff...
)

What is required is a parser of XPath.


NB. =========================================================

MAT=: ''
PRF=: 'tmpl'
erase PRF nl ''

add=:   3 : 'MAT=: MAT,<y'
match=: 2 : '(PRF,":<:#add m) =: (3 : n)'
try=:   3 : 0
  if. (#MAT) <: i=.MAT i.boxopen y do. _1 return. end.
  (PRF,":i)~ ''
)

NB. =========================================================
'qq' match 0
  smoutput 0
)
'zz' match 0
  smoutput 1
)
'a/b' match 'smoutput 2'

try 'qq'
try 'a/b'
try 'aa'


--- Oleg Kobchenko <[EMAIL PROTECTED]> wrote:

> Gilles,
> 
> SAX XML parsing works within the "push" model, i.e.
> the API calls you. You provide the callback functions 
> by overriding the base class, see saxclass definition.
> For the XML nodes events, these functions are called on,
> thus yielding a "visitor" design pattern.
> 
> In your class you maintain the state and selectively
> process the events. The event for text between tags
> is called "characters".
> It is demoed in the "table" and "rss" examples.
> 
> In "rss" example, a simple stack of nested elements is
> maintained in the "S" list. Then "characters" processes
> the text accroding to the current context.
> 
> You can pass the result for "process" in the
> output of "endDocument", which is the last event called.
> 
> 
> --- Gilles Kirouac <[EMAIL PROTECTED]> wrote:
> 
> > Oleg Kobchenko has published an XML addon to parse XML data; 
> > see Oleg's J Page http://olegykj.sourceforge.net/ where 
> > you can find many useful utilities.
> > 
> > After studying the given examples, I tried
> > 
> >    process_psax2_ '<root><P>Hi!</P></root>'
> > [root ]
> >   [P ]
> >   [/P]
> > [/root]
> > 
> > This is the expected result.
> > 
> > I also studied the chess data example.
> > 
> > But I have not found how to extract data 
> > between the start and end tags such as in the example above.
> > 
> > A little help would be most useful!
> > 
> > Gilles


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to