public static Document parseXHTMLDocument(String xhtml, JDOMFactory factory) throws IOException, JDOMException { //DTD ersetzen, da die originale nicht erreichbar bzw. nur sehr langsam ist, xhtml = xhtml.replace("http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd", "http://localhost:8777/dtd/www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"); ByteArrayInputStream bais = new ByteArrayInputStream(xhtml.getBytes("UTF-8")); SAXBuilder builder = new SAXBuilder(XMLReaders.NONVALIDATING); builder.setFeature("http://xml.org/sax/features/external-general-entities", false); builder.setFeature("http://xml.org/sax/features/external-parameter-entities", false); builder.setFeature("http://xml.org/sax/features/resolve-dtd-uris", false); builder.setFeature("http://xml.org/sax/features/validation", false); builder.setExpandEntities(false); if (factory != null) { builder.setJDOMFactory(factory); } Document document = builder.build(bais); return document; }
@Override protected void configure() { // Setup @MapScoped and bind MapDefinition as a seed object install(new MapInjectionScope().new Manifest()); final FactoryModuleBuilder fmb = new FactoryModuleBuilder(); install(fmb.build(MapFilePreprocessor.Factory.class)); install(fmb.build(MapLogger.Factory.class)); bind(SAXHandler.class).to(BoundedSAXHandler.class); bind(SAXHandlerFactory.class).toInstance(BoundedSAXHandler::new); bind(JDOMFactory.class).to(BoundedJDOMFactory.class); bind(PGMMap.Factory.class); bind(MapConfiguration.class).to(PGMMapConfiguration.class); bind(MapDoc.class).to(MapDocument.class); inSet(MapRootParser.class); bind(ValidationContext.class).to(FeatureDefinitionContext.class); bind(MapModuleContext.class).in(MapScoped.class); bind(ModuleExceptionHandler.class).to(MapModuleContext.class); expose(MapDefinition.class); expose(PGMMap.class); requestStaticInjection(XMLUtils.class); }
@Provides SAXBuilder saxBuilder(SAXHandlerFactory saxHandlerFactory, JDOMFactory jdomFactory) { return new SAXBuilder(null, saxHandlerFactory, jdomFactory); }
@Inject public BoundedSAXHandler(JDOMFactory factory) { super(factory); }
/** * @since 1.4.5 */ public JDom2Writer(final Element container, final JDOMFactory factory, final NameCoder nameCoder) { super(container, nameCoder); documentFactory = factory; }
/** * @since 1.4.5 */ public JDom2Writer(final Element container, final JDOMFactory factory) { this(container, factory, new XmlFriendlyNameCoder()); }
/** * @since 1.4.5 */ public JDom2Writer(final JDOMFactory factory, final NameCoder nameCoder) { this(null, factory, nameCoder); }
/** * @since 1.4.5 */ public JDom2Writer(final JDOMFactory factory) { this(null, factory); }
@Override public SAXHandler createSAXHandler(JDOMFactory factory) { return new EmptyAwareSAXHandler(factory); }
public EmptyAwareSAXHandler(JDOMFactory factory) { super(factory); }
public JDom2Writer(Element paramElement, JDOMFactory paramJDOMFactory) { this(paramElement, paramJDOMFactory, new XmlFriendlyNameCoder()); }
public JDom2Writer(Element paramElement, JDOMFactory paramJDOMFactory, NameCoder paramNameCoder) { super(paramElement, paramNameCoder); this.documentFactory = paramJDOMFactory; }
public JDom2Writer(JDOMFactory paramJDOMFactory) { this(null, paramJDOMFactory); }
public JDom2Writer(JDOMFactory paramJDOMFactory, NameCoder paramNameCoder) { this(null, paramJDOMFactory, paramNameCoder); }
@Override public SAXHandler createSAXHandler( JDOMFactory factory ) { return new EmptyAwareSAXHandler( factory ); }
public EmptyAwareSAXHandler( JDOMFactory factory ) { super( factory ); }