- if (baseType instanceof IdentityrefTypeDefinition && node.getValue() instanceof QName) {
- QName value = (QName) node.getValue();
- element.setAttribute("xmlns:x", value.getNamespace().toString());
- element.setTextContent("x:" + value.getLocalName());
+ if (baseType instanceof IdentityrefTypeDefinition) {
+ if (node.getValue() instanceof QName) {
+ IdentityValuesDTO valueDTO = (IdentityValuesDTO) RestCodec.from(type).serialize(node.getValue());
+ IdentityValue value = valueDTO.getValuesWithNamespaces().get(0);
+ String prefix = "x";
+ if (value.getPrefix() != null && !value.getPrefix().isEmpty()) {
+ prefix = value.getPrefix();
+ }
+ element.setAttribute("xmlns:" + prefix, value.getNamespace());
+ element.setTextContent(prefix + ":" + value.getValue());
+ } else {
+ logger.debug("Value of " + baseType.getQName().getNamespace() + ":"
+ + baseType.getQName().getLocalName() + " is not instance of " + QName.class + " but is " + node.getValue().getClass());
+ element.setTextContent(String.valueOf(node.getValue()));
+ }