M
mani
How can I now find the line number in the source XML file where this
node occurs?
node occurs?
How can I now find the line number in the source XML file where this
node occurs?
mani said:How can I now find the line number in the source XML file where this
node occurs?
It's a meaningless question. There are no line numbers in XML.
In this threadHow can I now find the line number in the source XML file where this
node occurs?
Really, Lew!
There are no line numbers in Java either, but somehow,
compilation messages that give line numbers are rather more useful
than messages without.
In this thread
Oli Charlesworth responded according to Arne,
CoolBeans responded according to Lew, and
Michael Kay responded according to Gene.
<http://boardreader.com/thread/Get_line_number_from_xml_node_java_5ft4kX2xcri.html>
Well, OK, if you wish. Although my comment wasn't intended as aOkay, I stand corrected.
Really, Lew!
There are no line numbers in Java either, but somehow,
compilation messages that give line numbers are rather more useful
than messages without.
Really, Gene!
By the time you have a DOM node in Java, there is no line number
information. Surely you are aware of that.
XML is explicitly a line-number-free format. Surely you are aware of that.
You can have the exact same XML document with various different line
breaks in whatever source you used. Surely you are aware of that.
Yes, you can associate line numbers from a particular expression of an
XML document with nodes in your tree, but that is meaningless because it
means nothing with other equivalent expressions. As surely you are aware.
A DOM (Document Object Model) is a tree-structured representation of an
XML document. There are no line numbers in a tree. Surely you are aware
of that.
Where line breaks occur between elements has no significance to XML, as
I'm so sure you are aware.
There may be a line number in a particular source file used to represent
an XML, but there really isn't a line number in the XML. To use your
lame analogy, a Java source file might have line numbers, but the
resulting class file doesn't. It might associate a line number from a
particular expression of that source in a debug map, but that isn't
going to help you know where the code is in an equivalent source module
with different line breaks.
My point was, really, Gene, that in a DOM the line numbers have no
significance. XML is frequently canonicalized, and "[a]ccording to the
W3C, if two XML documents have the same canonical form, then the two
documents are logically equivalent within the given application context
(except for limitations regarding a few unusual cases)."
<http://en.wikipedia.org/wiki/Canonical_XML>
Since XML is generally used to move information from one module or
component to another, the notion of line numbers between them becomes
utterly meaningless.
Really, Gene.
It's a meaningless question. There are no line numbers in XML.
Using what parser? W3C DOM? SAX? StAX? JDOM?
Given that OP asked for "line number in the source XML file" which
clearly exist and that a given node parsed from a given file start
at a particular line number, then all the lines above seems
utterly irrelevant.
Arne said:Given that OP asked for "line number in the source XML file" which
clearly exist and that a given node parsed from a given file start
at a particular line number, then all the lines above seems
utterly irrelevant.
It's a meaningless question. There are no line numbers in XML.
My installation of wc(1) begs to differ.
Aside from the fact that I've conceded the limits of my statement multiple
times before you posted, which apparently you've chosen to ignore in your rush
to seem clever, you completely missed my point.
Are there line numbers in a DOM tree?
No, of course not, and that's what I was trying to say. The line numbers don't
matter. What matters is the structure of the tree. Just like Java source line
Gene said:Lew wrote:
[snip]
Aside from the fact that I've conceded the limits of my statement multiple
times before you posted, which apparently you've chosen to ignore in your rush
to seem clever, you completely missed my point.
Odd use of "conceded" qwhen you continue to make your argument:
It depends on how you are looking at the data. If you are trying
track down an error, knowing what line the parser was working on when
it threw the error will usually help in locating the error.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.