/** * 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); }
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 DTDSchemaFactory() { super(XMLValidationSchema.SCHEMA_ID_DTD); mReaderConfig = ReaderConfig.createFullDefaults(); mSchemaConfig = ValidatorConfig.createDefaults(); }
public final Object safeGetProperty(String propName) { int id = findPropertyId(propName); if (id >= 0) { return getProperty(id); } id = findStdPropertyId(propName); if (id < 0) { return null; } return getStdProperty(id); }
/** * For Woodstox, this profile enables all basic well-formedness checks, * including checking for name validity. */ public void configureForXmlConformance() { doValidateAttributes(true); doValidateContent(true); doValidateStructure(true); doValidateNames(true); }
public boolean isPropertySupported(String propName) { return (findPropertyId(propName) >= 0) || (findStdPropertyId(propName) >= 0); }
public ReaderSource(ReaderConfig cfg, WstxInputSource parent, String fromEntity, String pubId, SystemId sysId, Reader r, boolean realClose) { super(parent, fromEntity, pubId, sysId); mConfig = cfg; mReader = r; mDoRealClose = realClose; int bufSize = cfg.getInputBufferLength(); mBuffer = cfg.allocFullCBuffer(bufSize); }
protected BaseStreamWriter(XmlWriter xw, String enc, WriterConfig cfg) { mWriter = xw; mEncoding = enc; mConfig = cfg; int flags = cfg.getConfigFlags(); mCheckStructure = (flags & OutputConfigFlags.CFG_VALIDATE_STRUCTURE) != 0; mCheckAttrs = (flags & OutputConfigFlags.CFG_VALIDATE_ATTR) != 0; mCfgAutomaticEmptyElems = (flags & OutputConfigFlags.CFG_AUTOMATIC_EMPTY_ELEMENTS) != 0; mReturnNullForDefaultNamespace = mConfig.returnNullForDefaultNamespace(); }
/** * @since 4.2.1 */ public void doUseDoubleQuotesInXmlDecl(boolean state) { setConfigFlag(CFG_USE_DOUBLE_QUOTES_IN_XML_DECL, state); }
public boolean isPropertySupported(String name) { // !!! TBI: not all these properties are really supported return mConfig.isPropertySupported(name); }
public boolean setProperty(String name, Object value) { /* Note: can not call local method, since it'll return false for * recognized but non-mutable properties */ return mConfig.setProperty(name, value); }
public static ReaderConfig createFullDefaults() { /* For full version, can use bit larger buffers to achieve better * overall performance. */ ReaderConfig rc = new ReaderConfig(null, false, null, DEFAULT_FLAGS_FULL, 0, // 8k input buffer (4000 chars): 4000, DEFAULT_SHORTEST_TEXT_SEGMENT); return rc; }
protected BaseSchemaFactory(String schemaType) { super(schemaType); mConfig = ValidatorConfig.createDefaults(); }
private void freeMergedBuffer() { if (mData != null) { byte[] data = mData; mData = null; if (mConfig != null) { mConfig.freeFullBBuffer(data); } } } }
public boolean isPropertySupported(String name) { // !!! TBI: not all these properties are really supported return mConfig.isPropertySupported(name); }
private void freeMergedBuffer() { if (mData != null) { char[] data = mData; mData = null; if (mConfig != null) { mConfig.freeSmallCBuffer(data); } } } }
/** * Special accessor to use to verify whether name interning has * explicitly been enabled; true if call was been made to set * it to true; false otherwise (default, or set to false) */ public boolean hasInternNamesBeenEnabled() { return _hasExplicitConfigFlag(CFG_INTERN_NAMES); }
/** * @return Prefix to use as the base for automatically generated * namespace prefixes ("namespace prefix prefix", so to speak). * Defaults to "wstxns". */ public String getAutomaticNsPrefix() { String prefix = (String) getSpecialProperty(SP_IX_AUTO_NS_PREFIX); if (prefix == null) { prefix = DEFAULT_AUTOMATIC_NS_PREFIX; } return prefix; }
/** * @param prefix Prefix to use as the base for automatically generated * namespace prefixes ("namespace prefix prefix", so to speak). */ public void setAutomaticNsPrefix(String prefix) { setSpecialProperty(SP_IX_AUTO_NS_PREFIX, prefix); }
public boolean setProperty(String name, Object value) { // Basic config accessor works just fine... return mConfig.setProperty(name, value); }