public XMLDocument load(Source source, String locationURI, Object options) throws IOException {
    // get XMLUnmarshaller once - as we may create a new instance if this helper isDirty=true
    XMLUnmarshaller anXMLUnmarshaller = getXmlUnmarshaller(options);
    Object unmarshalledObject = null;
    if (options == null) {
      try {
        unmarshalledObject = anXMLUnmarshaller.unmarshal(source);
      } catch (XMLMarshalException xmlException) {
        handleXMLMarshalException(xmlException);
      }
    } else {
      try {
        DataObject optionsDataObject = (DataObject) options;
        try {
          SDOType theType = (SDOType) optionsDataObject.get(SDOConstants.TYPE_LOAD_OPTION);
          try {
            if (theType != null) {
              unmarshalledObject = anXMLUnmarshaller.unmarshal(source, theType.getImplClass());
            } else {
              unmarshalledObject = anXMLUnmarshaller.unmarshal(source);
            }
          } catch (XMLMarshalException xmlException) {
            handleXMLMarshalException(xmlException);
          }
        } catch (ClassCastException ccException) {
          throw SDOException.typePropertyMustBeAType(ccException);
        }
      } catch (ClassCastException ccException) {
        throw SDOException.optionsMustBeADataObject(
            ccException, SDOConstants.ORACLE_SDO_URL, SDOConstants.XMLHELPER_LOAD_OPTIONS);
      }
    }

    if (unmarshalledObject instanceof XMLRoot) {
      XMLRoot xmlRoot = (XMLRoot) unmarshalledObject;
      XMLDocument xmlDocument =
          createDocument(
              (DataObject) ((XMLRoot) unmarshalledObject).getObject(),
              ((XMLRoot) unmarshalledObject).getNamespaceURI(),
              ((XMLRoot) unmarshalledObject).getLocalName());
      if (xmlRoot.getEncoding() != null) {
        xmlDocument.setEncoding(xmlRoot.getEncoding());
      }
      if (xmlRoot.getXMLVersion() != null) {
        xmlDocument.setXMLVersion(xmlRoot.getXMLVersion());
      }
      xmlDocument.setSchemaLocation(xmlRoot.getSchemaLocation());
      xmlDocument.setNoNamespaceSchemaLocation(xmlRoot.getNoNamespaceSchemaLocation());
      return xmlDocument;
    } else if (unmarshalledObject instanceof DataObject) {
      DataObject unmarshalledDataObject = (DataObject) unmarshalledObject;
      String localName =
          ((SDOType) ((DataObject) unmarshalledObject).getType())
              .getXmlDescriptor()
              .getDefaultRootElement();
      if (localName == null) {
        localName = ((SDOType) ((DataObject) unmarshalledObject).getType()).getXsdLocalName();
      }
      return createDocument(
          unmarshalledDataObject, unmarshalledDataObject.getType().getURI(), localName);
    } else if (unmarshalledObject instanceof XMLDocument) {
      return (XMLDocument) unmarshalledObject;
    }
    return null;
  }