Randy J. Ray wrote:
> After much longer than it *should* have taken me, I've finally gotten my
> Test::* module onto CPAN (in fact, this is the second release, as the first
> time around I bundled it on a machine that had an out-of-date EU::MM, so the
> META.yml wasn't quite up to par... plus I'd fumbled the specification of
> some of the pre-reqs).
> I settled on the name "Test::Formats". At present, the module provides
> Test::Formats and Test::Formats::XML. The latter has all the testing-hooks
> for checking XML documents against DTDs, XML Schema descriptions and RelaxNG
> schemas. In 0.11, for the heck of it, I also added simpler tests that can be
> used to see if a doc is just well-formed (parses without errors), without
> having to go through validation. I know that other modules do this, but I
> figure if you've loaded T::F::XML, you already have XML::LibXML in memory so
> there's no reason to make you load a completely separate new
> test-dependency.

Excellent.  If I may offer some suggestions.

Test::Schema would seem to be a better name.  While its ambiguous whether
you're testing the schemas themselves or testing using a schema, it at least
has the important word "schema" in the name.

is_valid_against_xmlschema() is wordy.  How about... xmlschema_ok() or
test_with_xmlschema()?

Rather than having a xmlschema and yamlschema and fooschema and barschema
proliferation, I suggest putting that information into a schema object.

my $schema = Test::Schema::XML->new(file => "structure.xsd");
for my $file (@xml_files) {
    test_with_schema($file, $schema);
}

This also lets you handle file vs string schemas more gracefully.  There will
be a similar problem with accepting just data files.  I'm going to want to
validate snippets of data without having to put them into a file.  You could
use the scalar-ref hack but it would be nice to address this up front.

The previous example alludes to a further suggestion, add a default
description which is something like "$file valid with $schema_file"

And finally note that I've reversed the order of arguments.  This falls in
line with the test($have, $want) ordering.  I have an XML $file and I want it
to match an XML $schema.


-- 
185. My name is not a killing word.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/

Reply via email to