SV: SV: [jdom-interest] Line numbers
Per Norrman
pernorrman at telia.com
Thu Aug 28 13:55:01 PDT 2003
Well, my interpretation of the original question was that
it was desirable to be able to track *all* elements to their
respective source locations, not just those (the one) that caused
an exception.
A couple of years ago, I did some work for a larger telecom
company. In this case, all interfaces and interactions between
their network nodes was defined in a synthesized xml document, and
I were doing the synthesization stuff. I can see, in hindsight, because
of circumstances that I will not comment on here, that it would have
been useful to annotate the synthesized document elements with
original source line numbers.
May be a far fetched use case, but still a use case.
/pmn
> -----Ursprungligt meddelande-----
> Från: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org] För Bradley S. Huffman
> Skickat: den 28 augusti 2003 17:56
> Till: jdom-interest at jdom.org
> Ämne: Re: SV: [jdom-interest] Line numbers
>
>
> So back to the original question, wouldn't this work?
>
> int lineNumber = -1;
> int columnNumber = -1;
> try {
> document = builder.build(file);
> }
> catch(JDOMException je) {
> Throwable cause = je;
> while(cause != null) {
> cause = je.getCause();
> if (cause instanceof SAXParseException) {
> lineNumber = (SAXParseException
> cause).getLineNumber();
> columnNumber = (SAXParseException
> cause).getColumnNumber();
> break;
> }
> }
> }
>
> The problem I have with storing line and column info. inside
> elements is
> after the first modification to the document the info.
> probably becomes meaningless. For example, read in a
> document, fetch the root element and do something like
>
> root.addContent(new Text("\n\n\n"));
>
> What are the line and column numbers of all of root's descendants?
>
> Brad
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com
More information about the jdom-interest
mailing list