When validating XML file, please include line number of error.

Senpai - January 2, 2009 - 21:39
Project:Patterns
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed
Description

I've been playing around with the newest 6.x version, and I'm liking the XML Validation that prevents the edited file from being re-saved until it's correct. However, there's something missing. A line number of the error would be helpful. Could we add a patterns_xml_validator() func?

patterns_edit_submit() could call patterns_xml_validator() function just prior to the patterns_save_pattern() on line 505. The validation function should parse all of the submitted XML for 'properness', and upon failure call a theme function that returns the line number of the first encountered error.

What say you? Does this idea play well into the abstracted configuration platform?

#1

Senpai - January 2, 2009 - 22:36

Line 283 of patterns.module has a TODO that plays nicely into this idea as well. Just FYI.

// @TODO validate XML and don't allow import if validation fails
$parse = xml_parser_create();
$success = xml_parse_into_struct($parse, $form_state['values']['xmlsource'], $vals, $index);

#2

vaish - January 12, 2009 - 15:24
Status:active» postponed

This seems like something we would want to leave for the next phase when we separate patterns module and configuration framework. There is going to be a lot of major changes to the code and improving and centralizing* XML validation fits well into that picture.

*validation needs to be done on list, import and edit operations

#3

Senpai - January 12, 2009 - 17:10

"validation needs to be done on list, import and edit operations"

Agreed. At the point in which the code becomes two modules, that's when this validation step should happen. Doing it now looks like it'll shoehorn a lot of cruft into the code in places it doesn't belong.

 
 

Drupal is a registered trademark of Dries Buytaert.