* Decides the way xs:base64Binary binds.
*
* This method checks the expected media type.
*/
private TypeUse lookupBinaryTypeBinding() {
XSComponent referer = getReferer();
String emt = referer.getForeignAttribute(XML_MIME_URI, Const.EXPECTED_CONTENT_TYPES);
if(emt!=null) {
acknowledgedXmimeContentTypes.add(referer);
try {
// see http://www.xml.com/lpt/a/2004/07/21/dive.html
List<MimeTypeRange> types = MimeTypeRange.parseRanges(emt);
MimeTypeRange mt = MimeTypeRange.merge(types);
// see spec table I-1 in appendix I section 2.1.1 for bindings
if(mt.majorType.equalsIgnoreCase("image"))
return CBuiltinLeafInfo.IMAGE.makeMimeTyped(mt.toMimeType());
if(( mt.majorType.equalsIgnoreCase("application") || mt.majorType.equalsIgnoreCase("text"))
&& isXml(mt.subType))
return CBuiltinLeafInfo.XML_SOURCE.makeMimeTyped(mt.toMimeType());
if((mt.majorType.equalsIgnoreCase("text") && (mt.subType.equalsIgnoreCase("plain")) )) {
return CBuiltinLeafInfo.STRING.makeMimeTyped(mt.toMimeType());
}
return CBuiltinLeafInfo.DATA_HANDLER.makeMimeTyped(mt.toMimeType());
} catch (ParseException e) {
getErrorReporter().error( referer.getLocator(),
Messages.format(Messages.ERR_ILLEGAL_EXPECTED_MIME_TYPE,emt, e.getMessage()) );
// recover by using the default
} catch (MimeTypeParseException e) {
getErrorReporter().error( referer.getLocator(),
Messages.format(Messages.ERR_ILLEGAL_EXPECTED_MIME_TYPE,emt, e.getMessage()) );
}
}
// default
return CBuiltinLeafInfo.BASE64_BYTE_ARRAY;