XML line numbers

I'm using the REXML stream parser to read in an xml file and check the
attributes as I go. If a check fails, I want to print out the line
number in the XML file that contains the offending element - is that
possible?

e.g.

<foo>
  <bar
    baz="5" <--- should be between 1 and 3
    quux="hello"
  />
</foo>

I want to print out "value of attribute 'baz' should be between 1 and 3
in line 3"

martin

Martin DeMello <martindemello@yahoo.com> wrote in message news:<uUvLc.77191$ek5.23924@pd7tw2no>...

I'm using the REXML stream parser to read in an xml file and check the
attributes as I go. If a check fails, I want to print out the line
number in the XML file that contains the offending element - is that
possible?

Martin,

Check out Source#current_line. Line number support in REXML is
limited at the moment, since a "line" for REXML isn't something ending
in a "\n", but is something ending in ">". I've been considering ways
of counting "\n" lines without imposing a significant performance
penalty, but have had little luck.

--- SER

Thanks - I'm going out of town for a few days, but I'll take a look at
it when I come back. This is a case where helpful error messages are
more useful than performance, so I don't mindf taking a bit of a speed
hit.

martin

···

Sean Russell <ser@germane-software.com> wrote:

Martin DeMello <martindemello@yahoo.com> wrote in message news:<uUvLc.77191$ek5.23924@pd7tw2no>...
> I'm using the REXML stream parser to read in an xml file and check the
> attributes as I go. If a check fails, I want to print out the line
> number in the XML file that contains the offending element - is that
> possible?

Martin,

Check out Source#current_line. Line number support in REXML is
limited at the moment, since a "line" for REXML isn't something ending
in a "\n", but is something ending in ">". I've been considering ways
of counting "\n" lines without imposing a significant performance
penalty, but have had little luck.