Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Reading XML

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The name of this question is Reading xml
Hello and Thank you in advance for any assistance.


System info:Netbeans

netbeans,glassfish,MySQL

The Purpose of this post is:

learn how to read XML into program.


The functionality of this code is:

To use the stack.push() to put XML elements in it and output XML elements System.out.println

My question is:

I do not understand stack.push(). It says it found the zooinventory.xml but the SAXModelBuider.java is not putting them on the stack.

The errors related to this code are:



Code description:

TestModelBuilder.java (main())



Code description

SAXModelBuilder.java (push elements to the stack)


Thanks again.
-ceyesumma

Note:
………………………………………………………………………………………………

Code description


 
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 a mess -
for example, in the loop at line 39 you

repeatedly push the same element, once for each attribute.

In line 46 and 58 you pop the stack without checking to see if it is empty.

If this is your first SAX program I suggest you start with something simpler.

For example, just doing a System.out.println in each of the event methods to verify that the events contain what you expect.

Bill
Note that we have an XML forum where this really belongs.
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:
Bill
Note that we have an XML forum where this really belongs.



XML and Related Technologies forum we go.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code is pretty difficult to understand... that setProperty method is impossible.

For example, if the method starts with "add", what ever happens? As far as I can tell, nothing.
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I apologize. I did not see the XML forum.

The program is an example from a book. I thought the class was responsible for putting elements from the XML on the stack. It has several more classes. I was under the impression that it works sense everything compiled. I was trying to find out if it would run but it starts by saying nothing is on the stack. I will continue working with it to see if I can figure out how it works.
I'll look for the XML forum I did not see it.

Thanks
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's the one that starts with "XML"--the post has already been moved.

Let this be a reminder--just because something compiles doesn't mean it does what we want!
 
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

The program is an example from a book.



If that is indeed a direct quote from the book, you should demand your money back. Not only does it have the errors various ranchers have pointed out, it is needlessly complicated for capture of SAX event data.

Bill
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://onjava.com/pub/a/onjava/excerpt/learnjava_23/index2.html?page=2

It's from the 2002 Learning Java O'Reilly book.
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I never figured out why the stack().push did work thanks though.

I just re wrote it to push elements into the array. works good enough for now. Thanks for all your time.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic