I've got XML and code to parse it, for example:
require 'xml/sax/sax'
saxclass 'psax2'
startDocument=: 3 : 0
L=: 0
BAD_base_=: IXNM_base_=: IXV_base_=: ''
PDV_base_=: ATR_base_=: 0 0$<''
PD=: ''
PDNMS=:
'performance_date';'index_return';'index_value';'num_constituents';'index_assets'
)
startElement=: 4 : 0
L=: L+1
select. y
case. 'index' do.
if. 0~:#IXV_base_ do. ATR_base_=: ATR_base_,IXV_base_
IXV_base_=: a:$~#IXNM_base_ end.
case. 'performance_data' do. PD=: a:$~>:#PDNMS
case. PDNMS do. PD=: (<x) (PDNMS i. y)}PD
case. IXNM_base_ do. IXV_base_=: (<x) (IXNM_base_ i. y)}IXV_base_
case. do. IXNM_base_=: IXNM_base_,<y[IXV_base_=: IXV_base_,<x
end.
)
endElement=: 3 : 0
L=: L-1
select. y
fcase. 'index' do. ATR_base_=: ATR_base_,IXV_base_
IXV_base_=: a:$~#IXNM_base_
case. 'performance_data' do. PDV_base_=: PDV_base_,PD
PD=: a:$~>:#PDNMS NB. Unknowns at end.
case. PDNMS do.
case. IXNM_base_ do. smoutput y
case. do. BAD_base_=: BAD_base_,<y
end.
)
sampleIx1=: 0 : 0
<?xml version='1.0' encoding='ISO-8859-1'?>
<MSCIHedgeFundIndexInfo ExtractDate='2008/05/26' ExtractTime='06:37:51'>
<index>
<msci_index_code>900671</msci_index_code>
<indexname>Discretionary Trading</indexname>
<inceptiondate>2001/12/31</inceptiondate>
<inceptionvalue>1000</inceptionvalue>
<performance_data>
<performance_date>1994/01/31</performance_date>
<index_return>-0.003838</index_return>
<index_value>401.710</index_value>
<num_constituents>9</num_constituents>
<index_assets>527853620</index_assets>
</performance_data>
<performance_data>
<performance_date>1994/02/28</performance_date>
<index_return>-0.005904</index_return>
<index_value>399.338</index_value>
<num_constituents>9</num_constituents>
<index_assets>532669357</index_assets>
</performance_data>
</index>
</MSCIHedgeFundIndexInfo>
)
I get results like this:
IXV_base_
++++++
||||||
++++++
ATR_base_
+--------+--------+--------+--------+--------+
|51799256| | | | |
+--------+--------+--------+--------+--------+
| |51799256|51799256|51799256|51799256|
+--------+--------+--------+--------+--------+
BAD_base_
PDV_base_
++++++--------+
||||||51799256|
++++++--------+
||||||51799256|
++++++--------+
|||||| |
++++++--------+
On more extensive data, I got similar results but with a slightly different
long number (which looks like it might be a pointer value or something).
Anyway, I'm completely confused and thought it might be clearer with another
package.
Thanks,
Devon
On 5/31/08, Oleg Kobchenko <[EMAIL PROTECTED]> wrote:
>
> For some apps XSLT is better. What sort of trouble?
>
>
>
> --- On Thu, 5/29/08, Devon McCormick <[EMAIL PROTECTED]> wrote:
>
> > Members of the Forum -
> >
> > has anyone used the XML addon "sax"? I'm
> > having trouble with it. Is "xlst"
> > better?
> >
> > Thanks,
> >
> > Devon
> >
> > --
> > Devon McCormick, CFA
> > ^me^ at acm.
> > org is my
> > preferred e-mail
>
> > ----------------------------------------------------------------------
> > For information about J forums see
> > http://www.jsoftware.com/forums.htm
>
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm