aspose file tools*
The moose likes XML and Related Technologies and the fly likes Stax problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Stax problem" Watch "Stax problem" New topic
Author

Stax problem

John Eric Hamacher
Ranch Hand

Joined: Apr 25, 2007
Posts: 230
Hello:

I'm using the implementation of Stax which comes with Java 6. My problem is about the Location object and when it cares to report location information. When I parse a file i'd like to be able to tell the user line numbers of data when there is a problem (e.g. if a certain number is out of range, I'd like to tell the user the line number of the piece of data in question). However, xmlStreamReader.getLocation().getLineNumber() never seems to return location information. So when does it? How can I coax this information out of stax when I need it?

Thanks, Eric




(Edited to make code not so wide - PC)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

Moving to our XML forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
Now I am curious - what does this statement return if not a line number?



Perhaps the xmlStreamReader does not track line numbers by itself and
you should enclose the FileReader in a java.io.LineNumberReader

Bill

Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stax problem
 
Similar Threads
problem with SJSXP implementation parsers
STAX Parser - Inconsistent performance for the same input file
Read and parse Flatpack xml file in java
MalformedURLException not understood
Edit cell with another JTable