#!/usr/bin/perl -w use strict; use warnings; use utf8; use open qw(:std :utf8); # use XML::Parser; # use XML::Simple; # use XML::LibXML; # Filter_3_test_wellformedness.pl # 2010-08-15 # Wolfgang Schmidle # This Filter is a wrapper for checking the well-formedness of an XML document using xmllint. # The Script assumes it is run as a text filter # (on the command line you would use xmllint directly) # text input my $file = shift @ARGV; unless ($ENV{'BB_DOC_NAME'} =~ m!\.xml$!) { warn "Don't forget to save your document as .xml !\n(Filename $ENV{'BB_DOC_NAME'})\n\n"; } my $result = `xmllint --noout "$file" 2>&1`; # 2>&1: redirect xmllint's output from stderr to stdout if ($result) { $result =~ s!/private[^:]+:!!g; } else { $result = "The document is well-formed.\n"; } die $result;