How to get Apache Axiom to correctly report source data line numbers when parsing XML

KevinC

New Member
Here's what I'm doing, essentially copy/paste:ing from the Axiom Quickstart documentation:\[code\]public GenericXmlParser(Reader input, String entryElementName, List<DciXmlMapping> dciXmlMappings) { this.input = OMXMLBuilderFactory.createOMBuilder(input).getDocument().getXMLStreamReader(false); this.dciXmlMappings = dciXmlMappings; this.entryElementName = new QName(entryElementName);}public FeedEntry next() { try { while (input.hasNext()) { if (input.getEventType() == XMLStreamReader.START_ELEMENT && input.getName().equals(entryElementName)) { OMElement element = OMXMLBuilderFactory.createStAXOMBuilder(input).getDocumentElement(); // Make sure that all events belonging to the element are consumed so that // that the XMLStreamReader points to a well defined location (namely the // event immediately following the END_ELEMENT event). element.build(); // Now process the element. return new FeedEntry(element.getLineNumber(), processEntryElement(element), ImmutableList.<String>of()); } input.next(); } return null; } catch (XMLStreamException e) { throw new ImpException(e); }}\[/code\]This works, but the problem is, the line number returned by the element.getLineNumber() always seems to be -1. There's not a lot of documentation on the getLineNumber() method, and it's not easy to find the place where a line number is expected to be defined in the source code. Is there some additional configuration I need to do in order to get Axiom to track line numbers?
 
Back
Top