<?vsp
--
--  $Id$
--
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--
--  Copyright (C) 1998-2018 OpenLink Software
--
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--  General Public License for more details.
--
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--

    declare _xml string;
    declare _xsl_path string;
    declare _mime_type string;
    declare stream any;
    declare host varchar;
    declare iIsDav integer;
    declare sHost varchar;

    iIsDav := 1;

    host := http_request_header(lines, 'Host', null, 'localhost');

    if (isstring (host) and strchr (host , ':') is null)
    {
      host := host || ':80';
    }

    _xml := http_get(sprintf('http://%s/photos/SOAP/services.wsdl',host,server_http_port ()));

    sHost := registry_get('_oGallery_path_');

    if (cast(sHost as varchar) = '0'){
      sHost := '/apps/oGallery/';
    }

    if (isnull(strstr(sHost, '/DAV'))){
      _xsl_path := 'file:/apps/oGallery/xslt/wsdl2js.xsl';
      iIsDav := 0;
    }else{
      _xsl_path := sprintf('virt://WS.WS.SYS_DAV_RES.RES_FULL_PATH.RES_CONTENT:%sxslt/wsdl2js.xsl',sHost);
    }

 --_xsl_path := 'file:/apps/oGallery/xslt/wsdl2js.xsl';
  _xsl_path := sprintf('%sxslt/wsdl2js.xsl',PHOTO.WA.base_path());

  _xml := PHOTO.WA.xslt(_xml,_xsl_path);

  _mime_type := 'text/html';

	-- Print to output
  http_rewrite();
  http_header (sprintf ('Content-type: %s\r\n', _mime_type));
  http(_xml);
?>
