﻿#!/usr/bin/perl -w
use strict;
use warnings;
use utf8;
use open qw(:std :utf8);


# Filter_4_test_validity.pl
# 2010-05-03
# Wolfgang Schmidle

# This Filter is a wrapper for validating an XML document with Jing.


# text input

my $file = shift @ARGV;

unless ($file =~ m!\.xml!) { warn "Don't forget to save your document as .xml !\n\n"; }


# read default parameters

my $filter = "mpdl-workflow-settings.pl";
my $result = `perl $filter`;

my $jing = ($result =~ m! jing=([^ ]+) ! ? $1 : "" );
my $schema = ($result =~ m! schema=([^ ]+) ! ? $1 : "" );


# run jing

$result = `java -jar $jing -c $schema "$file"`;

if ($result) {
	$result =~ s!/private[^:]+(xml|txt)\.S:!!g;
} else {
	$result = "The document is valid.\n";
}

die $result;
