<?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 ses any;
  ses := string_output();
  http (sprintf ('<?xml version="1.0" encoding="%s" ?>', current_charset()), ses);
  http ('<document>', ses);
  xml_auto('
      select 1 as tag, null as parent,
      "CategoryID" as ["category"!1!"cid"],
      "CategoryName" as ["category"!1!"name"],
      NULL as ["product"!2!"pid"],
      NULL as ["product"!2!"name"!"element"]
      from "Demo".."Categories"
      union all
      select 2, 1, "category" ."CategoryID", NULL, "ProductID", "ProductName"
      from "Demo".."Categories" "category", "Demo".."Products" as "product" 
      where "product"."CategoryID" = "category"."CategoryID" 
      order by ["category"!1!"cid"], 5
      for xml explicit
      ', vector (), ses);
  http ('</document>', ses);
  http_header ('Content-Type: text/xml\r\n');
  http (string_output_string (ses));
?>
