byte[] bytes = ((XMLConversionManager) executionSession.getDatasourcePlatform().getConversionManager()).convertSchemaBase64ToByteArray(element);
fieldValue = bytes;
}
} else {
//this was an element, so do the XOP/SWAREF/Inline binary cases for an element
XMLRecord record = (XMLRecord) element;
if (getNullPolicy().valueIsNull((Element) record.getDOM())) {
fieldValue = null;
}
else{
record.setSession(executionSession);
if ((unmarshaller.getAttachmentUnmarshaller() != null) && unmarshaller.getAttachmentUnmarshaller().isXOPPackage() && !this.isSwaRef() && !this.shouldInlineBinaryData()) {
//look for the include element:
String xpath = XMLConstants.EMPTY_STRING;
// need a prefix for XOP
String prefix = null;
NamespaceResolver descriptorResolver = ((XMLDescriptor) getDescriptor()).getNamespaceResolver();
if (descriptorResolver != null) {
prefix = descriptorResolver.resolveNamespaceURI(XMLConstants.XOP_URL);
}
if (prefix == null) {
prefix = XMLConstants.XOP_PREFIX;
}
NamespaceResolver tempResolver = new NamespaceResolver();
tempResolver.put(prefix, XMLConstants.XOP_URL);
xpath = prefix + XMLConstants.COLON + INCLUDE + "/@href";
XMLField field = new XMLField(xpath);
field.setNamespaceResolver(tempResolver);
String includeValue = (String) record.get(field);
if (element != null && includeValue != null) {
if ((getAttributeElementClass() == ClassConstants.ABYTE) || (getAttributeElementClass() == ClassConstants.APBYTE)) {
fieldValue = unmarshaller.getAttachmentUnmarshaller().getAttachmentAsByteArray(includeValue);
} else {
fieldValue = unmarshaller.getAttachmentUnmarshaller().getAttachmentAsDataHandler(includeValue);
}
} else {
//If we didn't find the Include element, check for inline
fieldValue = record.get(XMLConstants.TEXT);
//should be a base64 string
fieldValue = ((XMLConversionManager) executionSession.getDatasourcePlatform().getConversionManager()).convertSchemaBase64ToByteArray(fieldValue);
}
} else if ((unmarshaller.getAttachmentUnmarshaller() != null) && isSwaRef()) {
String refValue = (String) record.get(XMLConstants.TEXT);
if (refValue != null) {
fieldValue = unmarshaller.getAttachmentUnmarshaller().getAttachmentAsDataHandler(refValue);
}
} else {
fieldValue = record.get(XMLConstants.TEXT);
//should be a base64 string
fieldValue = ((XMLConversionManager) executionSession.getDatasourcePlatform().getConversionManager()).convertSchemaBase64ToByteArray(fieldValue);
}
}
}