Object (@NotNull Object o, @Nullable SerializationFilter filter) { Object value = accessor.read(o); Element targetElement = new Element(myTagName); if (myNameAttribute != null && !myNameAttribute.isEmpty()) { targetElement.setAttribute(myNameAttribute, name); } if (value == null) { return targetElement; } Converter<Object> converter = getConverter(); if (converter == null) { if (binding == null) { targetElement.setAttribute(myValueAttribute, JDOMUtil.removeControlChars(XmlSerializerImpl.convertToString(value))); } else if (binding instanceof BeanBinding && myValueAttribute.isEmpty()) { ((BeanBinding)binding).serializeInto(value, targetElement, filter); } else { Object node = binding.serialize(value, targetElement, filter); if (node != null && targetElement != node) { Binding.addContent(targetElement, node); } } } else { String text = converter.toString(value); if (text != null) { targetElement.setAttribute(myValueAttribute, JDOMUtil.removeControlChars(text)); } } return targetElement; }