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.
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"; callret VARCHAR _______________________________________________________________________________ <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.