• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I tried find the BUG in this SAX PARSER But NO-RESULT:

 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried find the BUG in this SAX PARSER But NO-RESULT:

line 102: output("\nName:" + searchname +.... //searchname goes to output SUCCESS (endDocument())
......................................
line 149: if (getRest==1 && state == 2) // endElement()
line 150: searchname=str; // this [u]does not go[/u] to line 102

Can you help?

what files allowed to attach, you can find sax.zip at http://www.poliscarhire.com/js/sax.zip [2KB]
contains java and xml files...
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What language are those code fragments in?

What do those fragments have to do with a SAX parser?

Bill
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java, see code in zip in url....
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't expect us to download and unzip that file, do you really? If you have a question about some code, then post it here. And if that code is very long, just post the relevant parts of it.
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have review file for 45min and also Netbeans does not highlight errors in code, is about 170 lines with comments, and I think is the only way find the bug...

otherwise see below:

[code] public void endDocument( ) throws SAXException {
try {
// Write newline character and then flush the output
newLine( );
writer.flush( );
// Display total number of plant tags encountered
output("Total number of different plants was: "
+ j);
//output("\nMinimum on hand balance is: " + min + " for plant " + minPlant);
output("\nName:" + searchname +
"\nOnHand:" + searchonHand +
"\nSci Name:" +searchscientificName+
"\ncolor:" + searchcolor); //searchonHand

} catch (IOException e) {
throw new SAXException("I/O error", e);
}
} // end of method endDocument
[/code]

[code] public void endElement(String namespaceURI,
String sName, String qName) throws SAXException {



if (state == 2 && searchname.equals(str))
getRest=1;

if (state == 2 && !searchname.equals(str))
getRest=0;

if (getRest==1 && state == 1) // here error does not go to endDocument( )
searchonHand=str; // if put eg str="ccc" does not go , so error on the way towards: line 102 endDocument( )

if (getRest==1 && state == 2)
searchname=str;

if (getRest==1 && state == 3)
searchscientificName=str;

if (getRest==1 && state == 4)
searchcolor=str;

} // end of method endElement [/code]
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please try to concisely state what you expected your program to do and what it actually does.

These code fragments are not helping.

I recommend Harold's free online XML and Java tutorial. At least read the SAX chapter.

Bill
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
run as
java FindPlant nameofplan
eg. nameofplan=Violet
to get below info for this nameofplan along with other data ...problem: does not get the below data?
Name:
OnHand:
Sci Name:
color:
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where in the program is the String from the command line used?

Showing a sketch of the endDocument event handler has nothing whatsoever to do with solving the problem.
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


[code]
.......................
static public String searchname = " ";
static public String searchscientificName = " ";
static public String searchonHand = " ";
static public String searchcolor = " ";
.......................
if (args.length !=1)
{
System.out.print("enter a plant name");
System.exit(1);
} else
searchname = args[0];
.......................
[/code]
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You know what?

I give up - I have helped teach a lot of people Java but usually they made an effort to listen to what I wrote.

Good luck!
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Netbeans does not highlight errors in code and I found no bug but stills do NOT give me the 4 values, well I know elementary Java , some Adv concepts, JSP/Servlets also get diploma(x3) from javaonline.org on java/adv java/jsp....
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic