/* This file is automatically generated by sql_to_c.awk */

#include "sqlnode.h"
#include "sqlfn.h"
#include "sqltype.h"

/* mono_type.xsl */

static const char *xsl1[]= {
"<!--\n"
" -\n"
" -  $Id$\n"
" -\n"
" -  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)\n"
" -  project.\n"
" -\n"
" -  Copyright (C) 1998-2012 OpenLink Software\n"
" -\n"
" -  This project is free software; you can redistribute it and/or modify it\n"
" -  under the terms of the GNU General Public License as published by the\n"
" -  Free Software Foundation; only version 2 of the License, dated June 1991.\n"
" -\n"
" -  This program is distributed in the hope that it will be useful, but\n"
" -  WITHOUT ANY WARRANTY; without even the implied warranty of\n"
" -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
" -  General Public License for more details.\n"
" -\n"
" -  You should have received a copy of the GNU General Public License along\n"
" -  with this program; if not, write to the Free Software Foundation, Inc.,\n"
" -  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n"
" -\n"
" -\n"
"-->\n"
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\"\n"
"                xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\"\n"
"                xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\"\n"
"                xmlns=\"http://www.w3.org/2001/XMLSchema\">\n"
"    <xsl:output method=\"text\" />\n"
"\n"
"    <!--xsl:template match=\"/\">\n"
"      <xsl:apply-templates select=\"*\"/>\n"
"    </xsl:template-->\n"
"\n"
"    <xsl:template match=\"class\">\n"
"      create type \"<xsl:value-of select=\"@pl_type\" />\"\n"
"      <xsl:if test=\"@pl_under != ''\">\n"
"        under \"<xsl:value-of select=\"@pl_under\"/>\"\n"
"      </xsl:if>\n"
"      language <xsl:value-of select=\"@pl_lang\" /> external name '<xsl:value-of select=\"@type\" />'\n"
"      <xsl:if test=\"count (field[@static='0']) > 0\">\n"
"        AS (<xsl:apply-templates select=\"field[@static='0']\"/>)\n"
"      </xsl:if>\n"
"      <xsl:value-of select=\"@restiction\" />\n"
"      <xsl:apply-templates select=\"constructor\" >\n"
"        <xsl:with-param name=\"class_name\" select=\"@pl_type\"/>\n"
"      </xsl:apply-templates>\n"
"      <xsl:if test=\"count (method) > 0 and count (constructor) > 0\" >\n"
"      ,\n"
"      </xsl:if>\n"
"      <xsl:apply-templates select=\"method\" />\n"
"      <xsl:if test=\"count (field[@static='1']) > 0 and count (field[@static='1']) > 0\" >\n"
"      ,\n"
"      </xsl:if>\n"
"      <xsl:apply-templates select=\"field[@static='1']\" />\n"
"      <xsl:if test=\"count (//class) > 1\">\n"
"        ;\n"
"      </xsl:if>\n"
"    </xsl:template>\n"
"\n"
"    <xsl:template match=\"field[@static='0']\">\n"
"      \"<xsl:value-of select=\"@name\" />\"<xsl:text> </xsl:text><xsl:if test=\"@plescape > 0\" >\"</xsl:if><xsl:value-of select=\"@pltype\" /><xsl:if test=\"@plescape > 0\" >\"</xsl:if>\n"
"	 external name '<xsl:value-of select=\"@name\" />' external type '<xsl:value-of select=\"@signature\"/>'\n"
"      <xsl:if test=\"position() &lt; count (../field[@static='0'])\">,</xsl:if>\n"
"      <!--xsl:text>\n"
"      </xsl:text-->\n"
"    </xsl:template>\n"
"\n"
"    <xsl:template match=\"field[@static='1']\">\n"
"        static method \"get<xsl:value-of select=\"@name\" />\" () returns <xsl:if test=\"@plescape > 0\" >\"</xsl:if><xsl:value-of select=\"@pltype\" /><xsl:if test=\"@plescape > 0\" >\"</xsl:if>\n"
"	    external variable name '<xsl:value-of select=\"@name\" />' external type '<xsl:value-of select=\"@signature\"/>'\n"
"	    <xsl:if test=\"position() &lt; count (../field[@static='1'])\">,</xsl:if>\n"
"    </xsl:template>\n"
"\n"
"    <xsl:template match=\"method\">\n"
"      <xsl:variable name=\"cur_method_name\"><xsl:value-of select=\"@name\"/></xsl:variable>\n"
"      <xsl:variable name=\"cur_method_pos\"><xsl:value-of select=\"position()\"/></xsl:variable>\n"
"        <xsl:if test=\"@static='1'\">STATIC</xsl:if><xsl:if test=\"@overriding='1'\">OVERRIDING</xsl:if>\n"
"	  METHOD\n"
"	    \"<xsl:value-of select=\"@name\" />\"\n"
"	      (\n"
"	    <xsl:apply-templates select=\"parameters/param\" mode=\"declare\" />\n"
"	      )\n"
"	  <xsl:apply-templates select=\"returnType\" />\n"
"          <xsl:if test=\"@overriding='0' or @overriding = ''\">\n"
"	    <xsl:apply-templates select=\"returnType\" mode=\"external\" />\n"
"	    external name '<xsl:value-of select=\"@name\" />'\n"
"	  </xsl:if>\n"
"	  <xsl:if test=\"$cur_method_pos &lt; count (../method)\">,</xsl:if>\n"
"    </xsl:template>\n"
"\n"
"    <xsl:template match=\"returnType\">\n"
"       returns <xsl:if test=\"@plescape > 0\" >\"</xsl:if><xsl:value-of select=\"@pltype\"/><xsl:if test=\"@plescape > 0\" >\"</xsl:if>\n"
"    </xsl:template>\n"
"\n"
"    <xsl:template match=\"returnType\" mode=\"external\">\n"
"       external type '<xsl:value-of select=\"@signature\" />'\n"
"    </xsl:template>\n"
"\n"
"    <xsl:template match=\"param\" mode=\"declare\">\n"
"      \"<xsl:value-of select=\"@name\" />\"<xsl:text> </xsl:text> <xsl:if test=\"@plescape > 0\" >\"</xsl:if><xsl:value-of select=\"@pltype\" /><xsl:if test=\"@plescape > 0\" >\"</xsl:if>\n"
"      <xsl:text> </xsl:text>\n"
"      <xsl:if test=\"@signature != ''\">\n"
"        external type '<xsl:value-of select=\"@signature\" />'\n"
"      </xsl:if>\n"
"      <xsl:if test=\"position() &lt; count (../*)\">,</xsl:if>\n"
"      <xsl:text>\n"
"      </xsl:text>\n"
"    </xsl:template>\n"
"\n"
"    <xsl:template match=\"constructor\">\n"
"      <xsl:param name=\"class_name\" />\n"
"      <xsl:variable name=\"cur_method_pos\"><xsl:value-of select=\"position()\"/></xsl:variable>\n"
"	  CONSTRUCTOR METHOD \"<xsl:value-of select=\"$class_name\" />\"\n"
"	      (\n"
"	    <xsl:apply-templates select=\"parameters/param\" mode=\"declare\" />\n"
"	      )\n"
"	  <xsl:if test=\"$cur_method_pos &lt; count (../constructor)\">,</xsl:if>\n"
"    </xsl:template>\n"
"    <xsl:template match=\"unrestricted\">\n"
"      <xsl:param name=\"class_name\" />\n"
"      <xsl:variable name=\"cur_method_pos\"><xsl:value-of select=\"position()\"/></xsl:variable>\n"
"	  CONSTRUCTOR METHOD \"<xsl:value-of select=\"$class_name\" />\"\n"
"	      (\n"
"	    <xsl:apply-templates select=\"parameters/param\" mode=\"declare\" />\n"
"	      )\n"
"	  <xsl:if test=\"$cur_method_pos &lt; count (../constructor)\">,</xsl:if>\n"
"    </xsl:template>\n"
"</xsl:stylesheet>\n"
"\n"
,
 NULL };

