xsd-based validation to support unit testing (pFUnit).

56 views
Skip to first unread message

Michael Rilee

unread,
Aug 6, 2014, 11:46:35 AM8/6/14
to fox-d...@googlegroups.com

I was hoping that FoX might provide a Fortran-based way to validate the xml we produce against the de facto JUnit xsd.  

Apparently this is not possible with FoX.  Please correct me if FoX does support this kind of validation.

We're adding JUnit-compatible xml output to the pFUnit unit-testing framework for Fortran/MPI/OpenMP-based codes.  As an aside:  as FoX is inspired by SAX, pFUnit is inspired by JUnit.

We're developing pFUnit to support Test Driven Development for science software and it would be nice to enable the use of continuous integration tools via xml output.  At the same time, we're trying to minimize requirements on pFUnit's build environment to make it easy for science users & projects to install and use.  (FoX seems to have been born of a similar wish.)

Thanks for the effort with FoX, it is exceptional.  The CMake and make builds are very smooth.

Regards,

Mike Rilee




Peter Murray-Rust

unread,
Aug 6, 2014, 12:17:59 PM8/6/14
to fox-d...@googlegroups.com
On Wed, Aug 6, 2014 at 4:46 PM, Michael Rilee <michael....@gmail.com> wrote:

I was hoping that FoX might provide a Fortran-based way to validate the xml we produce against the de facto JUnit xsd.  

Apparently this is not possible with FoX.  Please correct me if FoX does support this kind of validation.

It's almost certainly NOT possible and won't be. Because Fortran does not support objects well it is difficult to manage complex structures and XML is based on structure.

Even if FORTRAN could support objects it is incredibly challenging to write an XSD validator (I've been intimately involved with the development of XML. There are only a few in existence - Xerces(J and C) and MSXML being the best known. Even Java validation normally is a wrapper for Xerces.

I would suggest decoupling the validation into a separate process and using one of these validators (Xerces is F/OSS). Is there any reason why you looked to a FORTRAN solution


We're adding JUnit-compatible xml output to the pFUnit unit-testing framework for Fortran/MPI/OpenMP-based codes.  As an aside:  as FoX is inspired by SAX, pFUnit is inspired by JUnit.

We're developing pFUnit to support Test Driven Development for science software and it would be nice to enable the use of continuous integration tools via xml output.  At the same time, we're trying to minimize requirements on pFUnit's build environment to make it easy for science users & projects to install and use.  (FoX seems to have been born of a similar wish.)

Thanks for the effort with FoX, it is exceptional.  The CMake and make builds are very smooth.

Thanks for this support! [I'm not the official Mr FoX]

--
Peter Murray-Rust
Reader in Molecular Informatics
Unilever Centre, Dep. Of Chemistry
University of Cambridge
CB2 1EW, UK
+44-1223-763069

Andrew Walker

unread,
Aug 6, 2014, 12:34:29 PM8/6/14
to fox-d...@googlegroups.com
Hi Mike,

I'm afraid you are correct - the only validation FoX can perform is against a DTD. (Add validate=.true. to the arguments to the sax parse() function, for DOM set validate to .true. in the DOMConfiguration object, or for wxml use validate=.true. in xml_OpenFile if that's what you are using. The validity - rather than well-formdness - checks wxml performs on file creation are incomplete.)

Your best bet is probably to run validation using some other (almost certainly non-fortran) library: xmllint on the command line for example. In principle you could express a subset of the constraints of the XSD schema as a DTD and use that, but at best this would only cover the basic document structure.

I hope this helps,

Andrew



--
You received this message because you are subscribed to the Google Groups "FoX-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fox-discuss...@googlegroups.com.
To post to this group, send email to fox-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/fox-discuss.
For more options, visit https://groups.google.com/d/optout.



--
Andrew Walker
School of Earth and Environment
University of Leeds

Michael Rilee

unread,
Aug 6, 2014, 1:18:41 PM8/6/14
to fox-d...@googlegroups.com, pm...@cam.ac.uk

Thanks for the detailed response, it is helpful.  

Support for objects has improved with Fortran 2003 and 2008, and we use them extensively in pFUnit, but your point is well taken.

It looks like the xmllint solution proposed by our contributor is the way to go.

Regarding looking for a Fortran solution, we want to make it as easy as possible for developers and projects using Fortran to try out unit testing, particularly those working in supercomputing or with legacy code.  As you know, the challenges of working with such codes generally fosters great caution evolving code development techniques.  The more that's required to set up a new tool, the less likely it's going to be given a chance.

Cheers,

Mike

--
Michael Lee Rilee, Ph.D.
Rilee Systems Technologies LLC

Peter Murray-Rust

unread,
Aug 6, 2014, 2:58:46 PM8/6/14
to fox-d...@googlegroups.com
This seems to be a perception problem - developers feel unhappy outside a FORTRAN environment. My Fortran is out of date (F77...) but it should be possible to call C code from Fortran95 or whatever we are up to. So I'd build a FORTRAN wrapper for xmllint (or even Xerces-C), compile on target machines and distribute the C executable. The developers would call something like:

LOGICAL VALID = VALIDATE(FoxML, ERRORFILE)

where VALIDATE is a wrapper.

The error messages could be output to file rather than brought back into the system

But I may have missed something


--
You received this message because you are subscribed to the Google Groups "FoX-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fox-discuss...@googlegroups.com.
To post to this group, send email to fox-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/fox-discuss.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages