Integer lineWidth = (Integer)options.get(XMLResource.OPTION_LINE_WIDTH);
  protected void init(XMLResource resource, Map options)  {    declareXSI = false;    useEncodedAttributeStyle = Boolean.TRUE.equals(options.get(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE));    declareXML = !Boolean.FALSE.equals(options.get(XMLResource.OPTION_DECLARE_XML));    declareSchemaLocationImplementation = Boolean.TRUE.equals(options.get(XMLResource.OPTION_SCHEMA_LOCATION_IMPLEMENTATION));    declareSchemaLocation = declareSchemaLocationImplementation || Boolean.TRUE.equals(options.get(XMLResource.OPTION_SCHEMA_LOCATION));    Integer lineWidth = (Integer)options.get(XMLResource.OPTION_LINE_WIDTH);    saveTypeInfo = Boolean.TRUE.equals(options.get(XMLResource.OPTION_SAVE_TYPE_INFORMATION));            anyType = (EClass)options.get(XMLResource.OPTION_ANY_TYPE);    anySimpleType = (EClass)options.get(XMLResource.OPTION_ANY_SIMPLE_TYPE);    if (anyType == null)    {      anyType = XMLTypePackage.eINSTANCE.getAnyType();      anySimpleType = XMLTypePackage.eINSTANCE.getSimpleAnyType();    }        if (options.get(XMLResource.OPTION_FLUSH_THRESHOLD) instanceof Integer)    {      flushThreshold  = ((Integer)options.get(XMLResource.OPTION_FLUSH_THRESHOLD)).intValue();    }    String temporaryFileName =  null;    if (Boolean.TRUE.equals(options.get(XMLResource.OPTION_USE_FILE_BUFFER)))    {      try      {        temporaryFileName = File.createTempFile("XMLSave", null).getPath();      }      catch (IOException exception)      {        // If we can't create a temp file then we have to ignore the option.      }    }    int effectiveLineWidth = lineWidth == null ? Integer.MAX_VALUE : lineWidth.intValue();    if (Boolean.TRUE.equals(options.get(XMLResource.OPTION_SAVE_DOCTYPE)))    {      if (resource != null)      {        doc = new XMLString(effectiveLineWidth, resource.getPublicId(), resource.getSystemId(), temporaryFileName);      }      else      {        doc = new XMLString (effectiveLineWidth, null, null, temporaryFileName);      }    }    else     {      doc = new XMLString(effectiveLineWidth, temporaryFileName);    }    if (Boolean.FALSE.equals(options.get(XMLResource.OPTION_FORMATTED)))    {      doc.setUnformatted(true);    }    escape =      Boolean.TRUE.equals(options.get(XMLResource.OPTION_SKIP_ESCAPE)) ?        null :        new Escape();        escapeURI = Boolean.FALSE.equals(options.get(XMLResource.OPTION_SKIP_ESCAPE_URI)) ?        escape :        null;    if (options.containsKey(XMLResource.OPTION_ENCODING))    {      encoding = (String)options.get(XMLResource.OPTION_ENCODING);    }    else if (resource != null)    {      encoding = resource.getEncoding();    }    processDanglingHREF = (String) options.get(XMLResource.OPTION_PROCESS_DANGLING_HREF);    helper.setProcessDanglingHREF(processDanglingHREF);    map = (XMLResource.XMLMap) options.get(XMLResource.OPTION_XML_MAP);    if (map != null)    {      helper.setXMLMap(map);      if (map.getIDAttributeName() != null)      {        idAttributeName = map.getIDAttributeName();      }    }    Object extendedMetaDataOption = options.get(XMLResource.OPTION_EXTENDED_META_DATA);    if (extendedMetaDataOption instanceof Boolean)    {      if (extendedMetaDataOption.equals(Boolean.TRUE))      {        extendedMetaData =          resource == null || resource.getResourceSet() == null ?            ExtendedMetaData.INSTANCE :            new BasicExtendedMetaData(resource.getResourceSet().getPackageRegistry());      }    }    else    {      extendedMetaData = (ExtendedMetaData)options.get(XMLResource.OPTION_EXTENDED_META_DATA);    }    if (resource != null)    {      eObjectToExtensionMap = resource.getEObjectToExtensionMap();      if (eObjectToExtensionMap.isEmpty())      {        eObjectToExtensionMap = null;      }      else if (extendedMetaData == null)      {        extendedMetaData =          resource.getResourceSet() == null ?            ExtendedMetaData.INSTANCE :            new BasicExtendedMetaData(resource.getResourceSet().getPackageRegistry());      }    }    if (extendedMetaData != null)    {      helper.setExtendedMetaData(extendedMetaData);      if (resource != null && resource.getContents().size() >=1)      {        EObject root = (EObject)resource.getContents().get(0);        EClass eClass = root.eClass();        EReference xmlnsPrefixMapFeature = extendedMetaData.getXMLNSPrefixMapFeature(eClass);        if (xmlnsPrefixMapFeature != null)        {          EMap xmlnsPrefixMap = (EMap)root.eGet(xmlnsPrefixMapFeature);          helper.setPrefixToNamespaceMap(xmlnsPrefixMap);        }      }    }        List lookup = (List)options.get(XMLResource.OPTION_USE_CACHED_LOOKUP_TABLE);    if (lookup != null)    {      // caching turned on by the user      if (lookup.isEmpty())      {        featureTable = new Lookup(map, extendedMetaData);               lookup.add(featureTable);      }      else      {        featureTable = (Lookup)lookup.get(0);      }    }    else    {      //no caching      featureTable = new Lookup(map, extendedMetaData);    }  }