users@jaxb.java.net

problem with SAX parser

From: logancillo <alonsoir_at_gmail.com>
Date: Thu, 18 Oct 2007 01:39:28 -0700 (PDT)

Good days, I have to try a xml file that potentially can be very big, for
that, i decided to do a parser sax. The idea is to have a principal parser
in whose(which) method startElement i`ll detect the entity and delegate the
processing to a specializing parser, like this:

Principal Parser

public class ParserPrincipalHandler extends DefaultHandler{


 private ViewBean viewBean;

//contains xml
    private String contenido;
//subparser
private ParserViewHandler parserViewHandler;

public void endElement (String namespaceURI, String localName, String
rawName)
                                                             throws
SAXException
    {
        //cuando hemos acabado de procesar todas las entidades, las aƱado a
una coleccion
        if (localName.equalsIgnoreCase("result")){
           
this.getColeccionEntidades().removeAll(this.getColeccionEntidades());
            this.getColeccionEntidades().add(viewBean);
        }
    }
    
    
    public void startElement(String nsURI, String strippedName,
                            String tagName, Attributes attributes)
       throws SAXException {
        
        if (tagName.equalsIgnoreCase("view")){
            procesarEntidadView(attributes);
        }
        
    }
    private void procesarEntidadView(Attributes attributes) throws
SAXException{

        if (this.viewBean == null){
            this.viewBean = new ViewBean();
        }
        XMLReader parser = XMLReaderFactory.createXMLReader();
        parserViewHandler= new ParserViewHandler(parser,this,this.viewBean);
        parserViewHandler.setContenido(getContenido());
        synchronized(parserViewHandler){
            try {
                parserViewHandler.list();
            } catch (Exception e){
                throw new SAXException(e.getMessage());
            }finally {
                if (isMostrarLog()){
                    System.out.println("finally viewBean.getErrcode..." +
viewBean.getErrcode());
                    System.out.println("finally
viewBean.getErrapplication..." + viewBean.getErrapplication());
                    System.out.println("finally viewBean.getErrmessage..." +
viewBean.getErrmessage());
                    for(Iterator it=
this.viewBean.getContainerBean().getWidgetList().iterator();it.hasNext();){
                        WidgetBean nodo = (WidgetBean) it.next();
                        System.out.println("nodo.getDynamic(): " +
nodo.getDynamic());
                        System.out.println("nodo.getId(): " + nodo.getId());
                        System.out.println("nodo.getName(): " +
nodo.getName());
                        System.out.println("nodo.getPreload(): " +
nodo.getPreload());
                        System.out.println("nodo.getResource(): " +
nodo.getResource());
                    }
                }
                
            }
        }
    }

Since they can see, I have to spend(pass) the content of the whole xml to
the subparser and what I want to know is to be able to pass the chunk of the
xml to the subparser. Is it possible?

Thank you for reading hitherto.
-- 
View this message in context: http://www.nabble.com/problem-with-SAX-parser-tf4645623.html#a13270373
Sent from the java.net - jaxb users mailing list archive at Nabble.com.