value instanceof ResourceKey)
{
continue;
}
final AttributeMetaData attrMeta = type.getMetaData().getAttributeDescription(namespace, name);
if (attrMeta == null)
{
// if you want to use attributes in this output target, declare the attribute's metadata first.
continue;
}
final AttributeList attList = new AttributeList();
if (value instanceof String)
{
final String s = (String) value;
if (StringUtils.isEmpty(s))
{
continue;
}
if (xmlWriter.isNamespaceDefined(namespace) == false &&
attList.isNamespaceUriDefined(namespace) == false)
{
attList.addNamespaceDeclaration("autoGenNs", namespace);
}
// preserve strings, but discard anything else. Until a attribute has a definition, we cannot
// hope to understand the attribute's value. String-attributes can be expressed in XML easily,
// and string is also how all unknown attributes are stored by the parser.
attList.setAttribute(namespace, name, String.valueOf(value));
this.xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "attribute", attList, XmlWriter.CLOSE);
continue;
}
if (xmlWriter.isNamespaceDefined(namespace) == false &&
attList.isNamespaceUriDefined(namespace) == false)
{
attList.addNamespaceDeclaration("autoGenNs", namespace);
}
try
{
final PropertyEditor propertyEditor = attrMeta.getEditor();
final String textValue;
if (propertyEditor != null)
{
propertyEditor.setValue(value);
textValue = propertyEditor.getAsText();
}
else
{
textValue = ConverterRegistry.toAttributeValue(value);
}
if (textValue != null)
{
if ("".equals(textValue) == false)
{
attList.setAttribute(namespace, name, textValue);
this.xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "attribute", attList, XmlWriter.CLOSE);
}
}
else
{
if (value instanceof ResourceKey)
{
final ResourceKey reskey = (ResourceKey) value;
final String identifierAsString = reskey.getIdentifierAsString();
attList.setAttribute(namespace, name, "resource-key:" + reskey.getSchema() + ":" + identifierAsString);
this.xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "attribute", attList, XmlWriter.CLOSE);
}
else
{
XmlDocumentWriter.logger.debug(
"Attribute '" + namespace + '|' + name + "' is not convertible to a text - returned null: " + value);
}
}
}
catch (BeanException e)
{
if (attrMeta.isTransient() == false)
{
XmlDocumentWriter.logger.warn(
"Attribute '" + namespace + '|' + name + "' is not convertible with the bean-methods");
}
else