From: David Pollak Date: 2006-04-22T07:07:42+09:00 Subject: Re: XML parser with file names and line numbers ------=_Part_35449_9846691.1145657258807 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Henrik, I've already got a solution to the issue. libxml-ruby has the functionalit= y I need. One of my projects is SiteMap ( http://rubyforge.org/projects/sitemap ) which is a Domain Specific Language that descripts web site navigation, access control, link names, etc. SiteMap allows the designer to imbed Ruby code (e.g., to test access control, etc.) It would be nice to have the file/line of the generated methods in stack traces, etc. Thanks, David On 4/21/06, Henrik Martensson wrote: > > On Fri, 2006-04-21 at 00:01, David Pollak wrote: > > Howdy, > > > > Is there a Ruby XML parser that includes the file name and line number > for > > elements? > > XML does not have the concept of a line. XML deals only with describing > data and structure, not formatting. Carriage returns and line feeds are > considered to be whitespace. > > That is why true XML editors use separate style sheets, like CSS, > XSL-FO, or FOSI, to format XML documents. > > If you have an XML document, process it in some way, for example just by > parsing it and saving it, any carriage returns and line feeds may have > been removed. The parser may even add new ones. Whitespace is guaranteed > to be preserved in CDATA sections only. > > You might find it more useful to count the elements themselves. That way > the numbers won't change just because you open a file in an editor and > look at it. > > Elements do not have file names either. > > What is it you want to do? > > /Henrik > > -- > http://kallokain.blogspot.com/ - Blogging from the trenches of software > development > http://www.henrikmartensson.org/ - Reflections on software development > http://tocsim.rubyforge.com/ - Process simulation > http://testunitxml.rubyforge.org/ - XML test framework > http://declan.rubyforge.org/ - Declarative XML processing > > > > > ------=_Part_35449_9846691.1145657258807--