Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Identifying where bad XML is

Reply
Thread Tools

Identifying where bad XML is

 
 
Ben Burdick
Guest
Posts: n/a
 
      09-22-2005
I am somewhat new to ruby and would appreciate any help on this
matter. I have a custom assertion for running tests
"assert_valid_xml_response" - which will parse the output and check
for any bad xml..

My problem is, that with many changes constantly taking place, and
many of these assertions taking place, it is sometimes hard to
pinpoint exactly where the bad XML is hiding.

Has anyone stumbled across a solution to easily zero in on the
location of bad XML?



 
Reply With Quote
 
 
 
 
James Britt
Guest
Posts: n/a
 
      09-22-2005
Ben Burdick wrote:
> I am somewhat new to ruby and would appreciate any help on this
> matter. I have a custom assertion for running tests
> "assert_valid_xml_response" - which will parse the output and check for
> any bad xml..
>
> My problem is, that with many changes constantly taking place, and many
> of these assertions taking place, it is sometimes hard to pinpoint
> exactly where the bad XML is hiding.
>
> Has anyone stumbled across a solution to easily zero in on the location
> of bad XML?


Um, depends on what is making it bad.

If I have access to the complete XML document, then I try loading it
into IE or Firefox, which are pretty good at locating problems and
issuing useful info.

Or I run it though tidy or xmllint or something.

Often the problem is a stray '<' or '&' someplace, so grep + a decent
regexp could track it down, too.

If the XML is a set of repeated structures you could try using the REXML
stream or pull parser to read in chunks at a time and assemble smaller
sub-docs, and check those for well-formedness. If it fails it's easier
to then to write out the failing XML and inspect it.


James
--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys


 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      09-22-2005
Ben Burdick <(E-Mail Removed)> wrote:
> I am somewhat new to ruby and would appreciate any help on this
> matter. I have a custom assertion for running tests
> "assert_valid_xml_response" - which will parse the output and check
> for any bad xml..
>
> My problem is, that with many changes constantly taking place, and
> many of these assertions taking place, it is sometimes hard to
> pinpoint exactly where the bad XML is hiding.
>
> Has anyone stumbled across a solution to easily zero in on the
> location of bad XML?


What exactly do you mean by "bad"? Do you mean "ill formed"? In that case
any decent XML parser (validating and non validating) should give you
information about where it chokes. If you mean by "bad" that it doesn't fit
an XML Schema or DTD then a validating parser should point you where the
error lies.

Kind regards

robert

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
integer >= 1 == True and integer.0 == False is bad, bad, bad!!! rantingrick Python 44 07-13-2010 06:33 PM
Bad media, bad files or bad Nero? John Computer Information 23 01-08-2008 09:17 PM
ActiveX apologetic Larry Seltzer... "Sun paid for malicious ActiveX code, and Firefox is bad, bad bad baad. please use ActiveX, it's secure and nice!" (ok, the last part is irony on my part) fernando.cassia@gmail.com Java 0 04-16-2005 10:05 PM
24 Season 3 Bad Bad Bad (Spoiler) nospam@nospam.com DVD Video 12 02-23-2005 03:28 AM
24 Season 3 Bad Bad Bad (Spoiler) nospam@nospam.com DVD Video 0 02-19-2005 01:10 AM



Advertisments