| | * Formats the start of the XMLATTRIBUTES call. |
| | * |
| | - * @param name The name assigned to the attribute. |
| | + * @param table The table name assigned to the attribute. |
| | + * @param column The column name assigned to the attribute. |
| | + * @param node The document node name assigned to the attribute. |
| | * |
| | * @return The text used for SQL/XML XMLATTRIBUTES calls. |
| | */ |
| | - protected String startAttributes( String name ) { |
| | - return String.format( "XMLATTRIBUTES( %s AS ", name ); |
| | + protected String startAttributes( String table, String column, String node ) { |
| | + String result = "XMLATTRIBUTES( %s.%s%s"; |
| | + |
| | + // If the column name and attribute name are the same, then the |
| | + // "AS" clause is superfluous. |
| | + if( column.equals( node ) ) { |
| | + result = String.format( result, table, column, "" ); |
| | + } |
| | + else { |
| | + node = String.format( " AS \"%s\"", node ); |
| | + result = String.format( result, table, column, node ); |
| | + } |
| | + |
| | + return result; |
| | } |
| | |