Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #12203

Re: java get xml file line number for the current node

From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.programmer
Subject Re: java get xml file line number for the current node
Date 2012-02-20 14:42 -0800
Organization albasani.net
Message-ID <jhui9a$tdl$1@news.albasani.net> (permalink)
References <d3efe9cf-d789-4534-9087-236810197fea@p2g2000pbb.googlegroups.com> <jhu8la$90c$3@news.albasani.net> <r0f5k71t6b8b4daa2ii91l60blcvahruak@4ax.com>

Show all headers | View raw


On 02/20/2012 01:35 PM, Gene Wirchenko wrote:
> On Mon, 20 Feb 2012 11:58:34 -0800, Lew<noone@lewscanon.com>  wrote:
>
>> mani wrote:
>>> 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.
>
>       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.

Perhaps if the OP were to explain how they contemplate using line numbers, and 
how they plan to assure the numbers have meaning, and why they have to persist 
all the way into the DOM where they really have no relevance, things would 
become more clear.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

java get xml file line number for the current node mani <mekalai82@gmail.com> - 2012-02-20 02:50 -0800
  Re: java get xml file line number for the current node Arne Vajhøj <arne@vajhoej.dk> - 2012-02-20 09:32 -0500
    Re: java get xml file line number for the current node Arne Vajhøj <arne@vajhoej.dk> - 2012-02-20 19:59 -0500
  Re: java get xml file line number for the current node Lew <noone@lewscanon.com> - 2012-02-20 11:58 -0800
    Re: java get xml file line number for the current node Gene Wirchenko <genew@ocis.net> - 2012-02-20 13:35 -0800
      Re: java get xml file line number for the current node Lew <noone@lewscanon.com> - 2012-02-20 14:42 -0800
        Re: java get xml file line number for the current node Arne Vajhøj <arne@vajhoej.dk> - 2012-02-20 19:57 -0500
          Re: java get xml file line number for the current node Gene Wirchenko <genew@ocis.net> - 2012-02-20 17:21 -0800
          Re: java get xml file line number for the current node Lew <noone@lewscanon.com> - 2012-02-20 17:27 -0800
    Re: java get xml file line number for the current node Arne Vajhøj <arne@vajhoej.dk> - 2012-02-20 19:57 -0500
    Re: java get xml file line number for the current node Roedy Green <see_website@mindprod.com.invalid> - 2012-02-20 18:00 -0800
    Re: java get xml file line number for the current node bugbear <bugbear@trim_papermule.co.uk_trim> - 2012-02-21 09:21 +0000
      Re: java get xml file line number for the current node Lew <noone@lewscanon.com> - 2012-02-21 09:15 -0800
        Re: java get xml file line number for the current node Gene Wirchenko <genew@ocis.net> - 2012-02-21 10:07 -0800
          Re: java get xml file line number for the current node Lew <noone@lewscanon.com> - 2012-02-21 11:50 -0800
  Re: java get xml file line number for the current node Jeff Higgins <jeff@invalid.invalid> - 2012-02-20 17:35 -0500
    Re: java get xml file line number for the current node Lew <noone@lewscanon.com> - 2012-02-20 14:46 -0800
      Re: java get xml file line number for the current node Jeff Higgins <jeff@invalid.invalid> - 2012-02-20 19:48 -0500

csiph-web