public Element toXml(Document document) {
Element elem = getName().toXml(document);
for (int i = 0; i < columnNames.length; i++) {
String propertyName = columnNames[i];
String selectorName = selectorNames[i];
Value propertyValue = values[i];
Element columnEl = DomUtil.addChildElement(elem, COLUMN, ItemResourceConstants.NAMESPACE);
DomUtil.addChildElement(columnEl, JCR_NAME.getName(), JCR_NAME.getNamespace(), propertyName);
if (propertyValue != null) {
try {
String serializedValue = ValueHelper.serialize(propertyValue, true);
Element xmlValue = DomUtil.addChildElement(columnEl, XML_VALUE, ItemResourceConstants.NAMESPACE, serializedValue);
String type = PropertyType.nameFromValue(propertyValue.getType());
DomUtil.setAttribute(xmlValue, ATTR_VALUE_TYPE, ItemResourceConstants.NAMESPACE, type);
} catch (RepositoryException e) {
log.error(e.toString());
}
}