Refine search
protected XMLInputFactory createInputFactory() { final XMLInputFactory instance = new WstxInputFactory(); instance.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); return instance; }
/** * Stax parser for a given stream handler and iso control chars set awarness to on. * The iso control chars in the xml file will be replaced by simple spaces, usefull for * potentially bogus XML files to parse, this has a small perfs overhead so use it only when necessary * * @param streamHandler the xml stream handler * @param isoControlCharsAwareParser true or false */ public StaxParser(XmlStreamHandler streamHandler, boolean isoControlCharsAwareParser) { this.streamHandler = streamHandler; XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); if (xmlFactory instanceof WstxInputFactory) { WstxInputFactory wstxInputfactory = (WstxInputFactory) xmlFactory; wstxInputfactory.configureForLowMemUsage(); wstxInputfactory.getConfig().setUndeclaredEntityResolver(new UndeclaredEntitiesXMLResolver()); } xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, false); xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false); xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false); this.isoControlCharsAwareParser = isoControlCharsAwareParser; inf = new SMInputFactory(xmlFactory); }
protected XMLStreamReader2 createSR(SystemId systemId, InputStream in, String enc, boolean forER, boolean autoCloseInput) throws XMLStreamException { // sanity check: if (in == null) { throw new IllegalArgumentException("Null InputStream is not a valid argument"); } ReaderConfig cfg = createPrivateConfig(); if (enc == null || enc.length() == 0) { return createSR(cfg, systemId, StreamBootstrapper.getInstance (null, systemId, in), forER, autoCloseInput); } /* !!! 17-Feb-2006, TSa: We don't yet know if it's xml 1.0 or 1.1; * so have to specify 1.0 (which is less restrictive WRT input * streams). Would be better to let bootstrapper deal with it * though: */ Reader r = DefaultInputResolver.constructOptimizedReader(cfg, in, false, enc); return createSR(cfg, systemId, ReaderBootstrapper.getInstance (null, systemId, r, enc), forER, autoCloseInput); }
private XMLStreamReader parse(InputStream is, String systemIdStr, boolean restricted) throws IOException, XMLStreamException { if (!quietmode) { LOG.debug("parsing input stream " + is); } if (is == null) { return null; } SystemId systemId = SystemId.construct(systemIdStr); ReaderConfig readerConfig = XML_INPUT_FACTORY.createPrivateConfig(); if (restricted) { readerConfig.setProperty(XMLInputFactory.SUPPORT_DTD, false); } return XML_INPUT_FACTORY.createSR(readerConfig, systemId, StreamBootstrapper.getInstance(null, systemId, is), false, true); }
public XMLStreamReader2 createXMLStreamReader(URL src) throws XMLStreamException { /* true for auto-close, since caller has no access to the underlying * input stream created from the URL */ return createSR(createPrivateConfig(), src, false, true); }
return mStaxFactory.getConfig().willSupportExternalEntities(); } else if (stdFeat == SAXFeature.EXTERNAL_PARAMETER_ENTITIES) { return mStaxFactory.getConfig().willSupportExternalEntities(); } else if (stdFeat == SAXFeature.IS_STANDALONE) { return mStaxFactory.getConfig().willSupportNamespaces(); } else if (stdFeat == SAXFeature.NAMESPACE_PREFIXES) { return mFeatNsPrefixes; return mStaxFactory.getConfig().willInternNames(); } else if (stdFeat == SAXFeature.UNICODE_NORMALIZATION_CHECKING) { return false; return true; } else if (stdFeat == SAXFeature.VALIDATION) { return mStaxFactory.getConfig().willValidateWithDTD(); } else if (stdFeat == SAXFeature.XMLNS_URIS) {
mStaxFactory.getConfig().doSupportExternalEntities(value); } else if (stdFeat == SAXFeature.EXTERNAL_PARAMETER_ENTITIES) { mStaxFactory.getConfig().doSupportNamespaces(value); } else if (stdFeat == SAXFeature.NAMESPACE_PREFIXES) { mFeatNsPrefixes = value; readOnly = true; } else if (stdFeat == SAXFeature.VALIDATION) { mStaxFactory.getConfig().doValidateWithDTD(value); } else if (stdFeat == SAXFeature.XMLNS_URIS) { invalidValue = !value;
public XMLEventReader createXMLEventReader(InputStream in, String enc) throws XMLStreamException { // false for auto-close, since caller has access to the input stream return new WstxEventReader(createEventAllocator(), createSR(null, in, enc, true, false)); }
public XMLEventReader2 createXMLEventReader(File f) throws XMLStreamException { /* true for auto-close, since caller has no access to the underlying * input stream created from the File */ return new WstxEventReader(createEventAllocator(), createSR(f, true, true)); }
public Object getProperty(String name) { Object ob = mConfig.getProperty(name); if (ob == null) { if (name.equals(XMLInputFactory.ALLOCATOR)) { // Event allocator not available via J2ME subset... return getEventAllocator(); } } return ob; }
mConfig = sf.createPrivateConfig(); mConfig.doSupportDTDs(true); mConfig.setDtdResolver(r); mConfig.setEntityResolver(r); mConfig.setDTDEventListener(this);
@Override public Object getService(Bundle bundle, ServiceRegistration registration) { Properties props = new Properties(); props.setProperty(Stax2InputFactoryProvider.OSGI_SVC_PROP_IMPL_NAME, ReaderConfig.getImplName()); props.setProperty(Stax2InputFactoryProvider.OSGI_SVC_PROP_IMPL_VERSION, ReaderConfig.getImplVersion()); registration.setProperties(props); return new WstxInputFactory(); }
URL src = cfg.getBaseURL(); return doCreateSR(cfg, SystemId.construct(systemId, src), bs, forER, autoCloseInput);
public StaxJaxBStreamParserImpl() { WstxInputFactory inputFactory = new WstxInputFactory(); inputFactory.configureForSpeed(); documentFactory = inputFactory; }
@Override final XMLStreamReader getXMLStreamReader(boolean expandEntityReferences) throws XMLStreamException { WstxInputFactory factory = new WstxInputFactory(); factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.valueOf(expandEntityReferences)); factory.setProperty(WstxInputFactory.P_AUTO_CLOSE_INPUT, Boolean.TRUE); factory.setProperty(WstxInputFactory.P_REPORT_PROLOG_WHITESPACE, Boolean.TRUE); factory.setProperty(WstxInputFactory.P_REPORT_CDATA, Boolean.TRUE); factory.setProperty(WstxInputProperties.P_MIN_TEXT_SEGMENT, Integer.MAX_VALUE); return createXMLStreamReader(factory); }
public JaxbYElementBuilder(Class<?> objectFactoryClass, JaxbObjectConverter<T> objectConverter, JaxbTypedObjectFactory<T> typedObjectFactory) { try { inputFactory.configureForXmlConformance(); ReaderConfig config = inputFactory.getConfig(); config.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true); config.setProperty(XMLInputFactory.IS_VALIDATING, false); context = JAXBContext.newInstance(objectFactoryClass); } catch (JAXBException e) { throw new ConfigurationException(e); } this.objectConverter = objectConverter; this.typedObjectFactory = typedObjectFactory; }
protected XMLStreamReader2 createSR(File f, boolean forER, boolean autoCloseInput) throws XMLStreamException { ReaderConfig cfg = createPrivateConfig(); try { /* 18-Nov-2008, TSa: If P_BASE_URL is set, and File reference is * relative, let's resolve against base... */ if (!f.isAbsolute()) { URL base = cfg.getBaseURL(); if (base != null) { URL src = new URL(base, f.getPath()); return createSR(cfg, SystemId.construct(src), URLUtil.inputStreamFromURL(src), forER, autoCloseInput); } } final SystemId systemId = SystemId.construct(f.toURL()); return createSR(cfg, systemId, new FileInputStream(f), forER, autoCloseInput); } catch (IOException ie) { throw new WstxIOException(ie); } }
throws XMLStreamException ReaderConfig cfg = createPrivateConfig(); Reader r = null; InputStream in = null; autoCloseInput = cfg.willAutoCloseInput(); } else if (src instanceof SAXSource) { SAXSource ss = (SAXSource) src; autoCloseInput = cfg.willAutoCloseInput(); } else if (src instanceof DOMSource) { DOMSource domSrc = (DOMSource) src; return createSR(cfg, URLUtil.urlFromSystemId(sysId), forER, autoCloseInput); } catch (IOException ioe) { return createSR(cfg, sysId, bs, forER, autoCloseInput);
/** * Convenience factory method that allows for parsing a document * stored in the specified file. */ public XMLStreamReader2 createXMLStreamReader(File f) throws XMLStreamException { /* true for auto-close, since caller has no access to the underlying * input stream created from the File */ return createSR(f, false, true); }
private XMLStreamReader2 createSR(ReaderConfig cfg, SystemId systemId, InputStream in, boolean forER, boolean autoCloseInput) throws XMLStreamException { return doCreateSR(cfg, systemId, StreamBootstrapper.getInstance(null, systemId, in), forER, autoCloseInput); }