1%% ``Licensed under the Apache License, Version 2.0 (the "License"); 2%% you may not use this file except in compliance with the License. 3%% You may obtain a copy of the License at 4%% 5%% http://www.apache.org/licenses/LICENSE-2.0 6%% 7%% Unless required by applicable law or agreed to in writing, software 8%% distributed under the License is distributed on an "AS IS" BASIS, 9%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10%% See the License for the specific language governing permissions and 11%% limitations under the License. 12%% 13%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. 14%% Portions created by Ericsson are Copyright 1999-2000, Ericsson 15%% Utvecklings AB. All Rights Reserved.'' 16%% 17%% $Id$ 18%% 19-module(docgen_xml_check). 20 21-export([validate/1]). 22-deprecated([{validate,1,next_major_release}]). 23 24%% validate(File) -> ok | error | {error, badfile} 25%% File = string(), file name with or without ".xml" extension 26%% If XML validation fails for a file, the error information from 27%% Xmerl is printed to terminal and the function returns error. 28validate(File0) -> 29 File = case filename:extension(File0) of 30 ".xml" -> File0; 31 _ -> File0++".xml" 32 end, 33 case filelib:is_regular(File) of 34 true -> 35 DtdDir = filename:join(code:priv_dir(erl_docgen), "dtd"), 36 case catch xmerl_scan:file(File, [{validation,true}, 37 {fetch_path,[DtdDir]}]) of 38 {'EXIT', Error} -> 39 io:format("~p~n", [Error]), 40 error; 41 {_Doc, _Misc} -> 42 ok 43 end; 44 false -> 45 {error, badfile} 46 end. 47