use of org.eclipse.mylyn.docs.epub.internal.EPUBXMLHelperImp in project mylyn.docs by eclipse.
the class OPSPublication method registerNCXResourceFactory.
/**
* Registers a new resource factory for NCX data structures. This is normally done through Eclipse extension points
* but we also need to be able to create this factory without the Eclipse runtime.
*/
private void registerNCXResourceFactory() {
// Register package so that it is available even without the Eclipse runtime
@SuppressWarnings("unused") NCXPackage packageInstance = NCXPackage.eINSTANCE;
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(NCX_FILE_SUFFIX, new NCXResourceFactoryImpl() {
@Override
public Resource createResource(URI uri) {
NCXResourceImpl xmiResource = new NCXResourceImpl(uri) {
@Override
protected XMLHelper createXMLHelper() {
EPUBXMLHelperImp xmlHelper = new EPUBXMLHelperImp();
return xmlHelper;
}
};
Map<Object, Object> loadOptions = xmiResource.getDefaultLoadOptions();
Map<Object, Object> saveOptions = xmiResource.getDefaultSaveOptions();
// We use extended metadata
saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
// Required in order to correctly read in attributes
loadOptions.put(XMLResource.OPTION_LAX_FEATURE_PROCESSING, Boolean.TRUE);
// Treat "href" attributes as features
loadOptions.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
// UTF-8 encoding is required per specification
saveOptions.put(XMLResource.OPTION_ENCODING, XML_ENCODING);
// Do not download any external DTDs.
Map<String, Object> parserFeatures = new HashMap<String, Object>();
// $NON-NLS-1$
parserFeatures.put("http://xml.org/sax/features/validation", Boolean.FALSE);
// $NON-NLS-1$
parserFeatures.put(// $NON-NLS-1$
"http://apache.org/xml/features/nonvalidating/load-external-dtd", Boolean.FALSE);
loadOptions.put(XMLResource.OPTION_PARSER_FEATURES, parserFeatures);
return xmiResource;
}
});
}
use of org.eclipse.mylyn.docs.epub.internal.EPUBXMLHelperImp in project mylyn.docs by eclipse.
the class Publication method registerOPFResourceFactory.
/**
* Registers a new resource factory for OPF data structures. This is normally done through Eclipse extension points
* but we also need to be able to create this factory without the Eclipse runtime.
*/
private void registerOPFResourceFactory() {
// Register package so that it is available even without the Eclipse runtime
@SuppressWarnings("unused") OPFPackage packageInstance = OPFPackage.eINSTANCE;
// Register the file suffix
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(OPF_FILE_SUFFIX, new XMLResourceFactoryImpl() {
@Override
public Resource createResource(URI uri) {
OPFResourceImpl xmiResource = new OPFResourceImpl(uri) {
@Override
protected XMLHelper createXMLHelper() {
EPUBXMLHelperImp xmlHelper = new EPUBXMLHelperImp();
return xmlHelper;
}
};
Map<Object, Object> loadOptions = xmiResource.getDefaultLoadOptions();
Map<Object, Object> saveOptions = xmiResource.getDefaultSaveOptions();
// We use extended metadata
saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
// Required in order to correctly read in attributes
loadOptions.put(XMLResource.OPTION_LAX_FEATURE_PROCESSING, Boolean.TRUE);
// Treat "href" attributes as features
loadOptions.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
// UTF-8 encoding is required per specification
saveOptions.put(XMLResource.OPTION_ENCODING, XML_ENCODING);
// Do not download any external DTDs.
Map<String, Object> parserFeatures = new HashMap<String, Object>();
// $NON-NLS-1$
parserFeatures.put("http://xml.org/sax/features/validation", Boolean.FALSE);
// $NON-NLS-1$
parserFeatures.put(// $NON-NLS-1$
"http://apache.org/xml/features/nonvalidating/load-external-dtd", Boolean.FALSE);
loadOptions.put(XMLResource.OPTION_PARSER_FEATURES, parserFeatures);
return xmiResource;
}
});
}
Aggregations