#undef isp_schema
#define isp_schema(x) isp_schema_1(x)

static const char * xslt_define = "xslt_sheet (?, xtree_doc (?, 128, ?, 'LATIN-1', 'x-any', 'BuildStandalone=ENABLE'))";
static query_t *xslt_define_qr;

#define XSLT_DEFINE(name, text1) \
  { \
    caddr_t text = NULL;\
    static const char *elm;\
    int inx, len = 0;\
    for (inx = 0; ; inx++) { \
        elm = text1[inx];\
        if (!elm) break;\
        len += (int) strlen (elm);\
      }\
    text = dk_alloc_box (len + 1, DV_STRING);\
    text[0] = 0;\
    for (inx = 0; ; inx++) { \
        elm = text1[inx];\
        if (!elm) break;\
        strcat_box_ck (text, elm);\
      }\
    \
    if (!xslt_define_qr) \
      xslt_define_qr = sql_compile (xslt_define, bootstrap_cli, NULL, SQLC_DEFAULT); \
    if (xslt_define_qr) \
      { \
        caddr_t err = NULL; \
        err = qr_quick_exec (xslt_define_qr, bootstrap_cli, NULL, NULL, 3, \
               ":0", name, QRP_STR, ":1", text, QRP_STR, ":2", name, QRP_STR); \
        if (err) { \
          log_error ("Error executing a server init statement : %s: %s -- %.50s", \
          ((caddr_t *) err)[QC_ERRNO], ((caddr_t *) err)[QC_ERROR_STRING], \
                      text); \
          dk_free_tree (err); \
	    } \
	  local_commit (bootstrap_cli); \
      } \
    dk_free_box (text);\
  }

static int
sch_proc_def_exists (client_connection_t *cli, const char *proc_name, const int report)
{
  query_t *proc = NULL;
  char *full_name = sch_full_proc_name (isp_schema(NULL), proc_name,
	cli->cli_qualifier, CLI_OWNER (cli));
  if (full_name)
    proc = sch_proc_def (isp_schema(NULL), full_name);
  if (report && proc != NULL)
     log_debug ("built-in procedure \"%s\" overruled by the RDBMS", proc_name);
  return (proc != NULL);
}

#define DEFINE_PROC(name, proc) \
   if (!sch_proc_def_exists (bootstrap_cli, (name), log_proc_overwrite)) \
     ddl_std_proc_1 (proc, 0x0, 1)


#define DEFINE_PUBLIC_PROC(name, proc) \
   if (!sch_proc_def_exists (bootstrap_cli, (name), log_proc_overwrite)) \
     ddl_std_proc_1 (proc, 0x1, 1)


#define DEFINE_OVERWRITE_PROC(name, proc) \
   ddl_std_proc_1 (proc, 0x1, 1)


void
sqls_define_xslt (client_connection_t *bootstrap_cli)
{
  /* mono_type.xsl */

  XSLT_DEFINE ("http://local.virt/mono_type", xsl1);
}


void
sqls_arfw_define_xslt (void)
{
}
