diff options
author | Björn Gustavsson <[email protected]> | 2010-09-02 15:44:33 +0200 |
---|---|---|
committer | Lars Thorsen <[email protected]> | 2011-05-10 09:13:23 +0200 |
commit | 824a6db3ff111f8d2427ac5adad0362bf078630a (patch) | |
tree | f146685c27e4c8f91b07f76d3e1e3510553e2e88 /lib/xmerl/test/proprietary/mylib.erl | |
parent | 1a5796cd12061ebb21e7e51a0b7bdf05ed4786a7 (diff) | |
download | otp-824a6db3ff111f8d2427ac5adad0362bf078630a.tar.gz otp-824a6db3ff111f8d2427ac5adad0362bf078630a.tar.bz2 otp-824a6db3ff111f8d2427ac5adad0362bf078630a.zip |
Add test suite for xmerl
Diffstat (limited to 'lib/xmerl/test/proprietary/mylib.erl')
-rw-r--r-- | lib/xmerl/test/proprietary/mylib.erl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/xmerl/test/proprietary/mylib.erl b/lib/xmerl/test/proprietary/mylib.erl new file mode 100644 index 0000000000..2e154a5e5f --- /dev/null +++ b/lib/xmerl/test/proprietary/mylib.erl @@ -0,0 +1,54 @@ +%%%------------------------------------------------------------------- +%%% File : mylib.erl +%%% Author : Bertil Karlsson <bertil@finrod> +%%% Description : +%%% +%%% Created : 20 Sep 2006 by Bertil Karlsson <bertil@finrod> +%%%------------------------------------------------------------------- +-module(mylib). +-export([fetch/2,path_locate/3]). +-include("xmerl_xsd.hrl"). +-include("xmerl.hrl"). +-include_lib("kernel/include/file.hrl"). + +fetch(URI,S) -> + Split = filename:split(URI), + Filename = fun([])->[];(X)->lists:last(X) end (Split), + Fullname = + case Split of %% how about Windows systems? + ["file:"|Name]-> %% absolute path, see RFC2396 sect 3 + %% file:/dtd_name + filename:join(["/"|Name]); + ["/"|Rest] when Rest /= [] -> + %% absolute path name + URI; + ["http:"|_Rest] -> + {http,URI}; + [] -> %% empty systemliteral + []; + _ -> + filename:join(S#xsd_state.xsd_base, URI) + end, + Path = ?MODULE:path_locate(S#xsd_state.fetch_path, Filename, Fullname), + {ok, Path, S}. + +path_locate(_, _, {http,URI}) -> + application:start(inets), + http:set_options([{proxy, {{"www-proxy.ericsson.se", 8080},["localhost"]}}]), + {ok,{{_Version, 200, _ReasonPhrase}, _Headers, Body}} = + http:request(get, {URI, []}, [], []), + {string,Body}; +path_locate(_, _, []) -> + []; +path_locate([Dir|Dirs], FN, FullName) -> + F = filename:join(Dir, FN), + case file:read_file_info(F) of + {ok, #file_info{type = regular}} -> + {file,F}; + _ -> + path_locate(Dirs, FN, FullName) + end; +path_locate([], _FN, FullName) -> + {file,FullName}. + + |