}
if (fieldNos.getFullIdentifier() != null && fieldNos.getFullIdentifier().endsWith("XmlValue")) {
continue eachField;
}
final OneToOneAssociation valueAssociation = ((OneToOneAssociation) field);
final Element xmlValueElement = xmlFieldElement; // more
// meaningful
// locally
// scoped name
ObjectAdapter value;
try {
value = valueAssociation.get(adapter);
final ObjectSpecification valueNos = value.getSpecification();
// XML
isisMetaModel.setAttributesForValue(xmlValueElement, valueNos.getShortIdentifier());
// return parsed string, else encoded string, else title.
String valueStr;
final ParseableFacet parseableFacet = fieldNos.getFacet(ParseableFacet.class);
final EncodableFacet encodeableFacet = fieldNos.getFacet(EncodableFacet.class);
if (parseableFacet != null) {
valueStr = parseableFacet.parseableTitle(value);
} else if (encodeableFacet != null) {
valueStr = encodeableFacet.toEncodedString(value);
} else {
valueStr = value.titleString();
}
final boolean notEmpty = (valueStr.length() > 0);
if (notEmpty) {
xmlValueElement.appendChild(getXmlDocument().createTextNode(valueStr));
} else {
isisMetaModel.setIsEmptyAttribute(xmlValueElement, true);
}
} catch (final Exception ex) {
LOG.warn("objectToElement(NO): " + log("field", fieldName) + ": getField() threw exception - skipping XML generation");
}
// XSD
xsdFieldElement = schema.createXsElementForNofValue(xsElement, xmlValueElement, FacetUtil.getFacetsByType(valueAssociation));
} else if (field instanceof OneToOneAssociation) {
if (LOG.isDebugEnabled()) {
LOG.debug("objectToElement(NO): " + log("field", fieldName) + " is OneToOneAssociation");
}
final OneToOneAssociation oneToOneAssociation = ((OneToOneAssociation) field);
final String fullyQualifiedClassName = nos.getFullIdentifier();
final Element xmlReferenceElement = xmlFieldElement; // more
// meaningful
// locally
// scoped
// name
ObjectAdapter referencedObjectAdapter;
try {
referencedObjectAdapter = oneToOneAssociation.get(adapter);
// XML
isisMetaModel.setAttributesForReference(xmlReferenceElement, schema.getPrefix(), fullyQualifiedClassName);
if (referencedObjectAdapter != null) {
isisMetaModel.appendIsisTitle(xmlReferenceElement, referencedObjectAdapter.titleString());
} else {
isisMetaModel.setIsEmptyAttribute(xmlReferenceElement, true);
}
} catch (final Exception ex) {
LOG.warn("objectToElement(NO): " + log("field", fieldName) + ": getAssociation() threw exception - skipping XML generation");
}
// XSD
xsdFieldElement = schema.createXsElementForNofReference(xsElement, xmlReferenceElement, oneToOneAssociation.getSpecification().getFullIdentifier(), FacetUtil.getFacetsByType(oneToOneAssociation));
} else if (field instanceof OneToManyAssociation) {
if (LOG.isDebugEnabled()) {
LOG.debug("objectToElement(NO): " + log("field", fieldName) + " is OneToManyAssociation");