You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Akacem Mohammed <Mo...@arbeitsamt.de> on 2002/11/25 09:31:02 UTC

Parser Problem in the charachter methode

	
Hello,

I have the following problem with the Saxparser (xercesImpl.jar , xmlParserAPIs.jar) in the following code snippet:



in a tag named proxyhost I am expecting the string "proxy.vz.ba.de"  but i get the string "pr" and then "oxy.vz.ba.de"

It seems that the call back methode below ( characters() ) is called more than once when the parser encounters the "proxyhost"  tag. 

public void  characters(char[] ch, int start, int length)

{
	
	 if (currentTag=="proxyhost")
   	 {

    		  System.out.println("SCHEMALOCATION");
      		String s= (new String(ch,start,length)).trim();
      		if(s.length()>0)
      			{
       	 	config.setProxyhost(s);   // confgig is a container object
     	 	}
      		
    }


}// methode end

I tried to solve the problem as follow, but this is not a good idea . has some one any better solution?

public void  characters(char[] ch, int start, int length)

{
	
	 if (currentTag=="proxyhost")
   	 {

      		String s= (new String(ch,start,length)).trim();
       		 if(s.length()>0)

       		 {
        		String temp=config.getProxyhost();   // confgig is a container object
       	 	if(temp!=null) config.setProxyhost(temp + s);
        		else config.setProxyhost(s);
        		}


    }


}// methode end



Thanks for any help

Mohammed



Re: Parser Problem in the charachter methode

Posted by Joseph Kesselman <ke...@us.ibm.com>.
This is a FAQ. SAX may break up a block of text into several calls to 
characters(). It is the SAX application's responsibility to handle this 
appropriately.

______________________________________
Joe Kesselman  / IBM Research