0

help me that i am working in a sax parser project. it moves inside start and end document but not into start and end element.

2
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by Samudricka
0

Let me ask you a question. Why should we helping you when what you always does is drop a general question and demand answers, do not provide any supporting coding with the task you facing? Not even the part of code that you having problem with...
Do not take it wrong, but if you not make it easier for us to understand what exactly is the problem we can come with many suggestions that will lead to different outcomes. Just look back to your post http connection.

0
public void startSax( String xmlBlkStr) {
        try {
            //
            // turn it into an in-memory object.
            //
            //Parser parser;
           
            byte xmlByteAray[];
            ByteArrayInputStream byteStrm = null;
            InputSource xmlBlk = null;
            xmlByteAray = xmlBlkStr.getBytes();
            if(xmlByteAray!=null) {
                byteStrm = new ByteArrayInputStream(xmlByteAray);
                if(byteStrm!=null) {
                    xmlBlk = new InputSource(byteStrm);
                    SAXParserFactory spf = SAXParserFactory.newInstance();
                    SAXParser sp= spf.newSAXParser();
                    //String validation = System.getProperty( "javax.xml.parsers.validation", "false");
                     
                   //if (validation.equalsIgnoreCase("true"))
                        spf.setValidating(true);
                     sp.parse(xmlBlk,new  saxparser());
           //          sp.parse(xmlBlk, new  SaxErrorHandler());
                     //parser = sp.getParser();
                    //parser.setDocumentHandler(new saxparser());
                    //parser.setErrorHandler(new SaxErrorHandler());
                   // parser.parse(xmlBlk);
                }
            }
            
        } catch (SAXParseException err) {
           // PIPDebug.debugMsg("###Parsing error see teh XMLBlkStr " + xmlBlkStr);
          //  PIPDebug.debugMsg("** Parsing error"
                   // + ", line " + err.getLineNumber()
                  //  + ", uri " + err.getSystemId());
           // PIPDebug.debugMsg("   " + err.getMessage());
            
        } catch (SAXException e) {
            Exception	x = e;
            //if (e.getException() != null)
               // x = e.getException();
            x.printStackTrace();
            
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
    ......................................

  class saxparser extends DefaultHandler
 {
       
             public void startDocument()throws SAXException  {
        //PIPDebug.debugMsg("Document Start...");
             System.out.println("Document Start...");
             
        }
        
        public void startElement(String name,  Attributes atts)throws SAXException  {
             System.out.println("parsing...");
            processTag(name, true, atts);
        }
        public void characters(char[] ch, int start, int length)throws SAXException {
            if((getIFQry || getSQLQry || getColVal) && (length > 0))
                theValue.append(ch,start,length);
        }
           public void endElement(String name)throws SAXException  {
              
            processTag(name, false, null);
        }
            public void endDocument()throws SAXException  {
              
            System.out.println("Inside endDocument...");
        }
    }

SORRY FOR BEFORE MISTAKE HERE I HAVE GIVEN PART OF CODING...................

0

hi ,

i have solved my problem since if you noticed i would not have changed a main point that is as i have given below now it is working,.................. public void startElement(String name,String localName, String qname, Attributes atts)throws SAXException {...............}

0

now there si new problem that i get following error..........java.lang.NullPointerException
and i have found reason since start element variable is of void type.......can we change it into return type .........thanks in advance...........
my code is below

.................public void startElement(String name,String localName, String qname, Attributes atts)throws SAXException  { 
            processTag(qname, true, atts);
           stack.push(qname);
           System.out.println("Append--->"+ name+"-->"+qname+" -->"+atts);
             // System.out.println(p.accept.append("i"));
          [B] p.accept.append("Append--->"+ name+"-->"+qname+" -->"+atts);[/B]          /* if(qname.equals("ROW")){
                mid.accept.append("qname-->"+qname);
               
            }*/
           
        }........................

it is part of it whereas other values arebelow..........

public port p;..........midlet class........
public Form accept;...............

the error is shown around bold and in midlet class there is no void type methods..........

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.