Oracle DBMS_XMLGEN – Generate Lower Case Tag Names

oracleplsqlxml

I am generating XML in Oracle PL/SQL with the DBMS_XMLGEN package:

OPEN base_cursor FOR SELECT * FROM foo;
base_context := dbms_xmlgen.newcontext(base_cursor);
base_xml := dbms_xmlgen.getxmltype(base_context, dbms_xmlgen.none);

My problem is that whatever I do I always get the tag names in upper case. To maintain compatibility with things further downstream, I need them to be in lower case. Is there any way I can fix this?

I know there is an option for this in DBMS_XMLQUERY, but the docs says it is not recommended to use that package.

Best Answer

According to ORACLE-BASE,

Where possible DBMS_XMLGEN should be used as it is more efficient than using the Java based DBMS_XMLQUERY

And:

The example below is a copy of the previous code with all references to DBMS_XMLQUERY replaced by references to DBMS_XMLGEN. Note that two of the lines have been commented out as this functionality is currently not present in DBMS_XMLGEN

I added my emphasis, because this refers specifically to the settagcase you are looking for.

--DBMS_XMLGEN.settagcase(v_ctx, DBMS_XMLGen.LOWER_CASE);

So it looks like you are stuck with the slower DBMS_XMLQUERY.