XML formatter: null values – null attribute instead of „null“ string v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Wed, 08 Jan 2014 23:39:47 +0100
branchv_0
changeset 151 21eb46c5e2ec
parent 150 911b2d55bb08
child 152 7a3382823fc3
XML formatter: null values – null attribute instead of „null“ string
java/sql-dk/src/info/globalcode/sql/dk/formatting/XmlFormatter.java
--- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/XmlFormatter.java	Wed Jan 08 20:08:53 2014 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/XmlFormatter.java	Wed Jan 08 23:39:47 2014 +0100
@@ -138,11 +138,19 @@
 
 		Map<QName, String> attributes = null;
 		if (labeledColumns) {
-			attributes = new LinkedHashMap<>(1);
+			attributes = new LinkedHashMap<>(2);
 			attributes.put(qname("label"), getCurrentColumnsHeader().getColumnDescriptors().get(getCurrentColumnsCount() - 1).getLabel());
 		}
 
-		printTextElement(qname("column"), attributes, toString(value));
+		if (value == null) {
+			if (attributes == null) {
+				attributes = new LinkedHashMap<>(2);
+				attributes.put(qname("null"), "true");
+				printEmptyElement(qname("column"), attributes);
+			}
+		} else {
+			printTextElement(qname("column"), attributes, toString(value));
+		}
 	}
 
 	@Override