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 15121eb46c5e2ec
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
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/XmlFormatter.java	Wed Jan 08 20:08:53 2014 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/XmlFormatter.java	Wed Jan 08 23:39:47 2014 +0100
     1.3 @@ -138,11 +138,19 @@
     1.4  
     1.5  		Map<QName, String> attributes = null;
     1.6  		if (labeledColumns) {
     1.7 -			attributes = new LinkedHashMap<>(1);
     1.8 +			attributes = new LinkedHashMap<>(2);
     1.9  			attributes.put(qname("label"), getCurrentColumnsHeader().getColumnDescriptors().get(getCurrentColumnsCount() - 1).getLabel());
    1.10  		}
    1.11  
    1.12 -		printTextElement(qname("column"), attributes, toString(value));
    1.13 +		if (value == null) {
    1.14 +			if (attributes == null) {
    1.15 +				attributes = new LinkedHashMap<>(2);
    1.16 +				attributes.put(qname("null"), "true");
    1.17 +				printEmptyElement(qname("column"), attributes);
    1.18 +			}
    1.19 +		} else {
    1.20 +			printTextElement(qname("column"), attributes, toString(value));
    1.21 +		}
    1.22  	}
    1.23  
    1.24  	@Override