XMLATTRIBUTES — Creates a list of attributes and their values


XMLATTRIBUTES ( string_expr1 [AS alias1] varchar ,
  string_expr2 [AS alias2] varchar ,
  ... ,
  string_exprN [AS aliasN] varchar );


This function creates a vector that may be used only as argument of XMLELEMENT function. The vector has an even number of elements, each odd element is a name of an attribute, an even element is its value. If the attribute value is NULL, then no attribute and no value is created. If none of the attribute is created, then the function returns NULL. If string_expr is a column name, then you can omit the AS clause, and Virtuoso uses the partially escaped form of the column name as the attribute name.


String_exprI [AS aliasI]

string value; AS clause is mandatory if it is not a column name but an expression of some other sort.


Example 24.496. XMLATTRIBUTES() with two parameters

The following example produces an 'EmpName' elements with two attributes (if value of the column 'Region' is not NULL) or with one attribute (if value of the column 'Region' is NULL)

select XMLELEMENT ("EmpName",
                    XMLATTRIBUTES ("FirstName" || ' ' || "LastName" as "Name", "Region" ))
  from "Demo"."demo"."Employees";
<EmpName Name="Nancy Davolio" Region="WA" />
<EmpName Name="Andrew Fuller" Region="WA" />
<EmpName Name="Janet Leverling" Region="WA" />
<EmpName Name="Margaret Peacock" Region="WA" />
<EmpName Name="Steven Buchanan" />
<EmpName Name="Michael Suyama" />
<EmpName Name="Robert King" />
<EmpName Name="Laura Callahan" Region="WA" />
<EmpName Name="Anne Dodsworth" />

9 Rows.